public async Task <Response <ServiceEndpointPolicy> > GetAsync(string resourceGroupName, string serviceEndpointPolicyName, string expand = null, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (serviceEndpointPolicyName == null) { throw new ArgumentNullException(nameof(serviceEndpointPolicyName)); } using var message = CreateGetRequest(resourceGroupName, serviceEndpointPolicyName, expand); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { ServiceEndpointPolicy 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 = ServiceEndpointPolicy.DeserializeServiceEndpointPolicy(document.RootElement); } return(Response.FromValue(value, message.Response)); }
public virtual ServiceEndpointPoliciesCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string serviceEndpointPolicyName, ServiceEndpointPolicy parameters, CancellationToken cancellationToken = default) { if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (serviceEndpointPolicyName == null) { throw new ArgumentNullException(nameof(serviceEndpointPolicyName)); } if (parameters == null) { throw new ArgumentNullException(nameof(parameters)); } using var scope = _clientDiagnostics.CreateScope("ServiceEndpointPoliciesOperations.StartCreateOrUpdate"); scope.Start(); try { var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, serviceEndpointPolicyName, parameters, cancellationToken); return(new ServiceEndpointPoliciesCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, serviceEndpointPolicyName, parameters).Request, originalResponse)); } catch (Exception e) { scope.Failed(e); throw; } }