Beispiel #1
0
        SapCentralServerInstanceResource IOperationSource <SapCentralServerInstanceResource> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = SapCentralServerInstanceData.DeserializeSapCentralServerInstanceData(document.RootElement);

            return(new SapCentralServerInstanceResource(_client, data));
        }
Beispiel #2
0
        public async Task <Response <SapCentralServerInstanceData> > GetAsync(string subscriptionId, string resourceGroupName, string sapVirtualInstanceName, string centralInstanceName, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId));
            Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName));
            Argument.AssertNotNullOrEmpty(sapVirtualInstanceName, nameof(sapVirtualInstanceName));
            Argument.AssertNotNullOrEmpty(centralInstanceName, nameof(centralInstanceName));

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

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

                value = SapCentralServerInstanceData.DeserializeSapCentralServerInstanceData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
Beispiel #3
0
 internal SapCentralServerInstanceResource(ArmClient client, SapCentralServerInstanceData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
Beispiel #4
0
        public virtual async Task <ArmOperation <SapCentralServerInstanceResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string centralInstanceName, SapCentralServerInstanceData data = null, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(centralInstanceName, nameof(centralInstanceName));

            using var scope = _sapCentralServerInstanceSAPCentralInstancesClientDiagnostics.CreateScope("SapCentralServerInstanceCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _sapCentralServerInstanceSAPCentralInstancesRestClient.CreateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, centralInstanceName, data, cancellationToken).ConfigureAwait(false);

                var operation = new WorkloadsArmOperation <SapCentralServerInstanceResource>(new SapCentralServerInstanceOperationSource(Client), _sapCentralServerInstanceSAPCentralInstancesClientDiagnostics, Pipeline, _sapCentralServerInstanceSAPCentralInstancesRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, centralInstanceName, data).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }