public override async Task RejectAsync(string lockToken, CancellationToken cancellationToken)
        {
            IDictionary <string, string> customHeaders = PrepareCustomHeaders(
                CommonConstants.DeviceBoundPathRejectTemplate.FormatInvariant(_deviceId, lockToken),
                null,
                CommonConstants.CloudToDeviceOperation);

            var eTag = new ETagHolder {
                ETag = lockToken
            };

            await _httpClientHelper
            .DeleteAsync(
                GetRequestUri(
                    _deviceId,
                    CommonConstants.DeviceBoundPathTemplate + "/{0}".FormatInvariant(lockToken),
                    new Dictionary <string, string> {
                { "reject", null }
            }),
                eTag,
                ExceptionHandlingHelper.GetDefaultErrorMapping(),
                customHeaders,
                cancellationToken)
            .ConfigureAwait(false);
        }
        public override Task RemoveDeviceRegistrationAsync(string registrationId, CancellationToken cancellationToken)
        {
            var eTag = new ETagHolder {
                ETag = "*"
            };

            return(this.RemoveDeviceRegistrationAsync(registrationId, eTag, cancellationToken));
        }
        public override Task RemoveEnrollmentGroupAsync(string enrollmentGroupId, CancellationToken cancellationToken)
        {
            var eTag = new ETagHolder {
                ETag = "*"
            };

            return(this.RemoveEnrollmentGroupAsync(enrollmentGroupId, eTag, cancellationToken));
        }
Exemplo n.º 4
0
        public async Task DeleteDeviceAsyncTest()
        {
            var restOpMock = new Mock <IHttpClientHelper>();
            var mockETag   = new ETagHolder()
            {
                ETag = "*"
            };

            restOpMock.Setup(restOp => restOp.DeleteAsync(It.IsAny <Uri>(), mockETag, It.IsAny <IDictionary <HttpStatusCode, Func <HttpResponseMessage, Task <Exception> > > >(), null, It.IsAny <CancellationToken>())).Returns(Task.FromResult(0));
            var registryManager = new HttpRegistryManager(restOpMock.Object, IotHubName);
            await registryManager.RemoveDeviceAsync(new Device());

            restOpMock.VerifyAll();
        }
Exemplo n.º 5
0
        public override Task CompleteAsync(string lockToken, CancellationToken cancellationToken)
        {
            var customHeaders = PrepareCustomHeaders(
                CommonConstants.DeviceBoundPathCompleteTemplate.FormatInvariant(this.deviceId, lockToken),
                null,
                CommonConstants.CloudToDeviceOperation);

            var eTag = new ETagHolder {
                ETag = lockToken
            };

            return(this.httpClientHelper.DeleteAsync(
                       GetRequestUri(this.deviceId, CommonConstants.DeviceBoundPathTemplate + "/{0}".FormatInvariant(lockToken), null),
                       eTag,
                       ExceptionHandlingHelper.GetDefaultErrorMapping(),
                       customHeaders,
                       cancellationToken));
        }
Exemplo n.º 6
0
        protected override Task OnRejectAsync(string lockToken)
        {
            var customHeaders = PrepareCustomHeaders(
                CommonConstants.DeviceBoundPathRejectTemplate.FormatInvariant(this.deviceId, lockToken),
                null,
                CommonConstants.CloudToDeviceOperation);

            var eTag = new ETagHolder {
                ETag = lockToken
            };

            return(this.httpClientHelper.DeleteAsync(
                       GetRequestUri(this.deviceId, CommonConstants.DeviceBoundPathTemplate + "/{0}".FormatInvariant(lockToken), new Dictionary <string, string> {
                { "reject", null }
            }),
                       eTag,
                       ExceptionHandlingHelper.GetDefaultErrorMapping(),
                       customHeaders,
                       CancellationToken.None));
        }
        public override Task RejectAsync(string lockToken)
        {
            var customHeaders = PrepareCustomHeaders(
                CommonConstants.DeviceBoundPathRejectTemplate.FormatInvariant(this.deviceId, lockToken),
                null,
                CommonConstants.CloudToDeviceOperation);

            var eTag = new ETagHolder { ETag = lockToken };

            return this.httpClientHelper.DeleteAsync(
                GetRequestUri(this.deviceId, CommonConstants.DeviceBoundPathTemplate + "/{0}".FormatInvariant(lockToken), new Dictionary<string, string> { { "reject", null } }),
                eTag,
                ExceptionHandlingHelper.GetDefaultErrorMapping(),
                customHeaders,
                CancellationToken.None);
        }