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

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

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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        appVulnerabilityTaskToInitialize.ManagedDevices.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (appVulnerabilityTaskToInitialize.MobileApps != null && appVulnerabilityTaskToInitialize.MobileApps.CurrentPage != null)
                {
                    appVulnerabilityTaskToInitialize.MobileApps.AdditionalData = appVulnerabilityTaskToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        appVulnerabilityTaskToInitialize.MobileApps.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
 /// <summary>
 /// Creates the specified AppVulnerabilityTask using POST.
 /// </summary>
 /// <param name="appVulnerabilityTaskToCreate">The AppVulnerabilityTask to create.</param>
 /// <returns>The created AppVulnerabilityTask.</returns>
 public System.Threading.Tasks.Task <AppVulnerabilityTask> CreateAsync(AppVulnerabilityTask appVulnerabilityTaskToCreate)
 {
     return(this.CreateAsync(appVulnerabilityTaskToCreate, CancellationToken.None));
 }