Exemple #1
0
        internal AfdEndpoint(ArmResource options, AfdEndpointData data) : base(options, data.Id)
        {
            HasData                 = true;
            _data                   = data;
            _clientDiagnostics      = new ClientDiagnostics(ClientOptions);
            _afdEndpointsRestClient = new AfdEndpointsRestOperations(_clientDiagnostics, Pipeline, ClientOptions, BaseUri);
#if DEBUG
            ValidateResourceId(Id);
#endif
        }
Exemple #2
0
        public virtual AfdEndpointCreateOrUpdateOperation CreateOrUpdate(bool waitForCompletion, string endpointName, AfdEndpointData endpointInput, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNullOrEmpty(endpointName, nameof(endpointName));
            if (endpointInput == null)
            {
                throw new ArgumentNullException(nameof(endpointInput));
            }

            using var scope = _afdEndpointClientDiagnostics.CreateScope("AfdEndpointCollection.CreateOrUpdate");
            scope.Start();
            try
            {
                var response  = _afdEndpointRestClient.Create(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointName, endpointInput, cancellationToken);
                var operation = new AfdEndpointCreateOrUpdateOperation(ArmClient, _afdEndpointClientDiagnostics, Pipeline, _afdEndpointRestClient.CreateCreateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, endpointName, endpointInput).Request, response);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }