public async Task <Response <ManagedInstanceVulnerabilityAssessmentData> > GetAsync(string subscriptionId, string resourceGroupName, string managedInstanceName, VulnerabilityAssessmentName vulnerabilityAssessmentName, 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, vulnerabilityAssessmentName);
            await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);

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

                value = ManagedInstanceVulnerabilityAssessmentData.DeserializeManagedInstanceVulnerabilityAssessmentData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
 internal ManagedInstanceVulnerabilityAssessment(ArmResource options, ManagedInstanceVulnerabilityAssessmentData resource) : base(options, resource.Id)
 {
     HasData            = true;
     _data              = resource;
     _clientDiagnostics = new ClientDiagnostics(ClientOptions);
     _managedInstanceVulnerabilityAssessmentsRestClient = new ManagedInstanceVulnerabilityAssessmentsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
        public virtual async Task <ArmOperation <ManagedInstanceVulnerabilityAssessmentResource> > CreateOrUpdateAsync(WaitUntil waitUntil, VulnerabilityAssessmentName vulnerabilityAssessmentName, ManagedInstanceVulnerabilityAssessmentData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _managedInstanceVulnerabilityAssessmentClientDiagnostics.CreateScope("ManagedInstanceVulnerabilityAssessmentCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _managedInstanceVulnerabilityAssessmentRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, vulnerabilityAssessmentName, data, cancellationToken).ConfigureAwait(false);

                var operation = new SqlArmOperation <ManagedInstanceVulnerabilityAssessmentResource>(Response.FromValue(new ManagedInstanceVulnerabilityAssessmentResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public async virtual Task <ManagedInstanceVulnerabilityAssessmentCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, VulnerabilityAssessmentName vulnerabilityAssessmentName, ManagedInstanceVulnerabilityAssessmentData parameters, CancellationToken cancellationToken = default)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _managedInstanceVulnerabilityAssessmentClientDiagnostics.CreateScope("ManagedInstanceVulnerabilityAssessmentCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _managedInstanceVulnerabilityAssessmentRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, vulnerabilityAssessmentName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new ManagedInstanceVulnerabilityAssessmentCreateOrUpdateOperation(ArmClient, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
 internal ManagedInstanceVulnerabilityAssessmentResource(ArmClient client, ManagedInstanceVulnerabilityAssessmentData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
        public virtual ArmOperation <ManagedInstanceVulnerabilityAssessment> CreateOrUpdate(bool waitForCompletion, VulnerabilityAssessmentName vulnerabilityAssessmentName, ManagedInstanceVulnerabilityAssessmentData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _managedInstanceVulnerabilityAssessmentClientDiagnostics.CreateScope("ManagedInstanceVulnerabilityAssessmentCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _managedInstanceVulnerabilityAssessmentRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, vulnerabilityAssessmentName, parameters, cancellationToken);
                var operation = new SqlArmOperation <ManagedInstanceVulnerabilityAssessment>(Response.FromValue(new ManagedInstanceVulnerabilityAssessment(Client, response), response.GetRawResponse()));
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual ManagedInstanceVulnerabilityAssessmentCreateOrUpdateOperation CreateOrUpdate(VulnerabilityAssessmentName vulnerabilityAssessmentName, ManagedInstanceVulnerabilityAssessmentData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("ManagedInstanceVulnerabilityAssessmentCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _managedInstanceVulnerabilityAssessmentsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, vulnerabilityAssessmentName, parameters, cancellationToken);
                var operation = new ManagedInstanceVulnerabilityAssessmentCreateOrUpdateOperation(Parent, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }