Esempio n. 1
0
 internal SchemaGroup(ArmResource options, SchemaGroupData resource) : base(options, resource.Id)
 {
     HasData                   = true;
     _data                     = resource;
     _clientDiagnostics        = new ClientDiagnostics(ClientOptions);
     _schemaRegistryRestClient = new SchemaRegistryRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
        public async virtual Task <SchemaGroupCreateOrUpdateOperation> CreateOrUpdateAsync(bool waitForCompletion, string schemaGroupName, SchemaGroupData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(schemaGroupName, nameof(schemaGroupName));
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _schemaGroupSchemaRegistryClientDiagnostics.CreateScope("SchemaGroupCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _schemaGroupSchemaRegistryRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, schemaGroupName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new SchemaGroupCreateOrUpdateOperation(ArmClient, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Esempio n. 3
0
 internal SchemaGroup(ArmClient client, SchemaGroupData data) : this(client, data.Id)
 {
     HasData = true;
     _data   = data;
 }
Esempio n. 4
0
        public virtual SchemaRegistryCreateOrUpdateOperation CreateOrUpdate(string schemaGroupName, SchemaGroupData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (schemaGroupName == null)
            {
                throw new ArgumentNullException(nameof(schemaGroupName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("SchemaGroupCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _schemaRegistryRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, schemaGroupName, parameters, cancellationToken);
                var operation = new SchemaRegistryCreateOrUpdateOperation(Parent, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Esempio n. 5
0
        public virtual ArmOperation <SchemaGroup> CreateOrUpdate(WaitUntil waitUntil, string schemaGroupName, SchemaGroupData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(schemaGroupName, nameof(schemaGroupName));
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _schemaGroupSchemaRegistryClientDiagnostics.CreateScope("SchemaGroupCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _schemaGroupSchemaRegistryRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, schemaGroupName, parameters, cancellationToken);
                var operation = new EventHubsArmOperation <SchemaGroup>(Response.FromValue(new SchemaGroup(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
        public virtual async Task <ArmOperation <SchemaGroupResource> > UpdateAsync(WaitUntil waitUntil, SchemaGroupData data, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(data, nameof(data));

            using var scope = _schemaGroupSchemaRegistryClientDiagnostics.CreateScope("SchemaGroupResource.Update");
            scope.Start();
            try
            {
                var response = await _schemaGroupSchemaRegistryRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, data, cancellationToken).ConfigureAwait(false);

                var operation = new EventHubsArmOperation <SchemaGroupResource>(Response.FromValue(new SchemaGroupResource(Client, response), response.GetRawResponse()));
                if (waitUntil == WaitUntil.Completed)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }