CustomIPPrefix IOperationSource <CustomIPPrefix> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = CustomIPPrefixData.DeserializeCustomIPPrefixData(document.RootElement); return(new CustomIPPrefix(_client, data)); }
public async Task <Response <CustomIPPrefixData> > GetAsync(string subscriptionId, string resourceGroupName, string customIPPrefixName, string expand = null, CancellationToken cancellationToken = default) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } if (resourceGroupName == null) { throw new ArgumentNullException(nameof(resourceGroupName)); } if (customIPPrefixName == null) { throw new ArgumentNullException(nameof(customIPPrefixName)); } using var message = CreateGetRequest(subscriptionId, resourceGroupName, customIPPrefixName, expand); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { CustomIPPrefixData value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = CustomIPPrefixData.DeserializeCustomIPPrefixData(document.RootElement); return(Response.FromValue(value, message.Response)); }
internal CustomIPPrefixData(string id, string name, string type, string location, IDictionary <string, string> tags, Models.ExtendedLocation extendedLocation, string etag, IList <string> zones, string cidr, string signedMessage, string authorizationMessage, CustomIPPrefixData customIPPrefixParent, IReadOnlyList <CustomIPPrefixData> childCustomIPPrefixes, CommissionedState?commissionedState, IReadOnlyList <WritableSubResource> publicIPPrefixes, string resourceGuid, string failedReason, ProvisioningState?provisioningState) : base(id, name, type, location, tags) { ExtendedLocation = extendedLocation; Etag = etag; Zones = zones; Cidr = cidr; SignedMessage = signedMessage; AuthorizationMessage = authorizationMessage; CustomIPPrefixParent = customIPPrefixParent; ChildCustomIPPrefixes = childCustomIPPrefixes; CommissionedState = commissionedState; PublicIPPrefixes = publicIPPrefixes; ResourceGuid = resourceGuid; FailedReason = failedReason; ProvisioningState = provisioningState; }
public virtual async Task <ArmOperation <CustomIPPrefixResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string customIPPrefixName, CustomIPPrefixData data, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(customIPPrefixName, nameof(customIPPrefixName)); Argument.AssertNotNull(data, nameof(data)); using var scope = _customIPPrefixClientDiagnostics.CreateScope("CustomIPPrefixCollection.CreateOrUpdate"); scope.Start(); try { var response = await _customIPPrefixRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, customIPPrefixName, data, cancellationToken).ConfigureAwait(false); var operation = new NetworkArmOperation <CustomIPPrefixResource>(new CustomIPPrefixOperationSource(Client), _customIPPrefixClientDiagnostics, Pipeline, _customIPPrefixRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, customIPPrefixName, 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 CustomIPPrefixResource(ArmClient client, CustomIPPrefixData data) : this(client, new ResourceIdentifier(data.Id)) { HasData = true; _data = data; }
internal CustomIPPrefixResource(ArmClient client, CustomIPPrefixData data) : this(client, data.Id) { HasData = true; _data = data; }
public virtual ArmOperation <CustomIPPrefix> CreateOrUpdate(bool waitForCompletion, string customIPPrefixName, CustomIPPrefixData parameters, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(customIPPrefixName, nameof(customIPPrefixName)); Argument.AssertNotNull(parameters, nameof(parameters)); using var scope = _customIPPrefixClientDiagnostics.CreateScope("CustomIPPrefixCollection.CreateOrUpdate"); scope.Start(); try { var response = _customIPPrefixRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, customIPPrefixName, parameters, cancellationToken); var operation = new NetworkArmOperation <CustomIPPrefix>(new CustomIPPrefixOperationSource(Client), _customIPPrefixClientDiagnostics, Pipeline, _customIPPrefixRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, customIPPrefixName, parameters).Request, response, OperationFinalStateVia.Location); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }