Exemplo n.º 1
0
        ScVmmCloudResource IOperationSource <ScVmmCloudResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = ScVmmCloudData.DeserializeScVmmCloudData(document.RootElement);

            return(new ScVmmCloudResource(_client, data));
        }
Exemplo n.º 2
0
        public async Task <Response <ScVmmCloudData> > GetAsync(string subscriptionId, string resourceGroupName, string cloudName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
            Argument.AssertNotNullOrEmpty(cloudName, nameof(cloudName));

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

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

                value = ScVmmCloudData.DeserializeScVmmCloudData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
        public virtual async Task <ArmOperation <ScVmmCloudResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string cloudName, ScVmmCloudData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(cloudName, nameof(cloudName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _scVmmCloudCloudsClientDiagnostics.CreateScope("ScVmmCloudCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _scVmmCloudCloudsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, cloudName, data, cancellationToken).ConfigureAwait(false);

                var operation = new ArcScVmmArmOperation <ScVmmCloudResource>(new ScVmmCloudOperationSource(Client), _scVmmCloudCloudsClientDiagnostics, Pipeline, _scVmmCloudCloudsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, cloudName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 4
0
 internal ScVmmCloudResource(ArmClient client, ScVmmCloudData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }