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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
        /// <summary>
        /// Creates the specified PrivilegedRole using POST.
        /// </summary>
        /// <param name="privilegedRoleToCreate">The PrivilegedRole to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created PrivilegedRole.</returns>
        public async System.Threading.Tasks.Task <PrivilegedRole> CreateAsync(PrivilegedRole privilegedRoleToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <PrivilegedRole>(privilegedRoleToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="privilegedRoleToInitialize">The <see cref="PrivilegedRole"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(PrivilegedRole privilegedRoleToInitialize)
        {
            if (privilegedRoleToInitialize != null && privilegedRoleToInitialize.AdditionalData != null)
            {
                if (privilegedRoleToInitialize.Assignments != null && privilegedRoleToInitialize.Assignments.CurrentPage != null)
                {
                    privilegedRoleToInitialize.Assignments.AdditionalData = privilegedRoleToInitialize.AdditionalData;

                    object nextPageLink;
                    privilegedRoleToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        privilegedRoleToInitialize.Assignments.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
 /// <summary>
 /// Creates the specified PrivilegedRole using POST.
 /// </summary>
 /// <param name="privilegedRoleToCreate">The PrivilegedRole to create.</param>
 /// <returns>The created PrivilegedRole.</returns>
 public System.Threading.Tasks.Task <PrivilegedRole> CreateAsync(PrivilegedRole privilegedRoleToCreate)
 {
     return(this.CreateAsync(privilegedRoleToCreate, CancellationToken.None));
 }
示例#5
0
 /// <summary>
 /// Adds the specified PrivilegedRole to the collection via POST.
 /// </summary>
 /// <param name="privilegedRole">The PrivilegedRole to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created PrivilegedRole.</returns>
 public System.Threading.Tasks.Task <PrivilegedRole> AddAsync(PrivilegedRole privilegedRole, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <PrivilegedRole>(privilegedRole, cancellationToken));
 }
示例#6
0
 /// <summary>
 /// Adds the specified PrivilegedRole to the collection via POST.
 /// </summary>
 /// <param name="privilegedRole">The PrivilegedRole to add.</param>
 /// <returns>The created PrivilegedRole.</returns>
 public System.Threading.Tasks.Task <PrivilegedRole> AddAsync(PrivilegedRole privilegedRole)
 {
     return(this.AddAsync(privilegedRole, CancellationToken.None));
 }