예제 #1
0
        /// <summary>
        /// Create a Windows 10 Device Configuration in Intune
        /// </summary>
        /// <param name="displayName">The display name of the device configuration.</param>
        /// <param name="edgeHomePage">The homepage to show in Edge</param>
        /// <param name="enableDeveloperMode">Enable developer mode on the device.</param>
        /// <returns>The created device configuraton</returns>
        public async Task <DeviceConfiguration> CreateWindowsDeviceConfiguration(string displayName, string edgeHomePage, bool enableDeveloperMode)
        {
            var deviceConfiguration = new Windows10GeneralConfiguration
            {
                DisplayName            = displayName,
                EdgeHomepageUrls       = new[] { edgeHomePage },
                DeveloperUnlockSetting = enableDeveloperMode ? StateManagementSetting.Allowed : StateManagementSetting.Blocked
            };

            return(await _graphClient.DeviceManagement.DeviceConfigurations.Request().AddAsync(deviceConfiguration));
        }
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="windows10GeneralConfigurationToInitialize">The <see cref="Windows10GeneralConfiguration"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(Windows10GeneralConfiguration windows10GeneralConfigurationToInitialize)
        {
            if (windows10GeneralConfigurationToInitialize != null && windows10GeneralConfigurationToInitialize.AdditionalData != null)
            {
                if (windows10GeneralConfigurationToInitialize.PrivacyAccessControls != null && windows10GeneralConfigurationToInitialize.PrivacyAccessControls.CurrentPage != null)
                {
                    windows10GeneralConfigurationToInitialize.PrivacyAccessControls.AdditionalData = windows10GeneralConfigurationToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        windows10GeneralConfigurationToInitialize.PrivacyAccessControls.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
        /// <summary>
        /// Creates the specified Windows10GeneralConfiguration using POST.
        /// </summary>
        /// <param name="windows10GeneralConfigurationToCreate">The Windows10GeneralConfiguration to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created Windows10GeneralConfiguration.</returns>
        public async System.Threading.Tasks.Task <Windows10GeneralConfiguration> CreateAsync(Windows10GeneralConfiguration windows10GeneralConfigurationToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <Windows10GeneralConfiguration>(windows10GeneralConfigurationToCreate, cancellationToken).ConfigureAwait(false);

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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
예제 #6
0
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="windows10GeneralConfigurationToInitialize">The <see cref="Windows10GeneralConfiguration"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(Windows10GeneralConfiguration windows10GeneralConfigurationToInitialize)
 {
 }