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