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

            return(updatedEntity);
        }
Пример #2
0
 /// <summary>
 /// Adds the specified WindowsAutopilotDeploymentProfile to the collection via POST.
 /// </summary>
 /// <param name="windowsAutopilotDeploymentProfile">The WindowsAutopilotDeploymentProfile to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created WindowsAutopilotDeploymentProfile.</returns>
 public System.Threading.Tasks.Task <WindowsAutopilotDeploymentProfile> AddAsync(WindowsAutopilotDeploymentProfile windowsAutopilotDeploymentProfile, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     windowsAutopilotDeploymentProfile.ODataType = string.Concat("#", StringHelper.ConvertTypeToLowerCamelCase(windowsAutopilotDeploymentProfile.GetType().FullName));
     return(this.SendAsync <WindowsAutopilotDeploymentProfile>(windowsAutopilotDeploymentProfile, cancellationToken));
 }