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

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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="deviceManagementSettingInstanceToInitialize">The <see cref="DeviceManagementSettingInstance"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(DeviceManagementSettingInstance deviceManagementSettingInstanceToInitialize)
 {
 }
Пример #5
0
 /// <summary>
 /// Adds the specified DeviceManagementSettingInstance to the collection via POST.
 /// </summary>
 /// <param name="deviceManagementSettingInstance">The DeviceManagementSettingInstance to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created DeviceManagementSettingInstance.</returns>
 public System.Threading.Tasks.Task <DeviceManagementSettingInstance> AddAsync(DeviceManagementSettingInstance deviceManagementSettingInstance, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     deviceManagementSettingInstance.ODataType = string.Concat("#", StringHelper.ConvertTypeToLowerCamelCase(deviceManagementSettingInstance.GetType().FullName));
     return(this.SendAsync <DeviceManagementSettingInstance>(deviceManagementSettingInstance, cancellationToken));
 }