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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        securityBaselineTemplateToInitialize.DeviceStates.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (securityBaselineTemplateToInitialize.CategoryDeviceStateSummaries != null && securityBaselineTemplateToInitialize.CategoryDeviceStateSummaries.CurrentPage != null)
                {
                    securityBaselineTemplateToInitialize.CategoryDeviceStateSummaries.AdditionalData = securityBaselineTemplateToInitialize.AdditionalData;

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

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

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

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