예제 #1
0
        /// <summary>
        /// Updates the specified PermissionGrantPolicy using PATCH.
        /// </summary>
        /// <param name="permissionGrantPolicyToUpdate">The PermissionGrantPolicy 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 PermissionGrantPolicy.</returns>
        public async System.Threading.Tasks.Task <PermissionGrantPolicy> UpdateAsync(PermissionGrantPolicy permissionGrantPolicyToUpdate, CancellationToken cancellationToken)
        {
            if (permissionGrantPolicyToUpdate.AdditionalData != null)
            {
                if (permissionGrantPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    permissionGrantPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, permissionGrantPolicyToUpdate.GetType().Name)
                    });
                }
            }
            if (permissionGrantPolicyToUpdate.AdditionalData != null)
            {
                if (permissionGrantPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    permissionGrantPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, permissionGrantPolicyToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <PermissionGrantPolicy>(permissionGrantPolicyToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
예제 #2
0
        /// <summary>
        /// Creates the specified PermissionGrantPolicy using POST.
        /// </summary>
        /// <param name="permissionGrantPolicyToCreate">The PermissionGrantPolicy to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created PermissionGrantPolicy.</returns>
        public async System.Threading.Tasks.Task <PermissionGrantPolicy> CreateAsync(PermissionGrantPolicy permissionGrantPolicyToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <PermissionGrantPolicy>(permissionGrantPolicyToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
예제 #3
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="permissionGrantPolicyToInitialize">The <see cref="PermissionGrantPolicy"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(PermissionGrantPolicy permissionGrantPolicyToInitialize)
        {
            if (permissionGrantPolicyToInitialize != null && permissionGrantPolicyToInitialize.AdditionalData != null)
            {
                if (permissionGrantPolicyToInitialize.Excludes != null && permissionGrantPolicyToInitialize.Excludes.CurrentPage != null)
                {
                    permissionGrantPolicyToInitialize.Excludes.AdditionalData = permissionGrantPolicyToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        permissionGrantPolicyToInitialize.Excludes.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (permissionGrantPolicyToInitialize.Includes != null && permissionGrantPolicyToInitialize.Includes.CurrentPage != null)
                {
                    permissionGrantPolicyToInitialize.Includes.AdditionalData = permissionGrantPolicyToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        permissionGrantPolicyToInitialize.Includes.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
 /// <summary>
 /// Adds the specified PermissionGrantPolicy to the collection via POST.
 /// </summary>
 /// <param name="permissionGrantPolicy">The PermissionGrantPolicy to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created PermissionGrantPolicy.</returns>
 public System.Threading.Tasks.Task <PermissionGrantPolicy> AddAsync(PermissionGrantPolicy permissionGrantPolicy, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <PermissionGrantPolicy>(permissionGrantPolicy, cancellationToken));
 }
 /// <summary>
 /// Adds the specified PermissionGrantPolicy to the collection via POST.
 /// </summary>
 /// <param name="permissionGrantPolicy">The PermissionGrantPolicy to add.</param>
 /// <returns>The created PermissionGrantPolicy.</returns>
 public System.Threading.Tasks.Task <PermissionGrantPolicy> AddAsync(PermissionGrantPolicy permissionGrantPolicy)
 {
     return(this.AddAsync(permissionGrantPolicy, CancellationToken.None));
 }
예제 #6
0
 /// <summary>
 /// Creates the specified PermissionGrantPolicy using POST.
 /// </summary>
 /// <param name="permissionGrantPolicyToCreate">The PermissionGrantPolicy to create.</param>
 /// <returns>The created PermissionGrantPolicy.</returns>
 public System.Threading.Tasks.Task <PermissionGrantPolicy> CreateAsync(PermissionGrantPolicy permissionGrantPolicyToCreate)
 {
     return(this.CreateAsync(permissionGrantPolicyToCreate, CancellationToken.None));
 }