Пример #1
0
        public async Task <Response <SqlAgentConfigurationData> > GetAsync(string subscriptionId, string resourceGroupName, string managedInstanceName, CancellationToken cancellationToken = default)
        {
            if (subscriptionId == null)
            {
                throw new ArgumentNullException(nameof(subscriptionId));
            }
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (managedInstanceName == null)
            {
                throw new ArgumentNullException(nameof(managedInstanceName));
            }

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

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

                value = SqlAgentConfigurationData.DeserializeSqlAgentConfigurationData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
Пример #2
0
        public virtual SqlAgentCreateOrUpdateOperation CreateOrUpdate(SqlAgentConfigurationData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("SqlAgentConfiguration.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _sqlAgentRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, parameters, cancellationToken);
                var operation = new SqlAgentCreateOrUpdateOperation(this, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Пример #3
0
 internal SqlAgentConfiguration(ArmResource options, SqlAgentConfigurationData resource) : base(options, resource.Id)
 {
     HasData             = true;
     _data               = resource;
     Parent              = options;
     _clientDiagnostics  = new ClientDiagnostics(ClientOptions);
     _sqlAgentRestClient = new SqlAgentRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
Пример #4
0
 internal SqlAgentConfigurationResource(ArmClient client, SqlAgentConfigurationData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
Пример #5
0
        public virtual ArmOperation <SqlAgentConfigurationResource> CreateOrUpdate(WaitUntil waitUntil, SqlAgentConfigurationData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _sqlAgentConfigurationSqlAgentClientDiagnostics.CreateScope("SqlAgentConfigurationResource.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _sqlAgentConfigurationSqlAgentRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, data, cancellationToken);
                var operation = new SqlArmOperation <SqlAgentConfigurationResource>(Response.FromValue(new SqlAgentConfigurationResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Пример #6
0
        public virtual async Task <ArmOperation <SqlAgentConfiguration> > CreateOrUpdateAsync(WaitUntil waitUntil, SqlAgentConfigurationData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _sqlAgentConfigurationSqlAgentClientDiagnostics.CreateScope("SqlAgentConfiguration.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _sqlAgentConfigurationSqlAgentRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new SqlArmOperation <SqlAgentConfiguration>(Response.FromValue(new SqlAgentConfiguration(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
 internal SqlAgentConfiguration(ArmClient armClient, SqlAgentConfigurationData data) : this(armClient, data.Id)
 {
     HasData = true;
     _data   = data;
 }
        public async virtual Task <SqlAgentConfigurationCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, SqlAgentConfigurationData parameters, CancellationToken cancellationToken = default)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _sqlAgentConfigurationSqlAgentClientDiagnostics.CreateScope("SqlAgentConfiguration.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _sqlAgentConfigurationSqlAgentRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new SqlAgentConfigurationCreateOrUpdateOperation(ArmClient, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }