ScopedPrivateLinkResource IOperationSource <ScopedPrivateLinkResource> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = ScopedPrivateLinkData.DeserializeScopedPrivateLinkData(document.RootElement); return(new ScopedPrivateLinkResource(_client, data)); }
public async Task <Response <ScopedPrivateLinkData> > GetAsync(string subscriptionId, string resourceGroupName, string scopeName, string name, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); Argument.AssertNotNullOrEmpty(scopeName, nameof(scopeName)); Argument.AssertNotNullOrEmpty(name, nameof(name)); using var message = CreateGetRequest(subscriptionId, resourceGroupName, scopeName, name); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { ScopedPrivateLinkData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = ScopedPrivateLinkData.DeserializeScopedPrivateLinkData(document.RootElement); return(Response.FromValue(value, message.Response)); }
public virtual async Task <ArmOperation <ScopedPrivateLinkResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string name, ScopedPrivateLinkData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(name, nameof(name)); Argument.AssertNotNull(data, nameof(data)); using var scope = _scopedPrivateLinkPrivateLinkScopedResourcesClientDiagnostics.CreateScope("ScopedPrivateLinkCollection.CreateOrUpdate"); scope.Start(); try { var response = await _scopedPrivateLinkPrivateLinkScopedResourcesRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, name, data, cancellationToken).ConfigureAwait(false); var operation = new MonitorArmOperation <ScopedPrivateLinkResource>(new ScopedPrivateLinkOperationSource(Client), _scopedPrivateLinkPrivateLinkScopedResourcesClientDiagnostics, Pipeline, _scopedPrivateLinkPrivateLinkScopedResourcesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, name, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal ScopedPrivateLinkResource(ArmClient client, ScopedPrivateLinkData data) : this(client, data.Id) { HasData = true; _data = data; }
public virtual ArmOperation <ScopedPrivateLinkResource> Update(WaitUntil waitUntil, ScopedPrivateLinkData data, CancellationToken cancellationToken = default) { Argument.AssertNotNull(data, nameof(data)); using var scope = _scopedPrivateLinkPrivateLinkScopedResourcesClientDiagnostics.CreateScope("ScopedPrivateLinkResource.Update"); scope.Start(); try { var response = _scopedPrivateLinkPrivateLinkScopedResourcesRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken); var operation = new MonitorArmOperation <ScopedPrivateLinkResource>(new ScopedPrivateLinkOperationSource(Client), _scopedPrivateLinkPrivateLinkScopedResourcesClientDiagnostics, Pipeline, _scopedPrivateLinkPrivateLinkScopedResourcesRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }