public async Task <Response <DdosCustomPolicy> > GetAsync(string resourceGroupName, string ddosCustomPolicyName, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (ddosCustomPolicyName == null) { throw new ArgumentNullException(nameof(ddosCustomPolicyName)); } using var message = CreateGetRequest(resourceGroupName, ddosCustomPolicyName); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { DdosCustomPolicy value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); if (document.RootElement.ValueKind == JsonValueKind.Null) { value = null; } else { value = DdosCustomPolicy.DeserializeDdosCustomPolicy(document.RootElement); } return(Response.FromValue(value, message.Response)); }
public virtual DdosCustomPoliciesCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string ddosCustomPolicyName, DdosCustomPolicy parameters, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (ddosCustomPolicyName == null) { throw new ArgumentNullException(nameof(ddosCustomPolicyName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("DdosCustomPoliciesOperations.StartCreateOrUpdate"); scope.Start(); try { var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, ddosCustomPolicyName, parameters, cancellationToken); return(new DdosCustomPoliciesCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, ddosCustomPolicyName, parameters).Request, originalResponse)); } catch (Exception e) { scope.Failed(e); throw; } }