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

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

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