本文整理汇总了C#中OpenStack.Common.Http.HttpResponseAbstraction类的典型用法代码示例。如果您正苦于以下问题:C# HttpResponseAbstraction类的具体用法?C# HttpResponseAbstraction怎么用?C# HttpResponseAbstraction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpResponseAbstraction类属于OpenStack.Common.Http命名空间,在下文中一共展示了HttpResponseAbstraction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExceptionthrownWhenGettingAStorageFolderThatDoesNotExistAndCannotBeInferred
public async Task ExceptionthrownWhenGettingAStorageFolderThatDoesNotExistAndCannotBeInferred()
{
var containerName = "TestContainer";
var folderName = "a/b/c/";
var headers = new HttpHeadersAbstraction()
{
{"X-Container-Bytes-Used", "1234"},
{"X-Container-Object-Count", "1"}
};
var payload = @"[]";
var content = TestHelper.CreateStream(payload);
var restResp = new HttpResponseAbstraction(content, headers, HttpStatusCode.OK);
this.StorageServiceRestClient.Responses.Enqueue(restResp);
var client = new StorageServicePocoClientFactory().Create(GetValidContext(), this.ServiceLocator) as StorageServicePocoClient;
var resp = await client.GetStorageFolder(containerName, folderName);
}
示例2: CanGetNetworksWithOkResponse
public async Task CanGetNetworksWithOkResponse()
{
var payload = @"{
""networks"": [
{
""status"": ""ACTIVE"",
""subnets"": [
""d3839504-ec4c-47a4-b7c7-07af079a48bb""
],
""name"": ""myNetwork"",
""router:external"": false,
""tenant_id"": ""ffe683d1060449d09dac0bf9d7a371cd"",
""admin_state_up"": true,
""shared"": false,
""id"": ""12345""
}
]
}";
var content = TestHelper.CreateStream(payload);
var restResp = new HttpResponseAbstraction(content, new HttpHeadersAbstraction(), HttpStatusCode.OK);
this.NetworkServiceRestClient.Responses.Enqueue(restResp);
var client = new NetworkServicePocoClient(GetValidContext(), this.ServiceLocator);
var result = await client.GetNetworks();
Assert.IsNotNull(result);
var networks = result.ToList();
Assert.AreEqual(1, networks.Count());
var network = networks.First();
Assert.AreEqual("myNetwork", network.Name);
Assert.AreEqual("12345", network.Id);
Assert.AreEqual(NetworkStatus.Active, network.Status);
}
示例3: CannotAuthenticateWithNotFoundResponse
public async Task CannotAuthenticateWithNotFoundResponse()
{
var creds = GetValidCredentials();
var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.NotFound);
this.RestClient.Response = restResp;
var client = new IdentityServicePocoClient(creds, "Swift", CancellationToken.None, this.ServiceLocator);
await client.Authenticate();
}
示例4: CanCreateFloatingIpWithCreatedResponse
public async Task CanCreateFloatingIpWithCreatedResponse()
{
var payload = @"{
""floatingip"":
{
""router_id"": ""fafac59b-a94a-4525-8700-f4f448e0ac97"",
""status"": ""ACTIVE"",
""tenant_id"": ""ffe683d1060449d09dac0bf9d7a371cd"",
""floating_network_id"": ""3eaab3f7-d3f2-430f-aa73-d07f39aae8f4"",
""fixed_ip_address"": ""10.0.0.2"",
""floating_ip_address"": ""172.0.0.1"",
""port_id"": ""9da94672-6e6b-446c-9579-3dd5484b31fd"",
""id"": ""12345""
}
}";
var content = TestHelper.CreateStream(payload);
var restResp = new HttpResponseAbstraction(content, new HttpHeadersAbstraction(), HttpStatusCode.Created);
this.NetworkServiceRestClient.Responses.Enqueue(restResp);
var client = new NetworkServicePocoClient(GetValidContext(), this.ServiceLocator);
var result = await client.CreateFloatingIp("12345");
Assert.IsNotNull(result);
Assert.AreEqual("12345", result.Id);
Assert.AreEqual("172.0.0.1", result.FloatingIpAddress);
Assert.AreEqual(FloatingIpStatus.Active, result.Status);
}
示例5: CanDeleteFloatingIpWithNoContentResponse
public async Task CanDeleteFloatingIpWithNoContentResponse()
{
var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.NoContent);
this.NetworkServiceRestClient.Responses.Enqueue(restResp);
var client = new NetworkServicePocoClient(GetValidContext(), this.ServiceLocator);
await client.DeleteFloatingIp("12345");
}
示例6: CanDeleteComputeServerMetadataWithOkResponse
public async Task CanDeleteComputeServerMetadataWithOkResponse()
{
var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.OK);
this.ComputeServiceRestClient.Responses.Enqueue(restResp);
var client = new ComputeServicePocoClient(GetValidContext(), this.ServiceLocator);
await client.DeleteServerMetadata("1", "item1");
}
示例7: CanGetComputeImageWithOkResponse
public async Task CanGetComputeImageWithOkResponse()
{
var created = DateTime.Parse("2014-05-30T16:56:32Z").ToUniversalTime();
var updated = DateTime.Parse("2014-06-30T16:56:32Z").ToUniversalTime();
var payload = @"{
""image"" : {
""name"": ""image1"",
""status"": ""ACTIVE"",
""updated"": ""2014-06-30T16:56:32Z"",
""created"": ""2014-05-30T16:56:32Z"",
""minRam"": 512,
""minDisk"": 10,
""progress"": 100,
""links"": [
{
""href"": ""http://someuri.com/v2/images/12345"",
""rel"": ""self""
},
{
""href"": ""http://someuri.com/images/12345"",
""rel"": ""bookmark""
}
],
""id"": ""12345""
}
}";
var content = TestHelper.CreateStream(payload);
var restResp = new HttpResponseAbstraction(content, new HttpHeadersAbstraction(), HttpStatusCode.OK);
this.ComputeServiceRestClient.Responses.Enqueue(restResp);
var client = new ComputeServicePocoClient(GetValidContext(), this.ServiceLocator);
var result = await client.GetImage("12345");
Assert.IsNotNull(result);
Assert.AreEqual("image1", result.Name);
Assert.AreEqual("ACTIVE", result.Status);
Assert.AreEqual("12345", result.Id);
Assert.AreEqual(512, result.MinimumRamSize);
Assert.AreEqual(10, result.MinimumDiskSize);
Assert.AreEqual(100, result.UploadProgress);
Assert.AreEqual(created.ToLongTimeString(), result.CreateDate.ToLongTimeString());
Assert.AreEqual(updated.ToLongTimeString(), result.LastUpdated.ToLongTimeString());
Assert.AreEqual(new Uri("http://someuri.com/images/12345"), result.PermanentUri);
Assert.AreEqual(new Uri("http://someuri.com/v2/images/12345"), result.PublicUri);
}
示例8: CanGetComputeServerMetadataWithOkResponse
public async Task CanGetComputeServerMetadataWithOkResponse()
{
var metadata = new Dictionary<string, string>() { { "item1", "value1" }, { "item2", "value2" } };
var content = TestHelper.CreateStream(GenerateMetadataPayload(metadata));
var restResp = new HttpResponseAbstraction(content, new HttpHeadersAbstraction(), HttpStatusCode.OK);
this.ComputeServiceRestClient.Responses.Enqueue(restResp);
var client = new ComputeServicePocoClient(GetValidContext(), this.ServiceLocator);
var respData = await client.GetServerMetadata("1");
Assert.AreEqual(2, respData.Count);
Assert.AreEqual("value1", respData["item1"]);
Assert.AreEqual("value2", respData["item2"]);
}
示例9: CanCreateComputeServerWithOkResponse
public async Task CanCreateComputeServerWithOkResponse()
{
var serverId = "98765";
var keyName = "MyKey";
var publicUrl = "http://15.125.87.81:8774/v2/ffe683d1060449d09dac0bf9d7a371cd/servers/" + serverId;
var permUrl = "http://15.125.87.81:8774/ffe683d1060449d09dac0bf9d7a371cd/servers/" + serverId;
var adminPassword = "ABCDEF";
var serverFixture = @"{{
""server"": {{
""security_groups"": [
{{
""name"": ""default""
}},
{{
""name"": ""MyGroup""
}}
],
""OS-DCF:diskConfig"": ""MANUAL"",
""id"": ""{0}"",
""links"": [
{{
""href"": ""{1}"",
""rel"": ""self""
}},
{{
""href"": ""{2}"",
""rel"": ""bookmark""
}}
],
""adminPass"": ""{3}""
}}
}}";
var payload = string.Format(serverFixture, serverId, publicUrl, permUrl, adminPassword);
var content = TestHelper.CreateStream(payload);
var restResp = new HttpResponseAbstraction(content, new HttpHeadersAbstraction(), HttpStatusCode.OK);
this.ComputeServiceRestClient.Responses.Enqueue(restResp);
var client = new ComputeServicePocoClient(GetValidContext(), this.ServiceLocator);
var result = await client.CreateServer("MyServer", "12345", "1", "54321", keyName, new List<string>() { "MyGroup" });
Assert.IsNotNull(result);
Assert.AreEqual(serverId, result.Id);
Assert.AreEqual(adminPassword, result.AdminPassword);
Assert.AreEqual(new Uri(publicUrl), result.PublicUri);
Assert.AreEqual(new Uri(permUrl), result.PermanentUri);
}
示例10: CanGetComputeKeyPairWithNonAuthoritativeResponse
public async Task CanGetComputeKeyPairWithNonAuthoritativeResponse()
{
var content = TestHelper.CreateStream(KeyPairPayload);
var restResp = new HttpResponseAbstraction(content, new HttpHeadersAbstraction(), HttpStatusCode.NonAuthoritativeInformation);
this.ComputeServiceRestClient.Responses.Enqueue(restResp);
var client = new ComputeServicePocoClient(GetValidContext(), this.ServiceLocator);
var keyPair = await client.GetKeyPair("MyKey");
Assert.IsNotNull(keyPair);
Assert.AreEqual("MyKey", keyPair.Name);
Assert.AreEqual("ABCDEF", keyPair.PublicKey);
Assert.AreEqual("12345", keyPair.Fingerprint);
}
示例11: CanGetComputeFlavorsWithNonAuthoritativeResponse
public async Task CanGetComputeFlavorsWithNonAuthoritativeResponse()
{
var payload = @"{
""flavors"": [
{
""id"": ""1"",
""links"": [
{
""href"": ""http://someuri.com/v2/flavors/1"",
""rel"": ""self""
},
{
""href"": ""http://someuri.com/flavors/1"",
""rel"": ""bookmark""
}
],
""name"": ""m1.tiny""
}
]
}";
var content = TestHelper.CreateStream(payload);
var restResp = new HttpResponseAbstraction(content, new HttpHeadersAbstraction(), HttpStatusCode.NonAuthoritativeInformation);
this.ComputeServiceRestClient.Responses.Enqueue(restResp);
var client = new ComputeServicePocoClient(GetValidContext(), this.ServiceLocator);
var result = await client.GetFlavors();
Assert.IsNotNull(result);
var flavors = result.ToList();
Assert.AreEqual(1, flavors.Count());
var flavor = flavors.First();
Assert.AreEqual("m1.tiny", flavor.Name);
Assert.AreEqual("1", flavor.Id);
Assert.AreEqual(new Uri("http://someuri.com/v2/flavors/1"), flavor.PublicUri);
Assert.AreEqual(new Uri("http://someuri.com/flavors/1"), flavor.PermanentUri);
}
示例12: CanGetComputeKeyPairsWithOkResponse
public async Task CanGetComputeKeyPairsWithOkResponse()
{
var content = TestHelper.CreateStream(KeyPairsPayload);
var restResp = new HttpResponseAbstraction(content, new HttpHeadersAbstraction(), HttpStatusCode.OK);
this.ComputeServiceRestClient.Responses.Enqueue(restResp);
var client = new ComputeServicePocoClient(GetValidContext(), this.ServiceLocator);
var result = await client.GetKeyPairs();
Assert.IsNotNull(result);
var pairs = result.ToList();
Assert.AreEqual(1, pairs.Count());
var keyPair = pairs.First();
Assert.AreEqual("MyKey", keyPair.Name);
Assert.AreEqual("ABCDEF", keyPair.PublicKey);
Assert.AreEqual("12345", keyPair.Fingerprint);
}
示例13: CanGetComputeImagesWithOkResponse
public async Task CanGetComputeImagesWithOkResponse()
{
var payload = @"{
""images"": [
{
""id"": ""12345"",
""links"": [
{
""href"": ""http://someuri.com/v2/images/12345"",
""rel"": ""self""
},
{
""href"": ""http://someuri.com/images/12345"",
""rel"": ""bookmark""
}
],
""name"": ""image1""
}
]
}";
var content = TestHelper.CreateStream(payload);
var restResp = new HttpResponseAbstraction(content, new HttpHeadersAbstraction(), HttpStatusCode.OK);
this.ComputeServiceRestClient.Responses.Enqueue(restResp);
var client = new ComputeServicePocoClient(GetValidContext(), this.ServiceLocator);
var result = await client.GetImages();
Assert.IsNotNull(result);
var images = result.ToList();
Assert.AreEqual(1, images.Count());
var image = images.First();
Assert.AreEqual("image1", image.Name);
Assert.AreEqual("12345", image.Id);
Assert.AreEqual(new Uri("http://someuri.com/v2/images/12345"), image.PublicUri);
Assert.AreEqual(new Uri("http://someuri.com/images/12345"), image.PermanentUri);
}
示例14: ExceptionthrownWhenGettingAStorageFolderAndServerError
public async Task ExceptionthrownWhenGettingAStorageFolderAndServerError()
{
var containerName = "TestContainer";
var fodlerName = "a/b/b/";
var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.InternalServerError);
this.StorageServiceRestClient.Responses.Enqueue(restResp);
var client = new StorageServicePocoClient(GetValidContext(), this.ServiceLocator);
await client.GetStorageFolder(containerName, fodlerName);
}
示例15: CanUpdateComputeServerMetadataWithOkResponse
public async Task CanUpdateComputeServerMetadataWithOkResponse()
{
var metadata = new Dictionary<string, string>() { { "item1", "value1" }, { "item2", "value2" } };
var restResp = new HttpResponseAbstraction(new MemoryStream(), new HttpHeadersAbstraction(), HttpStatusCode.OK);
this.ComputeServiceRestClient.Responses.Enqueue(restResp);
var client = new ComputeServicePocoClient(GetValidContext(), this.ServiceLocator);
await client.UpdateServerMetadata("1", metadata);
}