/// <summary> /// Updates the specified ManagementCondition using PATCH. /// </summary> /// <param name="managementConditionToUpdate">The ManagementCondition 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 ManagementCondition.</returns> public async System.Threading.Tasks.Task <ManagementCondition> UpdateAsync(ManagementCondition managementConditionToUpdate, CancellationToken cancellationToken) { if (managementConditionToUpdate.AdditionalData != null) { if (managementConditionToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || managementConditionToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, managementConditionToUpdate.GetType().Name) }); } } if (managementConditionToUpdate.AdditionalData != null) { if (managementConditionToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || managementConditionToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, managementConditionToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <ManagementCondition>(managementConditionToUpdate, cancellationToken).ConfigureAwait(false); return(updatedEntity); }
/// <summary> /// Adds the specified ManagementCondition to the collection via POST. /// </summary> /// <param name="managementCondition">The ManagementCondition to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created ManagementCondition.</returns> public System.Threading.Tasks.Task <ManagementCondition> AddAsync(ManagementCondition managementCondition, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; managementCondition.ODataType = string.Concat("#", StringHelper.ConvertTypeToLowerCamelCase(managementCondition.GetType().FullName)); return(this.SendAsync <ManagementCondition>(managementCondition, cancellationToken)); }
/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="managementConditionToInitialize">The <see cref="ManagementCondition"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(ManagementCondition managementConditionToInitialize) { if (managementConditionToInitialize != null && managementConditionToInitialize.AdditionalData != null) { if (managementConditionToInitialize.ManagementConditionStatements != null && managementConditionToInitialize.ManagementConditionStatements.CurrentPage != null) { managementConditionToInitialize.ManagementConditionStatements.AdditionalData = managementConditionToInitialize.AdditionalData; object nextPageLink; managementConditionToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { managementConditionToInitialize.ManagementConditionStatements.InitializeNextPageRequest( this.Client, nextPageLinkString); } } } }
/// <summary> /// Creates the specified ManagementCondition using POST. /// </summary> /// <param name="managementConditionToCreate">The ManagementCondition to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created ManagementCondition.</returns> public async System.Threading.Tasks.Task <ManagementCondition> CreateAsync(ManagementCondition managementConditionToCreate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; var newEntity = await this.SendAsync <ManagementCondition>(managementConditionToCreate, cancellationToken).ConfigureAwait(false); return(newEntity); }
/// <summary> /// Adds the specified ManagementCondition to the collection via POST. /// </summary> /// <param name="managementCondition">The ManagementCondition to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The task to await.</returns> public System.Threading.Tasks.Task AddAsync(ManagementCondition managementCondition, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; if (string.IsNullOrEmpty(managementCondition.Id)) { throw new ServiceException(new Error { Code = "invalidRequest", Message = "ID is required to add a reference." }); } var requestBody = new ReferenceRequestBody { ODataId = string.Format("{0}/deviceManagement/managementConditions/{1}", this.Client.BaseUrl, managementCondition.Id) }; return(this.SendAsync(requestBody, cancellationToken)); }
/// <summary> /// Updates the specified ManagementCondition using PATCH. /// </summary> /// <param name="managementConditionToUpdate">The ManagementCondition to update.</param> /// <returns>The updated ManagementCondition.</returns> public System.Threading.Tasks.Task <ManagementCondition> UpdateAsync(ManagementCondition managementConditionToUpdate) { return(this.UpdateAsync(managementConditionToUpdate, CancellationToken.None)); }
/// <summary> /// Adds the specified ManagementCondition to the collection via POST. /// </summary> /// <param name="managementCondition">The ManagementCondition to add.</param> /// <returns>The created ManagementCondition.</returns> public System.Threading.Tasks.Task <ManagementCondition> AddAsync(ManagementCondition managementCondition) { return(this.AddAsync(managementCondition, CancellationToken.None)); }
/// <summary> /// Creates the specified ManagementCondition using POST. /// </summary> /// <param name="managementConditionToCreate">The ManagementCondition to create.</param> /// <returns>The created ManagementCondition.</returns> public System.Threading.Tasks.Task<ManagementCondition> CreateAsync(ManagementCondition managementConditionToCreate) { return this.CreateAsync(managementConditionToCreate, CancellationToken.None); }