public override Task RemoveDeviceAsync(string deviceId, CancellationToken cancellationToken) { this.EnsureInstanceNotClosed(); if (string.IsNullOrWhiteSpace(deviceId)) { throw new ArgumentException(IotHubApiResources.GetString(ApiResources.ParameterCannotBeNullOrWhitespace, "deviceId")); } // use wildcard etag var eTag = new ETagHolder { ETag = "*" }; return(this.RemoveDeviceAsync(deviceId, eTag, cancellationToken)); }
public override Task CancelJobAsync(string jobId, CancellationToken cancellationToken) { this.EnsureInstanceNotClosed(); var errorMappingOverrides = new Dictionary <HttpStatusCode, Func <HttpResponseMessage, Task <Exception> > >(); errorMappingOverrides.Add(HttpStatusCode.NotFound, responseMessage => Task.FromResult((Exception) new JobNotFoundException(jobId))); IETagHolder jobETag = new ETagHolder() { ETag = jobId }; return(this.httpClientHelper.DeleteAsync( GetJobUri("/{0}".FormatInvariant(jobId)), jobETag, errorMappingOverrides, null, cancellationToken)); }
public override Task CancelJobAsync(string jobId, CancellationToken cancellationToken) { this.EnsureInstanceNotClosed(); var errorMappingOverrides = new Dictionary<HttpStatusCode, Func<HttpResponseMessage, Task<Exception>>>(); errorMappingOverrides.Add(HttpStatusCode.NotFound, responseMessage => Task.FromResult((Exception)new JobNotFoundException(jobId))); IETagHolder jobETag = new ETagHolder() { ETag = jobId }; return this.httpClientHelper.DeleteAsync( GetJobUri("/{0}".FormatInvariant(jobId)), jobETag, errorMappingOverrides, null, cancellationToken); }
public override Task RemoveDeviceAsync(string deviceId, CancellationToken cancellationToken) { this.EnsureInstanceNotClosed(); if (string.IsNullOrWhiteSpace(deviceId)) { throw new ArgumentException(IotHubApiResources.GetString(ApiResources.ParameterCannotBeNullOrWhitespace, "deviceId")); } // use wildcard etag var eTag = new ETagHolder { ETag = "*" }; return this.RemoveDeviceAsync(deviceId, eTag, cancellationToken); }
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(); }