public async Task <Response <InstancePool> > GetAsync(string resourceGroupName, string instancePoolName, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (instancePoolName == null)
            {
                throw new ArgumentNullException(nameof(instancePoolName));
            }

            using var message = CreateGetRequest(resourceGroupName, instancePoolName);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

            switch (message.Response.Status)
            {
            case 200:
            {
                InstancePool value = default;
                using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false);

                value = InstancePool.DeserializeInstancePool(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
Example #2
0
        public virtual InstancePoolsCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string instancePoolName, InstancePool parameters, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (instancePoolName == null)
            {
                throw new ArgumentNullException(nameof(instancePoolName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("InstancePoolsOperations.StartCreateOrUpdate");
            scope.Start();
            try
            {
                var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, instancePoolName, parameters, cancellationToken);
                return(new InstancePoolsCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, instancePoolName, parameters).Request, originalResponse));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }