/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="securityConfigurationTaskToInitialize">The <see cref="SecurityConfigurationTask"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(SecurityConfigurationTask securityConfigurationTaskToInitialize) { if (securityConfigurationTaskToInitialize != null && securityConfigurationTaskToInitialize.AdditionalData != null) { if (securityConfigurationTaskToInitialize.ManagedDevices != null && securityConfigurationTaskToInitialize.ManagedDevices.CurrentPage != null) { securityConfigurationTaskToInitialize.ManagedDevices.AdditionalData = securityConfigurationTaskToInitialize.AdditionalData; object nextPageLink; securityConfigurationTaskToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink); var nextPageLinkString = nextPageLink as string; if (!string.IsNullOrEmpty(nextPageLinkString)) { securityConfigurationTaskToInitialize.ManagedDevices.InitializeNextPageRequest( this.Client, nextPageLinkString); } } } }
/// <summary> /// Creates the specified SecurityConfigurationTask using POST. /// </summary> /// <param name="securityConfigurationTaskToCreate">The SecurityConfigurationTask to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created SecurityConfigurationTask.</returns> public async System.Threading.Tasks.Task <SecurityConfigurationTask> CreateAsync(SecurityConfigurationTask securityConfigurationTaskToCreate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; var newEntity = await this.SendAsync <SecurityConfigurationTask>(securityConfigurationTaskToCreate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(newEntity); return(newEntity); }
/// <summary> /// Creates the specified SecurityConfigurationTask using POST. /// </summary> /// <param name="securityConfigurationTaskToCreate">The SecurityConfigurationTask to create.</param> /// <returns>The created SecurityConfigurationTask.</returns> public System.Threading.Tasks.Task <SecurityConfigurationTask> CreateAsync(SecurityConfigurationTask securityConfigurationTaskToCreate) { return(this.CreateAsync(securityConfigurationTaskToCreate, CancellationToken.None)); }
/// <summary> /// Updates the specified SecurityConfigurationTask using PATCH. /// </summary> /// <param name="securityConfigurationTaskToUpdate">The SecurityConfigurationTask 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 SecurityConfigurationTask.</returns> public async System.Threading.Tasks.Task <SecurityConfigurationTask> UpdateAsync(SecurityConfigurationTask securityConfigurationTaskToUpdate, CancellationToken cancellationToken) { if (securityConfigurationTaskToUpdate.AdditionalData != null) { if (securityConfigurationTaskToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || securityConfigurationTaskToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, securityConfigurationTaskToUpdate.GetType().Name) }); } } if (securityConfigurationTaskToUpdate.AdditionalData != null) { if (securityConfigurationTaskToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || securityConfigurationTaskToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, securityConfigurationTaskToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <SecurityConfigurationTask>(securityConfigurationTaskToUpdate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(updatedEntity); return(updatedEntity); }