コード例 #1
0
        /// <summary>
        /// Creates the specified AccessPackageResourceRole using POST.
        /// </summary>
        /// <param name="accessPackageResourceRoleToCreate">The AccessPackageResourceRole to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created AccessPackageResourceRole.</returns>
        public async System.Threading.Tasks.Task <AccessPackageResourceRole> CreateAsync(AccessPackageResourceRole accessPackageResourceRoleToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <AccessPackageResourceRole>(accessPackageResourceRoleToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
コード例 #2
0
 /// <summary>
 /// Creates the specified AccessPackageResourceRole using POST.
 /// </summary>
 /// <param name="accessPackageResourceRoleToCreate">The AccessPackageResourceRole to create.</param>
 /// <returns>The created AccessPackageResourceRole.</returns>
 public System.Threading.Tasks.Task <AccessPackageResourceRole> CreateAsync(AccessPackageResourceRole accessPackageResourceRoleToCreate)
 {
     return(this.CreateAsync(accessPackageResourceRoleToCreate, CancellationToken.None));
 }
コード例 #3
0
        /// <summary>
        /// Updates the specified AccessPackageResourceRole using PATCH.
        /// </summary>
        /// <param name="accessPackageResourceRoleToUpdate">The AccessPackageResourceRole 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 AccessPackageResourceRole.</returns>
        public async System.Threading.Tasks.Task <AccessPackageResourceRole> UpdateAsync(AccessPackageResourceRole accessPackageResourceRoleToUpdate, CancellationToken cancellationToken)
        {
            if (accessPackageResourceRoleToUpdate.AdditionalData != null)
            {
                if (accessPackageResourceRoleToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    accessPackageResourceRoleToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, accessPackageResourceRoleToUpdate.GetType().Name)
                    });
                }
            }
            if (accessPackageResourceRoleToUpdate.AdditionalData != null)
            {
                if (accessPackageResourceRoleToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    accessPackageResourceRoleToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, accessPackageResourceRoleToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <AccessPackageResourceRole>(accessPackageResourceRoleToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
コード例 #4
0
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="accessPackageResourceRoleToInitialize">The <see cref="AccessPackageResourceRole"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(AccessPackageResourceRole accessPackageResourceRoleToInitialize)
 {
 }
コード例 #5
0
 /// <summary>
 /// Adds the specified AccessPackageResourceRole to the collection via POST.
 /// </summary>
 /// <param name="accessPackageResourceRole">The AccessPackageResourceRole to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created AccessPackageResourceRole.</returns>
 public System.Threading.Tasks.Task <AccessPackageResourceRole> AddAsync(AccessPackageResourceRole accessPackageResourceRole, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <AccessPackageResourceRole>(accessPackageResourceRole, cancellationToken));
 }