internal DeviceUpdateAccount(ArmResource options, DeviceUpdateAccountData resource) : base(options, resource.Id) { HasData = true; _data = resource; _clientDiagnostics = new ClientDiagnostics(ClientOptions); _deviceUpdateAccountsRestClient = new DeviceUpdateAccountsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri); }
DeviceUpdateAccountResource IOperationSource <DeviceUpdateAccountResource> .CreateResult(Response response, CancellationToken cancellationToken) { using var document = JsonDocument.Parse(response.ContentStream); var data = DeviceUpdateAccountData.DeserializeDeviceUpdateAccountData(document.RootElement); return(new DeviceUpdateAccountResource(_client, data)); }
public virtual async Task <ArmOperation <DeviceUpdateAccount> > CreateOrUpdateAsync(WaitUntil waitUntil, string accountName, DeviceUpdateAccountData account, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); Argument.AssertNotNull(account, nameof(account)); using var scope = _deviceUpdateAccountAccountsClientDiagnostics.CreateScope("DeviceUpdateAccountCollection.CreateOrUpdate"); scope.Start(); try { var response = await _deviceUpdateAccountAccountsRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, accountName, account, cancellationToken).ConfigureAwait(false); var operation = new DeviceUpdateArmOperation <DeviceUpdateAccount>(new DeviceUpdateAccountOperationSource(Client), _deviceUpdateAccountAccountsClientDiagnostics, Pipeline, _deviceUpdateAccountAccountsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, accountName, account).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public async virtual Task <DeviceUpdateAccountCreateOperation> CreateOrUpdateAsync(string accountName, DeviceUpdateAccountData account, bool waitForCompletion = true, CancellationToken cancellationToken = default) { if (accountName == null) { throw new ArgumentNullException(nameof(accountName)); } if (account == null) { throw new ArgumentNullException(nameof(account)); } using var scope = _clientDiagnostics.CreateScope("DeviceUpdateAccountCollection.CreateOrUpdate"); scope.Start(); try { var response = await _deviceUpdateAccountsRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, accountName, account, cancellationToken).ConfigureAwait(false); var operation = new DeviceUpdateAccountCreateOperation(Parent, _clientDiagnostics, Pipeline, _deviceUpdateAccountsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, accountName, account).Request, response); if (waitForCompletion) { await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
internal DeviceUpdateAccountResource(ArmClient client, DeviceUpdateAccountData data) : this(client, data.Id) { HasData = true; _data = data; }
internal DeviceUpdateAccount(ArmClient armClient, DeviceUpdateAccountData data) : this(armClient, data.Id) { HasData = true; _data = data; }
public virtual DeviceUpdateAccountCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string accountName, DeviceUpdateAccountData account, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(accountName, nameof(accountName)); if (account == null) { throw new ArgumentNullException(nameof(account)); } using var scope = _deviceUpdateAccountAccountsClientDiagnostics.CreateScope("DeviceUpdateAccountCollection.CreateOrUpdate"); scope.Start(); try { var response = _deviceUpdateAccountAccountsRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, accountName, account, cancellationToken); var operation = new DeviceUpdateAccountCreateOrUpdateOperation(ArmClient, _deviceUpdateAccountAccountsClientDiagnostics, Pipeline, _deviceUpdateAccountAccountsRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, accountName, account).Request, response); if (waitForCompletion) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }