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

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

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
 /// <summary>
 /// Adds the specified HostSecurityProfile to the collection via POST.
 /// </summary>
 /// <param name="hostSecurityProfile">The HostSecurityProfile to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created HostSecurityProfile.</returns>
 public System.Threading.Tasks.Task <HostSecurityProfile> AddAsync(HostSecurityProfile hostSecurityProfile, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <HostSecurityProfile>(hostSecurityProfile, cancellationToken));
 }
 /// <summary>
 /// Adds the specified HostSecurityProfile to the collection via POST.
 /// </summary>
 /// <param name="hostSecurityProfile">The HostSecurityProfile to add.</param>
 /// <returns>The created HostSecurityProfile.</returns>
 public System.Threading.Tasks.Task <HostSecurityProfile> AddAsync(HostSecurityProfile hostSecurityProfile)
 {
     return(this.AddAsync(hostSecurityProfile, CancellationToken.None));
 }
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="hostSecurityProfileToInitialize">The <see cref="HostSecurityProfile"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(HostSecurityProfile hostSecurityProfileToInitialize)
 {
 }
 /// <summary>
 /// Updates the specified HostSecurityProfile using PATCH.
 /// </summary>
 /// <param name="hostSecurityProfileToUpdate">The HostSecurityProfile to update.</param>
 /// <returns>The updated HostSecurityProfile.</returns>
 public System.Threading.Tasks.Task <HostSecurityProfile> UpdateAsync(HostSecurityProfile hostSecurityProfileToUpdate)
 {
     return(this.UpdateAsync(hostSecurityProfileToUpdate, CancellationToken.None));
 }