/// <summary>
        /// Adds the specified PrivilegedRoleAssignment to the collection via POST.
        /// </summary>
        /// <param name="privilegedRoleAssignment">The PrivilegedRoleAssignment 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(PrivilegedRoleAssignment privilegedRoleAssignment, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";

            if (string.IsNullOrEmpty(privilegedRoleAssignment.Id))
            {
                throw new ServiceException(new Error {
                    Code = "invalidRequest", Message = "ID is required to add a reference."
                });
            }

            var requestBody = new ReferenceRequestBody {
                ODataId = string.Format("{0}/privilegedRoleAssignments/{1}", this.Client.BaseUrl, privilegedRoleAssignment.Id)
            };

            return(this.SendAsync(requestBody, cancellationToken));
        }
Example #2
0
 /// <summary>
 /// Updates the specified PrivilegedRoleAssignment using PATCH.
 /// </summary>
 /// <param name="privilegedRoleAssignmentToUpdate">The PrivilegedRoleAssignment to update.</param>
 /// <returns>The updated PrivilegedRoleAssignment.</returns>
 public System.Threading.Tasks.Task <PrivilegedRoleAssignment> UpdateAsync(PrivilegedRoleAssignment privilegedRoleAssignmentToUpdate)
 {
     return(this.UpdateAsync(privilegedRoleAssignmentToUpdate, CancellationToken.None));
 }
Example #3
0
        /// <summary>
        /// Creates the specified PrivilegedRoleAssignment using POST.
        /// </summary>
        /// <param name="privilegedRoleAssignmentToCreate">The PrivilegedRoleAssignment to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created PrivilegedRoleAssignment.</returns>
        public async System.Threading.Tasks.Task <PrivilegedRoleAssignment> CreateAsync(PrivilegedRoleAssignment privilegedRoleAssignmentToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <PrivilegedRoleAssignment>(privilegedRoleAssignmentToCreate, cancellationToken).ConfigureAwait(false);

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

            return(updatedEntity);
        }
 /// <summary>
 /// Adds the specified PrivilegedRoleAssignment to the collection via POST.
 /// </summary>
 /// <param name="privilegedRoleAssignment">The PrivilegedRoleAssignment to add.</param>
 /// <returns>The task to await.</returns>
 public System.Threading.Tasks.Task AddAsync(PrivilegedRoleAssignment privilegedRoleAssignment)
 {
     return(this.AddAsync(privilegedRoleAssignment, CancellationToken.None));
 }
Example #6
0
 /// <summary>
 /// Adds the specified PrivilegedRoleAssignment to the collection via POST.
 /// </summary>
 /// <param name="privilegedRoleAssignment">The PrivilegedRoleAssignment to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created PrivilegedRoleAssignment.</returns>
 public System.Threading.Tasks.Task <PrivilegedRoleAssignment> AddAsync(PrivilegedRoleAssignment privilegedRoleAssignment, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <PrivilegedRoleAssignment>(privilegedRoleAssignment, cancellationToken));
 }
Example #7
0
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="privilegedRoleAssignmentToInitialize">The <see cref="PrivilegedRoleAssignment"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(PrivilegedRoleAssignment privilegedRoleAssignmentToInitialize)
 {
 }