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

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

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

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

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

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

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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        managedDeviceToInitialize.DeviceConfigurationStates.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (managedDeviceToInitialize.DeviceCompliancePolicyStates != null && managedDeviceToInitialize.DeviceCompliancePolicyStates.CurrentPage != null)
                {
                    managedDeviceToInitialize.DeviceCompliancePolicyStates.AdditionalData = managedDeviceToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        managedDeviceToInitialize.DeviceCompliancePolicyStates.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
Beispiel #6
0
 /// <summary>
 /// Adds the specified ManagedDevice to the collection via POST.
 /// </summary>
 /// <param name="managedDevice">The ManagedDevice to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created ManagedDevice.</returns>
 public System.Threading.Tasks.Task <ManagedDevice> AddAsync(ManagedDevice managedDevice, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <ManagedDevice>(managedDevice, cancellationToken));
 }
Beispiel #7
0
 /// <summary>
 /// Adds the specified ManagedDevice to the collection via POST.
 /// </summary>
 /// <param name="managedDevice">The ManagedDevice to add.</param>
 /// <returns>The created ManagedDevice.</returns>
 public System.Threading.Tasks.Task <ManagedDevice> AddAsync(ManagedDevice managedDevice)
 {
     return(this.AddAsync(managedDevice, CancellationToken.None));
 }
Beispiel #8
0
 /// <summary>
 /// Creates the specified ManagedDevice using POST.
 /// </summary>
 /// <param name="managedDeviceToCreate">The ManagedDevice to create.</param>
 /// <returns>The created ManagedDevice.</returns>
 public System.Threading.Tasks.Task <ManagedDevice> CreateAsync(ManagedDevice managedDeviceToCreate)
 {
     return(this.CreateAsync(managedDeviceToCreate, CancellationToken.None));
 }
Beispiel #9
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="managedDeviceToInitialize">The <see cref="ManagedDevice"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(ManagedDevice managedDeviceToInitialize)
        {
            if (managedDeviceToInitialize != null && managedDeviceToInitialize.AdditionalData != null)
            {
                if (managedDeviceToInitialize.DeviceCompliancePolicyStates != null && managedDeviceToInitialize.DeviceCompliancePolicyStates.CurrentPage != null)
                {
                    managedDeviceToInitialize.DeviceCompliancePolicyStates.AdditionalData = managedDeviceToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        managedDeviceToInitialize.DeviceCompliancePolicyStates.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (managedDeviceToInitialize.AssignmentFilterEvaluationStatusDetails != null && managedDeviceToInitialize.AssignmentFilterEvaluationStatusDetails.CurrentPage != null)
                {
                    managedDeviceToInitialize.AssignmentFilterEvaluationStatusDetails.AdditionalData = managedDeviceToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        managedDeviceToInitialize.AssignmentFilterEvaluationStatusDetails.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (managedDeviceToInitialize.DeviceConfigurationStates != null && managedDeviceToInitialize.DeviceConfigurationStates.CurrentPage != null)
                {
                    managedDeviceToInitialize.DeviceConfigurationStates.AdditionalData = managedDeviceToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        managedDeviceToInitialize.DeviceConfigurationStates.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (managedDeviceToInitialize.ManagedDeviceMobileAppConfigurationStates != null && managedDeviceToInitialize.ManagedDeviceMobileAppConfigurationStates.CurrentPage != null)
                {
                    managedDeviceToInitialize.ManagedDeviceMobileAppConfigurationStates.AdditionalData = managedDeviceToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        managedDeviceToInitialize.ManagedDeviceMobileAppConfigurationStates.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (managedDeviceToInitialize.SecurityBaselineStates != null && managedDeviceToInitialize.SecurityBaselineStates.CurrentPage != null)
                {
                    managedDeviceToInitialize.SecurityBaselineStates.AdditionalData = managedDeviceToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        managedDeviceToInitialize.SecurityBaselineStates.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (managedDeviceToInitialize.DetectedApps != null && managedDeviceToInitialize.DetectedApps.CurrentPage != null)
                {
                    managedDeviceToInitialize.DetectedApps.AdditionalData = managedDeviceToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        managedDeviceToInitialize.DetectedApps.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (managedDeviceToInitialize.LogCollectionRequests != null && managedDeviceToInitialize.LogCollectionRequests.CurrentPage != null)
                {
                    managedDeviceToInitialize.LogCollectionRequests.AdditionalData = managedDeviceToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        managedDeviceToInitialize.LogCollectionRequests.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (managedDeviceToInitialize.Users != null && managedDeviceToInitialize.Users.CurrentPage != null)
                {
                    managedDeviceToInitialize.Users.AdditionalData = managedDeviceToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        managedDeviceToInitialize.Users.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }