/// <summary> /// Convert to service model /// </summary> public static StartNewKeyPairRequestModel ToServiceModel( this StartNewKeyPairRequestApiModel model) { if (model == null) { return(null); } return(new StartNewKeyPairRequestModel { EntityId = model.EntityId, GroupId = model.GroupId, SubjectName = model.SubjectName, DomainNames = model.DomainNames?.ToList(), }); }
/// <inheritdoc/> public async Task <StartNewKeyPairRequestResponseApiModel> StartNewKeyPairRequestAsync( StartNewKeyPairRequestApiModel model, CancellationToken ct) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var request = _httpClient.NewRequest($"{_serviceUri}/v2/requests/keypair", _resourceId); request.SetContent(model); var response = await _httpClient.PutAsync(request, ct).ConfigureAwait(false); response.Validate(); return(response.GetContent <StartNewKeyPairRequestResponseApiModel>()); }
/// <inheritdoc/> public async Task <StartNewKeyPairRequestResponseApiModel> StartNewKeyPairRequestAsync( StartNewKeyPairRequestApiModel model, CancellationToken ct) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var request = _httpClient.NewRequest($"{_serviceUri}/v2/requests/keypair", Resource.Platform); _serializer.SerializeToRequest(request, model); var response = await _httpClient.PutAsync(request, ct).ConfigureAwait(false); response.Validate(); return(_serializer.DeserializeResponse <StartNewKeyPairRequestResponseApiModel>(response)); }
public async Task <StartNewKeyPairRequestResponseApiModel> StartNewKeyPairRequestAsync( [FromBody][Required] StartNewKeyPairRequestApiModel newKeyPairRequest) { if (newKeyPairRequest == null) { throw new ArgumentNullException(nameof(newKeyPairRequest)); } HttpContext.User = null; // TODO: Set service principal var result = await _keyPair.StartNewKeyPairRequestAsync( newKeyPairRequest.ToServiceModel(), new VaultOperationContextModel { AuthorityId = User.Identity.Name, Time = DateTime.UtcNow }); return(result.ToApiModel()); }
/// <summary> /// Create a certificate request with a new key pair. /// </summary> /// <remarks> /// The request is in the 'New' state after this call. Requires Writer or /// Manager role. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='body'> /// The new key pair request parameters /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <StartNewKeyPairRequestResponseApiModel> StartNewKeyPairRequestAsync(this IAzureOpcVaultClient operations, StartNewKeyPairRequestApiModel body, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.StartNewKeyPairRequestWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Create a certificate request with a new key pair. /// </summary> /// <remarks> /// The request is in the 'New' state after this call. Requires Writer or /// Manager role. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='body'> /// The new key pair request parameters /// </param> public static StartNewKeyPairRequestResponseApiModel StartNewKeyPairRequest(this IAzureOpcVaultClient operations, StartNewKeyPairRequestApiModel body) { return(operations.StartNewKeyPairRequestAsync(body).GetAwaiter().GetResult()); }