Exemplo n.º 1
0
 internal IpGroup(ArmResource options, IpGroupData resource) : base(options, new ResourceIdentifier(resource.Id))
 {
     HasData             = true;
     _data               = resource;
     _clientDiagnostics  = new ClientDiagnostics(ClientOptions);
     _ipGroupsRestClient = new IpGroupsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
 }
Exemplo n.º 2
0
 internal IpGroup(ArmResource options, IpGroupData resource) : base(options, resource.Id)
 {
     HasData            = true;
     _data              = resource;
     _clientDiagnostics = new ClientDiagnostics(ClientOptions);
     _restClient        = new IpGroupsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, Id.SubscriptionId, BaseUri);
 }
Exemplo n.º 3
0
        public async Task <Response <IpGroupData> > GetAsync(string subscriptionId, string resourceGroupName, string ipGroupsName, string expand = null, CancellationToken cancellationToken = default)
        {
            if (subscriptionId == null)
            {
                throw new ArgumentNullException(nameof(subscriptionId));
            }
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (ipGroupsName == null)
            {
                throw new ArgumentNullException(nameof(ipGroupsName));
            }

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

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

                value = IpGroupData.DeserializeIpGroupData(document.RootElement);
                return(Response.FromValue(value, message.Response));
            }
        IpGroup IOperationSource <IpGroup> .CreateResult(Response response, CancellationToken cancellationToken)
        {
            using var document = JsonDocument.Parse(response.ContentStream);
            var data = IpGroupData.DeserializeIpGroupData(document.RootElement);

            return(new IpGroup(_client, data));
        }
Exemplo n.º 5
0
        public async virtual Task <IpGroupCreateOrUpdateOperation> CreateOrUpdateAsync(string ipGroupsName, IpGroupData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (ipGroupsName == null)
            {
                throw new ArgumentNullException(nameof(ipGroupsName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("IpGroupContainer.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _restClient.CreateOrUpdateAsync(Id.ResourceGroupName, ipGroupsName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new IpGroupCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _restClient.CreateCreateOrUpdateRequest(Id.ResourceGroupName, ipGroupsName, parameters).Request, response);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 6
0
 internal IpGroup(ArmClient client, IpGroupData data) : this(client, new ResourceIdentifier(data.Id))
 {
     HasData = true;
     _data   = data;
 }
Exemplo n.º 7
0
        public virtual IpGroupCreateOrUpdateOperation CreateOrUpdate(string ipGroupsName, IpGroupData parameters, bool waitForCompletion = true, CancellationToken cancellationToken = default)
        {
            if (ipGroupsName == null)
            {
                throw new ArgumentNullException(nameof(ipGroupsName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("IpGroupCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _ipGroupsRestClient.CreateOrUpdate(Id.SubscriptionId, Id.ResourceGroupName, ipGroupsName, parameters, cancellationToken);
                var operation = new IpGroupCreateOrUpdateOperation(Parent, _clientDiagnostics, Pipeline, _ipGroupsRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, ipGroupsName, parameters).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemplo n.º 8
0
        public async virtual Task <ArmOperation <IpGroup> > CreateOrUpdateAsync(bool waitForCompletion, string ipGroupsName, IpGroupData parameters, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(ipGroupsName, nameof(ipGroupsName));
            Argument.AssertNotNull(parameters, nameof(parameters));

            using var scope = _ipGroupClientDiagnostics.CreateScope("IpGroupCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response = await _ipGroupRestClient.CreateOrUpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, ipGroupsName, parameters, cancellationToken).ConfigureAwait(false);

                var operation = new NetworkArmOperation <IpGroup>(new IpGroupOperationSource(Client), _ipGroupClientDiagnostics, Pipeline, _ipGroupRestClient.CreateCreateOrUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, ipGroupsName, parameters).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitForCompletion)
                {
                    await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }