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

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

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

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

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

            return(this.SendAsync(requestBody, cancellationToken));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="roleScopeTagToInitialize">The <see cref="RoleScopeTag"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(RoleScopeTag roleScopeTagToInitialize)
        {
            if (roleScopeTagToInitialize != null && roleScopeTagToInitialize.AdditionalData != null)
            {
                if (roleScopeTagToInitialize.Assignments != null && roleScopeTagToInitialize.Assignments.CurrentPage != null)
                {
                    roleScopeTagToInitialize.Assignments.AdditionalData = roleScopeTagToInitialize.AdditionalData;

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

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