/// <summary>
 /// Adds the specified ManagedAppPolicy to the collection via POST.
 /// </summary>
 /// <param name="managedAppPolicy">The ManagedAppPolicy to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created ManagedAppPolicy.</returns>
 public System.Threading.Tasks.Task <ManagedAppPolicy> AddAsync(ManagedAppPolicy managedAppPolicy, CancellationToken cancellationToken)
 {
     this.ContentType           = "application/json";
     this.Method                = "POST";
     managedAppPolicy.ODataType = string.Concat("#", StringHelper.ConvertTypeToLowerCamelCase(managedAppPolicy.GetType().FullName));
     return(this.SendAsync <ManagedAppPolicy>(managedAppPolicy, cancellationToken));
 }
        /// <summary>
        /// Updates the specified ManagedAppPolicy using PATCH.
        /// </summary>
        /// <param name="managedAppPolicyToUpdate">The ManagedAppPolicy 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 ManagedAppPolicy.</returns>
        public async System.Threading.Tasks.Task <ManagedAppPolicy> UpdateAsync(ManagedAppPolicy managedAppPolicyToUpdate, CancellationToken cancellationToken)
        {
            if (managedAppPolicyToUpdate.AdditionalData != null)
            {
                if (managedAppPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    managedAppPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, managedAppPolicyToUpdate.GetType().Name)
                    });
                }
            }
            if (managedAppPolicyToUpdate.AdditionalData != null)
            {
                if (managedAppPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    managedAppPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, managedAppPolicyToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <ManagedAppPolicy>(managedAppPolicyToUpdate, cancellationToken).ConfigureAwait(false);

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