Example #1
0
 /// <summary>
 /// Adds the specified DirectorySettingTemplate to the collection via POST.
 /// </summary>
 /// <param name="directorySettingTemplate">The DirectorySettingTemplate to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created DirectorySettingTemplate.</returns>
 public System.Threading.Tasks.Task <DirectorySettingTemplate> AddAsync(DirectorySettingTemplate directorySettingTemplate, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <DirectorySettingTemplate>(directorySettingTemplate, cancellationToken));
 }
Example #2
0
 /// <summary>
 /// Adds the specified DirectorySettingTemplate to the collection via POST.
 /// </summary>
 /// <param name="directorySettingTemplate">The DirectorySettingTemplate to add.</param>
 /// <returns>The created DirectorySettingTemplate.</returns>
 public System.Threading.Tasks.Task <DirectorySettingTemplate> AddAsync(DirectorySettingTemplate directorySettingTemplate)
 {
     return(this.AddAsync(directorySettingTemplate, CancellationToken.None));
 }
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="directorySettingTemplateToInitialize">The <see cref="DirectorySettingTemplate"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(DirectorySettingTemplate directorySettingTemplateToInitialize)
 {
 }
        /// <summary>
        /// Creates the specified DirectorySettingTemplate using POST.
        /// </summary>
        /// <param name="directorySettingTemplateToCreate">The DirectorySettingTemplate to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created DirectorySettingTemplate.</returns>
        public async System.Threading.Tasks.Task <DirectorySettingTemplate> CreateAsync(DirectorySettingTemplate directorySettingTemplateToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <DirectorySettingTemplate>(directorySettingTemplateToCreate, cancellationToken).ConfigureAwait(false);

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

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