Пример #1
0
        /// <summary>
        /// Creates the specified DeviceRegistrationPolicy using POST.
        /// </summary>
        /// <param name="deviceRegistrationPolicyToCreate">The DeviceRegistrationPolicy to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created DeviceRegistrationPolicy.</returns>
        public async System.Threading.Tasks.Task <DeviceRegistrationPolicy> CreateAsync(DeviceRegistrationPolicy deviceRegistrationPolicyToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <DeviceRegistrationPolicy>(deviceRegistrationPolicyToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
Пример #2
0
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="deviceRegistrationPolicyToInitialize">The <see cref="DeviceRegistrationPolicy"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(DeviceRegistrationPolicy deviceRegistrationPolicyToInitialize)
 {
 }
Пример #3
0
 /// <summary>
 /// Creates the specified DeviceRegistrationPolicy using POST.
 /// </summary>
 /// <param name="deviceRegistrationPolicyToCreate">The DeviceRegistrationPolicy to create.</param>
 /// <returns>The created DeviceRegistrationPolicy.</returns>
 public System.Threading.Tasks.Task <DeviceRegistrationPolicy> CreateAsync(DeviceRegistrationPolicy deviceRegistrationPolicyToCreate)
 {
     return(this.CreateAsync(deviceRegistrationPolicyToCreate, CancellationToken.None));
 }
Пример #4
0
        /// <summary>
        /// Updates the specified DeviceRegistrationPolicy using PATCH.
        /// </summary>
        /// <param name="deviceRegistrationPolicyToUpdate">The DeviceRegistrationPolicy 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 DeviceRegistrationPolicy.</returns>
        public async System.Threading.Tasks.Task <DeviceRegistrationPolicy> UpdateAsync(DeviceRegistrationPolicy deviceRegistrationPolicyToUpdate, CancellationToken cancellationToken)
        {
            if (deviceRegistrationPolicyToUpdate.AdditionalData != null)
            {
                if (deviceRegistrationPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    deviceRegistrationPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, deviceRegistrationPolicyToUpdate.GetType().Name)
                    });
                }
            }
            if (deviceRegistrationPolicyToUpdate.AdditionalData != null)
            {
                if (deviceRegistrationPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    deviceRegistrationPolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, deviceRegistrationPolicyToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <DeviceRegistrationPolicy>(deviceRegistrationPolicyToUpdate, cancellationToken).ConfigureAwait(false);

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