public async Task <TrustGroupRegistrationResponseApiModel> CreateGroupAsync( [FromBody][Required] TrustGroupRegistrationRequestApiModel request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var result = await _groups.CreateGroupAsync(request.ToServiceModel()); return(result.ToApiModel()); }
/// <inheritdoc/> public async Task <TrustGroupRegistrationResponseApiModel> CreateGroupAsync( TrustGroupRegistrationRequestApiModel model, CancellationToken ct) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var request = _httpClient.NewRequest($"{_serviceUri}/v2/groups", _resourceId); request.SetContent(model); var response = await _httpClient.PutAsync(request, ct).ConfigureAwait(false); response.Validate(); return(response.GetContent <TrustGroupRegistrationResponseApiModel>()); }
/// <inheritdoc/> public async Task <TrustGroupRegistrationResponseApiModel> CreateGroupAsync( TrustGroupRegistrationRequestApiModel model, CancellationToken ct) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var request = _httpClient.NewRequest($"{_serviceUri}/v2/groups", Resource.Platform); _serializer.SerializeToRequest(request, model); var response = await _httpClient.PutAsync(request, ct).ConfigureAwait(false); response.Validate(); return(_serializer.DeserializeResponse <TrustGroupRegistrationResponseApiModel>(response)); }
/// <summary> /// Convert to service model /// </summary> /// <returns></returns> public static TrustGroupRegistrationRequestModel ToServiceModel( this TrustGroupRegistrationRequestApiModel model) { if (model == null) { return(null); } return(new TrustGroupRegistrationRequestModel { Name = model.Name, ParentId = model.ParentId, SubjectName = model.SubjectName, IssuedKeySize = model.IssuedKeySize, IssuedLifetime = model.IssuedLifetime, IssuedSignatureAlgorithm = (IIoT.OpcUa.Vault.Models.SignatureAlgorithm?)model.IssuedSignatureAlgorithm, }); }
/// <summary> /// Create new sub-group of an existing group. /// </summary> /// <remarks> /// Requires manager role. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='body'> /// The create request /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <TrustGroupRegistrationResponseApiModel> CreateGroupAsync(this IAzureOpcVaultClient operations, TrustGroupRegistrationRequestApiModel body, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateGroupWithHttpMessagesAsync(body, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Create new sub-group of an existing group. /// </summary> /// <remarks> /// Requires manager role. /// </remarks> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='body'> /// The create request /// </param> public static TrustGroupRegistrationResponseApiModel CreateGroup(this IAzureOpcVaultClient operations, TrustGroupRegistrationRequestApiModel body) { return(operations.CreateGroupAsync(body).GetAwaiter().GetResult()); }