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

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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="deviceManagementConfigurationCategoryToInitialize">The <see cref="DeviceManagementConfigurationCategory"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(DeviceManagementConfigurationCategory deviceManagementConfigurationCategoryToInitialize)
 {
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Adds the specified DeviceManagementConfigurationCategory to the collection via POST.
 /// </summary>
 /// <param name="deviceManagementConfigurationCategory">The DeviceManagementConfigurationCategory to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created DeviceManagementConfigurationCategory.</returns>
 public System.Threading.Tasks.Task <DeviceManagementConfigurationCategory> AddAsync(DeviceManagementConfigurationCategory deviceManagementConfigurationCategory, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <DeviceManagementConfigurationCategory>(deviceManagementConfigurationCategory, cancellationToken));
 }