diff --git a/src/SDKs/ContainerInstance/ContainerInstance.Tests/ContainerGroupScenarioTests.cs b/src/SDKs/ContainerInstance/ContainerInstance.Tests/ContainerGroupScenarioTests.cs new file mode 100644 index 000000000000..88398444a11e --- /dev/null +++ b/src/SDKs/ContainerInstance/ContainerInstance.Tests/ContainerGroupScenarioTests.cs @@ -0,0 +1,107 @@ +using System.Collections.Generic; +using System.Linq; +using Microsoft.Azure.Management.ContainerInstance; +using Microsoft.Azure.Management.ContainerInstance.Models; +using Microsoft.Azure.Management.ResourceManager.Models; +using Microsoft.Rest.Azure; +using Xunit; + +namespace ContainerInstance.Tests +{ + public class ContainerGroupScenarioTests + { + [Fact] + public void ContainerGroupCreateGetDeleteTests() + { + using (TestContext context = new TestContext(this)) + { + string containerInstanceLocation = "westus"; + + ResourceGroup resourceGroup = context.CreateResourceGroup("containergroupcrd-", containerInstanceLocation); + ContainerInstanceManagementClient containerClient = context.GetClient(); + + string containerGroupName = context.GenerateName("containergroup"); + string containerOsType = "Linux"; + + string containerName = "test1"; + string containerImage = "nginx"; + int containerPort = 80; + double containerCpu = 1; + double containerMemoryInGB = 1.5; + + // Add a containergroup with a container + ContainerGroup createdContainerGroup = containerClient.ContainerGroups.CreateOrUpdate(resourceGroup.Name, containerGroupName, new ContainerGroup + { + Location = resourceGroup.Location, + OsType = containerOsType, + Containers = new List + { + new Container + { + Name = containerName, + Image = containerImage, + Ports = new List + { + new ContainerPort(containerPort) + }, + Resources = new ResourceRequirements + { + Requests = new ResourceRequests + { + Cpu = containerCpu, + MemoryInGB = containerMemoryInGB + } + } + } + } + }); + Assert.NotNull(createdContainerGroup); + Assert.Equal(containerGroupName, createdContainerGroup.Name); + Assert.Equal(containerOsType, createdContainerGroup.OsType); + Assert.Equal(1, createdContainerGroup.Containers.Count); + + Container createdContainer = createdContainerGroup.Containers.First(); + Assert.Equal(containerName, createdContainer.Name); + Assert.Equal(containerImage, createdContainer.Image); + Assert.Equal(1, createdContainer.Ports.Count); + Assert.Equal(containerPort, createdContainer.Ports.First().Port); + Assert.Equal(containerCpu, createdContainer.Resources.Requests.Cpu); + Assert.Equal(containerMemoryInGB, createdContainer.Resources.Requests.MemoryInGB); + + // Wait till the container group is ready before proceeding + ContainerGroupUtilities.WaitTillProvisioningStateSucceeded(containerClient, resourceGroup.Name, containerGroupName); + + string containerGroupID = createdContainerGroup.Id; + + // Get the container group + ContainerGroup getContainerGroup = containerClient.ContainerGroups.Get(resourceGroup.Name, containerGroupName); + Assert.NotNull(createdContainerGroup); + Assert.Equal(containerGroupName, getContainerGroup.Name); + Assert.Equal(containerOsType, getContainerGroup.OsType); + + Container getContainer = getContainerGroup.Containers.First(); + Assert.Equal(containerName, getContainer.Name); + Assert.Equal(containerImage, getContainer.Image); + Assert.Equal(1, getContainer.Ports.Count); + Assert.Equal(containerPort, getContainer.Ports.First().Port); + Assert.Equal(containerCpu, getContainer.Resources.Requests.Cpu); + Assert.Equal(containerMemoryInGB, getContainer.Resources.Requests.MemoryInGB); + + // List the container group within the resource group + IPage listRgContainerGroup = containerClient.ContainerGroups.ListByResourceGroup(resourceGroup.Name); + Assert.NotNull(listRgContainerGroup); + Assert.Equal(1, listRgContainerGroup.Count()); + Assert.Equal(containerGroupName, listRgContainerGroup.First().Name); + + // List the container group within the subscription + IPage listSubContainerGroup = containerClient.ContainerGroups.List(); + Assert.NotNull(listRgContainerGroup); + Assert.True(listRgContainerGroup.Count() >= 1); + Assert.True(listRgContainerGroup.Any(x => containerGroupID.Equals(x?.Id))); + + // Delete the container group + containerClient.ContainerGroups.Delete(resourceGroup.Name, containerGroupName); + } + } + } +} diff --git a/src/SDKs/ContainerInstance/ContainerInstance.Tests/ContainerInstance.Tests.csproj b/src/SDKs/ContainerInstance/ContainerInstance.Tests/ContainerInstance.Tests.csproj new file mode 100644 index 000000000000..390813b7b2dd --- /dev/null +++ b/src/SDKs/ContainerInstance/ContainerInstance.Tests/ContainerInstance.Tests.csproj @@ -0,0 +1,44 @@ + + + + ContainerInstance.Tests + ContainerInstance.Tests + 1.0.0-preview + + + netcoreapp1.1 + + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + + + + + + + + diff --git a/src/SDKs/ContainerInstance/ContainerInstance.Tests/ContainerLogScenarioTests.cs b/src/SDKs/ContainerInstance/ContainerInstance.Tests/ContainerLogScenarioTests.cs new file mode 100644 index 000000000000..ae6f2575396b --- /dev/null +++ b/src/SDKs/ContainerInstance/ContainerInstance.Tests/ContainerLogScenarioTests.cs @@ -0,0 +1,71 @@ +using System.Collections.Generic; +using System.Threading; +using Microsoft.Azure.Management.ContainerInstance; +using Microsoft.Azure.Management.ContainerInstance.Models; +using Microsoft.Azure.Management.ResourceManager.Models; +using Xunit; + +namespace ContainerInstance.Tests +{ + public class ContainerLogScenarioTests + { + [Fact] + public void ContainerLogGetTest() + { + using (TestContext context = new TestContext(this)) + { + string containerInstanceLocation = "westus"; + + ResourceGroup resourceGroup = context.CreateResourceGroup("containerlogget-", containerInstanceLocation); + ContainerInstanceManagementClient containerClient = context.GetClient(); + + string containerGroupName = context.GenerateName("containergroup"); + string containerOsType = "Linux"; + string containerName = "test1"; + string containerImage = "nginx"; + int containerPort = 80; + double containerCpu = 1; + double containerMemoryInGB = 1.5; + + // Create an empty container group + ContainerGroup createdContainerGroup = containerClient.ContainerGroups.CreateOrUpdate(resourceGroup.Name, containerGroupName, new ContainerGroup + { + Location = resourceGroup.Location, + OsType = containerOsType, + Containers = new List + { + new Container + { + Name = containerName, + Image = containerImage, + Ports = new List + { + new ContainerPort(containerPort) + }, + Resources = new ResourceRequirements + { + Requests = new ResourceRequests + { + Cpu = containerCpu, + MemoryInGB = containerMemoryInGB + } + } + } + } + }); + Assert.NotNull(createdContainerGroup); + + // Wait till ready + ContainerGroupUtilities.WaitTillProvisioningStateSucceeded(containerClient, resourceGroup.Name, containerGroupName); + + // Check that we can list the logs + Logs logs = containerClient.ContainerLogs.List(resourceGroup.Name, containerName, containerGroupName); + Assert.NotNull(logs); + Assert.NotNull(logs.Content); + + // Delete the container group + containerClient.ContainerGroups.Delete(resourceGroup.Name, containerGroupName); + } + } + } +} diff --git a/src/SDKs/ContainerInstance/ContainerInstance.Tests/Properties/AssemblyInfo.cs b/src/SDKs/ContainerInstance/ContainerInstance.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..d1f55d2d4178 --- /dev/null +++ b/src/SDKs/ContainerInstance/ContainerInstance.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using System.Runtime.InteropServices; +using Xunit; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ContainerInstance.Tests")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ef989c56-f585-40a2-8af6-18789546f5bf")] \ No newline at end of file diff --git a/src/SDKs/ContainerInstance/ContainerInstance.Tests/SessionRecords/ContainerInstance.Tests.ContainerGroupScenarioTests/ContainerGroupCreateGetDeleteTests.json b/src/SDKs/ContainerInstance/ContainerInstance.Tests/SessionRecords/ContainerInstance.Tests.ContainerGroupScenarioTests/ContainerGroupCreateGetDeleteTests.json new file mode 100644 index 000000000000..1b5b44fd3e57 --- /dev/null +++ b/src/SDKs/ContainerInstance/ContainerInstance.Tests/SessionRecords/ContainerInstance.Tests.ContainerGroupScenarioTests/ContainerGroupCreateGetDeleteTests.json @@ -0,0 +1,549 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourcegroups/containergroupcrd-5725?api-version=2017-05-10", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZDhkY2Q1OGItZTIyZC00M2U3LWE5N2YtMTVmYTI5ZDhjOGVhL3Jlc291cmNlZ3JvdXBzL2NvbnRhaW5lcmdyb3VwY3JkLTU3MjU/YXBpLXZlcnNpb249MjAxNy0wNS0xMA==", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"location\": \"westus\",\r\n \"tags\": {\r\n \"containergroupcrd-5725\": \"2017-08-14 09:06:40Z\"\r\n }\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "101" + ], + "x-ms-client-request-id": [ + "6c53848a-e606-45f0-a303-28bf487d88fd" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/1.6.0.0" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containergroupcrd-5725\",\r\n \"name\": \"containergroupcrd-5725\",\r\n \"location\": \"westus\",\r\n \"tags\": {\r\n \"containergroupcrd-5725\": \"2017-08-14 09:06:40Z\"\r\n },\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\"\r\n }\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "254" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 14 Aug 2017 09:06:42 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1188" + ], + "x-ms-request-id": [ + "1f127495-cb6d-4cdb-b590-81b1b3abffa5" + ], + "x-ms-correlation-request-id": [ + "1f127495-cb6d-4cdb-b590-81b1b3abffa5" + ], + "x-ms-routing-request-id": [ + "AUSTRALIASOUTHEAST:20170814T090643Z:1f127495-cb6d-4cdb-b590-81b1b3abffa5" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ] + }, + "StatusCode": 201 + }, + { + "RequestUri": "/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containergroupcrd-5725/providers/Microsoft.ContainerInstance/containerGroups/containergroup3716?api-version=2017-08-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZDhkY2Q1OGItZTIyZC00M2U3LWE5N2YtMTVmYTI5ZDhjOGVhL3Jlc291cmNlR3JvdXBzL2NvbnRhaW5lcmdyb3VwY3JkLTU3MjUvcHJvdmlkZXJzL01pY3Jvc29mdC5Db250YWluZXJJbnN0YW5jZS9jb250YWluZXJHcm91cHMvY29udGFpbmVyZ3JvdXAzNzE2P2FwaS12ZXJzaW9uPTIwMTctMDgtMDEtcHJldmlldw==", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"properties\": {\r\n \"containers\": [\r\n {\r\n \"name\": \"test1\",\r\n \"properties\": {\r\n \"image\": \"nginx\",\r\n \"ports\": [\r\n {\r\n \"port\": 80\r\n }\r\n ],\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n }\r\n }\r\n }\r\n ],\r\n \"osType\": \"Linux\"\r\n },\r\n \"location\": \"westus\"\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "447" + ], + "x-ms-client-request-id": [ + "913dfc02-1f7e-4a1e-bc96-eabedb11677a" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.ContainerInstance.ContainerInstanceManagementClient/1.0.0.0" + ] + }, + "ResponseBody": "{\r\n \"properties\": {\r\n \"provisioningState\": \"Creating\",\r\n \"containers\": [\r\n {\r\n \"name\": \"test1\",\r\n \"properties\": {\r\n \"image\": \"nginx\",\r\n \"ports\": [\r\n {\r\n \"port\": 80\r\n }\r\n ],\r\n \"environmentVariables\": [],\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n }\r\n }\r\n }\r\n ],\r\n \"osType\": \"Linux\"\r\n },\r\n \"id\": \"/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containergroupcrd-5725/providers/Microsoft.ContainerInstance/containerGroups/containergroup3716\",\r\n \"name\": \"containergroup3716\",\r\n \"type\": \"Microsoft.ContainerInstance/containerGroups\",\r\n \"location\": \"westus\"\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "500" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 14 Aug 2017 09:06:48 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-request-id": [ + "westus:de5ebc0c-c1f4-4104-b8ba-9fb61b08e018" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1195" + ], + "x-ms-correlation-request-id": [ + "a5bbb0a0-49fe-4ede-8f11-ad05db4880cf" + ], + "x-ms-routing-request-id": [ + "AUSTRALIASOUTHEAST:20170814T090648Z:a5bbb0a0-49fe-4ede-8f11-ad05db4880cf" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ] + }, + "StatusCode": 201 + }, + { + "RequestUri": "/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containergroupcrd-5725/providers/Microsoft.ContainerInstance/containerGroups/containergroup3716?api-version=2017-08-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZDhkY2Q1OGItZTIyZC00M2U3LWE5N2YtMTVmYTI5ZDhjOGVhL3Jlc291cmNlR3JvdXBzL2NvbnRhaW5lcmdyb3VwY3JkLTU3MjUvcHJvdmlkZXJzL01pY3Jvc29mdC5Db250YWluZXJJbnN0YW5jZS9jb250YWluZXJHcm91cHMvY29udGFpbmVyZ3JvdXAzNzE2P2FwaS12ZXJzaW9uPTIwMTctMDgtMDEtcHJldmlldw==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "f737ff1a-f143-4e91-baa8-1a9ebc0119aa" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.ContainerInstance.ContainerInstanceManagementClient/1.0.0.0" + ] + }, + "ResponseBody": "{\r\n \"properties\": {\r\n \"provisioningState\": \"Creating\",\r\n \"containers\": [\r\n {\r\n \"name\": \"test1\",\r\n \"properties\": {\r\n \"image\": \"nginx\",\r\n \"ports\": [\r\n {\r\n \"port\": 80\r\n }\r\n ],\r\n \"environmentVariables\": [],\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n }\r\n }\r\n }\r\n ],\r\n \"osType\": \"Linux\",\r\n \"state\": \"Pending\"\r\n },\r\n \"id\": \"/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containergroupcrd-5725/providers/Microsoft.ContainerInstance/containerGroups/containergroup3716\",\r\n \"name\": \"containergroup3716\",\r\n \"type\": \"Microsoft.ContainerInstance/containerGroups\",\r\n \"location\": \"westus\"\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 14 Aug 2017 09:07:32 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-ms-request-id": [ + "westus:cd84b12a-2861-4ec5-9f8d-a4879578dd85" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "14951" + ], + "x-ms-correlation-request-id": [ + "2db37ab1-31c6-4c3d-980a-66e3ceee3ac3" + ], + "x-ms-routing-request-id": [ + "AUSTRALIASOUTHEAST:20170814T090733Z:2db37ab1-31c6-4c3d-980a-66e3ceee3ac3" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containergroupcrd-5725/providers/Microsoft.ContainerInstance/containerGroups/containergroup3716?api-version=2017-08-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZDhkY2Q1OGItZTIyZC00M2U3LWE5N2YtMTVmYTI5ZDhjOGVhL3Jlc291cmNlR3JvdXBzL2NvbnRhaW5lcmdyb3VwY3JkLTU3MjUvcHJvdmlkZXJzL01pY3Jvc29mdC5Db250YWluZXJJbnN0YW5jZS9jb250YWluZXJHcm91cHMvY29udGFpbmVyZ3JvdXAzNzE2P2FwaS12ZXJzaW9uPTIwMTctMDgtMDEtcHJldmlldw==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "61712385-a9c6-4052-b87f-2b38f5dc643e" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.ContainerInstance.ContainerInstanceManagementClient/1.0.0.0" + ] + }, + "ResponseBody": "{\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"containers\": [\r\n {\r\n \"name\": \"test1\",\r\n \"properties\": {\r\n \"image\": \"nginx\",\r\n \"ports\": [\r\n {\r\n \"port\": 80\r\n }\r\n ],\r\n \"environmentVariables\": [],\r\n \"instanceView\": {\r\n \"restartCount\": 0,\r\n \"currentState\": {\r\n \"state\": \"Running\",\r\n \"startTime\": \"2017-08-14T09:07:52Z\",\r\n \"detailStatus\": \"\"\r\n },\r\n \"events\": [\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:07:51Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:07:51Z\",\r\n \"message\": \"Pulling: pulling image \\\"nginx\\\"\",\r\n \"type\": \"Normal\"\r\n },\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"message\": \"Pulled: Successfully pulled image \\\"nginx\\\"\",\r\n \"type\": \"Normal\"\r\n },\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"message\": \"Created: Created container with id 4c717401a3ce5f3bcdee9472755e1b0537bb345057637520d5dda2eab04a282a\",\r\n \"type\": \"Normal\"\r\n },\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"message\": \"Started: Started container with id 4c717401a3ce5f3bcdee9472755e1b0537bb345057637520d5dda2eab04a282a\",\r\n \"type\": \"Normal\"\r\n }\r\n ]\r\n },\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n }\r\n }\r\n }\r\n ],\r\n \"osType\": \"Linux\",\r\n \"state\": \"Running\"\r\n },\r\n \"id\": \"/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containergroupcrd-5725/providers/Microsoft.ContainerInstance/containerGroups/containergroup3716\",\r\n \"name\": \"containergroup3716\",\r\n \"type\": \"Microsoft.ContainerInstance/containerGroups\",\r\n \"location\": \"westus\"\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 14 Aug 2017 09:08:18 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-ms-request-id": [ + "westus:dc988f06-52d8-4c4f-9d98-73cea977a84f" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "14950" + ], + "x-ms-correlation-request-id": [ + "88aa8a57-5281-4ae6-b29a-0877266e1987" + ], + "x-ms-routing-request-id": [ + "AUSTRALIASOUTHEAST:20170814T090818Z:88aa8a57-5281-4ae6-b29a-0877266e1987" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containergroupcrd-5725/providers/Microsoft.ContainerInstance/containerGroups/containergroup3716?api-version=2017-08-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZDhkY2Q1OGItZTIyZC00M2U3LWE5N2YtMTVmYTI5ZDhjOGVhL3Jlc291cmNlR3JvdXBzL2NvbnRhaW5lcmdyb3VwY3JkLTU3MjUvcHJvdmlkZXJzL01pY3Jvc29mdC5Db250YWluZXJJbnN0YW5jZS9jb250YWluZXJHcm91cHMvY29udGFpbmVyZ3JvdXAzNzE2P2FwaS12ZXJzaW9uPTIwMTctMDgtMDEtcHJldmlldw==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "44eb7c44-c095-4c60-a595-1e0a792fc793" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.ContainerInstance.ContainerInstanceManagementClient/1.0.0.0" + ] + }, + "ResponseBody": "{\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"containers\": [\r\n {\r\n \"name\": \"test1\",\r\n \"properties\": {\r\n \"image\": \"nginx\",\r\n \"ports\": [\r\n {\r\n \"port\": 80\r\n }\r\n ],\r\n \"environmentVariables\": [],\r\n \"instanceView\": {\r\n \"restartCount\": 0,\r\n \"currentState\": {\r\n \"state\": \"Running\",\r\n \"startTime\": \"2017-08-14T09:07:52Z\",\r\n \"detailStatus\": \"\"\r\n },\r\n \"events\": [\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:07:51Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:07:51Z\",\r\n \"message\": \"Pulling: pulling image \\\"nginx\\\"\",\r\n \"type\": \"Normal\"\r\n },\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"message\": \"Pulled: Successfully pulled image \\\"nginx\\\"\",\r\n \"type\": \"Normal\"\r\n },\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"message\": \"Created: Created container with id 4c717401a3ce5f3bcdee9472755e1b0537bb345057637520d5dda2eab04a282a\",\r\n \"type\": \"Normal\"\r\n },\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"message\": \"Started: Started container with id 4c717401a3ce5f3bcdee9472755e1b0537bb345057637520d5dda2eab04a282a\",\r\n \"type\": \"Normal\"\r\n }\r\n ]\r\n },\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n }\r\n }\r\n }\r\n ],\r\n \"osType\": \"Linux\",\r\n \"state\": \"Running\"\r\n },\r\n \"id\": \"/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containergroupcrd-5725/providers/Microsoft.ContainerInstance/containerGroups/containergroup3716\",\r\n \"name\": \"containergroup3716\",\r\n \"type\": \"Microsoft.ContainerInstance/containerGroups\",\r\n \"location\": \"westus\"\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 14 Aug 2017 09:08:18 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-ms-request-id": [ + "westus:74282068-1dea-4670-8082-4c7e076d3cdf" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "14949" + ], + "x-ms-correlation-request-id": [ + "5f968bcf-6295-497e-9c00-d6fcc655cdaa" + ], + "x-ms-routing-request-id": [ + "AUSTRALIASOUTHEAST:20170814T090819Z:5f968bcf-6295-497e-9c00-d6fcc655cdaa" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containergroupcrd-5725/providers/Microsoft.ContainerInstance/containerGroups?api-version=2017-08-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZDhkY2Q1OGItZTIyZC00M2U3LWE5N2YtMTVmYTI5ZDhjOGVhL3Jlc291cmNlR3JvdXBzL2NvbnRhaW5lcmdyb3VwY3JkLTU3MjUvcHJvdmlkZXJzL01pY3Jvc29mdC5Db250YWluZXJJbnN0YW5jZS9jb250YWluZXJHcm91cHM/YXBpLXZlcnNpb249MjAxNy0wOC0wMS1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "211d0bc3-9c72-427b-8410-be8f7d12f09b" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.ContainerInstance.ContainerInstanceManagementClient/1.0.0.0" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"containers\": [\r\n {\r\n \"name\": \"test1\",\r\n \"properties\": {\r\n \"image\": \"nginx\",\r\n \"ports\": [\r\n {\r\n \"port\": 80\r\n }\r\n ],\r\n \"environmentVariables\": [],\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n }\r\n }\r\n }\r\n ],\r\n \"osType\": \"Linux\"\r\n },\r\n \"id\": \"/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containergroupcrd-5725/providers/Microsoft.ContainerInstance/containerGroups/containergroup3716\",\r\n \"name\": \"containergroup3716\",\r\n \"type\": \"Microsoft.ContainerInstance/containerGroups\",\r\n \"location\": \"westus\"\r\n }\r\n ]\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 14 Aug 2017 09:08:18 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-ms-request-id": [ + "westus:8fd2a7eb-2c3a-4b8d-9ecb-7760db7e3e24" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "14948" + ], + "x-ms-correlation-request-id": [ + "62d8d43f-a153-4ced-9eb0-f8a13aa2947b" + ], + "x-ms-routing-request-id": [ + "AUSTRALIASOUTHEAST:20170814T090819Z:62d8d43f-a153-4ced-9eb0-f8a13aa2947b" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/providers/Microsoft.ContainerInstance/containerGroups?api-version=2017-08-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZDhkY2Q1OGItZTIyZC00M2U3LWE5N2YtMTVmYTI5ZDhjOGVhL3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29udGFpbmVySW5zdGFuY2UvY29udGFpbmVyR3JvdXBzP2FwaS12ZXJzaW9uPTIwMTctMDgtMDEtcHJldmlldw==", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "12da7c0a-94f3-45ce-98da-3f9fcbf755e1" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.ContainerInstance.ContainerInstanceManagementClient/1.0.0.0" + ] + }, + "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"containers\": [\r\n {\r\n \"name\": \"test1\",\r\n \"properties\": {\r\n \"image\": \"nginx\",\r\n \"ports\": [\r\n {\r\n \"port\": 80\r\n }\r\n ],\r\n \"environmentVariables\": [],\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n }\r\n }\r\n }\r\n ],\r\n \"osType\": \"Linux\"\r\n },\r\n \"id\": \"/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containergroupcrd-5725/providers/Microsoft.ContainerInstance/containerGroups/containergroup3716\",\r\n \"name\": \"containergroup3716\",\r\n \"type\": \"Microsoft.ContainerInstance/containerGroups\",\r\n \"location\": \"westus\"\r\n }\r\n ]\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 14 Aug 2017 09:08:18 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-ms-request-id": [ + "westus:ab93da42-5833-4860-bfa5-44971c91ad5f" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "14947" + ], + "x-ms-correlation-request-id": [ + "db832ad6-8056-4619-b65f-a06278af8531" + ], + "x-ms-routing-request-id": [ + "AUSTRALIASOUTHEAST:20170814T090819Z:db832ad6-8056-4619-b65f-a06278af8531" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containergroupcrd-5725/providers/Microsoft.ContainerInstance/containerGroups/containergroup3716?api-version=2017-08-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZDhkY2Q1OGItZTIyZC00M2U3LWE5N2YtMTVmYTI5ZDhjOGVhL3Jlc291cmNlR3JvdXBzL2NvbnRhaW5lcmdyb3VwY3JkLTU3MjUvcHJvdmlkZXJzL01pY3Jvc29mdC5Db250YWluZXJJbnN0YW5jZS9jb250YWluZXJHcm91cHMvY29udGFpbmVyZ3JvdXAzNzE2P2FwaS12ZXJzaW9uPTIwMTctMDgtMDEtcHJldmlldw==", + "RequestMethod": "DELETE", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "49e71e80-7787-40c3-a153-604fa938a88f" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.ContainerInstance.ContainerInstanceManagementClient/1.0.0.0" + ] + }, + "ResponseBody": "{\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"containers\": [\r\n {\r\n \"name\": \"test1\",\r\n \"properties\": {\r\n \"image\": \"nginx\",\r\n \"ports\": [\r\n {\r\n \"port\": 80\r\n }\r\n ],\r\n \"environmentVariables\": [],\r\n \"instanceView\": {\r\n \"restartCount\": 0,\r\n \"currentState\": {\r\n \"state\": \"Running\",\r\n \"startTime\": \"2017-08-14T09:07:52Z\",\r\n \"detailStatus\": \"\"\r\n },\r\n \"events\": [\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:07:51Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:07:51Z\",\r\n \"message\": \"Pulling: pulling image \\\"nginx\\\"\",\r\n \"type\": \"Normal\"\r\n },\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"message\": \"Pulled: Successfully pulled image \\\"nginx\\\"\",\r\n \"type\": \"Normal\"\r\n },\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"message\": \"Created: Created container with id 4c717401a3ce5f3bcdee9472755e1b0537bb345057637520d5dda2eab04a282a\",\r\n \"type\": \"Normal\"\r\n },\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:07:52Z\",\r\n \"message\": \"Started: Started container with id 4c717401a3ce5f3bcdee9472755e1b0537bb345057637520d5dda2eab04a282a\",\r\n \"type\": \"Normal\"\r\n }\r\n ]\r\n },\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n }\r\n }\r\n }\r\n ],\r\n \"osType\": \"Linux\",\r\n \"state\": \"Running\"\r\n },\r\n \"id\": \"/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containergroupcrd-5725/providers/Microsoft.ContainerInstance/containerGroups/containergroup3716\",\r\n \"name\": \"containergroup3716\",\r\n \"type\": \"Microsoft.ContainerInstance/containerGroups\",\r\n \"location\": \"westus\"\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 14 Aug 2017 09:08:21 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-ms-request-id": [ + "westus:64dc4fd9-c334-4bbc-b6fd-54f0ff5ab5e7" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1194" + ], + "x-ms-correlation-request-id": [ + "e86072a0-9a34-4d74-88ef-bebbdbfcf238" + ], + "x-ms-routing-request-id": [ + "AUSTRALIASOUTHEAST:20170814T090822Z:e86072a0-9a34-4d74-88ef-bebbdbfcf238" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourcegroups/containergroupcrd-5725?api-version=2017-05-10", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZDhkY2Q1OGItZTIyZC00M2U3LWE5N2YtMTVmYTI5ZDhjOGVhL3Jlc291cmNlZ3JvdXBzL2NvbnRhaW5lcmdyb3VwY3JkLTU3MjU/YXBpLXZlcnNpb249MjAxNy0wNS0xMA==", + "RequestMethod": "DELETE", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "6661ab34-3426-4955-b8b8-7a7b05abd9b4" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/1.6.0.0" + ] + }, + "ResponseBody": "", + "ResponseHeaders": { + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 14 Aug 2017 09:08:25 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Location": [ + "https://management.azure.com/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1DT05UQUlORVJHUk9VUENSRDoyRDU3MjUtV0VTVFVTIiwiam9iTG9jYXRpb24iOiJ3ZXN0dXMifQ?api-version=2017-05-10" + ], + "Retry-After": [ + "15" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1193" + ], + "x-ms-request-id": [ + "db27dc19-bcb1-4ca6-9da7-8430f1d10842" + ], + "x-ms-correlation-request-id": [ + "db27dc19-bcb1-4ca6-9da7-8430f1d10842" + ], + "x-ms-routing-request-id": [ + "AUSTRALIASOUTHEAST:20170814T090825Z:db27dc19-bcb1-4ca6-9da7-8430f1d10842" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ] + }, + "StatusCode": 202 + } + ], + "Names": { + "CreateResourceGroup": [ + "containergroupcrd-5725" + ], + "ContainerGroupCreateGetDeleteTests": [ + "containergroup3716" + ] + }, + "Variables": { + "SubscriptionId": "d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea" + } +} \ No newline at end of file diff --git a/src/SDKs/ContainerInstance/ContainerInstance.Tests/SessionRecords/ContainerInstance.Tests.ContainerLogScenarioTests/ContainerLogGetTest.json b/src/SDKs/ContainerInstance/ContainerInstance.Tests/SessionRecords/ContainerInstance.Tests.ContainerLogScenarioTests/ContainerLogGetTest.json new file mode 100644 index 000000000000..f11cd81f90e4 --- /dev/null +++ b/src/SDKs/ContainerInstance/ContainerInstance.Tests/SessionRecords/ContainerInstance.Tests.ContainerLogScenarioTests/ContainerLogGetTest.json @@ -0,0 +1,431 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourcegroups/containerlogget-2372?api-version=2017-05-10", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZDhkY2Q1OGItZTIyZC00M2U3LWE5N2YtMTVmYTI5ZDhjOGVhL3Jlc291cmNlZ3JvdXBzL2NvbnRhaW5lcmxvZ2dldC0yMzcyP2FwaS12ZXJzaW9uPTIwMTctMDUtMTA=", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"location\": \"westus\",\r\n \"tags\": {\r\n \"containerlogget-2372\": \"2017-08-14 09:08:28Z\"\r\n }\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "99" + ], + "x-ms-client-request-id": [ + "f2293741-13ec-4391-96a8-9f0739180ca5" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/1.6.0.0" + ] + }, + "ResponseBody": "{\r\n \"id\": \"/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containerlogget-2372\",\r\n \"name\": \"containerlogget-2372\",\r\n \"location\": \"westus\",\r\n \"tags\": {\r\n \"containerlogget-2372\": \"2017-08-14 09:08:28Z\"\r\n },\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\"\r\n }\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "248" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 14 Aug 2017 09:08:30 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1198" + ], + "x-ms-request-id": [ + "0cb45744-39c7-44e6-a012-b2e20ce7aaf5" + ], + "x-ms-correlation-request-id": [ + "0cb45744-39c7-44e6-a012-b2e20ce7aaf5" + ], + "x-ms-routing-request-id": [ + "AUSTRALIASOUTHEAST:20170814T090831Z:0cb45744-39c7-44e6-a012-b2e20ce7aaf5" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ] + }, + "StatusCode": 201 + }, + { + "RequestUri": "/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containerlogget-2372/providers/Microsoft.ContainerInstance/containerGroups/containergroup8458?api-version=2017-08-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZDhkY2Q1OGItZTIyZC00M2U3LWE5N2YtMTVmYTI5ZDhjOGVhL3Jlc291cmNlR3JvdXBzL2NvbnRhaW5lcmxvZ2dldC0yMzcyL3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29udGFpbmVySW5zdGFuY2UvY29udGFpbmVyR3JvdXBzL2NvbnRhaW5lcmdyb3VwODQ1OD9hcGktdmVyc2lvbj0yMDE3LTA4LTAxLXByZXZpZXc=", + "RequestMethod": "PUT", + "RequestBody": "{\r\n \"properties\": {\r\n \"containers\": [\r\n {\r\n \"name\": \"test1\",\r\n \"properties\": {\r\n \"image\": \"nginx\",\r\n \"ports\": [\r\n {\r\n \"port\": 80\r\n }\r\n ],\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n }\r\n }\r\n }\r\n ],\r\n \"osType\": \"Linux\"\r\n },\r\n \"location\": \"westus\"\r\n}", + "RequestHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Content-Length": [ + "447" + ], + "x-ms-client-request-id": [ + "7efcea1a-ca72-4df4-88db-640baea519fa" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.ContainerInstance.ContainerInstanceManagementClient/1.0.0.0" + ] + }, + "ResponseBody": "{\r\n \"properties\": {\r\n \"provisioningState\": \"Creating\",\r\n \"containers\": [\r\n {\r\n \"name\": \"test1\",\r\n \"properties\": {\r\n \"image\": \"nginx\",\r\n \"ports\": [\r\n {\r\n \"port\": 80\r\n }\r\n ],\r\n \"environmentVariables\": [],\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n }\r\n }\r\n }\r\n ],\r\n \"osType\": \"Linux\"\r\n },\r\n \"id\": \"/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containerlogget-2372/providers/Microsoft.ContainerInstance/containerGroups/containergroup8458\",\r\n \"name\": \"containergroup8458\",\r\n \"type\": \"Microsoft.ContainerInstance/containerGroups\",\r\n \"location\": \"westus\"\r\n}", + "ResponseHeaders": { + "Content-Length": [ + "498" + ], + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 14 Aug 2017 09:08:35 GMT" + ], + "Pragma": [ + "no-cache" + ], + "x-ms-request-id": [ + "westus:e62677d6-06b5-4bbb-8e1e-ae3506fc555e" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1187" + ], + "x-ms-correlation-request-id": [ + "f344b9f3-d60b-413a-b5c4-14963bff6e88" + ], + "x-ms-routing-request-id": [ + "AUSTRALIASOUTHEAST:20170814T090836Z:f344b9f3-d60b-413a-b5c4-14963bff6e88" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ] + }, + "StatusCode": 201 + }, + { + "RequestUri": "/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containerlogget-2372/providers/Microsoft.ContainerInstance/containerGroups/containergroup8458?api-version=2017-08-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZDhkY2Q1OGItZTIyZC00M2U3LWE5N2YtMTVmYTI5ZDhjOGVhL3Jlc291cmNlR3JvdXBzL2NvbnRhaW5lcmxvZ2dldC0yMzcyL3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29udGFpbmVySW5zdGFuY2UvY29udGFpbmVyR3JvdXBzL2NvbnRhaW5lcmdyb3VwODQ1OD9hcGktdmVyc2lvbj0yMDE3LTA4LTAxLXByZXZpZXc=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "0c1dbf8f-f9cb-4c85-bb56-3afea0798184" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.ContainerInstance.ContainerInstanceManagementClient/1.0.0.0" + ] + }, + "ResponseBody": "{\r\n \"properties\": {\r\n \"provisioningState\": \"Creating\",\r\n \"containers\": [\r\n {\r\n \"name\": \"test1\",\r\n \"properties\": {\r\n \"image\": \"nginx\",\r\n \"ports\": [\r\n {\r\n \"port\": 80\r\n }\r\n ],\r\n \"environmentVariables\": [],\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n }\r\n }\r\n }\r\n ],\r\n \"osType\": \"Linux\",\r\n \"state\": \"Pending\"\r\n },\r\n \"id\": \"/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containerlogget-2372/providers/Microsoft.ContainerInstance/containerGroups/containergroup8458\",\r\n \"name\": \"containergroup8458\",\r\n \"type\": \"Microsoft.ContainerInstance/containerGroups\",\r\n \"location\": \"westus\"\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 14 Aug 2017 09:09:21 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-ms-request-id": [ + "westus:15e8697e-bf8f-446f-8d08-a63d3672713e" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "14947" + ], + "x-ms-correlation-request-id": [ + "0d04d85f-8c93-49ed-a940-3d495dc23347" + ], + "x-ms-routing-request-id": [ + "AUSTRALIASOUTHEAST:20170814T090921Z:0d04d85f-8c93-49ed-a940-3d495dc23347" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containerlogget-2372/providers/Microsoft.ContainerInstance/containerGroups/containergroup8458?api-version=2017-08-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZDhkY2Q1OGItZTIyZC00M2U3LWE5N2YtMTVmYTI5ZDhjOGVhL3Jlc291cmNlR3JvdXBzL2NvbnRhaW5lcmxvZ2dldC0yMzcyL3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29udGFpbmVySW5zdGFuY2UvY29udGFpbmVyR3JvdXBzL2NvbnRhaW5lcmdyb3VwODQ1OD9hcGktdmVyc2lvbj0yMDE3LTA4LTAxLXByZXZpZXc=", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "815d300e-bd6c-47d5-873d-622dfcaf2ab5" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.ContainerInstance.ContainerInstanceManagementClient/1.0.0.0" + ] + }, + "ResponseBody": "{\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"containers\": [\r\n {\r\n \"name\": \"test1\",\r\n \"properties\": {\r\n \"image\": \"nginx\",\r\n \"ports\": [\r\n {\r\n \"port\": 80\r\n }\r\n ],\r\n \"environmentVariables\": [],\r\n \"instanceView\": {\r\n \"restartCount\": 0,\r\n \"currentState\": {\r\n \"state\": \"Running\",\r\n \"startTime\": \"2017-08-14T09:09:45Z\",\r\n \"detailStatus\": \"\"\r\n },\r\n \"events\": [\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:09:43Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:09:43Z\",\r\n \"message\": \"Pulling: pulling image \\\"nginx\\\"\",\r\n \"type\": \"Normal\"\r\n },\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:09:45Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:09:45Z\",\r\n \"message\": \"Pulled: Successfully pulled image \\\"nginx\\\"\",\r\n \"type\": \"Normal\"\r\n },\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:09:45Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:09:45Z\",\r\n \"message\": \"Created: Created container with id 13b3ad2a97b80a649daa46ac31d6296e761999981be37f05905735c1172c5057\",\r\n \"type\": \"Normal\"\r\n },\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:09:45Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:09:45Z\",\r\n \"message\": \"Started: Started container with id 13b3ad2a97b80a649daa46ac31d6296e761999981be37f05905735c1172c5057\",\r\n \"type\": \"Normal\"\r\n }\r\n ]\r\n },\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n }\r\n }\r\n }\r\n ],\r\n \"osType\": \"Linux\",\r\n \"state\": \"Running\"\r\n },\r\n \"id\": \"/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containerlogget-2372/providers/Microsoft.ContainerInstance/containerGroups/containergroup8458\",\r\n \"name\": \"containergroup8458\",\r\n \"type\": \"Microsoft.ContainerInstance/containerGroups\",\r\n \"location\": \"westus\"\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 14 Aug 2017 09:10:06 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-ms-request-id": [ + "westus:5c2fb702-abcb-4849-ae1c-638a8c8d0e83" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "14949" + ], + "x-ms-correlation-request-id": [ + "2059721d-e5c1-4a5f-8389-5f4ee09b8e8c" + ], + "x-ms-routing-request-id": [ + "AUSTRALIASOUTHEAST:20170814T091007Z:2059721d-e5c1-4a5f-8389-5f4ee09b8e8c" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containerlogget-2372/providers/Microsoft.ContainerInstance/containerGroups/containergroup8458/containers/test1/logs?api-version=2017-08-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZDhkY2Q1OGItZTIyZC00M2U3LWE5N2YtMTVmYTI5ZDhjOGVhL3Jlc291cmNlR3JvdXBzL2NvbnRhaW5lcmxvZ2dldC0yMzcyL3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29udGFpbmVySW5zdGFuY2UvY29udGFpbmVyR3JvdXBzL2NvbnRhaW5lcmdyb3VwODQ1OC9jb250YWluZXJzL3Rlc3QxL2xvZ3M/YXBpLXZlcnNpb249MjAxNy0wOC0wMS1wcmV2aWV3", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "bb8c322d-7d74-45c9-932f-c3ca4a83bb3c" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.ContainerInstance.ContainerInstanceManagementClient/1.0.0.0" + ] + }, + "ResponseBody": "{\r\n \"content\": \"\"\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 14 Aug 2017 09:10:07 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-ms-request-id": [ + "westus:3ba2488e-a91c-4627-ba5b-7e7523de695c" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "14948" + ], + "x-ms-correlation-request-id": [ + "7ae96fc1-6457-4939-9da7-e883363ebf39" + ], + "x-ms-routing-request-id": [ + "AUSTRALIASOUTHEAST:20170814T091007Z:7ae96fc1-6457-4939-9da7-e883363ebf39" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containerlogget-2372/providers/Microsoft.ContainerInstance/containerGroups/containergroup8458?api-version=2017-08-01-preview", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZDhkY2Q1OGItZTIyZC00M2U3LWE5N2YtMTVmYTI5ZDhjOGVhL3Jlc291cmNlR3JvdXBzL2NvbnRhaW5lcmxvZ2dldC0yMzcyL3Byb3ZpZGVycy9NaWNyb3NvZnQuQ29udGFpbmVySW5zdGFuY2UvY29udGFpbmVyR3JvdXBzL2NvbnRhaW5lcmdyb3VwODQ1OD9hcGktdmVyc2lvbj0yMDE3LTA4LTAxLXByZXZpZXc=", + "RequestMethod": "DELETE", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "b244fc7a-06cc-4ba7-bab1-2b3ccbc9bcd8" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.ContainerInstance.ContainerInstanceManagementClient/1.0.0.0" + ] + }, + "ResponseBody": "{\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\",\r\n \"containers\": [\r\n {\r\n \"name\": \"test1\",\r\n \"properties\": {\r\n \"image\": \"nginx\",\r\n \"ports\": [\r\n {\r\n \"port\": 80\r\n }\r\n ],\r\n \"environmentVariables\": [],\r\n \"instanceView\": {\r\n \"restartCount\": 0,\r\n \"currentState\": {\r\n \"state\": \"Running\",\r\n \"startTime\": \"2017-08-14T09:09:45Z\",\r\n \"detailStatus\": \"\"\r\n },\r\n \"events\": [\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:09:43Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:09:43Z\",\r\n \"message\": \"Pulling: pulling image \\\"nginx\\\"\",\r\n \"type\": \"Normal\"\r\n },\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:09:45Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:09:45Z\",\r\n \"message\": \"Pulled: Successfully pulled image \\\"nginx\\\"\",\r\n \"type\": \"Normal\"\r\n },\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:09:45Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:09:45Z\",\r\n \"message\": \"Created: Created container with id 13b3ad2a97b80a649daa46ac31d6296e761999981be37f05905735c1172c5057\",\r\n \"type\": \"Normal\"\r\n },\r\n {\r\n \"count\": 1,\r\n \"firstTimestamp\": \"2017-08-14T09:09:45Z\",\r\n \"lastTimestamp\": \"2017-08-14T09:09:45Z\",\r\n \"message\": \"Started: Started container with id 13b3ad2a97b80a649daa46ac31d6296e761999981be37f05905735c1172c5057\",\r\n \"type\": \"Normal\"\r\n }\r\n ]\r\n },\r\n \"resources\": {\r\n \"requests\": {\r\n \"memoryInGB\": 1.5,\r\n \"cpu\": 1.0\r\n }\r\n }\r\n }\r\n }\r\n ],\r\n \"osType\": \"Linux\",\r\n \"state\": \"Running\"\r\n },\r\n \"id\": \"/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourceGroups/containerlogget-2372/providers/Microsoft.ContainerInstance/containerGroups/containergroup8458\",\r\n \"name\": \"containergroup8458\",\r\n \"type\": \"Microsoft.ContainerInstance/containerGroups\",\r\n \"location\": \"westus\"\r\n}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 14 Aug 2017 09:10:09 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Transfer-Encoding": [ + "chunked" + ], + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-ms-request-id": [ + "westus:8eccbf44-e376-4af4-8a89-bf4fb5c9508c" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1187" + ], + "x-ms-correlation-request-id": [ + "40bda064-4836-486b-a53b-4515097361de" + ], + "x-ms-routing-request-id": [ + "AUSTRALIASOUTHEAST:20170814T091009Z:40bda064-4836-486b-a53b-4515097361de" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ] + }, + "StatusCode": 200 + }, + { + "RequestUri": "/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/resourcegroups/containerlogget-2372?api-version=2017-05-10", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvZDhkY2Q1OGItZTIyZC00M2U3LWE5N2YtMTVmYTI5ZDhjOGVhL3Jlc291cmNlZ3JvdXBzL2NvbnRhaW5lcmxvZ2dldC0yMzcyP2FwaS12ZXJzaW9uPTIwMTctMDUtMTA=", + "RequestMethod": "DELETE", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "634e564e-32ca-465a-900a-bc3b2f87da1c" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "FxVersion/4.6.25211.01", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/1.6.0.0" + ] + }, + "ResponseBody": "", + "ResponseHeaders": { + "Content-Length": [ + "0" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Mon, 14 Aug 2017 09:10:12 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Location": [ + "https://management.azure.com/subscriptions/d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1DT05UQUlORVJMT0dHRVQ6MkQyMzcyLVdFU1RVUyIsImpvYkxvY2F0aW9uIjoid2VzdHVzIn0?api-version=2017-05-10" + ], + "Retry-After": [ + "15" + ], + "x-ms-ratelimit-remaining-subscription-writes": [ + "1195" + ], + "x-ms-request-id": [ + "282af06c-5dab-477f-be88-ca3168d8b00c" + ], + "x-ms-correlation-request-id": [ + "282af06c-5dab-477f-be88-ca3168d8b00c" + ], + "x-ms-routing-request-id": [ + "AUSTRALIASOUTHEAST:20170814T091013Z:282af06c-5dab-477f-be88-ca3168d8b00c" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ] + }, + "StatusCode": 202 + } + ], + "Names": { + "CreateResourceGroup": [ + "containerlogget-2372" + ], + "ContainerLogGetTest": [ + "containergroup8458" + ] + }, + "Variables": { + "SubscriptionId": "d8dcd58b-e22d-43e7-a97f-15fa29d8c8ea" + } +} \ No newline at end of file diff --git a/src/SDKs/ContainerInstance/ContainerInstance.Tests/Utilities/ContainerGroupUtilities.cs b/src/SDKs/ContainerInstance/ContainerInstance.Tests/Utilities/ContainerGroupUtilities.cs new file mode 100644 index 000000000000..bfeaf450b7e1 --- /dev/null +++ b/src/SDKs/ContainerInstance/ContainerInstance.Tests/Utilities/ContainerGroupUtilities.cs @@ -0,0 +1,45 @@ +using System; +using System.Threading; +using Microsoft.Azure.Management.ContainerInstance; +using Microsoft.Azure.Management.ContainerInstance.Models; +using Microsoft.Azure.Test.HttpRecorder; + +namespace ContainerInstance.Tests +{ + public class ContainerGroupUtilities + { + private static readonly TimeSpan WaitTillTimeout = TimeSpan.FromMinutes(15); + private static readonly TimeSpan DefaultSleepPeriod = TimeSpan.FromSeconds(45); + + private const string SucceededProvisioningState = "Succeeded"; + private const string CreatingProvisioningState = "Creating"; + + public static void WaitTillProvisioningStateSucceeded(ContainerInstanceManagementClient client, string resourceGroupName, string containerGroupName) + { + DateTime startTime = DateTime.Now; + + TimeSpan sleepPeriod = HttpMockServer.Mode == HttpRecorderMode.Record ? DefaultSleepPeriod : TimeSpan.Zero; + + string status = null; + + while (status == null || status.Equals(CreatingProvisioningState, StringComparison.OrdinalIgnoreCase)) + { + if(DateTime.Now - startTime > WaitTillTimeout) + { + throw new TimeoutException($"Container Group didn't enter provisioning state '{SucceededProvisioningState}' within timeout"); + } + + Thread.Sleep((int)sleepPeriod.TotalMilliseconds); + + ContainerGroup group = client.ContainerGroups.Get(resourceGroupName, containerGroupName); + + status = group.ProvisioningState; + } + + if(!status.Equals(SucceededProvisioningState, StringComparison.OrdinalIgnoreCase)) + { + throw new InvalidOperationException($"Container Group is in '{status}' status, expected '{SucceededProvisioningState}'"); + } + } + } +} diff --git a/src/SDKs/ContainerInstance/ContainerInstance.Tests/Utilities/ContainerInstanceTestUtilities.cs b/src/SDKs/ContainerInstance/ContainerInstance.Tests/Utilities/ContainerInstanceTestUtilities.cs new file mode 100644 index 000000000000..c0a631f676c5 --- /dev/null +++ b/src/SDKs/ContainerInstance/ContainerInstance.Tests/Utilities/ContainerInstanceTestUtilities.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace ContainerInstance.Tests.Utilities +{ + class ContainerInstanceTestUtilities + { + public const string DefaultLocationId = "japaneast"; + + public const string DefaultLocation = "Japan East"; + + + } +} diff --git a/src/SDKs/ContainerInstance/ContainerInstance.Tests/Utilities/TestContext.cs b/src/SDKs/ContainerInstance/ContainerInstance.Tests/Utilities/TestContext.cs new file mode 100644 index 000000000000..264f3af9581a --- /dev/null +++ b/src/SDKs/ContainerInstance/ContainerInstance.Tests/Utilities/TestContext.cs @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using Microsoft.Azure.Management.ResourceManager; +using Microsoft.Azure.Management.ResourceManager.Models; +using Microsoft.Azure.Test.HttpRecorder; +using Microsoft.Rest.ClientRuntime.Azure.TestFramework; + +namespace ContainerInstance.Tests +{ + class TestContext : IDisposable + { + public const string DefaultTestPrefix = "defaulttestprefix-"; + public const string DefaultResourceGroupPrefix = "testresourcegroup-"; + public const string DefaultLocationId = "japaneast"; + public const string DefaultLocation = "Japan East"; + + private readonly MockContext _mockContext; + private readonly Dictionary _serviceClientCache = new Dictionary(); + private readonly List _resourceGroups = new List(); + private bool _disposedValue = false; // To detect redundant calls + + public TestContext( + object suiteObject, + [CallerMemberName] + string testName="error_determining_test_name") + { + _mockContext = MockContext.Start(suiteObject.GetType().FullName, testName); + } + + public TServiceClient GetClient() where TServiceClient : class, IDisposable + { + if (_serviceClientCache.TryGetValue(typeof(TServiceClient), out IDisposable clientObject)) + { + return (TServiceClient)clientObject; + } + + TServiceClient client = _mockContext.GetServiceClient(); + _serviceClientCache.Add(typeof(TServiceClient), client); + return client; + } + + public ResourceGroup CreateResourceGroup(string prefix = DefaultResourceGroupPrefix, string location = DefaultLocationId) + { + ResourceManagementClient resourceClient = GetClient(); + + string rgName = GenerateName(prefix); + ResourceGroup resourceGroup = resourceClient.ResourceGroups.CreateOrUpdate(rgName, + new ResourceGroup + { + Location = location, + Tags = new Dictionary() { { rgName, DateTime.UtcNow.ToString("u") } } + }); + + _resourceGroups.Add(resourceGroup); + + return resourceGroup; + } + + public string GenerateName(string prefix = DefaultTestPrefix, [CallerMemberName] string methodName="GenerateName_failed") + { + try + { + return HttpMockServer.GetAssetName(methodName, prefix); + } + catch (KeyNotFoundException e) + { + throw new KeyNotFoundException(string.Format("Generated name not found for calling method: {0}", methodName), e); + } + } + + protected virtual void Dispose(bool disposing) + { + if (!_disposedValue) + { + if (disposing) + { + // Begin deleting resource groups + ResourceManagementClient resourceClient = GetClient(); + _resourceGroups.ForEach(rg => resourceClient.ResourceGroups.BeginDelete(rg.Name)); + + // Dispose clients + foreach (IDisposable client in _serviceClientCache.Values) + { + client.Dispose(); + } + + // Dispose context + _mockContext.Dispose(); + } + _disposedValue = true; + } + } + + public void Dispose() + { + Dispose(true); + } + } +} diff --git a/src/SDKs/ContainerInstance/ContainerInstance.sln b/src/SDKs/ContainerInstance/ContainerInstance.sln new file mode 100644 index 000000000000..3081d972f485 --- /dev/null +++ b/src/SDKs/ContainerInstance/ContainerInstance.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26403.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.ContainerInstance", "Management.ContainerInstance\Microsoft.Azure.Management.ContainerInstance.csproj", "{629E1D0F-4B01-4DEF-9E52-3F9AD8B5006B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ContainerInstance.Tests", "ContainerInstance.Tests\ContainerInstance.Tests.csproj", "{8F0B929B-ECFB-43E0-AC2B-648B18CE3771}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {629E1D0F-4B01-4DEF-9E52-3F9AD8B5006B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {629E1D0F-4B01-4DEF-9E52-3F9AD8B5006B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {629E1D0F-4B01-4DEF-9E52-3F9AD8B5006B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {629E1D0F-4B01-4DEF-9E52-3F9AD8B5006B}.Release|Any CPU.Build.0 = Release|Any CPU + {8F0B929B-ECFB-43E0-AC2B-648B18CE3771}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8F0B929B-ECFB-43E0-AC2B-648B18CE3771}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8F0B929B-ECFB-43E0-AC2B-648B18CE3771}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8F0B929B-ECFB-43E0-AC2B-648B18CE3771}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/ContainerGroupsOperations.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/ContainerGroupsOperations.cs new file mode 100644 index 000000000000..2f4f137cb701 --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/ContainerGroupsOperations.cs @@ -0,0 +1,1393 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ContainerGroupsOperations operations. + /// + internal partial class ContainerGroupsOperations : IServiceOperations, IContainerGroupsOperations + { + /// + /// Initializes a new instance of the ContainerGroupsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ContainerGroupsOperations(ContainerInstanceManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ContainerInstanceManagementClient + /// + public ContainerInstanceManagementClient Client { get; private set; } + + /// + /// Get the list of container groups in a given subscription. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.ContainerInstance/containerGroups").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get the list of container groups in a given resource group. + /// + /// + /// Azure resource group name + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroup", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get details for this container group. + /// + /// + /// Azure resource group name + /// + /// + /// Container group name + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> GetWithHttpMessagesAsync(string resourceGroupName, string containerGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (containerGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerGroupName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("containerGroupName", containerGroupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{containerGroupName}", System.Uri.EscapeDataString(containerGroupName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Create or update container groups. + /// + /// + /// Azure resource group name + /// + /// + /// Container group name + /// + /// + /// Definition of the container to be created. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string containerGroupName, ContainerGroup containerGroup, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (containerGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerGroupName"); + } + if (containerGroup == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerGroup"); + } + if (containerGroup != null) + { + containerGroup.Validate(); + } + if (containerGroup == null) + { + containerGroup = new ContainerGroup(); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("containerGroupName", containerGroupName); + tracingParameters.Add("containerGroup", containerGroup); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{containerGroupName}", System.Uri.EscapeDataString(containerGroupName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("PUT"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + if(containerGroup != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(containerGroup, Client.SerializationSettings); + _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8); + _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + } + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 201) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + // Deserialize Response + if ((int)_statusCode == 201) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete container groups. + /// + /// + /// Azure resource group name + /// + /// + /// Name of the container group to be deleted + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string containerGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (containerGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerGroupName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("containerGroupName", containerGroupName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{containerGroupName}", System.Uri.EscapeDataString(containerGroupName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("DELETE"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200 && (int)_statusCode != 204) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get the list of container groups in a given subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get the list of container groups in a given resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (nextPageLink == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextPageLink", nextPageLink); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListByResourceGroupNext", tracingParameters); + } + // Construct URL + string _url = "{nextLink}"; + _url = _url.Replace("{nextLink}", nextPageLink); + List _queryParameters = new List(); + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse>(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/ContainerGroupsOperationsExtensions.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/ContainerGroupsOperationsExtensions.cs new file mode 100644 index 000000000000..5031bd48c5ef --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/ContainerGroupsOperationsExtensions.cs @@ -0,0 +1,281 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ContainerGroupsOperations. + /// + public static partial class ContainerGroupsOperationsExtensions + { + /// + /// Get the list of container groups in a given subscription. + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IContainerGroupsOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Get the list of container groups in a given subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IContainerGroupsOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the list of container groups in a given resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Azure resource group name + /// + public static IPage ListByResourceGroup(this IContainerGroupsOperations operations, string resourceGroupName) + { + return operations.ListByResourceGroupAsync(resourceGroupName).GetAwaiter().GetResult(); + } + + /// + /// Get the list of container groups in a given resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Azure resource group name + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this IContainerGroupsOperations operations, string resourceGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get details for this container group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Azure resource group name + /// + /// + /// Container group name + /// + public static ContainerGroup Get(this IContainerGroupsOperations operations, string resourceGroupName, string containerGroupName) + { + return operations.GetAsync(resourceGroupName, containerGroupName).GetAwaiter().GetResult(); + } + + /// + /// Get details for this container group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Azure resource group name + /// + /// + /// Container group name + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IContainerGroupsOperations operations, string resourceGroupName, string containerGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, containerGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or update container groups. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Azure resource group name + /// + /// + /// Container group name + /// + /// + /// Definition of the container to be created. + /// + public static ContainerGroup CreateOrUpdate(this IContainerGroupsOperations operations, string resourceGroupName, string containerGroupName, ContainerGroup containerGroup) + { + return operations.CreateOrUpdateAsync(resourceGroupName, containerGroupName, containerGroup).GetAwaiter().GetResult(); + } + + /// + /// Create or update container groups. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Azure resource group name + /// + /// + /// Container group name + /// + /// + /// Definition of the container to be created. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IContainerGroupsOperations operations, string resourceGroupName, string containerGroupName, ContainerGroup containerGroup, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, containerGroupName, containerGroup, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete container groups. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Azure resource group name + /// + /// + /// Name of the container group to be deleted + /// + public static ContainerGroup Delete(this IContainerGroupsOperations operations, string resourceGroupName, string containerGroupName) + { + return operations.DeleteAsync(resourceGroupName, containerGroupName).GetAwaiter().GetResult(); + } + + /// + /// Delete container groups. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Azure resource group name + /// + /// + /// Name of the container group to be deleted + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IContainerGroupsOperations operations, string resourceGroupName, string containerGroupName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.DeleteWithHttpMessagesAsync(resourceGroupName, containerGroupName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the list of container groups in a given subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IContainerGroupsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get the list of container groups in a given subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListNextAsync(this IContainerGroupsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get the list of container groups in a given resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByResourceGroupNext(this IContainerGroupsOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get the list of container groups in a given resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupNextAsync(this IContainerGroupsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/ContainerInstanceManagementClient.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/ContainerInstanceManagementClient.cs new file mode 100644 index 000000000000..c6fca7c779f9 --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/ContainerInstanceManagementClient.cs @@ -0,0 +1,324 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Serialization; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + + public partial class ContainerInstanceManagementClient : ServiceClient, IContainerInstanceManagementClient, IAzureClient + { + /// + /// The base URI of the service. + /// + public System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + public JsonSerializerSettings SerializationSettings { get; private set; } + + /// + /// Gets or sets json deserialization settings. + /// + public JsonSerializerSettings DeserializationSettings { get; private set; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + public ServiceClientCredentials Credentials { get; private set; } + + /// + /// Subscription credentials which uniquely identify Microsoft Azure + /// subscription. The subscription ID forms part of the URI for every service + /// call. + /// + public string SubscriptionId { get; set; } + + /// + /// Client API version + /// + public string ApiVersion { get; private set; } + + /// + /// Gets or sets the preferred language for the response. + /// + public string AcceptLanguage { get; set; } + + /// + /// Gets or sets the retry timeout in seconds for Long Running Operations. + /// Default value is 30. + /// + public int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// When set to true a unique x-ms-client-request-id value is generated and + /// included in each request. Default is true. + /// + public bool? GenerateClientRequestId { get; set; } + + /// + /// Gets the IContainerGroupsOperations. + /// + public virtual IContainerGroupsOperations ContainerGroups { get; private set; } + + /// + /// Gets the IContainerLogsOperations. + /// + public virtual IContainerLogsOperations ContainerLogs { get; private set; } + + /// + /// Initializes a new instance of the ContainerInstanceManagementClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected ContainerInstanceManagementClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ContainerInstanceManagementClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected ContainerInstanceManagementClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ContainerInstanceManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected ContainerInstanceManagementClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the ContainerInstanceManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + protected ContainerInstanceManagementClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the ContainerInstanceManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public ContainerInstanceManagementClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the ContainerInstanceManagementClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public ContainerInstanceManagementClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the ContainerInstanceManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public ContainerInstanceManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the ContainerInstanceManagementClient class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + /// + /// Thrown when a required parameter is null + /// + public ContainerInstanceManagementClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + BaseUri = baseUri; + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// An optional partial-method to perform custom initialization. + /// + partial void CustomInitialize(); + /// + /// Initializes client properties. + /// + private void Initialize() + { + ContainerGroups = new ContainerGroupsOperations(this); + ContainerLogs = new ContainerLogsOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2017-08-01-preview"; + AcceptLanguage = "en-US"; + LongRunningOperationRetryTimeout = 30; + GenerateClientRequestId = true; + SerializationSettings = new JsonSerializerSettings + { + Formatting = Newtonsoft.Json.Formatting.Indented, + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + SerializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings = new JsonSerializerSettings + { + DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, + NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, + ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver(), + Converters = new List + { + new Iso8601TimeSpanConverter() + } + }; + CustomInitialize(); + DeserializationSettings.Converters.Add(new TransformationJsonConverter()); + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/ContainerLogsOperations.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/ContainerLogsOperations.cs new file mode 100644 index 000000000000..237bdeeaac9b --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/ContainerLogsOperations.cs @@ -0,0 +1,268 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + using System.Net; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ContainerLogsOperations operations. + /// + internal partial class ContainerLogsOperations : IServiceOperations, IContainerLogsOperations + { + /// + /// Initializes a new instance of the ContainerLogsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ContainerLogsOperations(ContainerInstanceManagementClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ContainerInstanceManagementClient + /// + public ContainerInstanceManagementClient Client { get; private set; } + + /// + /// Get the logs for this container. + /// + /// + /// Azure resource group name + /// + /// + /// Container name + /// + /// + /// Container group name + /// + /// + /// Only show this number of log lines. If not provided, all available logs are + /// shown. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// Thrown when a required parameter is null + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task> ListWithHttpMessagesAsync(string resourceGroupName, string containerName, string containerGroupName, int? tail = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (Client.ApiVersion == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (containerName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerName"); + } + if (containerGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "containerGroupName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("containerName", containerName); + tracingParameters.Add("containerGroupName", containerGroupName); + tracingParameters.Add("tail", tail); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/logs").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{containerName}", System.Uri.EscapeDataString(containerName)); + _url = _url.Replace("{containerGroupName}", System.Uri.EscapeDataString(containerGroupName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (tail != null) + { + _queryParameters.Add(string.Format("tail={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(tail, Client.SerializationSettings).Trim('"')))); + } + if (_queryParameters.Count > 0) + { + _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters); + } + // Create HTTP transport objects + var _httpRequest = new HttpRequestMessage(); + HttpResponseMessage _httpResponse = null; + _httpRequest.Method = new HttpMethod("GET"); + _httpRequest.RequestUri = new System.Uri(_url); + // Set Headers + if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value) + { + _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString()); + } + if (Client.AcceptLanguage != null) + { + if (_httpRequest.Headers.Contains("accept-language")) + { + _httpRequest.Headers.Remove("accept-language"); + } + _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage); + } + + + if (customHeaders != null) + { + foreach(var _header in customHeaders) + { + if (_httpRequest.Headers.Contains(_header.Key)) + { + _httpRequest.Headers.Remove(_header.Key); + } + _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value); + } + } + + // Serialize Request + string _requestContent = null; + // Set Credentials + if (Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (_shouldTrace) + { + ServiceClientTracing.SendRequest(_invocationId, _httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false); + if (_shouldTrace) + { + ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse); + } + HttpStatusCode _statusCode = _httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + string _responseContent = null; + if ((int)_statusCode != 200) + { + var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + if (_errorBody != null) + { + ex = new CloudException(_errorBody.Message); + ex.Body = _errorBody; + } + } + catch (JsonException) + { + // Ignore the exception + } + ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent); + ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent); + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (_shouldTrace) + { + ServiceClientTracing.Error(_invocationId, ex); + } + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw ex; + } + // Create Result + var _result = new AzureOperationResponse(); + _result.Request = _httpRequest; + _result.Response = _httpResponse; + if (_httpResponse.Headers.Contains("x-ms-request-id")) + { + _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + // Deserialize Response + if ((int)_statusCode == 200) + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + try + { + _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings); + } + catch (JsonException ex) + { + _httpRequest.Dispose(); + if (_httpResponse != null) + { + _httpResponse.Dispose(); + } + throw new SerializationException("Unable to deserialize the response.", _responseContent, ex); + } + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/ContainerLogsOperationsExtensions.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/ContainerLogsOperationsExtensions.cs new file mode 100644 index 000000000000..9ebe69cdd39a --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/ContainerLogsOperationsExtensions.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ContainerLogsOperations. + /// + public static partial class ContainerLogsOperationsExtensions + { + /// + /// Get the logs for this container. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Azure resource group name + /// + /// + /// Container name + /// + /// + /// Container group name + /// + /// + /// Only show this number of log lines. If not provided, all available logs are + /// shown. + /// + public static Logs List(this IContainerLogsOperations operations, string resourceGroupName, string containerName, string containerGroupName, int? tail = default(int?)) + { + return operations.ListAsync(resourceGroupName, containerName, containerGroupName, tail).GetAwaiter().GetResult(); + } + + /// + /// Get the logs for this container. + /// + /// + /// The operations group for this extension method. + /// + /// + /// Azure resource group name + /// + /// + /// Container name + /// + /// + /// Container group name + /// + /// + /// Only show this number of log lines. If not provided, all available logs are + /// shown. + /// + /// + /// The cancellation token. + /// + public static async Task ListAsync(this IContainerLogsOperations operations, string resourceGroupName, string containerName, string containerGroupName, int? tail = default(int?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, containerName, containerGroupName, tail, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/IContainerGroupsOperations.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/IContainerGroupsOperations.cs new file mode 100644 index 000000000000..c818d94c320f --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/IContainerGroupsOperations.cs @@ -0,0 +1,190 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ContainerGroupsOperations operations. + /// + public partial interface IContainerGroupsOperations + { + /// + /// Get the list of container groups in a given subscription. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the list of container groups in a given resource group. + /// + /// + /// Azure resource group name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get details for this container group. + /// + /// + /// Azure resource group name + /// + /// + /// Container group name + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> GetWithHttpMessagesAsync(string resourceGroupName, string containerGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or update container groups. + /// + /// + /// Azure resource group name + /// + /// + /// Container group name + /// + /// + /// Definition of the container to be created. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string containerGroupName, ContainerGroup containerGroup, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete container groups. + /// + /// + /// Azure resource group name + /// + /// + /// Name of the container group to be deleted + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> DeleteWithHttpMessagesAsync(string resourceGroupName, string containerGroupName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the list of container groups in a given subscription. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get the list of container groups in a given resource group. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task>> ListByResourceGroupNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/IContainerInstanceManagementClient.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/IContainerInstanceManagementClient.cs new file mode 100644 index 000000000000..35e5679f91fd --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/IContainerInstanceManagementClient.cs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// + public partial interface IContainerInstanceManagementClient : System.IDisposable + { + /// + /// The base URI of the service. + /// + System.Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + JsonSerializerSettings DeserializationSettings { get; } + + /// + /// Credentials needed for the client to connect to Azure. + /// + ServiceClientCredentials Credentials { get; } + + /// + /// Subscription credentials which uniquely identify Microsoft Azure + /// subscription. The subscription ID forms part of the URI for every + /// service call. + /// + string SubscriptionId { get; set; } + + /// + /// Client API version + /// + string ApiVersion { get; } + + /// + /// Gets or sets the preferred language for the response. + /// + string AcceptLanguage { get; set; } + + /// + /// Gets or sets the retry timeout in seconds for Long Running + /// Operations. Default value is 30. + /// + int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// When set to true a unique x-ms-client-request-id value is generated + /// and included in each request. Default is true. + /// + bool? GenerateClientRequestId { get; set; } + + + /// + /// Gets the IContainerGroupsOperations. + /// + IContainerGroupsOperations ContainerGroups { get; } + + /// + /// Gets the IContainerLogsOperations. + /// + IContainerLogsOperations ContainerLogs { get; } + + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/IContainerLogsOperations.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/IContainerLogsOperations.cs new file mode 100644 index 000000000000..3e3b366b9e8c --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/IContainerLogsOperations.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ContainerLogsOperations operations. + /// + public partial interface IContainerLogsOperations + { + /// + /// Get the logs for this container. + /// + /// + /// Azure resource group name + /// + /// + /// Container name + /// + /// + /// Container group name + /// + /// + /// Only show this number of log lines. If not provided, all available + /// logs are shown. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when unable to deserialize the response + /// + /// + /// Thrown when a required parameter is null + /// + Task> ListWithHttpMessagesAsync(string resourceGroupName, string containerName, string containerGroupName, int? tail = default(int?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/AzureFileVolume.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/AzureFileVolume.cs new file mode 100644 index 000000000000..c59b544531a6 --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/AzureFileVolume.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The Azure file volume. + /// + public partial class AzureFileVolume + { + /// + /// Initializes a new instance of the AzureFileVolume class. + /// + public AzureFileVolume() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AzureFileVolume class. + /// + /// The Azure file share name. + /// The storage account name to access + /// to the Azure file. + /// The flag indicating whether the + /// Azure file volume is read only. + /// The storage account key to access + /// to the Azure file. + public AzureFileVolume(string shareName, string storageAccountName, bool? readOnlyProperty = default(bool?), string storageAccountKey = default(string)) + { + ShareName = shareName; + ReadOnlyProperty = readOnlyProperty; + StorageAccountName = storageAccountName; + StorageAccountKey = storageAccountKey; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the Azure file share name. + /// + [JsonProperty(PropertyName = "shareName")] + public string ShareName { get; set; } + + /// + /// Gets or sets the flag indicating whether the Azure file volume is + /// read only. + /// + [JsonProperty(PropertyName = "readOnly")] + public bool? ReadOnlyProperty { get; set; } + + /// + /// Gets or sets the storage account name to access to the Azure file. + /// + [JsonProperty(PropertyName = "storageAccountName")] + public string StorageAccountName { get; set; } + + /// + /// Gets or sets the storage account key to access to the Azure file. + /// + [JsonProperty(PropertyName = "storageAccountKey")] + public string StorageAccountKey { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ShareName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ShareName"); + } + if (StorageAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "StorageAccountName"); + } + } + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Container.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Container.cs new file mode 100644 index 000000000000..81be18c5e60b --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Container.cs @@ -0,0 +1,175 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A container instance. + /// + [Rest.Serialization.JsonTransformation] + public partial class Container + { + /// + /// Initializes a new instance of the Container class. + /// + public Container() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Container class. + /// + /// The user-provided name of this container + /// The name of the image used when creating this + /// container + /// The resource requirements of this + /// container. + /// Command array to execute within the container + /// in exec form. + /// The ports exposed by this container + /// The environment variables to set + /// in this container + /// The instance view of the container. Only + /// valid in response. + /// The volume mounts. + public Container(string name, string image, ResourceRequirements resources, IList command = default(IList), IList ports = default(IList), IList environmentVariables = default(IList), ContainerPropertiesInstanceView instanceView = default(ContainerPropertiesInstanceView), IList volumeMounts = default(IList)) + { + Name = name; + Image = image; + Command = command; + Ports = ports; + EnvironmentVariables = environmentVariables; + InstanceView = instanceView; + Resources = resources; + VolumeMounts = volumeMounts; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the user-provided name of this container + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the name of the image used when creating this + /// container + /// + [JsonProperty(PropertyName = "properties.image")] + public string Image { get; set; } + + /// + /// Gets or sets command array to execute within the container in exec + /// form. + /// + [JsonProperty(PropertyName = "properties.command")] + public IList Command { get; set; } + + /// + /// Gets or sets the ports exposed by this container + /// + [JsonProperty(PropertyName = "properties.ports")] + public IList Ports { get; set; } + + /// + /// Gets or sets the environment variables to set in this container + /// + [JsonProperty(PropertyName = "properties.environmentVariables")] + public IList EnvironmentVariables { get; set; } + + /// + /// Gets the instance view of the container. Only valid in response. + /// + [JsonProperty(PropertyName = "properties.instanceView")] + public ContainerPropertiesInstanceView InstanceView { get; private set; } + + /// + /// Gets or sets the resource requirements of this container. + /// + [JsonProperty(PropertyName = "properties.resources")] + public ResourceRequirements Resources { get; set; } + + /// + /// Gets or sets the volume mounts. + /// + [JsonProperty(PropertyName = "properties.volumeMounts")] + public IList VolumeMounts { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (Image == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Image"); + } + if (Resources == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Resources"); + } + if (Ports != null) + { + foreach (var element in Ports) + { + if (element != null) + { + element.Validate(); + } + } + } + if (EnvironmentVariables != null) + { + foreach (var element1 in EnvironmentVariables) + { + if (element1 != null) + { + element1.Validate(); + } + } + } + if (Resources != null) + { + Resources.Validate(); + } + if (VolumeMounts != null) + { + foreach (var element2 in VolumeMounts) + { + if (element2 != null) + { + element2.Validate(); + } + } + } + } + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerEvent.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerEvent.cs new file mode 100644 index 000000000000..e7a4332c9555 --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerEvent.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Newtonsoft.Json; + using System.Linq; + + /// + /// A container event. + /// + public partial class ContainerEvent + { + /// + /// Initializes a new instance of the ContainerEvent class. + /// + public ContainerEvent() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ContainerEvent class. + /// + /// The count of the event. + /// Date/time of the first event. + /// Date/time of the last event. + /// The event message + /// The event type. + public ContainerEvent(int? count = default(int?), System.DateTime? firstTimestamp = default(System.DateTime?), System.DateTime? lastTimestamp = default(System.DateTime?), string message = default(string), string type = default(string)) + { + Count = count; + FirstTimestamp = firstTimestamp; + LastTimestamp = lastTimestamp; + Message = message; + Type = type; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the count of the event. + /// + [JsonProperty(PropertyName = "count")] + public int? Count { get; set; } + + /// + /// Gets or sets date/time of the first event. + /// + [JsonProperty(PropertyName = "firstTimestamp")] + public System.DateTime? FirstTimestamp { get; set; } + + /// + /// Gets or sets date/time of the last event. + /// + [JsonProperty(PropertyName = "lastTimestamp")] + public System.DateTime? LastTimestamp { get; set; } + + /// + /// Gets or sets the event message + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + /// + /// Gets or sets the event type. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerGroup.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerGroup.cs new file mode 100644 index 000000000000..06739e1d7a03 --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerGroup.cs @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// A container group. + /// + [Rest.Serialization.JsonTransformation] + public partial class ContainerGroup : Resource + { + /// + /// Initializes a new instance of the ContainerGroup class. + /// + public ContainerGroup() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ContainerGroup class. + /// + /// Resource location + /// Resource Id + /// Resource name + /// Resource type + /// Resource tags + /// The provisioning state, which only + /// appears in the response. + /// The containers in this container + /// group. + /// The image registry + /// credentials by which the container group is created from. + /// - `always` Always restart + /// . Possible values include: 'always' + /// The IP address type. + /// The base level OS type required by the + /// containers in the group. Possible values include: 'Windows', + /// 'Linux' + /// The state of the container group. Only valid in + /// response. + /// The volumes for this container group. + public ContainerGroup(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary), string provisioningState = default(string), IList containers = default(IList), IList imageRegistryCredentials = default(IList), string restartPolicy = default(string), IpAddress ipAddress = default(IpAddress), string osType = default(string), string state = default(string), IList volumes = default(IList)) + : base(location, id, name, type, tags) + { + ProvisioningState = provisioningState; + Containers = containers; + ImageRegistryCredentials = imageRegistryCredentials; + RestartPolicy = restartPolicy; + IpAddress = ipAddress; + OsType = osType; + State = state; + Volumes = volumes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the provisioning state, which only appears in the response. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets or sets the containers in this container group. + /// + [JsonProperty(PropertyName = "properties.containers")] + public IList Containers { get; set; } + + /// + /// Gets or sets the image registry credentials by which the container + /// group is created from. + /// + [JsonProperty(PropertyName = "properties.imageRegistryCredentials")] + public IList ImageRegistryCredentials { get; set; } + + /// + /// Gets or sets - `always` Always restart + /// . Possible values include: 'always' + /// + [JsonProperty(PropertyName = "properties.restartPolicy")] + public string RestartPolicy { get; set; } + + /// + /// Gets or sets the IP address type. + /// + [JsonProperty(PropertyName = "properties.ipAddress")] + public IpAddress IpAddress { get; set; } + + /// + /// Gets or sets the base level OS type required by the containers in + /// the group. Possible values include: 'Windows', 'Linux' + /// + [JsonProperty(PropertyName = "properties.osType")] + public string OsType { get; set; } + + /// + /// Gets the state of the container group. Only valid in response. + /// + [JsonProperty(PropertyName = "properties.state")] + public string State { get; private set; } + + /// + /// Gets or sets the volumes for this container group. + /// + [JsonProperty(PropertyName = "properties.volumes")] + public IList Volumes { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public override void Validate() + { + base.Validate(); + if (Containers != null) + { + foreach (var element in Containers) + { + if (element != null) + { + element.Validate(); + } + } + } + if (ImageRegistryCredentials != null) + { + foreach (var element1 in ImageRegistryCredentials) + { + if (element1 != null) + { + element1.Validate(); + } + } + } + if (IpAddress != null) + { + IpAddress.Validate(); + } + if (Volumes != null) + { + foreach (var element2 in Volumes) + { + if (element2 != null) + { + element2.Validate(); + } + } + } + } + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerGroupNetworkProtocol.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerGroupNetworkProtocol.cs new file mode 100644 index 000000000000..6ee77a98e63b --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerGroupNetworkProtocol.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + + /// + /// Defines values for ContainerGroupNetworkProtocol. + /// + public static class ContainerGroupNetworkProtocol + { + public const string TCP = "TCP"; + public const string UDP = "UDP"; + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerPort.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerPort.cs new file mode 100644 index 000000000000..78a1f0507039 --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerPort.cs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The container port. + /// + public partial class ContainerPort + { + /// + /// Initializes a new instance of the ContainerPort class. + /// + public ContainerPort() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ContainerPort class. + /// + /// Port number to expose within the container + /// group. + public ContainerPort(int port) + { + Port = port; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets port number to expose within the container group. + /// + [JsonProperty(PropertyName = "port")] + public int Port { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + //Nothing to validate + } + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerPropertiesInstanceView.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerPropertiesInstanceView.cs new file mode 100644 index 000000000000..0b6d60c6a168 --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerPropertiesInstanceView.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The instance view of the container. Only valid in response. + /// + public partial class ContainerPropertiesInstanceView + { + /// + /// Initializes a new instance of the ContainerPropertiesInstanceView + /// class. + /// + public ContainerPropertiesInstanceView() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ContainerPropertiesInstanceView + /// class. + /// + /// The number of times that the container + /// has been restarted. + /// Current container state. + /// Previous container state. + /// The events of this container instance. + public ContainerPropertiesInstanceView(int? restartCount = default(int?), ContainerState currentState = default(ContainerState), ContainerState previousState = default(ContainerState), IList events = default(IList)) + { + RestartCount = restartCount; + CurrentState = currentState; + PreviousState = previousState; + Events = events; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the number of times that the container has been + /// restarted. + /// + [JsonProperty(PropertyName = "restartCount")] + public int? RestartCount { get; set; } + + /// + /// Gets or sets current container state. + /// + [JsonProperty(PropertyName = "currentState")] + public ContainerState CurrentState { get; set; } + + /// + /// Gets or sets previous container state. + /// + [JsonProperty(PropertyName = "previousState")] + public ContainerState PreviousState { get; set; } + + /// + /// Gets or sets the events of this container instance. + /// + [JsonProperty(PropertyName = "events")] + public IList Events { get; set; } + + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerRestartPolicy.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerRestartPolicy.cs new file mode 100644 index 000000000000..18aaad897314 --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerRestartPolicy.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + + /// + /// Defines values for ContainerRestartPolicy. + /// + public static class ContainerRestartPolicy + { + public const string Always = "always"; + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerState.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerState.cs new file mode 100644 index 000000000000..eef7873d50da --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ContainerState.cs @@ -0,0 +1,87 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The container state. + /// + public partial class ContainerState + { + /// + /// Initializes a new instance of the ContainerState class. + /// + public ContainerState() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ContainerState class. + /// + /// The state of this container + /// Date/time when the container state + /// started. + /// The container exit code. + /// Date/time when the container state + /// finished. + /// Human-readable status of this + /// state. + public ContainerState(string state = default(string), System.DateTime? startTime = default(System.DateTime?), int? exitCode = default(int?), System.DateTime? finishTime = default(System.DateTime?), string detailStatus = default(string)) + { + State = state; + StartTime = startTime; + ExitCode = exitCode; + FinishTime = finishTime; + DetailStatus = detailStatus; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the state of this container + /// + [JsonProperty(PropertyName = "state")] + public string State { get; set; } + + /// + /// Gets or sets date/time when the container state started. + /// + [JsonProperty(PropertyName = "startTime")] + public System.DateTime? StartTime { get; set; } + + /// + /// Gets or sets the container exit code. + /// + [JsonProperty(PropertyName = "exitCode")] + public int? ExitCode { get; set; } + + /// + /// Gets or sets date/time when the container state finished. + /// + [JsonProperty(PropertyName = "finishTime")] + public System.DateTime? FinishTime { get; set; } + + /// + /// Gets or sets human-readable status of this state. + /// + [JsonProperty(PropertyName = "detailStatus")] + public string DetailStatus { get; set; } + + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/EnvironmentVariable.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/EnvironmentVariable.cs new file mode 100644 index 000000000000..7086ee6fe2ad --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/EnvironmentVariable.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Environment variable to set within the container. + /// + public partial class EnvironmentVariable + { + /// + /// Initializes a new instance of the EnvironmentVariable class. + /// + public EnvironmentVariable() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EnvironmentVariable class. + /// + /// The name of the environment variable. + /// The value of the environment variable. + public EnvironmentVariable(string name, string value) + { + Name = name; + Value = value; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the name of the environment variable. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the value of the environment variable. + /// + [JsonProperty(PropertyName = "value")] + public string Value { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (Value == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Value"); + } + } + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ImageRegistryCredential.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ImageRegistryCredential.cs new file mode 100644 index 000000000000..5d3e0ea8b5bc --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ImageRegistryCredential.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Image registry credential. + /// + public partial class ImageRegistryCredential + { + /// + /// Initializes a new instance of the ImageRegistryCredential class. + /// + public ImageRegistryCredential() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ImageRegistryCredential class. + /// + /// Docker image registry server, without protocol + /// such as "http" and "https". + /// The username for the private + /// registry. + /// The password for the private + /// registry. + public ImageRegistryCredential(string server, string username, string password = default(string)) + { + Server = server; + Username = username; + Password = password; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets docker image registry server, without protocol such as + /// "http" and "https". + /// + [JsonProperty(PropertyName = "server")] + public string Server { get; set; } + + /// + /// Gets or sets the username for the private registry. + /// + [JsonProperty(PropertyName = "username")] + public string Username { get; set; } + + /// + /// Gets or sets the password for the private registry. + /// + [JsonProperty(PropertyName = "password")] + public string Password { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Server == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Server"); + } + if (Username == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Username"); + } + } + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/IpAddress.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/IpAddress.cs new file mode 100644 index 000000000000..0e91056e93f3 --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/IpAddress.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// IP address for the group. + /// + public partial class IpAddress + { + /// + /// Initializes a new instance of the IpAddress class. + /// + public IpAddress() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the IpAddress class. + /// + /// The ports. + /// The IP exposed to the public internet. + public IpAddress(IList ports, string ip = default(string)) + { + Ports = ports; + Ip = ip; + CustomInit(); + } + /// + /// Static constructor for IpAddress class. + /// + static IpAddress() + { + Type = "Public"; + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the ports. + /// + [JsonProperty(PropertyName = "ports")] + public IList Ports { get; set; } + + /// + /// Gets or sets the IP exposed to the public internet. + /// + [JsonProperty(PropertyName = "ip")] + public string Ip { get; set; } + + /// + /// Determines whether the IP is exposed to the public internet. + /// + [JsonProperty(PropertyName = "type")] + public static string Type { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Ports == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Ports"); + } + if (Ports != null) + { + foreach (var element in Ports) + { + if (element != null) + { + element.Validate(); + } + } + } + } + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Logs.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Logs.cs new file mode 100644 index 000000000000..474765d39021 --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Logs.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The logs. + /// + public partial class Logs + { + /// + /// Initializes a new instance of the Logs class. + /// + public Logs() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Logs class. + /// + /// content of the log. + public Logs(string content = default(string)) + { + Content = content; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets content of the log. + /// + [JsonProperty(PropertyName = "content")] + public string Content { get; set; } + + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/OperatingSystemTypes.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/OperatingSystemTypes.cs new file mode 100644 index 000000000000..274412f27c13 --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/OperatingSystemTypes.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + + /// + /// Defines values for OperatingSystemTypes. + /// + public static class OperatingSystemTypes + { + public const string Windows = "Windows"; + public const string Linux = "Linux"; + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Page.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Page.cs new file mode 100644 index 000000000000..857dee09aff4 --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Page.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + + /// + /// Defines a page in Azure responses. + /// + /// Type of the page content items + [JsonObject] + public class Page : IPage + { + /// + /// Gets the link to the next page. + /// + [JsonProperty("nextLink")] + public string NextPageLink { get; private set; } + + [JsonProperty("value")] + private IList Items{ get; set; } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + public IEnumerator GetEnumerator() + { + return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator(); + } + + /// + /// Returns an enumerator that iterates through the collection. + /// + /// A an enumerator that can be used to iterate through the collection. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Port.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Port.cs new file mode 100644 index 000000000000..755bb0207f7a --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Port.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The port. + /// + public partial class Port + { + /// + /// Initializes a new instance of the Port class. + /// + public Port() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Port class. + /// + /// The port. + /// The protocol associated with the port. + /// Possible values include: 'TCP', 'UDP' + public Port(int portProperty, string protocol = default(string)) + { + Protocol = protocol; + PortProperty = portProperty; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the protocol associated with the port. Possible values + /// include: 'TCP', 'UDP' + /// + [JsonProperty(PropertyName = "protocol")] + public string Protocol { get; set; } + + /// + /// Gets or sets the port. + /// + [JsonProperty(PropertyName = "port")] + public int PortProperty { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + } + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Resource.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Resource.cs new file mode 100644 index 000000000000..758bea57f421 --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Resource.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The Resource model definition. + /// + public partial class Resource : IResource + { + /// + /// Initializes a new instance of the Resource class. + /// + public Resource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Resource class. + /// + /// Resource location + /// Resource Id + /// Resource name + /// Resource type + /// Resource tags + public Resource(string location, string id = default(string), string name = default(string), string type = default(string), IDictionary tags = default(IDictionary)) + { + Id = id; + Name = name; + Type = type; + Location = location; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets resource Id + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets resource name + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets resource type + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets resource location + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets resource tags + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Location == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Location"); + } + } + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ResourceLimits.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ResourceLimits.cs new file mode 100644 index 000000000000..c4f92339b9bb --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ResourceLimits.cs @@ -0,0 +1,61 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The resource limits. + /// + public partial class ResourceLimits + { + /// + /// Initializes a new instance of the ResourceLimits class. + /// + public ResourceLimits() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceLimits class. + /// + /// The memory limit in GB of this + /// container. + /// The CPU limit of this container. + public ResourceLimits(double? memoryInGB = default(double?), double? cpu = default(double?)) + { + MemoryInGB = memoryInGB; + Cpu = cpu; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the memory limit in GB of this container. + /// + [JsonProperty(PropertyName = "memoryInGB")] + public double? MemoryInGB { get; set; } + + /// + /// Gets or sets the CPU limit of this container. + /// + [JsonProperty(PropertyName = "cpu")] + public double? Cpu { get; set; } + + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ResourceRequests.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ResourceRequests.cs new file mode 100644 index 000000000000..1ddf1866f47e --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ResourceRequests.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The resource requests. + /// + public partial class ResourceRequests + { + /// + /// Initializes a new instance of the ResourceRequests class. + /// + public ResourceRequests() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceRequests class. + /// + /// The memory request in GB of this + /// container. + /// The CPU request of this container. + public ResourceRequests(double memoryInGB, double cpu) + { + MemoryInGB = memoryInGB; + Cpu = cpu; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the memory request in GB of this container. + /// + [JsonProperty(PropertyName = "memoryInGB")] + public double MemoryInGB { get; set; } + + /// + /// Gets or sets the CPU request of this container. + /// + [JsonProperty(PropertyName = "cpu")] + public double Cpu { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + //Nothing to validate + } + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ResourceRequirements.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ResourceRequirements.cs new file mode 100644 index 000000000000..658129aaa431 --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/ResourceRequirements.cs @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The resource requirements. + /// + public partial class ResourceRequirements + { + /// + /// Initializes a new instance of the ResourceRequirements class. + /// + public ResourceRequirements() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceRequirements class. + /// + /// The resource requests of this + /// container. + /// The resource limits of this container. + public ResourceRequirements(ResourceRequests requests, ResourceLimits limits = default(ResourceLimits)) + { + Requests = requests; + Limits = limits; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource requests of this container. + /// + [JsonProperty(PropertyName = "requests")] + public ResourceRequests Requests { get; set; } + + /// + /// Gets or sets the resource limits of this container. + /// + [JsonProperty(PropertyName = "limits")] + public ResourceLimits Limits { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Requests == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Requests"); + } + if (Requests != null) + { + Requests.Validate(); + } + } + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Volume.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Volume.cs new file mode 100644 index 000000000000..fe4e96c51e60 --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/Volume.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The volume. + /// + public partial class Volume + { + /// + /// Initializes a new instance of the Volume class. + /// + public Volume() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Volume class. + /// + /// The volume name. + /// The Azure file volume. + public Volume(string name, AzureFileVolume azureFile) + { + Name = name; + AzureFile = azureFile; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the volume name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the Azure file volume. + /// + [JsonProperty(PropertyName = "azureFile")] + public AzureFileVolume AzureFile { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (AzureFile == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "AzureFile"); + } + if (AzureFile != null) + { + AzureFile.Validate(); + } + } + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/VolumeMount.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/VolumeMount.cs new file mode 100644 index 000000000000..fffaffc815eb --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Generated/Models/VolumeMount.cs @@ -0,0 +1,90 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Microsoft.Azure.Management.ContainerInstance.Models +{ + using Microsoft.Azure; + using Microsoft.Azure.Management; + using Microsoft.Azure.Management.ContainerInstance; + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// The volume mount. + /// + public partial class VolumeMount + { + /// + /// Initializes a new instance of the VolumeMount class. + /// + public VolumeMount() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VolumeMount class. + /// + /// The volume mount name. + /// The path with in the container at which the + /// volume should be mounted. Must not contain ':'. + /// The flag indicating whether the + /// volume mount is read only. + public VolumeMount(string name, string mountPath, bool? readOnlyProperty = default(bool?)) + { + Name = name; + MountPath = mountPath; + ReadOnlyProperty = readOnlyProperty; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the volume mount name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the path with in the container at which the volume + /// should be mounted. Must not contain ':'. + /// + [JsonProperty(PropertyName = "mountPath")] + public string MountPath { get; set; } + + /// + /// Gets or sets the flag indicating whether the volume mount is read + /// only. + /// + [JsonProperty(PropertyName = "readOnly")] + public bool? ReadOnlyProperty { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (MountPath == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "MountPath"); + } + } + } +} diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Microsoft.Azure.Management.ContainerInstance.csproj b/src/SDKs/ContainerInstance/Management.ContainerInstance/Microsoft.Azure.Management.ContainerInstance.csproj new file mode 100644 index 000000000000..23a6096718bb --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Microsoft.Azure.Management.ContainerInstance.csproj @@ -0,0 +1,13 @@ + + + + Microsoft.Azure.Management.ContainerInstance + Azure Container Instance Management SDK library + Microsoft.Azure.Management.ContainerInstance + 1.0.0 + Microsoft Azure Container Instance Management;Container Instance;Container Management;Container Groups; + + + net452;netstandard1.4 + + \ No newline at end of file diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/Properties/AssemblyInfo.cs b/src/SDKs/ContainerInstance/Management.ContainerInstance/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..b462b1f8e315 --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using System.Reflection; +using System.Resources; + +[assembly: AssemblyTitle("Microsoft Azure Container Instance Management Library")] +[assembly: AssemblyDescription("Provides management functionality for Microsoft Azure Container Instances.")] + +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] + +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Microsoft Azure .NET SDK")] +[assembly: AssemblyCopyright("Copyright (c) Microsoft Corporation")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] \ No newline at end of file diff --git a/src/SDKs/ContainerInstance/Management.ContainerInstance/generate.cmd b/src/SDKs/ContainerInstance/Management.ContainerInstance/generate.cmd new file mode 100644 index 000000000000..d3139841b336 --- /dev/null +++ b/src/SDKs/ContainerInstance/Management.ContainerInstance/generate.cmd @@ -0,0 +1,7 @@ +:: +:: Microsoft Azure SDK for Net - Generate library code +:: Copyright (C) Microsoft Corporation. All Rights Reserved. +:: + +@echo off +call %~dp0..\..\..\..\tools\generate.cmd containerinstance/resource-manager %* diff --git a/src/SDKs/_metadata/containerinstance_resource-manager.txt b/src/SDKs/_metadata/containerinstance_resource-manager.txt new file mode 100644 index 000000000000..ecadc4136fc8 --- /dev/null +++ b/src/SDKs/_metadata/containerinstance_resource-manager.txt @@ -0,0 +1,10 @@ +2017-08-14 03:48:50 UTC + +1) azure-rest-api-specs repository information +GitHub user: Azure +Branch: current +Commit: e5ad3c65d448dd92b0f1637cdd994b581cc6bab7 + +2) AutoRest information +Requested version: latest +Latest version: 1.2.2 diff --git a/src/SDKs/dirs.proj b/src/SDKs/dirs.proj index 44a87fcb4138..31e4fe07d461 100644 --- a/src/SDKs/dirs.proj +++ b/src/SDKs/dirs.proj @@ -12,6 +12,7 @@ + @@ -69,6 +70,7 @@ +