Ejemplo n.º 1
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="privateLinkResourcePolicyToInitialize">The <see cref="PrivateLinkResourcePolicy"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(PrivateLinkResourcePolicy privateLinkResourcePolicyToInitialize)
        {
            if (privateLinkResourcePolicyToInitialize != null && privateLinkResourcePolicyToInitialize.AdditionalData != null)
            {
                if (privateLinkResourcePolicyToInitialize.PrivateEndpointConnections != null && privateLinkResourcePolicyToInitialize.PrivateEndpointConnections.CurrentPage != null)
                {
                    privateLinkResourcePolicyToInitialize.PrivateEndpointConnections.AdditionalData = privateLinkResourcePolicyToInitialize.AdditionalData;

                    object nextPageLink;
                    privateLinkResourcePolicyToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        privateLinkResourcePolicyToInitialize.PrivateEndpointConnections.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds the specified PrivateLinkResourcePolicy to the collection via POST.
 /// </summary>
 /// <param name="privateLinkResourcePolicy">The PrivateLinkResourcePolicy to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created PrivateLinkResourcePolicy.</returns>
 public System.Threading.Tasks.Task <PrivateLinkResourcePolicy> AddAsync(PrivateLinkResourcePolicy privateLinkResourcePolicy, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <PrivateLinkResourcePolicy>(privateLinkResourcePolicy, cancellationToken));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds the specified PrivateLinkResourcePolicy to the collection via POST.
 /// </summary>
 /// <param name="privateLinkResourcePolicy">The PrivateLinkResourcePolicy to add.</param>
 /// <returns>The created PrivateLinkResourcePolicy.</returns>
 public System.Threading.Tasks.Task <PrivateLinkResourcePolicy> AddAsync(PrivateLinkResourcePolicy privateLinkResourcePolicy)
 {
     return(this.AddAsync(privateLinkResourcePolicy, CancellationToken.None));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates the specified PrivateLinkResourcePolicy using POST.
        /// </summary>
        /// <param name="privateLinkResourcePolicyToCreate">The PrivateLinkResourcePolicy to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created PrivateLinkResourcePolicy.</returns>
        public async System.Threading.Tasks.Task <PrivateLinkResourcePolicy> CreateAsync(PrivateLinkResourcePolicy privateLinkResourcePolicyToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <PrivateLinkResourcePolicy>(privateLinkResourcePolicyToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Creates the specified PrivateLinkResourcePolicy using POST.
 /// </summary>
 /// <param name="privateLinkResourcePolicyToCreate">The PrivateLinkResourcePolicy to create.</param>
 /// <returns>The created PrivateLinkResourcePolicy.</returns>
 public System.Threading.Tasks.Task <PrivateLinkResourcePolicy> CreateAsync(PrivateLinkResourcePolicy privateLinkResourcePolicyToCreate)
 {
     return(this.CreateAsync(privateLinkResourcePolicyToCreate, CancellationToken.None));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="privateLinkResourcePolicyToInitialize">The <see cref="PrivateLinkResourcePolicy"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(PrivateLinkResourcePolicy privateLinkResourcePolicyToInitialize)
 {
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Updates the specified PrivateLinkResourcePolicy using PATCH.
        /// </summary>
        /// <param name="privateLinkResourcePolicyToUpdate">The PrivateLinkResourcePolicy to update.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
        /// <returns>The updated PrivateLinkResourcePolicy.</returns>
        public async System.Threading.Tasks.Task <PrivateLinkResourcePolicy> UpdateAsync(PrivateLinkResourcePolicy privateLinkResourcePolicyToUpdate, CancellationToken cancellationToken)
        {
            if (privateLinkResourcePolicyToUpdate.AdditionalData != null)
            {
                if (privateLinkResourcePolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    privateLinkResourcePolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, privateLinkResourcePolicyToUpdate.GetType().Name)
                    });
                }
            }
            if (privateLinkResourcePolicyToUpdate.AdditionalData != null)
            {
                if (privateLinkResourcePolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    privateLinkResourcePolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, privateLinkResourcePolicyToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <PrivateLinkResourcePolicy>(privateLinkResourcePolicyToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }