-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/sc 1490/create basic crud operations for cli (#8)
* CUD operations for environment * EnvironmentClient API * Domain API * Removed unused import and variable * Updated file location for log and state files * CRUD commands
- Loading branch information
Showing
45 changed files
with
1,149 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,36 @@ | ||
namespace Enterspeed.Cli.Api.Domain; | ||
using Enterspeed.Cli.Domain.Models; | ||
using Enterspeed.Cli.Services.EnterspeedClient; | ||
using MediatR; | ||
using RestSharp; | ||
|
||
internal class CreateDomain | ||
namespace Enterspeed.Cli.Api.Domain; | ||
|
||
public class CreateDomainRequest : IRequest<CreateDomainResponse> | ||
{ | ||
public string Name { get; set; } | ||
public string[] Hostnames { get; set; } | ||
} | ||
|
||
public class CreateDomainResponse | ||
{ | ||
public DomainId DomainId { get; set; } | ||
} | ||
|
||
public class CreateDomainRequestRequestHandler : IRequestHandler<CreateDomainRequest, CreateDomainResponse> | ||
{ | ||
private readonly IEnterspeedClient _enterspeedClient; | ||
|
||
public CreateDomainRequestRequestHandler(IEnterspeedClient enterspeedClient) | ||
{ | ||
_enterspeedClient = enterspeedClient; | ||
} | ||
|
||
public async Task<CreateDomainResponse> Handle(CreateDomainRequest createDomainRequest, CancellationToken cancellationToken) | ||
{ | ||
var request = new RestRequest("tenant/domains", Method.Post) | ||
.AddJsonBody(createDomainRequest); | ||
|
||
var response = await _enterspeedClient.ExecuteAsync<CreateDomainResponse>(request, cancellationToken); | ||
return response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,38 @@ | ||
namespace Enterspeed.Cli.Api.Domain; | ||
using Enterspeed.Cli.Domain.Models; | ||
using Enterspeed.Cli.Services.EnterspeedClient; | ||
using MediatR; | ||
using RestSharp; | ||
|
||
internal class DeleteDomain | ||
namespace Enterspeed.Cli.Api.Domain; | ||
|
||
public class DeleteDomainRequest : IRequest<DeleteDomainResponse> | ||
{ | ||
public DomainId DomainId { get; } | ||
|
||
public DeleteDomainRequest(DomainId domainId) | ||
{ | ||
DomainId = domainId; | ||
} | ||
} | ||
|
||
public class DeleteDomainResponse | ||
{ | ||
} | ||
|
||
public class DeleteEnvironmentRequestRequestHandler : IRequestHandler<DeleteDomainRequest, DeleteDomainResponse> | ||
{ | ||
private readonly IEnterspeedClient _enterspeedClient; | ||
|
||
public DeleteEnvironmentRequestRequestHandler(IEnterspeedClient enterspeedClient) | ||
{ | ||
_enterspeedClient = enterspeedClient; | ||
} | ||
|
||
public async Task<DeleteDomainResponse> Handle(DeleteDomainRequest deleteDomainRequest, CancellationToken cancellationToken) | ||
{ | ||
var request = new RestRequest($"tenant/domains/{deleteDomainRequest.DomainId.DomainGuid}", Method.Delete); | ||
|
||
var response = await _enterspeedClient.ExecuteAsync<DeleteDomainResponse>(request, cancellationToken); | ||
return response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,39 @@ | ||
using Enterspeed.Cli.Domain.Models; | ||
using Enterspeed.Cli.Services.EnterspeedClient; | ||
using MediatR; | ||
using RestSharp; | ||
|
||
namespace Enterspeed.Cli.Api.Environment | ||
{ | ||
public class DeleteEnvironmentRequest : IRequest<DeleteEnvironmentResponse> | ||
{ | ||
public EnvironmentId EnvironmentId { get; set; } | ||
public EnvironmentId EnvironmentId { get; } | ||
|
||
public DeleteEnvironmentRequest(EnvironmentId environmentId) | ||
{ | ||
EnvironmentId = environmentId; | ||
} | ||
} | ||
|
||
public class DeleteEnvironmentResponse | ||
{ | ||
} | ||
|
||
public class DeleteEnvironmentRequestRequestHandler : IRequestHandler<DeleteEnvironmentRequest, DeleteEnvironmentResponse> | ||
{ | ||
private readonly IEnterspeedClient _enterspeedClient; | ||
|
||
public DeleteEnvironmentRequestRequestHandler(IEnterspeedClient enterspeedClient) | ||
{ | ||
_enterspeedClient = enterspeedClient; | ||
} | ||
|
||
public async Task<DeleteEnvironmentResponse> Handle(DeleteEnvironmentRequest deleteEnvironmentsRequest, CancellationToken cancellationToken) | ||
{ | ||
var request = new RestRequest($"tenant/environments/{deleteEnvironmentsRequest.EnvironmentId.EnvironmentGuid}", Method.Delete); | ||
|
||
var response = await _enterspeedClient.ExecuteAsync<DeleteEnvironmentResponse>(request, cancellationToken); | ||
return response; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,43 @@ | ||
using Enterspeed.Cli.Domain.Models; | ||
using System.Text.Json.Serialization; | ||
using Enterspeed.Cli.Domain.Models; | ||
using Enterspeed.Cli.Services.EnterspeedClient; | ||
using MediatR; | ||
using RestSharp; | ||
|
||
namespace Enterspeed.Cli.Api.Environment | ||
{ | ||
public class UpdateEnvironmentRequest : IRequest<UpdateEnvironmentResponse> | ||
{ | ||
public EnvironmentId EnvironmentId { get; set; } | ||
[JsonIgnore] | ||
public EnvironmentId EnvironmentId { get; } | ||
public string Name { get; set; } | ||
|
||
public UpdateEnvironmentRequest(EnvironmentId environmentId) | ||
{ | ||
EnvironmentId = environmentId; | ||
} | ||
} | ||
|
||
public class UpdateEnvironmentResponse | ||
{ | ||
} | ||
|
||
public class UpdateEnvironmentRequestRequestHandler : IRequestHandler<UpdateEnvironmentRequest, UpdateEnvironmentResponse> | ||
{ | ||
private readonly IEnterspeedClient _enterspeedClient; | ||
|
||
public UpdateEnvironmentRequestRequestHandler(IEnterspeedClient enterspeedClient) | ||
{ | ||
_enterspeedClient = enterspeedClient; | ||
} | ||
|
||
public async Task<UpdateEnvironmentResponse> Handle(UpdateEnvironmentRequest updateEnvironmentRequest, CancellationToken cancellationToken) | ||
{ | ||
var request = new RestRequest($"tenant/environments/{updateEnvironmentRequest.EnvironmentId.EnvironmentGuid}", Method.Put) | ||
.AddJsonBody(updateEnvironmentRequest); | ||
|
||
var response = await _enterspeedClient.ExecuteAsync<UpdateEnvironmentResponse>(request, cancellationToken); | ||
return response; | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/Enterspeed.Cli/Api/EnvironmentClient/CreateEnvironmentClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Enterspeed.Cli.Domain.Models; | ||
using Enterspeed.Cli.Services.EnterspeedClient; | ||
using MediatR; | ||
using RestSharp; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Enterspeed.Cli.Api.EnvironmentClient | ||
{ | ||
public class CreateEnvironmentClientRequest : IRequest<CreateEnvironmentClientResponse> | ||
{ | ||
public string Name { get; set; } | ||
public string[] AllowedDomains { get; set; } | ||
|
||
public bool RegenerateAccessKey { get; set; } | ||
|
||
[JsonIgnore] | ||
public EnvironmentId EnvironmentId { get; } | ||
|
||
public CreateEnvironmentClientRequest(EnvironmentId environmentId) | ||
{ | ||
EnvironmentId = environmentId; | ||
} | ||
} | ||
|
||
public class CreateEnvironmentClientResponse | ||
{ | ||
public EnvironmentClientId EnvironmentClientId { get; set; } | ||
} | ||
|
||
public class CreateEnvironmentClientRequestRequestHandler : IRequestHandler<CreateEnvironmentClientRequest, CreateEnvironmentClientResponse> | ||
{ | ||
private readonly IEnterspeedClient _enterspeedClient; | ||
|
||
public CreateEnvironmentClientRequestRequestHandler(IEnterspeedClient enterspeedClient) | ||
{ | ||
_enterspeedClient = enterspeedClient; | ||
} | ||
|
||
public async Task<CreateEnvironmentClientResponse> Handle(CreateEnvironmentClientRequest createEnvironmentClientRequest, CancellationToken cancellationToken) | ||
{ | ||
var request = new RestRequest($"tenant/environment-clients/{createEnvironmentClientRequest.EnvironmentId.EnvironmentGuid}", Method.Post) | ||
.AddJsonBody(createEnvironmentClientRequest); | ||
|
||
var response = await _enterspeedClient.ExecuteAsync<CreateEnvironmentClientResponse>(request, cancellationToken); | ||
return response; | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/Enterspeed.Cli/Api/EnvironmentClient/DeleteEnvironmentClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Enterspeed.Cli.Domain.Models; | ||
using Enterspeed.Cli.Services.EnterspeedClient; | ||
using MediatR; | ||
using RestSharp; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Enterspeed.Cli.Api.EnvironmentClient | ||
{ | ||
public class DeleteEnvironmentClientRequest : IRequest<DeleteEnvironmentClientResponse> | ||
{ | ||
[JsonIgnore] | ||
public EnvironmentClientId EnvironmentClientId { get; } | ||
|
||
public DeleteEnvironmentClientRequest(EnvironmentClientId environmentClientId) | ||
{ | ||
EnvironmentClientId = environmentClientId; | ||
} | ||
} | ||
|
||
public class DeleteEnvironmentClientResponse | ||
{ | ||
} | ||
|
||
public class DeleteEnvironmentClientRequestRequestHandler : IRequestHandler<DeleteEnvironmentClientRequest, DeleteEnvironmentClientResponse> | ||
{ | ||
private readonly IEnterspeedClient _enterspeedClient; | ||
|
||
public DeleteEnvironmentClientRequestRequestHandler(IEnterspeedClient enterspeedClient) | ||
{ | ||
_enterspeedClient = enterspeedClient; | ||
} | ||
|
||
public async Task<DeleteEnvironmentClientResponse> Handle(DeleteEnvironmentClientRequest deleteEnvironmentClientRequest, CancellationToken cancellationToken) | ||
{ | ||
var request = | ||
new RestRequest( | ||
$"tenant/environment-clients/{deleteEnvironmentClientRequest.EnvironmentClientId.EnvironmentGuid}/{deleteEnvironmentClientRequest.EnvironmentClientId.ClientGuid}/", | ||
Method.Delete); | ||
|
||
var response = await _enterspeedClient.ExecuteAsync<DeleteEnvironmentClientResponse>(request, cancellationToken); | ||
return response; | ||
} | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
src/Enterspeed.Cli/Api/EnvironmentClient/UpdateEnvironmentClient.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Enterspeed.Cli.Domain.Models; | ||
using Enterspeed.Cli.Services.EnterspeedClient; | ||
using MediatR; | ||
using RestSharp; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Enterspeed.Cli.Api.EnvironmentClient | ||
{ | ||
public class UpdateEnvironmentClientRequest : IRequest<UpdateEnvironmentClientResponse> | ||
{ | ||
public string Name { get; set; } | ||
public string[] AllowedDomains { get; set; } | ||
|
||
public bool RegenerateAccessKey { get; set; } | ||
|
||
[JsonIgnore] | ||
public EnvironmentClientId EnvironmentClientId { get; } | ||
|
||
public UpdateEnvironmentClientRequest(EnvironmentClientId environmentClientId) | ||
{ | ||
EnvironmentClientId = environmentClientId; | ||
} | ||
} | ||
|
||
public class UpdateEnvironmentClientResponse | ||
{ | ||
public EnvironmentClientId EnvironmentClientId { get; set; } | ||
} | ||
|
||
public class UpdateEnvironmentClientRequestRequestHandler : IRequestHandler<UpdateEnvironmentClientRequest, UpdateEnvironmentClientResponse> | ||
{ | ||
private readonly IEnterspeedClient _enterspeedClient; | ||
|
||
public UpdateEnvironmentClientRequestRequestHandler(IEnterspeedClient enterspeedClient) | ||
{ | ||
_enterspeedClient = enterspeedClient; | ||
} | ||
|
||
public async Task<UpdateEnvironmentClientResponse> Handle(UpdateEnvironmentClientRequest updateEnvironmentClientRequest, CancellationToken cancellationToken) | ||
{ | ||
var request = new RestRequest($"tenant/environment-clients/{updateEnvironmentClientRequest.EnvironmentClientId.EnvironmentGuid}/{updateEnvironmentClientRequest.EnvironmentClientId.ClientGuid}/", Method.Put) | ||
.AddJsonBody(updateEnvironmentClientRequest); | ||
|
||
var response = await _enterspeedClient.ExecuteAsync<UpdateEnvironmentClientResponse>(request, cancellationToken); | ||
return response; | ||
} | ||
} | ||
} |
Oops, something went wrong.