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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        windowsFeatureUpdateProfileToInitialize.Assignments.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (windowsFeatureUpdateProfileToInitialize.DeviceUpdateStates != null && windowsFeatureUpdateProfileToInitialize.DeviceUpdateStates.CurrentPage != null)
                {
                    windowsFeatureUpdateProfileToInitialize.DeviceUpdateStates.AdditionalData = windowsFeatureUpdateProfileToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        windowsFeatureUpdateProfileToInitialize.DeviceUpdateStates.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
        /// <summary>
        /// Creates the specified WindowsFeatureUpdateProfile using POST.
        /// </summary>
        /// <param name="windowsFeatureUpdateProfileToCreate">The WindowsFeatureUpdateProfile to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created WindowsFeatureUpdateProfile.</returns>
        public async System.Threading.Tasks.Task <WindowsFeatureUpdateProfile> CreateAsync(WindowsFeatureUpdateProfile windowsFeatureUpdateProfileToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <WindowsFeatureUpdateProfile>(windowsFeatureUpdateProfileToCreate, cancellationToken).ConfigureAwait(false);

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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
 /// <summary>
 /// Adds the specified WindowsFeatureUpdateProfile to the collection via POST.
 /// </summary>
 /// <param name="windowsFeatureUpdateProfile">The WindowsFeatureUpdateProfile to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created WindowsFeatureUpdateProfile.</returns>
 public System.Threading.Tasks.Task <WindowsFeatureUpdateProfile> AddAsync(WindowsFeatureUpdateProfile windowsFeatureUpdateProfile, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <WindowsFeatureUpdateProfile>(windowsFeatureUpdateProfile, cancellationToken));
 }