/// <summary>
 /// Adds the specified GovernanceRoleAssignmentRequestObject to the collection via POST.
 /// </summary>
 /// <param name="governanceRoleAssignmentRequest">The GovernanceRoleAssignmentRequestObject to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created GovernanceRoleAssignmentRequestObject.</returns>
 public System.Threading.Tasks.Task <GovernanceRoleAssignmentRequestObject> AddAsync(GovernanceRoleAssignmentRequestObject governanceRoleAssignmentRequest, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <GovernanceRoleAssignmentRequestObject>(governanceRoleAssignmentRequest, cancellationToken));
 }
 /// <summary>
 /// Adds the specified GovernanceRoleAssignmentRequestObject to the collection via POST.
 /// </summary>
 /// <param name="governanceRoleAssignmentRequest">The GovernanceRoleAssignmentRequestObject to add.</param>
 /// <returns>The created GovernanceRoleAssignmentRequestObject.</returns>
 public System.Threading.Tasks.Task <GovernanceRoleAssignmentRequestObject> AddAsync(GovernanceRoleAssignmentRequestObject governanceRoleAssignmentRequest)
 {
     return(this.AddAsync(governanceRoleAssignmentRequest, CancellationToken.None));
 }
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="governanceRoleAssignmentRequestObjectToInitialize">The <see cref="GovernanceRoleAssignmentRequestObject"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(GovernanceRoleAssignmentRequestObject governanceRoleAssignmentRequestObjectToInitialize)
 {
 }
        /// <summary>
        /// Creates the specified GovernanceRoleAssignmentRequestObject using POST.
        /// </summary>
        /// <param name="governanceRoleAssignmentRequestObjectToCreate">The GovernanceRoleAssignmentRequestObject to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created GovernanceRoleAssignmentRequestObject.</returns>
        public async System.Threading.Tasks.Task <GovernanceRoleAssignmentRequestObject> CreateAsync(GovernanceRoleAssignmentRequestObject governanceRoleAssignmentRequestObjectToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <GovernanceRoleAssignmentRequestObject>(governanceRoleAssignmentRequestObjectToCreate, cancellationToken).ConfigureAwait(false);

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

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