コード例 #1
0
        SyncAgent IOperationSource <SyncAgent> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = SyncAgentData.DeserializeSyncAgentData(document.RootElement);

            return(new SyncAgent(_client, data));
        }
コード例 #2
0
        public async Task <Response <SyncAgentData> > GetAsync(string subscriptionId, string resourceGroupName, string serverName, string syncAgentName, CancellationToken cancellationToken = default)
        {
            if (subscriptionId == null)
            {
                throw new ArgumentNullException(nameof(subscriptionId));
            }
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (serverName == null)
            {
                throw new ArgumentNullException(nameof(serverName));
            }
            if (syncAgentName == null)
            {
                throw new ArgumentNullException(nameof(syncAgentName));
            }

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

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

                value = SyncAgentData.DeserializeSyncAgentData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
コード例 #3
0
 internal SyncAgent(ArmResource options, SyncAgentData resource) : base(options, resource.Id)
 {
     HasData               = true;
     _data                 = resource;
     _clientDiagnostics    = new ClientDiagnostics(ClientOptions);
     _syncAgentsRestClient = new SyncAgentsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
コード例 #4
0
        public virtual ArmOperation <SyncAgentResource> Update(WaitUntil waitUntil, SyncAgentData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _syncAgentClientDiagnostics.CreateScope("SyncAgentResource.Update");
            scope.Start();
            try
            {
                var response  = _syncAgentRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken);
                var operation = new SqlArmOperation <SyncAgentResource>(new SyncAgentOperationSource(Client), _syncAgentClientDiagnostics, Pipeline, _syncAgentRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
コード例 #5
0
        public virtual async Task <ArmOperation <SyncAgentResource> > CreateOrUpdateAsync(WaitUntil waitUntil, string syncAgentName, SyncAgentData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(syncAgentName, nameof(syncAgentName));
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _syncAgentClientDiagnostics.CreateScope("SyncAgentCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _syncAgentRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, syncAgentName, data, cancellationToken).ConfigureAwait(false);

                var operation = new SqlArmOperation <SyncAgentResource>(new SyncAgentOperationSource(Client), _syncAgentClientDiagnostics, Pipeline, _syncAgentRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, syncAgentName, data).Request, response, OperationFinalStateVia.Location);
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
コード例 #6
0
        public virtual SyncAgentCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string syncAgentName, SyncAgentData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(syncAgentName, nameof(syncAgentName));
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _syncAgentClientDiagnostics.CreateScope("SyncAgentCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _syncAgentRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, syncAgentName, parameters, cancellationToken);
                var operation = new SyncAgentCreateOrUpdateOperation(ArmClient, _syncAgentClientDiagnostics, Pipeline, _syncAgentRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, syncAgentName, parameters).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
コード例 #7
0
 internal SyncAgentResource(ArmClient client, SyncAgentData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
コード例 #8
0
 internal SyncAgent(ArmClient armClient, SyncAgentData data) : this(armClient, data.Id)
 {
     HasData = true;
     _data   = data;
 }
コード例 #9
0
        public async virtual Task <SyncAgentCreateOrUpdateOperation> CreateOrUpdateAsync(string syncAgentName, SyncAgentData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (syncAgentName == null)
            {
                throw new ArgumentNullException(nameof(syncAgentName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("SyncAgentCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _syncAgentsRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, syncAgentName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new SyncAgentCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _syncAgentsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, syncAgentName, parameters).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }