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

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

            return(newEntity);
        }
        /// <summary>
        /// Updates the specified DetectedApp using PATCH.
        /// </summary>
        /// <param name="detectedAppToUpdate">The DetectedApp to update.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The updated DetectedApp.</returns>
        public async System.Threading.Tasks.Task <DetectedApp> UpdateAsync(DetectedApp detectedAppToUpdate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <DetectedApp>(detectedAppToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
Esempio n. 4
0
        /// <summary>
        /// Adds the specified DetectedApp to the collection via POST.
        /// </summary>
        /// <param name="detectedApp">The DetectedApp 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(DetectedApp detectedApp, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";

            if (string.IsNullOrEmpty(detectedApp.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/detectedApps/{1}", this.Client.BaseUrl, detectedApp.Id)
            };

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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        detectedAppToInitialize.ManagedDevices.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
 /// <summary>
 /// Creates the specified DetectedApp using POST.
 /// </summary>
 /// <param name="detectedAppToCreate">The DetectedApp to create.</param>
 /// <returns>The created DetectedApp.</returns>
 public System.Threading.Tasks.Task <DetectedApp> CreateAsync(DetectedApp detectedAppToCreate)
 {
     return(this.CreateAsync(detectedAppToCreate, CancellationToken.None));
 }
Esempio n. 7
0
 /// <summary>
 /// Adds the specified DetectedApp to the collection via POST.
 /// </summary>
 /// <param name="detectedApp">The DetectedApp to add.</param>
 /// <returns>The task to await.</returns>
 public System.Threading.Tasks.Task AddAsync(DetectedApp detectedApp)
 {
     return(this.AddAsync(detectedApp, CancellationToken.None));
 }
 /// <summary>
 /// Adds the specified DetectedApp to the collection via POST.
 /// </summary>
 /// <param name="detectedApp">The DetectedApp to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created DetectedApp.</returns>
 public System.Threading.Tasks.Task <DetectedApp> AddAsync(DetectedApp detectedApp, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <DetectedApp>(detectedApp, cancellationToken));
 }