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

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

            return(newEntity);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Adds the specified ClaimsMappingPolicy to the collection via POST.
        /// </summary>
        /// <param name="claimsMappingPolicy">The ClaimsMappingPolicy 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(ClaimsMappingPolicy claimsMappingPolicy, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";

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

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

            return(this.SendAsync(requestBody, cancellationToken));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates the specified ClaimsMappingPolicy using POST.
 /// </summary>
 /// <param name="claimsMappingPolicyToCreate">The ClaimsMappingPolicy to create.</param>
 /// <returns>The created ClaimsMappingPolicy.</returns>
 public System.Threading.Tasks.Task <ClaimsMappingPolicy> CreateAsync(ClaimsMappingPolicy claimsMappingPolicyToCreate)
 {
     return(this.CreateAsync(claimsMappingPolicyToCreate, CancellationToken.None));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="claimsMappingPolicyToInitialize">The <see cref="ClaimsMappingPolicy"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(ClaimsMappingPolicy claimsMappingPolicyToInitialize)
 {
 }
 /// <summary>
 /// Adds the specified ClaimsMappingPolicy to the collection via POST.
 /// </summary>
 /// <param name="claimsMappingPolicy">The ClaimsMappingPolicy to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created ClaimsMappingPolicy.</returns>
 public System.Threading.Tasks.Task <ClaimsMappingPolicy> AddAsync(ClaimsMappingPolicy claimsMappingPolicy, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <ClaimsMappingPolicy>(claimsMappingPolicy, cancellationToken));
 }
 /// <summary>
 /// Adds the specified ClaimsMappingPolicy to the collection via POST.
 /// </summary>
 /// <param name="claimsMappingPolicy">The ClaimsMappingPolicy to add.</param>
 /// <returns>The created ClaimsMappingPolicy.</returns>
 public System.Threading.Tasks.Task <ClaimsMappingPolicy> AddAsync(ClaimsMappingPolicy claimsMappingPolicy)
 {
     return(this.AddAsync(claimsMappingPolicy, CancellationToken.None));
 }