/// <summary>
 /// Adds the specified DeviceCustomAttributeShellScript to the collection via POST.
 /// </summary>
 /// <param name="deviceCustomAttributeShellScript">The DeviceCustomAttributeShellScript to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created DeviceCustomAttributeShellScript.</returns>
 public System.Threading.Tasks.Task <DeviceCustomAttributeShellScript> AddAsync(DeviceCustomAttributeShellScript deviceCustomAttributeShellScript, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <DeviceCustomAttributeShellScript>(deviceCustomAttributeShellScript, cancellationToken));
 }
 /// <summary>
 /// Adds the specified DeviceCustomAttributeShellScript to the collection via POST.
 /// </summary>
 /// <param name="deviceCustomAttributeShellScript">The DeviceCustomAttributeShellScript to add.</param>
 /// <returns>The created DeviceCustomAttributeShellScript.</returns>
 public System.Threading.Tasks.Task <DeviceCustomAttributeShellScript> AddAsync(DeviceCustomAttributeShellScript deviceCustomAttributeShellScript)
 {
     return(this.AddAsync(deviceCustomAttributeShellScript, CancellationToken.None));
 }
예제 #3
0
        /// <summary>
        /// Creates the specified DeviceCustomAttributeShellScript using POST.
        /// </summary>
        /// <param name="deviceCustomAttributeShellScriptToCreate">The DeviceCustomAttributeShellScript to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created DeviceCustomAttributeShellScript.</returns>
        public async System.Threading.Tasks.Task <DeviceCustomAttributeShellScript> CreateAsync(DeviceCustomAttributeShellScript deviceCustomAttributeShellScriptToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <DeviceCustomAttributeShellScript>(deviceCustomAttributeShellScriptToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
예제 #4
0
 /// <summary>
 /// Creates the specified DeviceCustomAttributeShellScript using POST.
 /// </summary>
 /// <param name="deviceCustomAttributeShellScriptToCreate">The DeviceCustomAttributeShellScript to create.</param>
 /// <returns>The created DeviceCustomAttributeShellScript.</returns>
 public System.Threading.Tasks.Task <DeviceCustomAttributeShellScript> CreateAsync(DeviceCustomAttributeShellScript deviceCustomAttributeShellScriptToCreate)
 {
     return(this.CreateAsync(deviceCustomAttributeShellScriptToCreate, CancellationToken.None));
 }
예제 #5
0
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="deviceCustomAttributeShellScriptToInitialize">The <see cref="DeviceCustomAttributeShellScript"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(DeviceCustomAttributeShellScript deviceCustomAttributeShellScriptToInitialize)
        {
            if (deviceCustomAttributeShellScriptToInitialize != null && deviceCustomAttributeShellScriptToInitialize.AdditionalData != null)
            {
                if (deviceCustomAttributeShellScriptToInitialize.Assignments != null && deviceCustomAttributeShellScriptToInitialize.Assignments.CurrentPage != null)
                {
                    deviceCustomAttributeShellScriptToInitialize.Assignments.AdditionalData = deviceCustomAttributeShellScriptToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        deviceCustomAttributeShellScriptToInitialize.Assignments.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (deviceCustomAttributeShellScriptToInitialize.DeviceRunStates != null && deviceCustomAttributeShellScriptToInitialize.DeviceRunStates.CurrentPage != null)
                {
                    deviceCustomAttributeShellScriptToInitialize.DeviceRunStates.AdditionalData = deviceCustomAttributeShellScriptToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        deviceCustomAttributeShellScriptToInitialize.DeviceRunStates.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (deviceCustomAttributeShellScriptToInitialize.GroupAssignments != null && deviceCustomAttributeShellScriptToInitialize.GroupAssignments.CurrentPage != null)
                {
                    deviceCustomAttributeShellScriptToInitialize.GroupAssignments.AdditionalData = deviceCustomAttributeShellScriptToInitialize.AdditionalData;

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        deviceCustomAttributeShellScriptToInitialize.GroupAssignments.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (deviceCustomAttributeShellScriptToInitialize.UserRunStates != null && deviceCustomAttributeShellScriptToInitialize.UserRunStates.CurrentPage != null)
                {
                    deviceCustomAttributeShellScriptToInitialize.UserRunStates.AdditionalData = deviceCustomAttributeShellScriptToInitialize.AdditionalData;

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

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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }