diff --git a/src/SDKs/LabServices/AzSdk.RP.props b/src/SDKs/LabServices/AzSdk.RP.props new file mode 100644 index 000000000000..b1a1835fd090 --- /dev/null +++ b/src/SDKs/LabServices/AzSdk.RP.props @@ -0,0 +1,7 @@ + + + + LabServices_2018-10-15; + $(PackageTags);$(CommonTags);$(AzureApiTag); + + \ No newline at end of file diff --git a/src/SDKs/LabServices/LabServices.Tests/LabServices.Tests.csproj b/src/SDKs/LabServices/LabServices.Tests/LabServices.Tests.csproj new file mode 100644 index 000000000000..1619b2328d94 --- /dev/null +++ b/src/SDKs/LabServices/LabServices.Tests/LabServices.Tests.csproj @@ -0,0 +1,23 @@ + + + + LabServices.Tests Class Library + LabServices.Tests + LabServices.Tests + 1.0.0 + + + + + + + + PreserveNewest + + + + + + + + \ No newline at end of file diff --git a/src/SDKs/LabServices/LabServices.Tests/Properties/AssemblyInfo.cs b/src/SDKs/LabServices/LabServices.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..d8e5ee6b7295 --- /dev/null +++ b/src/SDKs/LabServices/LabServices.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,16 @@ +// 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; + +// 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: AssemblyTitle("LabServices.")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("LabServices.Tests")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] diff --git a/src/SDKs/LabServices/LabServices.Tests/SessionRecords/LabServices.Tests.LabTests/ListLabsTest.json b/src/SDKs/LabServices/LabServices.Tests/SessionRecords/LabServices.Tests.LabTests/ListLabsTest.json new file mode 100644 index 000000000000..6e8400e1d178 --- /dev/null +++ b/src/SDKs/LabServices/LabServices.Tests/SessionRecords/LabServices.Tests.LabTests/ListLabsTest.json @@ -0,0 +1,65 @@ +{ + "Entries": [ + { + "RequestUri": "/subscriptions/33855c90-c8cf-44a0-a266-9b548fb8e7b0/providers/Microsoft.LabServices/labaccounts?api-version=2018-10-15", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "2de605b0-19a2-481e-af6b-0da68dd0dac7" + ], + "accept-language": [ + "en-US" + ], + "User-Agent": [ + "Microsoft.Azure.Management.LabServices.ManagedLabsClient/1.0.0.0" + ] + }, + "ResponseBody": "{\"value\":[{\"properties\":{\"sizeConfiguration\":{\"environmentSizes\":[{\"name\":\"Basic\",\"vmSizes\":[{\"computeSize\":\"Standard_A2_v2\",\"price\":0.1,\"numberOfCores\":2,\"memory\":4.0},{\"computeSize\":\"Standard_A2\",\"price\":0.1,\"numberOfCores\":2,\"memory\":3.5}],\"maxPrice\":0.1,\"minNumberOfCores\":2,\"minMemory\":3.5},{\"name\":\"Standard\",\"vmSizes\":[{\"computeSize\":\"Standard_A4_v2\",\"price\":0.21,\"numberOfCores\":4,\"memory\":8.0},{\"computeSize\":\"Standard_A3\",\"price\":0.21,\"numberOfCores\":4,\"memory\":7.0}],\"maxPrice\":0.21,\"minNumberOfCores\":4,\"minMemory\":7.0},{\"name\":\"Performance\",\"vmSizes\":[{\"computeSize\":\"Standard_D8s_v3\",\"price\":0.42,\"numberOfCores\":8,\"memory\":32.0}],\"maxPrice\":0.42,\"minNumberOfCores\":8,\"minMemory\":32.0}]},\"enabledRegionSelection\":false,\"provisioningState\":\"Succeeded\",\"uniqueIdentifier\":\"70223f58-e5ab-4bc7-a224-c6a4a7309204\",\"latestOperationResult\":{}},\"id\":\"/subscriptions/33855c90-c8cf-44a0-a266-9b548fb8e7b0/resourcegroups/mlmonitor/providers/microsoft.labservices/labaccounts/mlmonitor-lab-eastus2\",\"name\":\"mlmonitor-lab-eastus2\",\"type\":\"Microsoft.LabServices/labAccounts\",\"location\":\"westus2\"}]}", + "ResponseHeaders": { + "Content-Type": [ + "application/json; charset=utf-8" + ], + "Expires": [ + "-1" + ], + "Cache-Control": [ + "no-cache" + ], + "Date": [ + "Thu, 13 Dec 2018 18:35:15 GMT" + ], + "Pragma": [ + "no-cache" + ], + "Vary": [ + "Accept-Encoding" + ], + "x-ms-original-request-ids": [ + "", + "" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11999" + ], + "x-ms-request-id": [ + "613f60e1-fc98-4759-946b-ca0ec1435d14" + ], + "x-ms-correlation-request-id": [ + "613f60e1-fc98-4759-946b-ca0ec1435d14" + ], + "x-ms-routing-request-id": [ + "WESTUS2:20181213T183515Z:613f60e1-fc98-4759-946b-ca0ec1435d14" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ] + }, + "StatusCode": 200 + } + ], + "Names": {}, + "Variables": { + "SubscriptionId": "33855c90-c8cf-44a0-a266-9b548fb8e7b0" + } +} \ No newline at end of file diff --git a/src/SDKs/LabServices/LabServices.Tests/Tests/BasicTests.cs b/src/SDKs/LabServices/LabServices.Tests/Tests/BasicTests.cs new file mode 100644 index 000000000000..a8a226cca335 --- /dev/null +++ b/src/SDKs/LabServices/LabServices.Tests/Tests/BasicTests.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using Microsoft.Azure.Management.LabServices; +using Microsoft.Rest.ClientRuntime.Azure.TestFramework; +using System.Linq; +using Xunit; + +namespace LabServices.Tests +{ + public class LabTests : LabServicesTestBase + { + [Fact] + public void ListLabsTest() + { + using (MockContext context = MockContext.Start(this.GetType().FullName)) + { + ManagedLabsClient client = GetManagedLabsClient(context); + + var labs = client.LabAccounts.ListBySubscription().ToList(); + Assert.NotEmpty(labs); + } + } + } +} diff --git a/src/SDKs/LabServices/LabServices.Tests/Tests/LabServicesTestBase.cs b/src/SDKs/LabServices/LabServices.Tests/Tests/LabServicesTestBase.cs new file mode 100644 index 000000000000..c71b5c703288 --- /dev/null +++ b/src/SDKs/LabServices/LabServices.Tests/Tests/LabServicesTestBase.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +using Microsoft.Azure.Management.LabServices; +using Microsoft.Azure.Management.LabServices.Models; +using Microsoft.Azure.Test.HttpRecorder; +using Microsoft.Rest.ClientRuntime.Azure.TestFramework; +using System; +using System.Linq; +using System.Threading; + +namespace LabServices.Tests +{ + public class TestEnvironmentInfo + { + public TestEnvironmentInfo() + { + } + + public TestEnvironmentInfo(string s) + { + SubscriptionId = s; + } + + public string SubscriptionId { get; set; } + } + + public class LabServicesTestBase : TestBase + { + public const string SubscriptionIdKey = "SubscriptionId"; + + public TestEnvironmentInfo GetEnvironmentInfo() + { + SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); + TestEnvironmentInfo result = new TestEnvironmentInfo(); + if (HttpMockServer.Mode == HttpRecorderMode.Record) + { + var environment = TestEnvironmentFactory.GetTestEnvironment(); + result.SubscriptionId = environment.SubscriptionId; + + HttpMockServer.Variables[SubscriptionIdKey] = result.SubscriptionId; + } + else if (HttpMockServer.Mode == HttpRecorderMode.Playback) + { + result.SubscriptionId = HttpMockServer.Variables[SubscriptionIdKey]; + } + return result; + } + + public ManagedLabsClient GetManagedLabsClient(MockContext context) + { + var client = context.GetServiceClient(); + + client.SubscriptionId = GetEnvironmentInfo().SubscriptionId; + + return client; + } + + public Lab CreateKeyCredential() + { + var lab = new Lab + { + Location = "westus", + }; + + return lab; + } + } +} diff --git a/src/SDKs/LabServices/LabServices.sln b/src/SDKs/LabServices/LabServices.sln new file mode 100644 index 000000000000..19209d00fb77 --- /dev/null +++ b/src/SDKs/LabServices/LabServices.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.4 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Management.LabServices", "Management.LabServices\Microsoft.Azure.Management.LabServices.csproj", "{B2143F8C-A1B8-4042-ACAB-CB7797E24C9F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LabServices.Tests", "LabServices.Tests\LabServices.Tests.csproj", "{DC1024AF-4E20-4E65-9ED8-09CC26385B8B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B2143F8C-A1B8-4042-ACAB-CB7797E24C9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B2143F8C-A1B8-4042-ACAB-CB7797E24C9F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B2143F8C-A1B8-4042-ACAB-CB7797E24C9F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B2143F8C-A1B8-4042-ACAB-CB7797E24C9F}.Release|Any CPU.Build.0 = Release|Any CPU + {DC1024AF-4E20-4E65-9ED8-09CC26385B8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DC1024AF-4E20-4E65-9ED8-09CC26385B8B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DC1024AF-4E20-4E65-9ED8-09CC26385B8B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DC1024AF-4E20-4E65-9ED8-09CC26385B8B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4429D4FA-7D6F-4CB8-8D6C-355D4CFDCD6F} + EndGlobalSection +EndGlobal diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/EnvironmentSettingsOperations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/EnvironmentSettingsOperations.cs new file mode 100644 index 000000000000..3864a0841d8e --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/EnvironmentSettingsOperations.cs @@ -0,0 +1,2249 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + 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; + + /// + /// EnvironmentSettingsOperations operations. + /// + internal partial class EnvironmentSettingsOperations : IServiceOperations, IEnvironmentSettingsOperations + { + /// + /// Initializes a new instance of the EnvironmentSettingsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal EnvironmentSettingsOperations(ManagedLabsClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagedLabsClient + /// + public ManagedLabsClient Client { get; private set; } + + /// + /// List environment setting in a given lab. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// OData parameters to apply to the 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>> ListWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + 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("odataQuery", odataQuery); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 environment setting + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Specify the $expand query. Example: 'properties($select=publishingState)' + /// + /// + /// 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 labAccountName, string labName, string environmentSettingName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (environmentSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSettingName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("environmentSettingName", environmentSettingName); + tracingParameters.Add("expand", expand); + 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{environmentSettingName}", System.Uri.EscapeDataString(environmentSettingName)); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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 replace an existing Environment Setting. This operation can take + /// a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Represents settings of an environment, from which environment instances + /// would be created + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task> CreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, EnvironmentSetting environmentSetting, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send Request + AzureOperationResponse _response = await BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentSetting, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPutOrPatchOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Delete environment setting. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Modify properties of environment setting. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Represents settings of an environment, from which environment instances + /// would 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, EnvironmentSettingFragment environmentSetting, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (environmentSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSettingName"); + } + if (environmentSetting == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSetting"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("environmentSettingName", environmentSettingName); + tracingParameters.Add("environmentSetting", environmentSetting); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{environmentSettingName}", System.Uri.EscapeDataString(environmentSettingName)); + 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("PATCH"); + _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(environmentSetting != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(environmentSetting, 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) + { + 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; + } + + /// + /// Claims a random environment for a user in an environment settings + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 ClaimAnyWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (environmentSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSettingName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("environmentSettingName", environmentSettingName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ClaimAny", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/claimAny").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{environmentSettingName}", System.Uri.EscapeDataString(environmentSettingName)); + 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("POST"); + _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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Provisions/deprovisions required resources for an environment setting based + /// on current state of the lab/environment setting. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Payload for Publish operation on EnvironmentSetting. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 PublishWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, PublishPayload publishPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (environmentSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSettingName"); + } + if (publishPayload == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "publishPayload"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("environmentSettingName", environmentSettingName); + tracingParameters.Add("publishPayload", publishPayload); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Publish", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/publish").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{environmentSettingName}", System.Uri.EscapeDataString(environmentSettingName)); + 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("POST"); + _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(publishPayload != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(publishPayload, 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) + { + 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Starts a template by starting all resources inside the template. This + /// operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task StartWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginStartWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Starts a template by starting all resources inside the template. This + /// operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task StopWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginStopWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Create or replace an existing Environment Setting. This operation can take + /// a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Represents settings of an environment, from which environment instances + /// would 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> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, EnvironmentSetting environmentSetting, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (environmentSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSettingName"); + } + if (environmentSetting == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSetting"); + } + if (environmentSetting != null) + { + environmentSetting.Validate(); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("environmentSettingName", environmentSettingName); + tracingParameters.Add("environmentSetting", environmentSetting); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginCreateOrUpdate", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{environmentSettingName}", System.Uri.EscapeDataString(environmentSettingName)); + 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(environmentSetting != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(environmentSetting, 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 environment setting. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (environmentSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSettingName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("environmentSettingName", environmentSettingName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{environmentSettingName}", System.Uri.EscapeDataString(environmentSettingName)); + 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 != 202 && (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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Starts a template by starting all resources inside the template. This + /// operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 BeginStartWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (environmentSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSettingName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("environmentSettingName", environmentSettingName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginStart", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/start").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{environmentSettingName}", System.Uri.EscapeDataString(environmentSettingName)); + 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("POST"); + _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 != 202) + { + 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Starts a template by starting all resources inside the template. This + /// operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 BeginStopWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (environmentSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSettingName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("environmentSettingName", environmentSettingName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginStop", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/stop").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{environmentSettingName}", System.Uri.EscapeDataString(environmentSettingName)); + 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("POST"); + _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 != 202) + { + 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List environment setting in a given lab. + /// + /// + /// 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; + } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/EnvironmentSettingsOperationsExtensions.cs b/src/SDKs/LabServices/Management.LabServices/Generated/EnvironmentSettingsOperationsExtensions.cs new file mode 100644 index 000000000000..0ff6be40f638 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/EnvironmentSettingsOperationsExtensions.cs @@ -0,0 +1,762 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for EnvironmentSettingsOperations. + /// + public static partial class EnvironmentSettingsOperationsExtensions + { + /// + /// List environment setting in a given lab. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage List(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAsync(resourceGroupName, labAccountName, labName, odataQuery).GetAwaiter().GetResult(); + } + + /// + /// List environment setting in a given lab. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get environment setting + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Specify the $expand query. Example: 'properties($select=publishingState)' + /// + public static EnvironmentSetting Get(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string expand = default(string)) + { + return operations.GetAsync(resourceGroupName, labAccountName, labName, environmentSettingName, expand).GetAwaiter().GetResult(); + } + + /// + /// Get environment setting + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Specify the $expand query. Example: 'properties($select=publishingState)' + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or replace an existing Environment Setting. This operation can take + /// a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Represents settings of an environment, from which environment instances + /// would be created + /// + public static EnvironmentSetting CreateOrUpdate(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, EnvironmentSetting environmentSetting) + { + return operations.CreateOrUpdateAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentSetting).GetAwaiter().GetResult(); + } + + /// + /// Create or replace an existing Environment Setting. This operation can take + /// a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Represents settings of an environment, from which environment instances + /// would be created + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, EnvironmentSetting environmentSetting, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentSetting, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete environment setting. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + public static void Delete(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName) + { + operations.DeleteAsync(resourceGroupName, labAccountName, labName, environmentSettingName).GetAwaiter().GetResult(); + } + + /// + /// Delete environment setting. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Modify properties of environment setting. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Represents settings of an environment, from which environment instances + /// would be created + /// + public static EnvironmentSetting Update(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, EnvironmentSettingFragment environmentSetting) + { + return operations.UpdateAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentSetting).GetAwaiter().GetResult(); + } + + /// + /// Modify properties of environment setting. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Represents settings of an environment, from which environment instances + /// would be created + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, EnvironmentSettingFragment environmentSetting, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentSetting, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Claims a random environment for a user in an environment settings + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + public static void ClaimAny(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName) + { + operations.ClaimAnyAsync(resourceGroupName, labAccountName, labName, environmentSettingName).GetAwaiter().GetResult(); + } + + /// + /// Claims a random environment for a user in an environment settings + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The cancellation token. + /// + public static async Task ClaimAnyAsync(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.ClaimAnyWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Provisions/deprovisions required resources for an environment setting based + /// on current state of the lab/environment setting. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Payload for Publish operation on EnvironmentSetting. + /// + public static void Publish(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, PublishPayload publishPayload) + { + operations.PublishAsync(resourceGroupName, labAccountName, labName, environmentSettingName, publishPayload).GetAwaiter().GetResult(); + } + + /// + /// Provisions/deprovisions required resources for an environment setting based + /// on current state of the lab/environment setting. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Payload for Publish operation on EnvironmentSetting. + /// + /// + /// The cancellation token. + /// + public static async Task PublishAsync(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, PublishPayload publishPayload, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.PublishWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, publishPayload, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Starts a template by starting all resources inside the template. This + /// operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + public static void Start(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName) + { + operations.StartAsync(resourceGroupName, labAccountName, labName, environmentSettingName).GetAwaiter().GetResult(); + } + + /// + /// Starts a template by starting all resources inside the template. This + /// operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The cancellation token. + /// + public static async Task StartAsync(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.StartWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Starts a template by starting all resources inside the template. This + /// operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + public static void Stop(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName) + { + operations.StopAsync(resourceGroupName, labAccountName, labName, environmentSettingName).GetAwaiter().GetResult(); + } + + /// + /// Starts a template by starting all resources inside the template. This + /// operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The cancellation token. + /// + public static async Task StopAsync(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.StopWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Create or replace an existing Environment Setting. This operation can take + /// a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Represents settings of an environment, from which environment instances + /// would be created + /// + public static EnvironmentSetting BeginCreateOrUpdate(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, EnvironmentSetting environmentSetting) + { + return operations.BeginCreateOrUpdateAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentSetting).GetAwaiter().GetResult(); + } + + /// + /// Create or replace an existing Environment Setting. This operation can take + /// a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Represents settings of an environment, from which environment instances + /// would be created + /// + /// + /// The cancellation token. + /// + public static async Task BeginCreateOrUpdateAsync(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, EnvironmentSetting environmentSetting, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentSetting, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete environment setting. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + public static void BeginDelete(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName) + { + operations.BeginDeleteAsync(resourceGroupName, labAccountName, labName, environmentSettingName).GetAwaiter().GetResult(); + } + + /// + /// Delete environment setting. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Starts a template by starting all resources inside the template. This + /// operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + public static void BeginStart(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName) + { + operations.BeginStartAsync(resourceGroupName, labAccountName, labName, environmentSettingName).GetAwaiter().GetResult(); + } + + /// + /// Starts a template by starting all resources inside the template. This + /// operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The cancellation token. + /// + public static async Task BeginStartAsync(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginStartWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Starts a template by starting all resources inside the template. This + /// operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + public static void BeginStop(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName) + { + operations.BeginStopAsync(resourceGroupName, labAccountName, labName, environmentSettingName).GetAwaiter().GetResult(); + } + + /// + /// Starts a template by starting all resources inside the template. This + /// operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The cancellation token. + /// + public static async Task BeginStopAsync(this IEnvironmentSettingsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginStopWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// List environment setting in a given lab. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IEnvironmentSettingsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List environment setting in a given lab. + /// + /// + /// 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 IEnvironmentSettingsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/EnvironmentsOperations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/EnvironmentsOperations.cs new file mode 100644 index 000000000000..021da5a6267a --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/EnvironmentsOperations.cs @@ -0,0 +1,2338 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + 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; + + /// + /// EnvironmentsOperations operations. + /// + internal partial class EnvironmentsOperations : IServiceOperations, IEnvironmentsOperations + { + /// + /// Initializes a new instance of the EnvironmentsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal EnvironmentsOperations(ManagedLabsClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagedLabsClient + /// + public ManagedLabsClient Client { get; private set; } + + /// + /// List environments in a given environment setting. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// OData parameters to apply to the 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>> ListWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (environmentSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSettingName"); + } + 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("odataQuery", odataQuery); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("environmentSettingName", environmentSettingName); + 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{environmentSettingName}", System.Uri.EscapeDataString(environmentSettingName)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 environment + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Specify the $expand query. Example: 'properties($expand=networkInterface)' + /// + /// + /// 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 labAccountName, string labName, string environmentSettingName, string environmentName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (environmentSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSettingName"); + } + if (environmentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("environmentSettingName", environmentSettingName); + tracingParameters.Add("environmentName", environmentName); + tracingParameters.Add("expand", expand); + 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{environmentSettingName}", System.Uri.EscapeDataString(environmentSettingName)); + _url = _url.Replace("{environmentName}", System.Uri.EscapeDataString(environmentName)); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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 replace an existing Environment. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Represents an environment instance + /// + /// + /// 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 labAccountName, string labName, string environmentSettingName, string environmentName, Environment environment, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (environmentSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSettingName"); + } + if (environmentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentName"); + } + if (environment == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environment"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("environmentSettingName", environmentSettingName); + tracingParameters.Add("environmentName", environmentName); + tracingParameters.Add("environment", environment); + 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{environmentSettingName}", System.Uri.EscapeDataString(environmentSettingName)); + _url = _url.Replace("{environmentName}", System.Uri.EscapeDataString(environmentName)); + 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(environment != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(environment, 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 environment. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Modify properties of environments. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Represents an environment instance + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, EnvironmentFragment environment, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (environmentSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSettingName"); + } + if (environmentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentName"); + } + if (environment == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environment"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("environmentSettingName", environmentSettingName); + tracingParameters.Add("environmentName", environmentName); + tracingParameters.Add("environment", environment); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{environmentSettingName}", System.Uri.EscapeDataString(environmentSettingName)); + _url = _url.Replace("{environmentName}", System.Uri.EscapeDataString(environmentName)); + 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("PATCH"); + _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(environment != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(environment, 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) + { + 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; + } + + /// + /// Claims the environment and assigns it to the user + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 ClaimWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (environmentSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSettingName"); + } + if (environmentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("environmentSettingName", environmentSettingName); + tracingParameters.Add("environmentName", environmentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Claim", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/claim").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{environmentSettingName}", System.Uri.EscapeDataString(environmentSettingName)); + _url = _url.Replace("{environmentName}", System.Uri.EscapeDataString(environmentName)); + 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("POST"); + _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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Resets the user password on an environment This operation can take a while + /// to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Represents the payload for resetting passwords. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task ResetPasswordWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, ResetPasswordPayload resetPasswordPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginResetPasswordWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, resetPasswordPayload, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Starts an environment by starting all resources inside the environment. + /// This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task StartWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginStartWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Stops an environment by stopping all resources inside the environment This + /// operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task StopWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginStopWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Delete environment. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (environmentSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSettingName"); + } + if (environmentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("environmentSettingName", environmentSettingName); + tracingParameters.Add("environmentName", environmentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{environmentSettingName}", System.Uri.EscapeDataString(environmentSettingName)); + _url = _url.Replace("{environmentName}", System.Uri.EscapeDataString(environmentName)); + 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 != 202 && (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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Resets the user password on an environment This operation can take a while + /// to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Represents the payload for resetting passwords. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 BeginResetPasswordWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, ResetPasswordPayload resetPasswordPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (environmentSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSettingName"); + } + if (environmentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentName"); + } + if (resetPasswordPayload == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resetPasswordPayload"); + } + if (resetPasswordPayload != null) + { + resetPasswordPayload.Validate(); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("environmentSettingName", environmentSettingName); + tracingParameters.Add("environmentName", environmentName); + tracingParameters.Add("resetPasswordPayload", resetPasswordPayload); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginResetPassword", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/resetPassword").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{environmentSettingName}", System.Uri.EscapeDataString(environmentSettingName)); + _url = _url.Replace("{environmentName}", System.Uri.EscapeDataString(environmentName)); + 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("POST"); + _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(resetPasswordPayload != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(resetPasswordPayload, 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 != 202) + { + 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Starts an environment by starting all resources inside the environment. + /// This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 BeginStartWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (environmentSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSettingName"); + } + if (environmentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("environmentSettingName", environmentSettingName); + tracingParameters.Add("environmentName", environmentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginStart", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/start").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{environmentSettingName}", System.Uri.EscapeDataString(environmentSettingName)); + _url = _url.Replace("{environmentName}", System.Uri.EscapeDataString(environmentName)); + 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("POST"); + _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 != 202) + { + 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Stops an environment by stopping all resources inside the environment This + /// operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 BeginStopWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (environmentSettingName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentSettingName"); + } + if (environmentName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("environmentSettingName", environmentSettingName); + tracingParameters.Add("environmentName", environmentName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginStop", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/environmentsettings/{environmentSettingName}/environments/{environmentName}/stop").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{environmentSettingName}", System.Uri.EscapeDataString(environmentSettingName)); + _url = _url.Replace("{environmentName}", System.Uri.EscapeDataString(environmentName)); + 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("POST"); + _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 != 202) + { + 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List environments in a given environment setting. + /// + /// + /// 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; + } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/EnvironmentsOperationsExtensions.cs b/src/SDKs/LabServices/Management.LabServices/Generated/EnvironmentsOperationsExtensions.cs new file mode 100644 index 000000000000..bc5b22bac39a --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/EnvironmentsOperationsExtensions.cs @@ -0,0 +1,829 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for EnvironmentsOperations. + /// + public static partial class EnvironmentsOperationsExtensions + { + /// + /// List environments in a given environment setting. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage List(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAsync(resourceGroupName, labAccountName, labName, environmentSettingName, odataQuery).GetAwaiter().GetResult(); + } + + /// + /// List environments in a given environment setting. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get environment + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Specify the $expand query. Example: 'properties($expand=networkInterface)' + /// + public static Environment Get(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, string expand = default(string)) + { + return operations.GetAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, expand).GetAwaiter().GetResult(); + } + + /// + /// Get environment + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Specify the $expand query. Example: 'properties($expand=networkInterface)' + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or replace an existing Environment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Represents an environment instance + /// + public static Environment CreateOrUpdate(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, Environment environment) + { + return operations.CreateOrUpdateAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, environment).GetAwaiter().GetResult(); + } + + /// + /// Create or replace an existing Environment. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Represents an environment instance + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, Environment environment, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, environment, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete environment. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + public static void Delete(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName) + { + operations.DeleteAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName).GetAwaiter().GetResult(); + } + + /// + /// Delete environment. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Modify properties of environments. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Represents an environment instance + /// + public static Environment Update(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, EnvironmentFragment environment) + { + return operations.UpdateAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, environment).GetAwaiter().GetResult(); + } + + /// + /// Modify properties of environments. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Represents an environment instance + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, EnvironmentFragment environment, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, environment, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Claims the environment and assigns it to the user + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + public static void Claim(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName) + { + operations.ClaimAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName).GetAwaiter().GetResult(); + } + + /// + /// Claims the environment and assigns it to the user + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// The cancellation token. + /// + public static async Task ClaimAsync(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.ClaimWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Resets the user password on an environment This operation can take a while + /// to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Represents the payload for resetting passwords. + /// + public static void ResetPassword(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, ResetPasswordPayload resetPasswordPayload) + { + operations.ResetPasswordAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, resetPasswordPayload).GetAwaiter().GetResult(); + } + + /// + /// Resets the user password on an environment This operation can take a while + /// to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Represents the payload for resetting passwords. + /// + /// + /// The cancellation token. + /// + public static async Task ResetPasswordAsync(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, ResetPasswordPayload resetPasswordPayload, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.ResetPasswordWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, resetPasswordPayload, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Starts an environment by starting all resources inside the environment. + /// This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + public static void Start(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName) + { + operations.StartAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName).GetAwaiter().GetResult(); + } + + /// + /// Starts an environment by starting all resources inside the environment. + /// This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// The cancellation token. + /// + public static async Task StartAsync(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.StartWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Stops an environment by stopping all resources inside the environment This + /// operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + public static void Stop(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName) + { + operations.StopAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName).GetAwaiter().GetResult(); + } + + /// + /// Stops an environment by stopping all resources inside the environment This + /// operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// The cancellation token. + /// + public static async Task StopAsync(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.StopWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Delete environment. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + public static void BeginDelete(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName) + { + operations.BeginDeleteAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName).GetAwaiter().GetResult(); + } + + /// + /// Delete environment. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Resets the user password on an environment This operation can take a while + /// to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Represents the payload for resetting passwords. + /// + public static void BeginResetPassword(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, ResetPasswordPayload resetPasswordPayload) + { + operations.BeginResetPasswordAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, resetPasswordPayload).GetAwaiter().GetResult(); + } + + /// + /// Resets the user password on an environment This operation can take a while + /// to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Represents the payload for resetting passwords. + /// + /// + /// The cancellation token. + /// + public static async Task BeginResetPasswordAsync(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, ResetPasswordPayload resetPasswordPayload, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginResetPasswordWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, resetPasswordPayload, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Starts an environment by starting all resources inside the environment. + /// This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + public static void BeginStart(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName) + { + operations.BeginStartAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName).GetAwaiter().GetResult(); + } + + /// + /// Starts an environment by starting all resources inside the environment. + /// This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// The cancellation token. + /// + public static async Task BeginStartAsync(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginStartWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Stops an environment by stopping all resources inside the environment This + /// operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + public static void BeginStop(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName) + { + operations.BeginStopAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName).GetAwaiter().GetResult(); + } + + /// + /// Stops an environment by stopping all resources inside the environment This + /// operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// The cancellation token. + /// + public static async Task BeginStopAsync(this IEnvironmentsOperations operations, string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginStopWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, environmentSettingName, environmentName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// List environments in a given environment setting. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IEnvironmentsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List environments in a given environment setting. + /// + /// + /// 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 IEnvironmentsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/GalleryImagesOperations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/GalleryImagesOperations.cs new file mode 100644 index 000000000000..0fab14d265fc --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/GalleryImagesOperations.cs @@ -0,0 +1,1289 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + 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; + + /// + /// GalleryImagesOperations operations. + /// + internal partial class GalleryImagesOperations : IServiceOperations, IGalleryImagesOperations + { + /// + /// Initializes a new instance of the GalleryImagesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal GalleryImagesOperations(ManagedLabsClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagedLabsClient + /// + public ManagedLabsClient Client { get; private set; } + + /// + /// List gallery images in a given lab account. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// OData parameters to apply to the 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>> ListWithHttpMessagesAsync(string resourceGroupName, string labAccountName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + 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("odataQuery", odataQuery); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + 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.LabServices/labaccounts/{labAccountName}/galleryimages").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 gallery image + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the gallery Image. + /// + /// + /// Specify the $expand query. Example: 'properties($select=author)' + /// + /// + /// 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 labAccountName, string galleryImageName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (galleryImageName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "galleryImageName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("galleryImageName", galleryImageName); + tracingParameters.Add("expand", expand); + 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.LabServices/labaccounts/{labAccountName}/galleryimages/{galleryImageName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{galleryImageName}", System.Uri.EscapeDataString(galleryImageName)); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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 replace an existing Gallery Image. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the gallery Image. + /// + /// + /// Represents an image from the Azure Marketplace + /// + /// + /// 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 labAccountName, string galleryImageName, GalleryImage galleryImage, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (galleryImageName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "galleryImageName"); + } + if (galleryImage == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "galleryImage"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("galleryImageName", galleryImageName); + tracingParameters.Add("galleryImage", galleryImage); + 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.LabServices/labaccounts/{labAccountName}/galleryimages/{galleryImageName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{galleryImageName}", System.Uri.EscapeDataString(galleryImageName)); + 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(galleryImage != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(galleryImage, 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 gallery image. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the gallery Image. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 labAccountName, string galleryImageName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (galleryImageName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "galleryImageName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("galleryImageName", galleryImageName); + 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.LabServices/labaccounts/{labAccountName}/galleryimages/{galleryImageName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{galleryImageName}", System.Uri.EscapeDataString(galleryImageName)); + 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Modify properties of gallery images. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the gallery Image. + /// + /// + /// Represents an image from the Azure Marketplace + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string galleryImageName, GalleryImageFragment galleryImage, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (galleryImageName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "galleryImageName"); + } + if (galleryImage == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "galleryImage"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("galleryImageName", galleryImageName); + tracingParameters.Add("galleryImage", galleryImage); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", 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.LabServices/labaccounts/{labAccountName}/galleryimages/{galleryImageName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{galleryImageName}", System.Uri.EscapeDataString(galleryImageName)); + 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("PATCH"); + _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(galleryImage != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(galleryImage, 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) + { + 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; + } + + /// + /// List gallery images in a given lab account. + /// + /// + /// 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; + } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/GalleryImagesOperationsExtensions.cs b/src/SDKs/LabServices/Management.LabServices/Generated/GalleryImagesOperationsExtensions.cs new file mode 100644 index 000000000000..69f0f6af1248 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/GalleryImagesOperationsExtensions.cs @@ -0,0 +1,305 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for GalleryImagesOperations. + /// + public static partial class GalleryImagesOperationsExtensions + { + /// + /// List gallery images in a given lab account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage List(this IGalleryImagesOperations operations, string resourceGroupName, string labAccountName, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAsync(resourceGroupName, labAccountName, odataQuery).GetAwaiter().GetResult(); + } + + /// + /// List gallery images in a given lab account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IGalleryImagesOperations operations, string resourceGroupName, string labAccountName, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, labAccountName, odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get gallery image + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the gallery Image. + /// + /// + /// Specify the $expand query. Example: 'properties($select=author)' + /// + public static GalleryImage Get(this IGalleryImagesOperations operations, string resourceGroupName, string labAccountName, string galleryImageName, string expand = default(string)) + { + return operations.GetAsync(resourceGroupName, labAccountName, galleryImageName, expand).GetAwaiter().GetResult(); + } + + /// + /// Get gallery image + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the gallery Image. + /// + /// + /// Specify the $expand query. Example: 'properties($select=author)' + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IGalleryImagesOperations operations, string resourceGroupName, string labAccountName, string galleryImageName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, labAccountName, galleryImageName, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or replace an existing Gallery Image. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the gallery Image. + /// + /// + /// Represents an image from the Azure Marketplace + /// + public static GalleryImage CreateOrUpdate(this IGalleryImagesOperations operations, string resourceGroupName, string labAccountName, string galleryImageName, GalleryImage galleryImage) + { + return operations.CreateOrUpdateAsync(resourceGroupName, labAccountName, galleryImageName, galleryImage).GetAwaiter().GetResult(); + } + + /// + /// Create or replace an existing Gallery Image. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the gallery Image. + /// + /// + /// Represents an image from the Azure Marketplace + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IGalleryImagesOperations operations, string resourceGroupName, string labAccountName, string galleryImageName, GalleryImage galleryImage, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, labAccountName, galleryImageName, galleryImage, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete gallery image. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the gallery Image. + /// + public static void Delete(this IGalleryImagesOperations operations, string resourceGroupName, string labAccountName, string galleryImageName) + { + operations.DeleteAsync(resourceGroupName, labAccountName, galleryImageName).GetAwaiter().GetResult(); + } + + /// + /// Delete gallery image. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the gallery Image. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IGalleryImagesOperations operations, string resourceGroupName, string labAccountName, string galleryImageName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, labAccountName, galleryImageName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Modify properties of gallery images. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the gallery Image. + /// + /// + /// Represents an image from the Azure Marketplace + /// + public static GalleryImage Update(this IGalleryImagesOperations operations, string resourceGroupName, string labAccountName, string galleryImageName, GalleryImageFragment galleryImage) + { + return operations.UpdateAsync(resourceGroupName, labAccountName, galleryImageName, galleryImage).GetAwaiter().GetResult(); + } + + /// + /// Modify properties of gallery images. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the gallery Image. + /// + /// + /// Represents an image from the Azure Marketplace + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IGalleryImagesOperations operations, string resourceGroupName, string labAccountName, string galleryImageName, GalleryImageFragment galleryImage, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, labAccountName, galleryImageName, galleryImage, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List gallery images in a given lab account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IGalleryImagesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List gallery images in a given lab account. + /// + /// + /// 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 IGalleryImagesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/GlobalUsersOperations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/GlobalUsersOperations.cs new file mode 100644 index 000000000000..259c3b95e5ed --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/GlobalUsersOperations.cs @@ -0,0 +1,2026 @@ +// +// 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.LabServices +{ + 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; + + /// + /// GlobalUsersOperations operations. + /// + internal partial class GlobalUsersOperations : IServiceOperations, IGlobalUsersOperations + { + /// + /// Initializes a new instance of the GlobalUsersOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal GlobalUsersOperations(ManagedLabsClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagedLabsClient + /// + public ManagedLabsClient Client { get; private set; } + + /// + /// Gets the virtual machine details + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + /// + /// Specify the $expand query. Example: 'properties($expand=environment)' + /// + /// + /// 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> GetEnvironmentWithHttpMessagesAsync(string userName, EnvironmentOperationsPayload environmentOperationsPayload, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (userName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userName"); + } + if (environmentOperationsPayload == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentOperationsPayload"); + } + if (environmentOperationsPayload != null) + { + environmentOperationsPayload.Validate(); + } + 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("userName", userName); + tracingParameters.Add("environmentOperationsPayload", environmentOperationsPayload); + tracingParameters.Add("expand", expand); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetEnvironment", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.LabServices/users/{userName}/getEnvironment").ToString(); + _url = _url.Replace("{userName}", System.Uri.EscapeDataString(userName)); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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("POST"); + _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(environmentOperationsPayload != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(environmentOperationsPayload, 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) + { + 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 batch operation status + /// + /// + /// The name of the user. + /// + /// + /// Payload to get the status of an 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> GetOperationBatchStatusWithHttpMessagesAsync(string userName, OperationBatchStatusPayload operationBatchStatusPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (userName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userName"); + } + if (operationBatchStatusPayload == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationBatchStatusPayload"); + } + if (operationBatchStatusPayload != null) + { + operationBatchStatusPayload.Validate(); + } + 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("userName", userName); + tracingParameters.Add("operationBatchStatusPayload", operationBatchStatusPayload); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetOperationBatchStatus", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.LabServices/users/{userName}/getOperationBatchStatus").ToString(); + _url = _url.Replace("{userName}", System.Uri.EscapeDataString(userName)); + 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("POST"); + _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(operationBatchStatusPayload != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(operationBatchStatusPayload, 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) + { + 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; + } + + /// + /// Gets the status of long running operation + /// + /// + /// The name of the user. + /// + /// + /// Payload to get the status of an 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> GetOperationStatusWithHttpMessagesAsync(string userName, OperationStatusPayload operationStatusPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (userName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userName"); + } + if (operationStatusPayload == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationStatusPayload"); + } + if (operationStatusPayload != null) + { + operationStatusPayload.Validate(); + } + 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("userName", userName); + tracingParameters.Add("operationStatusPayload", operationStatusPayload); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetOperationStatus", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.LabServices/users/{userName}/getOperationStatus").ToString(); + _url = _url.Replace("{userName}", System.Uri.EscapeDataString(userName)); + 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("POST"); + _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(operationStatusPayload != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(operationStatusPayload, 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) + { + 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 personal preferences for a user + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + /// + /// 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> GetPersonalPreferencesWithHttpMessagesAsync(string userName, PersonalPerferencesOperationsPayload personalPerferencesOperationsPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (userName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userName"); + } + if (personalPerferencesOperationsPayload == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "personalPerferencesOperationsPayload"); + } + 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("userName", userName); + tracingParameters.Add("personalPerferencesOperationsPayload", personalPerferencesOperationsPayload); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetPersonalPreferences", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.LabServices/users/{userName}/getPersonalPreferences").ToString(); + _url = _url.Replace("{userName}", System.Uri.EscapeDataString(userName)); + 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("POST"); + _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(personalPerferencesOperationsPayload != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(personalPerferencesOperationsPayload, 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) + { + 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; + } + + /// + /// List Environments for the user + /// + /// + /// The name of the user. + /// + /// + /// Represents the payload to list environments owned by a user + /// + /// + /// 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> ListEnvironmentsWithHttpMessagesAsync(string userName, ListEnvironmentsPayload listEnvironmentsPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (userName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userName"); + } + if (listEnvironmentsPayload == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "listEnvironmentsPayload"); + } + 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("userName", userName); + tracingParameters.Add("listEnvironmentsPayload", listEnvironmentsPayload); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListEnvironments", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.LabServices/users/{userName}/listEnvironments").ToString(); + _url = _url.Replace("{userName}", System.Uri.EscapeDataString(userName)); + 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("POST"); + _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(listEnvironmentsPayload != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(listEnvironmentsPayload, 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) + { + 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; + } + + /// + /// List labs for the user. + /// + /// + /// The name of the user. + /// + /// + /// 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> ListLabsWithHttpMessagesAsync(string userName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (userName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userName"); + } + 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("userName", userName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListLabs", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.LabServices/users/{userName}/listLabs").ToString(); + _url = _url.Replace("{userName}", System.Uri.EscapeDataString(userName)); + 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("POST"); + _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; + } + + /// + /// Register a user to a managed lab + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for Register action. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 RegisterWithHttpMessagesAsync(string userName, RegisterPayload registerPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (userName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userName"); + } + if (registerPayload == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "registerPayload"); + } + 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("userName", userName); + tracingParameters.Add("registerPayload", registerPayload); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Register", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.LabServices/users/{userName}/register").ToString(); + _url = _url.Replace("{userName}", System.Uri.EscapeDataString(userName)); + 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("POST"); + _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(registerPayload != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(registerPayload, 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) + { + 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Resets the user password on an environment This operation can take a while + /// to complete + /// + /// + /// The name of the user. + /// + /// + /// Represents the payload for resetting passwords. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task ResetPasswordWithHttpMessagesAsync(string userName, ResetPasswordPayload resetPasswordPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginResetPasswordWithHttpMessagesAsync(userName, resetPasswordPayload, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Starts an environment by starting all resources inside the environment. + /// This operation can take a while to complete + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task StartEnvironmentWithHttpMessagesAsync(string userName, EnvironmentOperationsPayload environmentOperationsPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginStartEnvironmentWithHttpMessagesAsync(userName, environmentOperationsPayload, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Stops an environment by stopping all resources inside the environment This + /// operation can take a while to complete + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task StopEnvironmentWithHttpMessagesAsync(string userName, EnvironmentOperationsPayload environmentOperationsPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginStopEnvironmentWithHttpMessagesAsync(userName, environmentOperationsPayload, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Resets the user password on an environment This operation can take a while + /// to complete + /// + /// + /// The name of the user. + /// + /// + /// Represents the payload for resetting passwords. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 BeginResetPasswordWithHttpMessagesAsync(string userName, ResetPasswordPayload resetPasswordPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (userName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userName"); + } + if (resetPasswordPayload == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resetPasswordPayload"); + } + if (resetPasswordPayload != null) + { + resetPasswordPayload.Validate(); + } + 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("userName", userName); + tracingParameters.Add("resetPasswordPayload", resetPasswordPayload); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginResetPassword", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.LabServices/users/{userName}/resetPassword").ToString(); + _url = _url.Replace("{userName}", System.Uri.EscapeDataString(userName)); + 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("POST"); + _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(resetPasswordPayload != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(resetPasswordPayload, 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 != 202) + { + 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Starts an environment by starting all resources inside the environment. + /// This operation can take a while to complete + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 BeginStartEnvironmentWithHttpMessagesAsync(string userName, EnvironmentOperationsPayload environmentOperationsPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (userName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userName"); + } + if (environmentOperationsPayload == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentOperationsPayload"); + } + if (environmentOperationsPayload != null) + { + environmentOperationsPayload.Validate(); + } + 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("userName", userName); + tracingParameters.Add("environmentOperationsPayload", environmentOperationsPayload); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginStartEnvironment", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.LabServices/users/{userName}/startEnvironment").ToString(); + _url = _url.Replace("{userName}", System.Uri.EscapeDataString(userName)); + 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("POST"); + _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(environmentOperationsPayload != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(environmentOperationsPayload, 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 != 202) + { + 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Stops an environment by stopping all resources inside the environment This + /// operation can take a while to complete + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 BeginStopEnvironmentWithHttpMessagesAsync(string userName, EnvironmentOperationsPayload environmentOperationsPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (userName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userName"); + } + if (environmentOperationsPayload == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "environmentOperationsPayload"); + } + if (environmentOperationsPayload != null) + { + environmentOperationsPayload.Validate(); + } + 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("userName", userName); + tracingParameters.Add("environmentOperationsPayload", environmentOperationsPayload); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginStopEnvironment", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.LabServices/users/{userName}/stopEnvironment").ToString(); + _url = _url.Replace("{userName}", System.Uri.EscapeDataString(userName)); + 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("POST"); + _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(environmentOperationsPayload != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(environmentOperationsPayload, 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 != 202) + { + 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/GlobalUsersOperationsExtensions.cs b/src/SDKs/LabServices/Management.LabServices/Generated/GlobalUsersOperationsExtensions.cs new file mode 100644 index 000000000000..684e85ecd37d --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/GlobalUsersOperationsExtensions.cs @@ -0,0 +1,548 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for GlobalUsersOperations. + /// + public static partial class GlobalUsersOperationsExtensions + { + /// + /// Gets the virtual machine details + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + /// + /// Specify the $expand query. Example: 'properties($expand=environment)' + /// + public static GetEnvironmentResponse GetEnvironment(this IGlobalUsersOperations operations, string userName, EnvironmentOperationsPayload environmentOperationsPayload, string expand = default(string)) + { + return operations.GetEnvironmentAsync(userName, environmentOperationsPayload, expand).GetAwaiter().GetResult(); + } + + /// + /// Gets the virtual machine details + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + /// + /// Specify the $expand query. Example: 'properties($expand=environment)' + /// + /// + /// The cancellation token. + /// + public static async Task GetEnvironmentAsync(this IGlobalUsersOperations operations, string userName, EnvironmentOperationsPayload environmentOperationsPayload, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetEnvironmentWithHttpMessagesAsync(userName, environmentOperationsPayload, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get batch operation status + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Payload to get the status of an operation + /// + public static OperationBatchStatusResponse GetOperationBatchStatus(this IGlobalUsersOperations operations, string userName, OperationBatchStatusPayload operationBatchStatusPayload) + { + return operations.GetOperationBatchStatusAsync(userName, operationBatchStatusPayload).GetAwaiter().GetResult(); + } + + /// + /// Get batch operation status + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Payload to get the status of an operation + /// + /// + /// The cancellation token. + /// + public static async Task GetOperationBatchStatusAsync(this IGlobalUsersOperations operations, string userName, OperationBatchStatusPayload operationBatchStatusPayload, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetOperationBatchStatusWithHttpMessagesAsync(userName, operationBatchStatusPayload, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Gets the status of long running operation + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Payload to get the status of an operation + /// + public static OperationStatusResponse GetOperationStatus(this IGlobalUsersOperations operations, string userName, OperationStatusPayload operationStatusPayload) + { + return operations.GetOperationStatusAsync(userName, operationStatusPayload).GetAwaiter().GetResult(); + } + + /// + /// Gets the status of long running operation + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Payload to get the status of an operation + /// + /// + /// The cancellation token. + /// + public static async Task GetOperationStatusAsync(this IGlobalUsersOperations operations, string userName, OperationStatusPayload operationStatusPayload, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetOperationStatusWithHttpMessagesAsync(userName, operationStatusPayload, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get personal preferences for a user + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + public static GetPersonalPreferencesResponse GetPersonalPreferences(this IGlobalUsersOperations operations, string userName, PersonalPerferencesOperationsPayload personalPerferencesOperationsPayload) + { + return operations.GetPersonalPreferencesAsync(userName, personalPerferencesOperationsPayload).GetAwaiter().GetResult(); + } + + /// + /// Get personal preferences for a user + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + /// + /// The cancellation token. + /// + public static async Task GetPersonalPreferencesAsync(this IGlobalUsersOperations operations, string userName, PersonalPerferencesOperationsPayload personalPerferencesOperationsPayload, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetPersonalPreferencesWithHttpMessagesAsync(userName, personalPerferencesOperationsPayload, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List Environments for the user + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents the payload to list environments owned by a user + /// + public static ListEnvironmentsResponse ListEnvironments(this IGlobalUsersOperations operations, string userName, ListEnvironmentsPayload listEnvironmentsPayload) + { + return operations.ListEnvironmentsAsync(userName, listEnvironmentsPayload).GetAwaiter().GetResult(); + } + + /// + /// List Environments for the user + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents the payload to list environments owned by a user + /// + /// + /// The cancellation token. + /// + public static async Task ListEnvironmentsAsync(this IGlobalUsersOperations operations, string userName, ListEnvironmentsPayload listEnvironmentsPayload, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListEnvironmentsWithHttpMessagesAsync(userName, listEnvironmentsPayload, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List labs for the user. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + public static ListLabsResponse ListLabs(this IGlobalUsersOperations operations, string userName) + { + return operations.ListLabsAsync(userName).GetAwaiter().GetResult(); + } + + /// + /// List labs for the user. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// The cancellation token. + /// + public static async Task ListLabsAsync(this IGlobalUsersOperations operations, string userName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListLabsWithHttpMessagesAsync(userName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Register a user to a managed lab + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for Register action. + /// + public static void Register(this IGlobalUsersOperations operations, string userName, RegisterPayload registerPayload) + { + operations.RegisterAsync(userName, registerPayload).GetAwaiter().GetResult(); + } + + /// + /// Register a user to a managed lab + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for Register action. + /// + /// + /// The cancellation token. + /// + public static async Task RegisterAsync(this IGlobalUsersOperations operations, string userName, RegisterPayload registerPayload, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.RegisterWithHttpMessagesAsync(userName, registerPayload, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Resets the user password on an environment This operation can take a while + /// to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents the payload for resetting passwords. + /// + public static void ResetPassword(this IGlobalUsersOperations operations, string userName, ResetPasswordPayload resetPasswordPayload) + { + operations.ResetPasswordAsync(userName, resetPasswordPayload).GetAwaiter().GetResult(); + } + + /// + /// Resets the user password on an environment This operation can take a while + /// to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents the payload for resetting passwords. + /// + /// + /// The cancellation token. + /// + public static async Task ResetPasswordAsync(this IGlobalUsersOperations operations, string userName, ResetPasswordPayload resetPasswordPayload, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.ResetPasswordWithHttpMessagesAsync(userName, resetPasswordPayload, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Starts an environment by starting all resources inside the environment. + /// This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + public static void StartEnvironment(this IGlobalUsersOperations operations, string userName, EnvironmentOperationsPayload environmentOperationsPayload) + { + operations.StartEnvironmentAsync(userName, environmentOperationsPayload).GetAwaiter().GetResult(); + } + + /// + /// Starts an environment by starting all resources inside the environment. + /// This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + /// + /// The cancellation token. + /// + public static async Task StartEnvironmentAsync(this IGlobalUsersOperations operations, string userName, EnvironmentOperationsPayload environmentOperationsPayload, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.StartEnvironmentWithHttpMessagesAsync(userName, environmentOperationsPayload, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Stops an environment by stopping all resources inside the environment This + /// operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + public static void StopEnvironment(this IGlobalUsersOperations operations, string userName, EnvironmentOperationsPayload environmentOperationsPayload) + { + operations.StopEnvironmentAsync(userName, environmentOperationsPayload).GetAwaiter().GetResult(); + } + + /// + /// Stops an environment by stopping all resources inside the environment This + /// operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + /// + /// The cancellation token. + /// + public static async Task StopEnvironmentAsync(this IGlobalUsersOperations operations, string userName, EnvironmentOperationsPayload environmentOperationsPayload, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.StopEnvironmentWithHttpMessagesAsync(userName, environmentOperationsPayload, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Resets the user password on an environment This operation can take a while + /// to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents the payload for resetting passwords. + /// + public static void BeginResetPassword(this IGlobalUsersOperations operations, string userName, ResetPasswordPayload resetPasswordPayload) + { + operations.BeginResetPasswordAsync(userName, resetPasswordPayload).GetAwaiter().GetResult(); + } + + /// + /// Resets the user password on an environment This operation can take a while + /// to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents the payload for resetting passwords. + /// + /// + /// The cancellation token. + /// + public static async Task BeginResetPasswordAsync(this IGlobalUsersOperations operations, string userName, ResetPasswordPayload resetPasswordPayload, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginResetPasswordWithHttpMessagesAsync(userName, resetPasswordPayload, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Starts an environment by starting all resources inside the environment. + /// This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + public static void BeginStartEnvironment(this IGlobalUsersOperations operations, string userName, EnvironmentOperationsPayload environmentOperationsPayload) + { + operations.BeginStartEnvironmentAsync(userName, environmentOperationsPayload).GetAwaiter().GetResult(); + } + + /// + /// Starts an environment by starting all resources inside the environment. + /// This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + /// + /// The cancellation token. + /// + public static async Task BeginStartEnvironmentAsync(this IGlobalUsersOperations operations, string userName, EnvironmentOperationsPayload environmentOperationsPayload, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginStartEnvironmentWithHttpMessagesAsync(userName, environmentOperationsPayload, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Stops an environment by stopping all resources inside the environment This + /// operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + public static void BeginStopEnvironment(this IGlobalUsersOperations operations, string userName, EnvironmentOperationsPayload environmentOperationsPayload) + { + operations.BeginStopEnvironmentAsync(userName, environmentOperationsPayload).GetAwaiter().GetResult(); + } + + /// + /// Stops an environment by stopping all resources inside the environment This + /// operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, stop, + /// connect + /// + /// + /// The cancellation token. + /// + public static async Task BeginStopEnvironmentAsync(this IGlobalUsersOperations operations, string userName, EnvironmentOperationsPayload environmentOperationsPayload, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginStopEnvironmentWithHttpMessagesAsync(userName, environmentOperationsPayload, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/IEnvironmentSettingsOperations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/IEnvironmentSettingsOperations.cs new file mode 100644 index 000000000000..20dfaeeb1f2c --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/IEnvironmentSettingsOperations.cs @@ -0,0 +1,457 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// EnvironmentSettingsOperations operations. + /// + public partial interface IEnvironmentSettingsOperations + { + /// + /// List environment setting in a given lab. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// OData parameters to apply to the 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>> ListWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get environment setting + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Specify the $expand query. Example: + /// 'properties($select=publishingState)' + /// + /// + /// 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 labAccountName, string labName, string environmentSettingName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or replace an existing Environment Setting. This operation + /// can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Represents settings of an environment, from which environment + /// instances would 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 labAccountName, string labName, string environmentSettingName, EnvironmentSetting environmentSetting, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete environment setting. This operation can take a while to + /// complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Modify properties of environment setting. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Represents settings of an environment, from which environment + /// instances would 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, EnvironmentSettingFragment environmentSetting, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Claims a random environment for a user in an environment settings + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task ClaimAnyWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Provisions/deprovisions required resources for an environment + /// setting based on current state of the lab/environment setting. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Payload for Publish operation on EnvironmentSetting. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task PublishWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, PublishPayload publishPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Starts a template by starting all resources inside the template. + /// This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task StartWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Starts a template by starting all resources inside the template. + /// This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task StopWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or replace an existing Environment Setting. This operation + /// can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// Represents settings of an environment, from which environment + /// instances would 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> BeginCreateOrUpdateWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, EnvironmentSetting environmentSetting, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete environment setting. This operation can take a while to + /// complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Starts a template by starting all resources inside the template. + /// This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginStartWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Starts a template by starting all resources inside the template. + /// This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginStopWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List environment setting in a given lab. + /// + /// + /// 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)); + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/IEnvironmentsOperations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/IEnvironmentsOperations.cs new file mode 100644 index 000000000000..d574d435ef9d --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/IEnvironmentsOperations.cs @@ -0,0 +1,487 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// EnvironmentsOperations operations. + /// + public partial interface IEnvironmentsOperations + { + /// + /// List environments in a given environment setting. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// OData parameters to apply to the 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>> ListWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get environment + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Specify the $expand query. Example: + /// 'properties($expand=networkInterface)' + /// + /// + /// 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 labAccountName, string labName, string environmentSettingName, string environmentName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or replace an existing Environment. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Represents an environment instance + /// + /// + /// 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 labAccountName, string labName, string environmentSettingName, string environmentName, Environment environment, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete environment. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Modify properties of environments. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Represents an environment instance + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, EnvironmentFragment environment, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Claims the environment and assigns it to the user + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task ClaimWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Resets the user password on an environment This operation can take + /// a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Represents the payload for resetting passwords. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task ResetPasswordWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, ResetPasswordPayload resetPasswordPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Starts an environment by starting all resources inside the + /// environment. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task StartWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Stops an environment by stopping all resources inside the + /// environment This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task StopWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete environment. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Resets the user password on an environment This operation can take + /// a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// Represents the payload for resetting passwords. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginResetPasswordWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, ResetPasswordPayload resetPasswordPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Starts an environment by starting all resources inside the + /// environment. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginStartWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Stops an environment by stopping all resources inside the + /// environment This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the environment Setting. + /// + /// + /// The name of the environment. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginStopWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string environmentSettingName, string environmentName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List environments in a given environment setting. + /// + /// + /// 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)); + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/IGalleryImagesOperations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/IGalleryImagesOperations.cs new file mode 100644 index 000000000000..56d7eaace1b3 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/IGalleryImagesOperations.cs @@ -0,0 +1,196 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// GalleryImagesOperations operations. + /// + public partial interface IGalleryImagesOperations + { + /// + /// List gallery images in a given lab account. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// OData parameters to apply to the 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>> ListWithHttpMessagesAsync(string resourceGroupName, string labAccountName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get gallery image + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the gallery Image. + /// + /// + /// Specify the $expand query. Example: 'properties($select=author)' + /// + /// + /// 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 labAccountName, string galleryImageName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or replace an existing Gallery Image. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the gallery Image. + /// + /// + /// Represents an image from the Azure Marketplace + /// + /// + /// 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 labAccountName, string galleryImageName, GalleryImage galleryImage, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete gallery image. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the gallery Image. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string galleryImageName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Modify properties of gallery images. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the gallery Image. + /// + /// + /// Represents an image from the Azure Marketplace + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string galleryImageName, GalleryImageFragment galleryImage, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List gallery images in a given lab account. + /// + /// + /// 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)); + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/IGlobalUsersOperations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/IGlobalUsersOperations.cs new file mode 100644 index 000000000000..a69eef11ce71 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/IGlobalUsersOperations.cs @@ -0,0 +1,344 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// GlobalUsersOperations operations. + /// + public partial interface IGlobalUsersOperations + { + /// + /// Gets the virtual machine details + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, + /// stop, connect + /// + /// + /// Specify the $expand query. Example: + /// 'properties($expand=environment)' + /// + /// + /// 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> GetEnvironmentWithHttpMessagesAsync(string userName, EnvironmentOperationsPayload environmentOperationsPayload, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get batch operation status + /// + /// + /// The name of the user. + /// + /// + /// Payload to get the status of an 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> GetOperationBatchStatusWithHttpMessagesAsync(string userName, OperationBatchStatusPayload operationBatchStatusPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Gets the status of long running operation + /// + /// + /// The name of the user. + /// + /// + /// Payload to get the status of an 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> GetOperationStatusWithHttpMessagesAsync(string userName, OperationStatusPayload operationStatusPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get personal preferences for a user + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, + /// stop, connect + /// + /// + /// 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> GetPersonalPreferencesWithHttpMessagesAsync(string userName, PersonalPerferencesOperationsPayload personalPerferencesOperationsPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List Environments for the user + /// + /// + /// The name of the user. + /// + /// + /// Represents the payload to list environments owned by a user + /// + /// + /// 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> ListEnvironmentsWithHttpMessagesAsync(string userName, ListEnvironmentsPayload listEnvironmentsPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List labs for the user. + /// + /// + /// The name of the user. + /// + /// + /// 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> ListLabsWithHttpMessagesAsync(string userName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Register a user to a managed lab + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for Register action. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task RegisterWithHttpMessagesAsync(string userName, RegisterPayload registerPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Resets the user password on an environment This operation can take + /// a while to complete + /// + /// + /// The name of the user. + /// + /// + /// Represents the payload for resetting passwords. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task ResetPasswordWithHttpMessagesAsync(string userName, ResetPasswordPayload resetPasswordPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Starts an environment by starting all resources inside the + /// environment. This operation can take a while to complete + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, + /// stop, connect + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task StartEnvironmentWithHttpMessagesAsync(string userName, EnvironmentOperationsPayload environmentOperationsPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Stops an environment by stopping all resources inside the + /// environment This operation can take a while to complete + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, + /// stop, connect + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task StopEnvironmentWithHttpMessagesAsync(string userName, EnvironmentOperationsPayload environmentOperationsPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Resets the user password on an environment This operation can take + /// a while to complete + /// + /// + /// The name of the user. + /// + /// + /// Represents the payload for resetting passwords. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginResetPasswordWithHttpMessagesAsync(string userName, ResetPasswordPayload resetPasswordPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Starts an environment by starting all resources inside the + /// environment. This operation can take a while to complete + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, + /// stop, connect + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginStartEnvironmentWithHttpMessagesAsync(string userName, EnvironmentOperationsPayload environmentOperationsPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Stops an environment by stopping all resources inside the + /// environment This operation can take a while to complete + /// + /// + /// The name of the user. + /// + /// + /// Represents payload for any Environment operations like get, start, + /// stop, connect + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginStopEnvironmentWithHttpMessagesAsync(string userName, EnvironmentOperationsPayload environmentOperationsPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/ILabAccountsOperations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/ILabAccountsOperations.cs new file mode 100644 index 000000000000..27c601d9c91c --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/ILabAccountsOperations.cs @@ -0,0 +1,300 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// LabAccountsOperations operations. + /// + public partial interface ILabAccountsOperations + { + /// + /// List lab accounts in a subscription. + /// + /// + /// OData parameters to apply to the 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>> ListBySubscriptionWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List lab accounts in a resource group. + /// + /// + /// The name of the resource group. + /// + /// + /// OData parameters to apply to the 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get lab account + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// Specify the $expand query. Example: + /// 'properties($expand=sizeConfiguration)' + /// + /// + /// 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 labAccountName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or replace an existing Lab Account. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// Represents a lab account. + /// + /// + /// 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 labAccountName, LabAccount labAccount, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete lab account. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Modify properties of lab accounts. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// Represents a lab account. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string labAccountName, LabAccountFragment labAccount, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create a lab in a lab account. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// Properties for creating a managed lab and a default environment + /// setting + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task CreateLabWithHttpMessagesAsync(string resourceGroupName, string labAccountName, CreateLabProperties createLabProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get regional availability information for each size category + /// configured under a lab account + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// 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> GetRegionalAvailabilityWithHttpMessagesAsync(string resourceGroupName, string labAccountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete lab account. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List lab accounts in a 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>> ListBySubscriptionNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List lab accounts in a 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/LabServices/Management.LabServices/Generated/ILabsOperations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/ILabsOperations.cs new file mode 100644 index 000000000000..119c3f218779 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/ILabsOperations.cs @@ -0,0 +1,275 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// LabsOperations operations. + /// + public partial interface ILabsOperations + { + /// + /// List labs in a given lab account. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// OData parameters to apply to the 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>> ListWithHttpMessagesAsync(string resourceGroupName, string labAccountName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get lab + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Specify the $expand query. Example: + /// 'properties($select=maxUsersInLab)' + /// + /// + /// 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 labAccountName, string labName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or replace an existing Lab. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Represents a lab. + /// + /// + /// 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 labAccountName, string labName, Lab lab, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete lab. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Modify properties of labs. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Represents a lab. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, LabFragment lab, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Add users to a lab + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Payload for Add Users operation on a Lab. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task AddUsersWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, AddUsersPayload addUsersPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Register to managed lab. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task RegisterWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete lab. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List labs in a given lab account. + /// + /// + /// 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)); + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/IManagedLabsClient.cs b/src/SDKs/LabServices/Management.LabServices/Generated/IManagedLabsClient.cs new file mode 100644 index 000000000000..11fa97f251e6 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/IManagedLabsClient.cs @@ -0,0 +1,118 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// The Managed Labs Client. + /// + public partial interface IManagedLabsClient : 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; } + + /// + /// Client API version. + /// + string ApiVersion { get; } + + /// + /// The subscription ID. + /// + string SubscriptionId { get; set; } + + /// + /// The preferred language for the response. + /// + string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default + /// value is 30. + /// + int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. 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 IProviderOperations. + /// + IProviderOperations ProviderOperations { get; } + + /// + /// Gets the IGlobalUsersOperations. + /// + IGlobalUsersOperations GlobalUsers { get; } + + /// + /// Gets the ILabAccountsOperations. + /// + ILabAccountsOperations LabAccounts { get; } + + /// + /// Gets the IOperations. + /// + IOperations Operations { get; } + + /// + /// Gets the IGalleryImagesOperations. + /// + IGalleryImagesOperations GalleryImages { get; } + + /// + /// Gets the ILabsOperations. + /// + ILabsOperations Labs { get; } + + /// + /// Gets the IEnvironmentSettingsOperations. + /// + IEnvironmentSettingsOperations EnvironmentSettings { get; } + + /// + /// Gets the IEnvironmentsOperations. + /// + IEnvironmentsOperations Environments { get; } + + /// + /// Gets the IUsersOperations. + /// + IUsersOperations Users { get; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/IOperations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/IOperations.cs new file mode 100644 index 000000000000..fe513d5f20b5 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/IOperations.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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Operations operations. + /// + public partial interface IOperations + { + /// + /// Get operation + /// + /// + /// The name of the location. + /// + /// + /// The name of the 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> GetWithHttpMessagesAsync(string locationName, string operationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/IProviderOperations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/IProviderOperations.cs new file mode 100644 index 000000000000..3953ba4dc044 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/IProviderOperations.cs @@ -0,0 +1,68 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// ProviderOperations operations. + /// + public partial interface IProviderOperations + { + /// + /// Result of the request to list REST API operations + /// + /// + /// 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)); + /// + /// Result of the request to list REST API operations + /// + /// + /// 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)); + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/IUsersOperations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/IUsersOperations.cs new file mode 100644 index 000000000000..5731f8c87967 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/IUsersOperations.cs @@ -0,0 +1,239 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// UsersOperations operations. + /// + public partial interface IUsersOperations + { + /// + /// List users in a given lab. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// OData parameters to apply to the 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>> ListWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get user + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// Specify the $expand query. Example: 'properties($select=email)' + /// + /// + /// 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 labAccountName, string labName, string userName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Create or replace an existing User. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// The User registered to a lab + /// + /// + /// 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 labAccountName, string labName, string userName, User user, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete user. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task DeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string userName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Modify properties of users. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// The User registered to a lab + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string userName, UserFragment user, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Delete user. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// Thrown when a required parameter is null + /// + Task BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string userName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// List users in a given lab. + /// + /// + /// 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)); + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/LabAccountsOperations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/LabAccountsOperations.cs new file mode 100644 index 000000000000..00a1f7a24bb8 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/LabAccountsOperations.cs @@ -0,0 +1,2019 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + 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; + + /// + /// LabAccountsOperations operations. + /// + internal partial class LabAccountsOperations : IServiceOperations, ILabAccountsOperations + { + /// + /// Initializes a new instance of the LabAccountsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal LabAccountsOperations(ManagedLabsClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagedLabsClient + /// + public ManagedLabsClient Client { get; private set; } + + /// + /// List lab accounts in a subscription. + /// + /// + /// OData parameters to apply to the 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>> ListBySubscriptionWithHttpMessagesAsync(ODataQuery odataQuery = default(ODataQuery), 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("odataQuery", odataQuery); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "ListBySubscription", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/providers/Microsoft.LabServices/labaccounts").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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; + } + + /// + /// List lab accounts in a resource group. + /// + /// + /// The name of the resource group. + /// + /// + /// OData parameters to apply to the 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>> ListByResourceGroupWithHttpMessagesAsync(string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + 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("odataQuery", odataQuery); + 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.LabServices/labaccounts").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 lab account + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// Specify the $expand query. Example: 'properties($expand=sizeConfiguration)' + /// + /// + /// 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 labAccountName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("expand", expand); + 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.LabServices/labaccounts/{labAccountName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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 replace an existing Lab Account. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// Represents a lab account. + /// + /// + /// 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 labAccountName, LabAccount labAccount, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labAccount == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccount"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labAccount", labAccount); + 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.LabServices/labaccounts/{labAccountName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + 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(labAccount != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(labAccount, 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 lab account. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, labAccountName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Modify properties of lab accounts. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// Represents a lab account. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string labAccountName, LabAccountFragment labAccount, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labAccount == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccount"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labAccount", labAccount); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", 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.LabServices/labaccounts/{labAccountName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + 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("PATCH"); + _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(labAccount != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(labAccount, 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) + { + 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 a lab in a lab account. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// Properties for creating a managed lab and a default environment setting + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 CreateLabWithHttpMessagesAsync(string resourceGroupName, string labAccountName, CreateLabProperties createLabProperties, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (createLabProperties == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "createLabProperties"); + } + if (createLabProperties != null) + { + createLabProperties.Validate(); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("createLabProperties", createLabProperties); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "CreateLab", 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.LabServices/labaccounts/{labAccountName}/createLab").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + 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("POST"); + _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(createLabProperties != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createLabProperties, 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) + { + 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Get regional availability information for each size category configured + /// under a lab account + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// 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> GetRegionalAvailabilityWithHttpMessagesAsync(string resourceGroupName, string labAccountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "GetRegionalAvailability", 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.LabServices/labaccounts/{labAccountName}/getRegionalAvailability").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + 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("POST"); + _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; + } + + /// + /// Delete lab account. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", 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.LabServices/labaccounts/{labAccountName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + 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 != 202 && (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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List lab accounts in a 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>> ListBySubscriptionNextWithHttpMessagesAsync(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, "ListBySubscriptionNext", 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; + } + + /// + /// List lab accounts in a 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/LabServices/Management.LabServices/Generated/LabAccountsOperationsExtensions.cs b/src/SDKs/LabServices/Management.LabServices/Generated/LabAccountsOperationsExtensions.cs new file mode 100644 index 000000000000..b1d1d876345c --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/LabAccountsOperationsExtensions.cs @@ -0,0 +1,465 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for LabAccountsOperations. + /// + public static partial class LabAccountsOperationsExtensions + { + /// + /// List lab accounts in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage ListBySubscription(this ILabAccountsOperations operations, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListBySubscriptionAsync(odataQuery).GetAwaiter().GetResult(); + } + + /// + /// List lab accounts in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListBySubscriptionAsync(this ILabAccountsOperations operations, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionWithHttpMessagesAsync(odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List lab accounts in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage ListByResourceGroup(this ILabAccountsOperations operations, string resourceGroupName, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListByResourceGroupAsync(resourceGroupName, odataQuery).GetAwaiter().GetResult(); + } + + /// + /// List lab accounts in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListByResourceGroupAsync(this ILabAccountsOperations operations, string resourceGroupName, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListByResourceGroupWithHttpMessagesAsync(resourceGroupName, odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get lab account + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// Specify the $expand query. Example: 'properties($expand=sizeConfiguration)' + /// + public static LabAccount Get(this ILabAccountsOperations operations, string resourceGroupName, string labAccountName, string expand = default(string)) + { + return operations.GetAsync(resourceGroupName, labAccountName, expand).GetAwaiter().GetResult(); + } + + /// + /// Get lab account + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// Specify the $expand query. Example: 'properties($expand=sizeConfiguration)' + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ILabAccountsOperations operations, string resourceGroupName, string labAccountName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, labAccountName, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or replace an existing Lab Account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// Represents a lab account. + /// + public static LabAccount CreateOrUpdate(this ILabAccountsOperations operations, string resourceGroupName, string labAccountName, LabAccount labAccount) + { + return operations.CreateOrUpdateAsync(resourceGroupName, labAccountName, labAccount).GetAwaiter().GetResult(); + } + + /// + /// Create or replace an existing Lab Account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// Represents a lab account. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this ILabAccountsOperations operations, string resourceGroupName, string labAccountName, LabAccount labAccount, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, labAccountName, labAccount, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete lab account. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + public static void Delete(this ILabAccountsOperations operations, string resourceGroupName, string labAccountName) + { + operations.DeleteAsync(resourceGroupName, labAccountName).GetAwaiter().GetResult(); + } + + /// + /// Delete lab account. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this ILabAccountsOperations operations, string resourceGroupName, string labAccountName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, labAccountName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Modify properties of lab accounts. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// Represents a lab account. + /// + public static LabAccount Update(this ILabAccountsOperations operations, string resourceGroupName, string labAccountName, LabAccountFragment labAccount) + { + return operations.UpdateAsync(resourceGroupName, labAccountName, labAccount).GetAwaiter().GetResult(); + } + + /// + /// Modify properties of lab accounts. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// Represents a lab account. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this ILabAccountsOperations operations, string resourceGroupName, string labAccountName, LabAccountFragment labAccount, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, labAccountName, labAccount, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create a lab in a lab account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// Properties for creating a managed lab and a default environment setting + /// + public static void CreateLab(this ILabAccountsOperations operations, string resourceGroupName, string labAccountName, CreateLabProperties createLabProperties) + { + operations.CreateLabAsync(resourceGroupName, labAccountName, createLabProperties).GetAwaiter().GetResult(); + } + + /// + /// Create a lab in a lab account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// Properties for creating a managed lab and a default environment setting + /// + /// + /// The cancellation token. + /// + public static async Task CreateLabAsync(this ILabAccountsOperations operations, string resourceGroupName, string labAccountName, CreateLabProperties createLabProperties, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.CreateLabWithHttpMessagesAsync(resourceGroupName, labAccountName, createLabProperties, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Get regional availability information for each size category configured + /// under a lab account + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + public static GetRegionalAvailabilityResponse GetRegionalAvailability(this ILabAccountsOperations operations, string resourceGroupName, string labAccountName) + { + return operations.GetRegionalAvailabilityAsync(resourceGroupName, labAccountName).GetAwaiter().GetResult(); + } + + /// + /// Get regional availability information for each size category configured + /// under a lab account + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The cancellation token. + /// + public static async Task GetRegionalAvailabilityAsync(this ILabAccountsOperations operations, string resourceGroupName, string labAccountName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetRegionalAvailabilityWithHttpMessagesAsync(resourceGroupName, labAccountName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete lab account. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + public static void BeginDelete(this ILabAccountsOperations operations, string resourceGroupName, string labAccountName) + { + operations.BeginDeleteAsync(resourceGroupName, labAccountName).GetAwaiter().GetResult(); + } + + /// + /// Delete lab account. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this ILabAccountsOperations operations, string resourceGroupName, string labAccountName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, labAccountName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// List lab accounts in a subscription. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListBySubscriptionNext(this ILabAccountsOperations operations, string nextPageLink) + { + return operations.ListBySubscriptionNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List lab accounts in a 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> ListBySubscriptionNextAsync(this ILabAccountsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListBySubscriptionNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// List lab accounts in a resource group. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListByResourceGroupNext(this ILabAccountsOperations operations, string nextPageLink) + { + return operations.ListByResourceGroupNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List lab accounts in a 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 ILabAccountsOperations 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/LabServices/Management.LabServices/Generated/LabsOperations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/LabsOperations.cs new file mode 100644 index 000000000000..2e6c3d911b49 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/LabsOperations.cs @@ -0,0 +1,1700 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + 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; + + /// + /// LabsOperations operations. + /// + internal partial class LabsOperations : IServiceOperations, ILabsOperations + { + /// + /// Initializes a new instance of the LabsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal LabsOperations(ManagedLabsClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagedLabsClient + /// + public ManagedLabsClient Client { get; private set; } + + /// + /// List labs in a given lab account. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// OData parameters to apply to the 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>> ListWithHttpMessagesAsync(string resourceGroupName, string labAccountName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + 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("odataQuery", odataQuery); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + 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.LabServices/labaccounts/{labAccountName}/labs").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 lab + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Specify the $expand query. Example: 'properties($select=maxUsersInLab)' + /// + /// + /// 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 labAccountName, string labName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("expand", expand); + 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.LabServices/labaccounts/{labAccountName}/labs/{labName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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 replace an existing Lab. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Represents a lab. + /// + /// + /// 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 labAccountName, string labName, Lab lab, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (lab == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "lab"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("lab", lab); + 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.LabServices/labaccounts/{labAccountName}/labs/{labName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + 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(lab != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(lab, 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 lab. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Modify properties of labs. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Represents a lab. + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, LabFragment lab, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (lab == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "lab"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("lab", lab); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + 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("PATCH"); + _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(lab != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(lab, 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) + { + 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; + } + + /// + /// Add users to a lab + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Payload for Add Users operation on a Lab. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 AddUsersWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, AddUsersPayload addUsersPayload, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (addUsersPayload == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "addUsersPayload"); + } + if (addUsersPayload != null) + { + addUsersPayload.Validate(); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("addUsersPayload", addUsersPayload); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "AddUsers", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/addUsers").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + 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("POST"); + _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(addUsersPayload != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(addUsersPayload, 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) + { + 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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Register to managed lab. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 RegisterWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Register", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/register").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + 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("POST"); + _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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// Delete lab. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + 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 != 202 && (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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List labs in a given lab account. + /// + /// + /// 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; + } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/LabsOperationsExtensions.cs b/src/SDKs/LabServices/Management.LabServices/Generated/LabsOperationsExtensions.cs new file mode 100644 index 000000000000..32a3feb16a85 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/LabsOperationsExtensions.cs @@ -0,0 +1,440 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for LabsOperations. + /// + public static partial class LabsOperationsExtensions + { + /// + /// List labs in a given lab account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage List(this ILabsOperations operations, string resourceGroupName, string labAccountName, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAsync(resourceGroupName, labAccountName, odataQuery).GetAwaiter().GetResult(); + } + + /// + /// List labs in a given lab account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this ILabsOperations operations, string resourceGroupName, string labAccountName, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, labAccountName, odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get lab + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Specify the $expand query. Example: 'properties($select=maxUsersInLab)' + /// + public static Lab Get(this ILabsOperations operations, string resourceGroupName, string labAccountName, string labName, string expand = default(string)) + { + return operations.GetAsync(resourceGroupName, labAccountName, labName, expand).GetAwaiter().GetResult(); + } + + /// + /// Get lab + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Specify the $expand query. Example: 'properties($select=maxUsersInLab)' + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this ILabsOperations operations, string resourceGroupName, string labAccountName, string labName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or replace an existing Lab. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Represents a lab. + /// + public static Lab CreateOrUpdate(this ILabsOperations operations, string resourceGroupName, string labAccountName, string labName, Lab lab) + { + return operations.CreateOrUpdateAsync(resourceGroupName, labAccountName, labName, lab).GetAwaiter().GetResult(); + } + + /// + /// Create or replace an existing Lab. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Represents a lab. + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this ILabsOperations operations, string resourceGroupName, string labAccountName, string labName, Lab lab, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, lab, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete lab. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + public static void Delete(this ILabsOperations operations, string resourceGroupName, string labAccountName, string labName) + { + operations.DeleteAsync(resourceGroupName, labAccountName, labName).GetAwaiter().GetResult(); + } + + /// + /// Delete lab. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this ILabsOperations operations, string resourceGroupName, string labAccountName, string labName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Modify properties of labs. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Represents a lab. + /// + public static Lab Update(this ILabsOperations operations, string resourceGroupName, string labAccountName, string labName, LabFragment lab) + { + return operations.UpdateAsync(resourceGroupName, labAccountName, labName, lab).GetAwaiter().GetResult(); + } + + /// + /// Modify properties of labs. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Represents a lab. + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this ILabsOperations operations, string resourceGroupName, string labAccountName, string labName, LabFragment lab, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, lab, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Add users to a lab + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Payload for Add Users operation on a Lab. + /// + public static void AddUsers(this ILabsOperations operations, string resourceGroupName, string labAccountName, string labName, AddUsersPayload addUsersPayload) + { + operations.AddUsersAsync(resourceGroupName, labAccountName, labName, addUsersPayload).GetAwaiter().GetResult(); + } + + /// + /// Add users to a lab + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// Payload for Add Users operation on a Lab. + /// + /// + /// The cancellation token. + /// + public static async Task AddUsersAsync(this ILabsOperations operations, string resourceGroupName, string labAccountName, string labName, AddUsersPayload addUsersPayload, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.AddUsersWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, addUsersPayload, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Register to managed lab. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + public static void Register(this ILabsOperations operations, string resourceGroupName, string labAccountName, string labName) + { + operations.RegisterAsync(resourceGroupName, labAccountName, labName).GetAwaiter().GetResult(); + } + + /// + /// Register to managed lab. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The cancellation token. + /// + public static async Task RegisterAsync(this ILabsOperations operations, string resourceGroupName, string labAccountName, string labName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.RegisterWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Delete lab. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + public static void BeginDelete(this ILabsOperations operations, string resourceGroupName, string labAccountName, string labName) + { + operations.BeginDeleteAsync(resourceGroupName, labAccountName, labName).GetAwaiter().GetResult(); + } + + /// + /// Delete lab. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this ILabsOperations operations, string resourceGroupName, string labAccountName, string labName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// List labs in a given lab account. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this ILabsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List labs in a given lab account. + /// + /// + /// 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 ILabsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/ManagedLabsClient.cs b/src/SDKs/LabServices/Management.LabServices/Generated/ManagedLabsClient.cs new file mode 100644 index 000000000000..5903f151ebed --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/ManagedLabsClient.cs @@ -0,0 +1,408 @@ +// +// 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.LabServices +{ + 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; + + /// + /// The Managed Labs Client. + /// + public partial class ManagedLabsClient : ServiceClient, IManagedLabsClient, 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; } + + /// + /// Client API version. + /// + public string ApiVersion { get; private set; } + + /// + /// The subscription ID. + /// + public string SubscriptionId { get; set; } + + /// + /// The preferred language for the response. + /// + public string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default value is + /// 30. + /// + public int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. 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 IProviderOperations. + /// + public virtual IProviderOperations ProviderOperations { get; private set; } + + /// + /// Gets the IGlobalUsersOperations. + /// + public virtual IGlobalUsersOperations GlobalUsers { get; private set; } + + /// + /// Gets the ILabAccountsOperations. + /// + public virtual ILabAccountsOperations LabAccounts { get; private set; } + + /// + /// Gets the IOperations. + /// + public virtual IOperations Operations { get; private set; } + + /// + /// Gets the IGalleryImagesOperations. + /// + public virtual IGalleryImagesOperations GalleryImages { get; private set; } + + /// + /// Gets the ILabsOperations. + /// + public virtual ILabsOperations Labs { get; private set; } + + /// + /// Gets the IEnvironmentSettingsOperations. + /// + public virtual IEnvironmentSettingsOperations EnvironmentSettings { get; private set; } + + /// + /// Gets the IEnvironmentsOperations. + /// + public virtual IEnvironmentsOperations Environments { get; private set; } + + /// + /// Gets the IUsersOperations. + /// + public virtual IUsersOperations Users { get; private set; } + + /// + /// Initializes a new instance of the ManagedLabsClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling ManagedLabsClient.Dispose(). False: will not dispose provided httpClient + protected ManagedLabsClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ManagedLabsClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected ManagedLabsClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ManagedLabsClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected ManagedLabsClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the ManagedLabsClient 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 ManagedLabsClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the ManagedLabsClient 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 ManagedLabsClient(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 ManagedLabsClient 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 ManagedLabsClient(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 ManagedLabsClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling ManagedLabsClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public ManagedLabsClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the ManagedLabsClient 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 ManagedLabsClient(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 ManagedLabsClient 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 ManagedLabsClient(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 ManagedLabsClient 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 ManagedLabsClient(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() + { + ProviderOperations = new ProviderOperations(this); + GlobalUsers = new GlobalUsersOperations(this); + LabAccounts = new LabAccountsOperations(this); + Operations = new Operations(this); + GalleryImages = new GalleryImagesOperations(this); + Labs = new LabsOperations(this); + EnvironmentSettings = new EnvironmentSettingsOperations(this); + Environments = new EnvironmentsOperations(this); + Users = new UsersOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2018-10-15"; + 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/LabServices/Management.LabServices/Generated/Models/AddRemove.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/AddRemove.cs new file mode 100644 index 000000000000..f569bf6c0352 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/AddRemove.cs @@ -0,0 +1,28 @@ +// +// 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.LabServices.Models +{ + + /// + /// Defines values for AddRemove. + /// + public static class AddRemove + { + /// + /// Indicates that a user is adding a favorite lab + /// + public const string Add = "Add"; + /// + /// Indicates that a user is removing a favorite lab + /// + public const string Remove = "Remove"; + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/AddUsersPayload.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/AddUsersPayload.cs new file mode 100644 index 000000000000..b75748495b72 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/AddUsersPayload.cs @@ -0,0 +1,68 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Payload for Add Users operation on a Lab. + /// + public partial class AddUsersPayload + { + /// + /// Initializes a new instance of the AddUsersPayload class. + /// + public AddUsersPayload() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the AddUsersPayload class. + /// + /// List of user emails addresses to add + /// to the lab. + public AddUsersPayload(IList emailAddresses) + { + EmailAddresses = emailAddresses; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of user emails addresses to add to the lab. + /// + [JsonProperty(PropertyName = "emailAddresses")] + public IList EmailAddresses { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (EmailAddresses == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "EmailAddresses"); + } + } + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/ConfigurationState.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ConfigurationState.cs new file mode 100644 index 000000000000..2b286e24cf91 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ConfigurationState.cs @@ -0,0 +1,29 @@ +// +// 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.LabServices.Models +{ + + /// + /// Defines values for ConfigurationState. + /// + public static class ConfigurationState + { + /// + /// User either hasn't started configuring their template + /// or they haven't started the configuration process. + /// + public const string NotApplicable = "NotApplicable"; + /// + /// User is finished modifying the template. + /// + public const string Completed = "Completed"; + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/CreateLabProperties.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/CreateLabProperties.cs new file mode 100644 index 000000000000..753588e9c998 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/CreateLabProperties.cs @@ -0,0 +1,109 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Properties for creating a managed lab and a default environment setting + /// + public partial class CreateLabProperties + { + /// + /// Initializes a new instance of the CreateLabProperties class. + /// + public CreateLabProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the CreateLabProperties class. + /// + /// Settings related to creating a + /// lab + /// The name of the resource + /// Settings related + /// to creating an environment setting + /// The location of the resource + /// The tags of the resource. + public CreateLabProperties(LabCreationParameters labCreationParameters, string name, EnvironmentSettingCreationParameters environmentSettingCreationParameters = default(EnvironmentSettingCreationParameters), string location = default(string), IDictionary tags = default(IDictionary)) + { + EnvironmentSettingCreationParameters = environmentSettingCreationParameters; + LabCreationParameters = labCreationParameters; + Name = name; + Location = location; + Tags = tags; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets settings related to creating an environment setting + /// + [JsonProperty(PropertyName = "environmentSettingCreationParameters")] + public EnvironmentSettingCreationParameters EnvironmentSettingCreationParameters { get; set; } + + /// + /// Gets or sets settings related to creating a lab + /// + [JsonProperty(PropertyName = "labCreationParameters")] + public LabCreationParameters LabCreationParameters { get; set; } + + /// + /// Gets or sets the name of the resource + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the location of the resource + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the tags of the resource. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (LabCreationParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "LabCreationParameters"); + } + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (EnvironmentSettingCreationParameters != null) + { + EnvironmentSettingCreationParameters.Validate(); + } + } + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/Environment.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/Environment.cs new file mode 100644 index 000000000000..dd7ed485d619 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/Environment.cs @@ -0,0 +1,163 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents an environment instance + /// + [Rest.Serialization.JsonTransformation] + public partial class Environment : Resource + { + /// + /// Initializes a new instance of the Environment class. + /// + public Environment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Environment class. + /// + /// The identifier of the resource. + /// The name of the resource. + /// The type of the resource. + /// The location of the resource. + /// The tags of the resource. + /// The set of a VM and the setting id it + /// was created for + /// The AAD object Id of the user + /// who has claimed the environment + /// The user principal Id of the + /// user who has claimed the environment + /// The name or email address of the + /// user who has claimed the environment + /// Is the environment claimed or not + /// Last known power state of the + /// environment + /// Network details of the + /// environment + /// How long the environment has been used by + /// a lab user + /// When the password was last reset on + /// the environment. + /// The provisioning status of the + /// resource. + /// The unique immutable identifier of a + /// resource (Guid). + /// The details of the latest + /// operation. ex: status, error + public Environment(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ResourceSet resourceSets = default(ResourceSet), string claimedByUserObjectId = default(string), string claimedByUserPrincipalId = default(string), string claimedByUserName = default(string), bool? isClaimed = default(bool?), string lastKnownPowerState = default(string), NetworkInterface networkInterface = default(NetworkInterface), System.TimeSpan? totalUsage = default(System.TimeSpan?), System.DateTime? passwordLastReset = default(System.DateTime?), string provisioningState = default(string), string uniqueIdentifier = default(string), LatestOperationResult latestOperationResult = default(LatestOperationResult)) + : base(id, name, type, location, tags) + { + ResourceSets = resourceSets; + ClaimedByUserObjectId = claimedByUserObjectId; + ClaimedByUserPrincipalId = claimedByUserPrincipalId; + ClaimedByUserName = claimedByUserName; + IsClaimed = isClaimed; + LastKnownPowerState = lastKnownPowerState; + NetworkInterface = networkInterface; + TotalUsage = totalUsage; + PasswordLastReset = passwordLastReset; + ProvisioningState = provisioningState; + UniqueIdentifier = uniqueIdentifier; + LatestOperationResult = latestOperationResult; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the set of a VM and the setting id it was created for + /// + [JsonProperty(PropertyName = "properties.resourceSets")] + public ResourceSet ResourceSets { get; set; } + + /// + /// Gets the AAD object Id of the user who has claimed the environment + /// + [JsonProperty(PropertyName = "properties.claimedByUserObjectId")] + public string ClaimedByUserObjectId { get; private set; } + + /// + /// Gets the user principal Id of the user who has claimed the + /// environment + /// + [JsonProperty(PropertyName = "properties.claimedByUserPrincipalId")] + public string ClaimedByUserPrincipalId { get; private set; } + + /// + /// Gets the name or email address of the user who has claimed the + /// environment + /// + [JsonProperty(PropertyName = "properties.claimedByUserName")] + public string ClaimedByUserName { get; private set; } + + /// + /// Gets is the environment claimed or not + /// + [JsonProperty(PropertyName = "properties.isClaimed")] + public bool? IsClaimed { get; private set; } + + /// + /// Gets last known power state of the environment + /// + [JsonProperty(PropertyName = "properties.lastKnownPowerState")] + public string LastKnownPowerState { get; private set; } + + /// + /// Gets network details of the environment + /// + [JsonProperty(PropertyName = "properties.networkInterface")] + public NetworkInterface NetworkInterface { get; private set; } + + /// + /// Gets how long the environment has been used by a lab user + /// + [JsonProperty(PropertyName = "properties.totalUsage")] + public System.TimeSpan? TotalUsage { get; private set; } + + /// + /// Gets when the password was last reset on the environment. + /// + [JsonProperty(PropertyName = "properties.passwordLastReset")] + public System.DateTime? PasswordLastReset { get; private set; } + + /// + /// Gets or sets the provisioning status of the resource. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets the unique immutable identifier of a resource (Guid). + /// + [JsonProperty(PropertyName = "properties.uniqueIdentifier")] + public string UniqueIdentifier { get; set; } + + /// + /// Gets the details of the latest operation. ex: status, error + /// + [JsonProperty(PropertyName = "properties.latestOperationResult")] + public LatestOperationResult LatestOperationResult { get; private set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentDetails.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentDetails.cs new file mode 100644 index 000000000000..ad7189370ad0 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentDetails.cs @@ -0,0 +1,125 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// This represents the details about a User's environment and its state. + /// + public partial class EnvironmentDetails + { + /// + /// Initializes a new instance of the EnvironmentDetails class. + /// + public EnvironmentDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EnvironmentDetails class. + /// + /// Name of the Environment + /// Description of the Environment + /// Resource Id of the environment + /// The provisioning state of the + /// environment. This also includes LabIsFull and NotYetProvisioned + /// status. + /// Details of backing DTL virtual + /// machine with compute and network details. + /// The details of the latest + /// operation. ex: status, error + /// Publishing state of the environment + /// setting Possible values are Creating, Created, Failed + /// How long the environment has been used by + /// a lab user + /// When the password was last reset on + /// the environment. + public EnvironmentDetails(string name = default(string), string description = default(string), string id = default(string), string provisioningState = default(string), VirtualMachineDetails virtualMachineDetails = default(VirtualMachineDetails), LatestOperationResult latestOperationResult = default(LatestOperationResult), string environmentState = default(string), System.TimeSpan? totalUsage = default(System.TimeSpan?), System.DateTime? passwordLastReset = default(System.DateTime?)) + { + Name = name; + Description = description; + Id = id; + ProvisioningState = provisioningState; + VirtualMachineDetails = virtualMachineDetails; + LatestOperationResult = latestOperationResult; + EnvironmentState = environmentState; + TotalUsage = totalUsage; + PasswordLastReset = passwordLastReset; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets name of the Environment + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets description of the Environment + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; private set; } + + /// + /// Gets resource Id of the environment + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the provisioning state of the environment. This also includes + /// LabIsFull and NotYetProvisioned status. + /// + [JsonProperty(PropertyName = "provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets details of backing DTL virtual machine with compute and + /// network details. + /// + [JsonProperty(PropertyName = "virtualMachineDetails")] + public VirtualMachineDetails VirtualMachineDetails { get; private set; } + + /// + /// Gets the details of the latest operation. ex: status, error + /// + [JsonProperty(PropertyName = "latestOperationResult")] + public LatestOperationResult LatestOperationResult { get; private set; } + + /// + /// Gets publishing state of the environment setting Possible values + /// are Creating, Created, Failed + /// + [JsonProperty(PropertyName = "environmentState")] + public string EnvironmentState { get; private set; } + + /// + /// Gets how long the environment has been used by a lab user + /// + [JsonProperty(PropertyName = "totalUsage")] + public System.TimeSpan? TotalUsage { get; private set; } + + /// + /// Gets when the password was last reset on the environment. + /// + [JsonProperty(PropertyName = "passwordLastReset")] + public System.DateTime? PasswordLastReset { get; private set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentFragment.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentFragment.cs new file mode 100644 index 000000000000..3b300f29d218 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentFragment.cs @@ -0,0 +1,81 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents an environment instance + /// + [Rest.Serialization.JsonTransformation] + public partial class EnvironmentFragment : Resource + { + /// + /// Initializes a new instance of the EnvironmentFragment class. + /// + public EnvironmentFragment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EnvironmentFragment class. + /// + /// The identifier of the resource. + /// The name of the resource. + /// The type of the resource. + /// The location of the resource. + /// The tags of the resource. + /// The set of a VM and the setting id it + /// was created for + /// The provisioning status of the + /// resource. + /// The unique immutable identifier of a + /// resource (Guid). + public EnvironmentFragment(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), ResourceSetFragment resourceSets = default(ResourceSetFragment), string provisioningState = default(string), string uniqueIdentifier = default(string)) + : base(id, name, type, location, tags) + { + ResourceSets = resourceSets; + ProvisioningState = provisioningState; + UniqueIdentifier = uniqueIdentifier; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the set of a VM and the setting id it was created for + /// + [JsonProperty(PropertyName = "properties.resourceSets")] + public ResourceSetFragment ResourceSets { get; set; } + + /// + /// Gets or sets the provisioning status of the resource. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets the unique immutable identifier of a resource (Guid). + /// + [JsonProperty(PropertyName = "properties.uniqueIdentifier")] + public string UniqueIdentifier { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentOperationsPayload.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentOperationsPayload.cs new file mode 100644 index 000000000000..80f0f9d7cd5a --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentOperationsPayload.cs @@ -0,0 +1,69 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents payload for any Environment operations like get, start, + /// stop, connect + /// + public partial class EnvironmentOperationsPayload + { + /// + /// Initializes a new instance of the EnvironmentOperationsPayload + /// class. + /// + public EnvironmentOperationsPayload() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EnvironmentOperationsPayload + /// class. + /// + /// The resourceId of the + /// environment + public EnvironmentOperationsPayload(string environmentId) + { + EnvironmentId = environmentId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resourceId of the environment + /// + [JsonProperty(PropertyName = "environmentId")] + public string EnvironmentId { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (EnvironmentId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "EnvironmentId"); + } + } + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentSetting.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentSetting.cs new file mode 100644 index 000000000000..bca1d48abc11 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentSetting.cs @@ -0,0 +1,169 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents settings of an environment, from which environment instances + /// would be created + /// + [Rest.Serialization.JsonTransformation] + public partial class EnvironmentSetting : Resource + { + /// + /// Initializes a new instance of the EnvironmentSetting class. + /// + public EnvironmentSetting() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EnvironmentSetting class. + /// + /// The resource specific + /// settings + /// The identifier of the resource. + /// The name of the resource. + /// The type of the resource. + /// The location of the resource. + /// The tags of the resource. + /// Describes the readiness of this + /// environment setting. Possible values include: 'Draft', + /// 'Publishing', 'Published', 'PublishFailed', 'Scaling' + /// Describes the user's progress in + /// configuring their environment setting. Possible values include: + /// 'NotApplicable', 'Completed' + /// Describes the environment and its + /// resource settings + /// Brief title describing the environment and its + /// resource settings + /// Time when the template VM was last + /// changed. + /// Time when the template VM was last sent + /// for publishing. + /// The provisioning status of the + /// resource. + /// The unique immutable identifier of a + /// resource (Guid). + /// The details of the latest + /// operation. ex: status, error + public EnvironmentSetting(ResourceSettings resourceSettings, string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string publishingState = default(string), string configurationState = default(string), string description = default(string), string title = default(string), System.DateTime? lastChanged = default(System.DateTime?), System.DateTime? lastPublished = default(System.DateTime?), string provisioningState = default(string), string uniqueIdentifier = default(string), LatestOperationResult latestOperationResult = default(LatestOperationResult)) + : base(id, name, type, location, tags) + { + PublishingState = publishingState; + ConfigurationState = configurationState; + Description = description; + Title = title; + ResourceSettings = resourceSettings; + LastChanged = lastChanged; + LastPublished = lastPublished; + ProvisioningState = provisioningState; + UniqueIdentifier = uniqueIdentifier; + LatestOperationResult = latestOperationResult; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets describes the readiness of this environment setting. Possible + /// values include: 'Draft', 'Publishing', 'Published', + /// 'PublishFailed', 'Scaling' + /// + [JsonProperty(PropertyName = "properties.publishingState")] + public string PublishingState { get; private set; } + + /// + /// Gets or sets describes the user's progress in configuring their + /// environment setting. Possible values include: 'NotApplicable', + /// 'Completed' + /// + [JsonProperty(PropertyName = "properties.configurationState")] + public string ConfigurationState { get; set; } + + /// + /// Gets or sets describes the environment and its resource settings + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets brief title describing the environment and its + /// resource settings + /// + [JsonProperty(PropertyName = "properties.title")] + public string Title { get; set; } + + /// + /// Gets or sets the resource specific settings + /// + [JsonProperty(PropertyName = "properties.resourceSettings")] + public ResourceSettings ResourceSettings { get; set; } + + /// + /// Gets time when the template VM was last changed. + /// + [JsonProperty(PropertyName = "properties.lastChanged")] + public System.DateTime? LastChanged { get; private set; } + + /// + /// Gets time when the template VM was last sent for publishing. + /// + [JsonProperty(PropertyName = "properties.lastPublished")] + public System.DateTime? LastPublished { get; private set; } + + /// + /// Gets or sets the provisioning status of the resource. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets the unique immutable identifier of a resource (Guid). + /// + [JsonProperty(PropertyName = "properties.uniqueIdentifier")] + public string UniqueIdentifier { get; set; } + + /// + /// Gets the details of the latest operation. ex: status, error + /// + [JsonProperty(PropertyName = "properties.latestOperationResult")] + public LatestOperationResult LatestOperationResult { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ResourceSettings == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ResourceSettings"); + } + if (ResourceSettings != null) + { + ResourceSettings.Validate(); + } + } + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentSettingCreationParameters.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentSettingCreationParameters.cs new file mode 100644 index 000000000000..da023393d194 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentSettingCreationParameters.cs @@ -0,0 +1,72 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Settings related to creating an environment setting + /// + public partial class EnvironmentSettingCreationParameters + { + /// + /// Initializes a new instance of the + /// EnvironmentSettingCreationParameters class. + /// + public EnvironmentSettingCreationParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// EnvironmentSettingCreationParameters class. + /// + /// The resource + /// specific settings + public EnvironmentSettingCreationParameters(ResourceSettingCreationParameters resourceSettingCreationParameters) + { + ResourceSettingCreationParameters = resourceSettingCreationParameters; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource specific settings + /// + [JsonProperty(PropertyName = "resourceSettingCreationParameters")] + public ResourceSettingCreationParameters ResourceSettingCreationParameters { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ResourceSettingCreationParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ResourceSettingCreationParameters"); + } + if (ResourceSettingCreationParameters != null) + { + ResourceSettingCreationParameters.Validate(); + } + } + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentSettingFragment.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentSettingFragment.cs new file mode 100644 index 000000000000..70a9592b95e5 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentSettingFragment.cs @@ -0,0 +1,113 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents settings of an environment, from which environment instances + /// would be created + /// + [Rest.Serialization.JsonTransformation] + public partial class EnvironmentSettingFragment : Resource + { + /// + /// Initializes a new instance of the EnvironmentSettingFragment class. + /// + public EnvironmentSettingFragment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EnvironmentSettingFragment class. + /// + /// The identifier of the resource. + /// The name of the resource. + /// The type of the resource. + /// The location of the resource. + /// The tags of the resource. + /// Describes the user's progress in + /// configuring their environment setting. Possible values include: + /// 'NotApplicable', 'Completed' + /// Describes the environment and its + /// resource settings + /// Brief title describing the environment and its + /// resource settings + /// The resource specific + /// settings + /// The provisioning status of the + /// resource. + /// The unique immutable identifier of a + /// resource (Guid). + public EnvironmentSettingFragment(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string configurationState = default(string), string description = default(string), string title = default(string), ResourceSettingsFragment resourceSettings = default(ResourceSettingsFragment), string provisioningState = default(string), string uniqueIdentifier = default(string)) + : base(id, name, type, location, tags) + { + ConfigurationState = configurationState; + Description = description; + Title = title; + ResourceSettings = resourceSettings; + ProvisioningState = provisioningState; + UniqueIdentifier = uniqueIdentifier; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets describes the user's progress in configuring their + /// environment setting. Possible values include: 'NotApplicable', + /// 'Completed' + /// + [JsonProperty(PropertyName = "properties.configurationState")] + public string ConfigurationState { get; set; } + + /// + /// Gets or sets describes the environment and its resource settings + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; set; } + + /// + /// Gets or sets brief title describing the environment and its + /// resource settings + /// + [JsonProperty(PropertyName = "properties.title")] + public string Title { get; set; } + + /// + /// Gets or sets the resource specific settings + /// + [JsonProperty(PropertyName = "properties.resourceSettings")] + public ResourceSettingsFragment ResourceSettings { get; set; } + + /// + /// Gets or sets the provisioning status of the resource. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets the unique immutable identifier of a resource (Guid). + /// + [JsonProperty(PropertyName = "properties.uniqueIdentifier")] + public string UniqueIdentifier { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentSize.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentSize.cs new file mode 100644 index 000000000000..722a9703c342 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentSize.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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a size category supported by this Lab Account (small, medium + /// or large) + /// + public partial class EnvironmentSize + { + /// + /// Initializes a new instance of the EnvironmentSize class. + /// + public EnvironmentSize() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EnvironmentSize class. + /// + /// The size category. Possible values include: + /// 'Basic', 'Standard', 'Performance' + /// Represents a set of compute sizes that can + /// serve this given size type + /// The pay-as-you-go dollar price per hour this + /// size will cost. It does not include discounts and may not reflect + /// the actual price the size will cost. This is the maximum price of + /// all prices within this tier. + /// The number of cores a VM of this + /// size has. This is the minimum number of cores within this + /// tier. + /// The amount of memory available (in GB). + /// This is the minimum amount of memory within this tier. + public EnvironmentSize(string name = default(string), IList vmSizes = default(IList), decimal? maxPrice = default(decimal?), int? minNumberOfCores = default(int?), double? minMemory = default(double?)) + { + Name = name; + VmSizes = vmSizes; + MaxPrice = maxPrice; + MinNumberOfCores = minNumberOfCores; + MinMemory = minMemory; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the size category. Possible values include: 'Basic', + /// 'Standard', 'Performance' + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets represents a set of compute sizes that can serve this + /// given size type + /// + [JsonProperty(PropertyName = "vmSizes")] + public IList VmSizes { get; set; } + + /// + /// Gets the pay-as-you-go dollar price per hour this size will cost. + /// It does not include discounts and may not reflect the actual price + /// the size will cost. This is the maximum price of all prices within + /// this tier. + /// + [JsonProperty(PropertyName = "maxPrice")] + public decimal? MaxPrice { get; private set; } + + /// + /// Gets the number of cores a VM of this size has. This is the minimum + /// number of cores within this tier. + /// + [JsonProperty(PropertyName = "minNumberOfCores")] + public int? MinNumberOfCores { get; private set; } + + /// + /// Gets the amount of memory available (in GB). This is the minimum + /// amount of memory within this tier. + /// + [JsonProperty(PropertyName = "minMemory")] + public double? MinMemory { get; private set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentSizeFragment.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentSizeFragment.cs new file mode 100644 index 000000000000..b44cf5d2c535 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/EnvironmentSizeFragment.cs @@ -0,0 +1,66 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a size category supported by this Lab Account (small, medium + /// or large) + /// + public partial class EnvironmentSizeFragment + { + /// + /// Initializes a new instance of the EnvironmentSizeFragment class. + /// + public EnvironmentSizeFragment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the EnvironmentSizeFragment class. + /// + /// The size category. Possible values include: + /// 'Basic', 'Standard', 'Performance' + /// Represents a set of compute sizes that can + /// serve this given size type + public EnvironmentSizeFragment(string name = default(string), IList vmSizes = default(IList)) + { + Name = name; + VmSizes = vmSizes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the size category. Possible values include: 'Basic', + /// 'Standard', 'Performance' + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets represents a set of compute sizes that can serve this + /// given size type + /// + [JsonProperty(PropertyName = "vmSizes")] + public IList VmSizes { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/GalleryImage.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/GalleryImage.cs new file mode 100644 index 000000000000..d37ec48047b7 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/GalleryImage.cs @@ -0,0 +1,162 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents an image from the Azure Marketplace + /// + [Rest.Serialization.JsonTransformation] + public partial class GalleryImage : Resource + { + /// + /// Initializes a new instance of the GalleryImage class. + /// + public GalleryImage() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GalleryImage class. + /// + /// The identifier of the resource. + /// The name of the resource. + /// The type of the resource. + /// The location of the resource. + /// The tags of the resource. + /// The author of the gallery image. + /// The creation date of the gallery + /// image. + /// The description of the gallery + /// image. + /// The image reference of the gallery + /// image. + /// The icon of the gallery image. + /// Indicates whether this gallery image is + /// enabled. + /// Indicates whether this gallery has been + /// overridden for this lab account + /// The third party plan that applies to this + /// image + /// Indicates if the plan has been + /// authorized for programmatic deployment. + /// The provisioning status of the + /// resource. + /// The unique immutable identifier of a + /// resource (Guid). + /// The details of the latest + /// operation. ex: status, error + public GalleryImage(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string author = default(string), System.DateTime? createdDate = default(System.DateTime?), string description = default(string), GalleryImageReference imageReference = default(GalleryImageReference), string icon = default(string), bool? isEnabled = default(bool?), bool? isOverride = default(bool?), string planId = default(string), bool? isPlanAuthorized = default(bool?), string provisioningState = default(string), string uniqueIdentifier = default(string), LatestOperationResult latestOperationResult = default(LatestOperationResult)) + : base(id, name, type, location, tags) + { + Author = author; + CreatedDate = createdDate; + Description = description; + ImageReference = imageReference; + Icon = icon; + IsEnabled = isEnabled; + IsOverride = isOverride; + PlanId = planId; + IsPlanAuthorized = isPlanAuthorized; + ProvisioningState = provisioningState; + UniqueIdentifier = uniqueIdentifier; + LatestOperationResult = latestOperationResult; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the author of the gallery image. + /// + [JsonProperty(PropertyName = "properties.author")] + public string Author { get; private set; } + + /// + /// Gets the creation date of the gallery image. + /// + [JsonProperty(PropertyName = "properties.createdDate")] + public System.DateTime? CreatedDate { get; private set; } + + /// + /// Gets the description of the gallery image. + /// + [JsonProperty(PropertyName = "properties.description")] + public string Description { get; private set; } + + /// + /// Gets the image reference of the gallery image. + /// + [JsonProperty(PropertyName = "properties.imageReference")] + public GalleryImageReference ImageReference { get; private set; } + + /// + /// Gets the icon of the gallery image. + /// + [JsonProperty(PropertyName = "properties.icon")] + public string Icon { get; private set; } + + /// + /// Gets or sets indicates whether this gallery image is enabled. + /// + [JsonProperty(PropertyName = "properties.isEnabled")] + public bool? IsEnabled { get; set; } + + /// + /// Gets or sets indicates whether this gallery has been overridden for + /// this lab account + /// + [JsonProperty(PropertyName = "properties.isOverride")] + public bool? IsOverride { get; set; } + + /// + /// Gets the third party plan that applies to this image + /// + [JsonProperty(PropertyName = "properties.planId")] + public string PlanId { get; private set; } + + /// + /// Gets or sets indicates if the plan has been authorized for + /// programmatic deployment. + /// + [JsonProperty(PropertyName = "properties.isPlanAuthorized")] + public bool? IsPlanAuthorized { get; set; } + + /// + /// Gets or sets the provisioning status of the resource. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets the unique immutable identifier of a resource (Guid). + /// + [JsonProperty(PropertyName = "properties.uniqueIdentifier")] + public string UniqueIdentifier { get; set; } + + /// + /// Gets the details of the latest operation. ex: status, error + /// + [JsonProperty(PropertyName = "properties.latestOperationResult")] + public LatestOperationResult LatestOperationResult { get; private set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/GalleryImageFragment.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/GalleryImageFragment.cs new file mode 100644 index 000000000000..728e66522fe3 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/GalleryImageFragment.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.LabServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents an image from the Azure Marketplace + /// + [Rest.Serialization.JsonTransformation] + public partial class GalleryImageFragment : Resource + { + /// + /// Initializes a new instance of the GalleryImageFragment class. + /// + public GalleryImageFragment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GalleryImageFragment class. + /// + /// The identifier of the resource. + /// The name of the resource. + /// The type of the resource. + /// The location of the resource. + /// The tags of the resource. + /// Indicates whether this gallery image is + /// enabled. + /// Indicates whether this gallery has been + /// overridden for this lab account + /// Indicates if the plan has been + /// authorized for programmatic deployment. + /// The provisioning status of the + /// resource. + /// The unique immutable identifier of a + /// resource (Guid). + public GalleryImageFragment(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), bool? isEnabled = default(bool?), bool? isOverride = default(bool?), bool? isPlanAuthorized = default(bool?), string provisioningState = default(string), string uniqueIdentifier = default(string)) + : base(id, name, type, location, tags) + { + IsEnabled = isEnabled; + IsOverride = isOverride; + IsPlanAuthorized = isPlanAuthorized; + ProvisioningState = provisioningState; + UniqueIdentifier = uniqueIdentifier; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets indicates whether this gallery image is enabled. + /// + [JsonProperty(PropertyName = "properties.isEnabled")] + public bool? IsEnabled { get; set; } + + /// + /// Gets or sets indicates whether this gallery has been overridden for + /// this lab account + /// + [JsonProperty(PropertyName = "properties.isOverride")] + public bool? IsOverride { get; set; } + + /// + /// Gets or sets indicates if the plan has been authorized for + /// programmatic deployment. + /// + [JsonProperty(PropertyName = "properties.isPlanAuthorized")] + public bool? IsPlanAuthorized { get; set; } + + /// + /// Gets or sets the provisioning status of the resource. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets the unique immutable identifier of a resource (Guid). + /// + [JsonProperty(PropertyName = "properties.uniqueIdentifier")] + public string UniqueIdentifier { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/GalleryImageReference.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/GalleryImageReference.cs new file mode 100644 index 000000000000..a4f61006bdad --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/GalleryImageReference.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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The reference information for an Azure Marketplace image. + /// + public partial class GalleryImageReference + { + /// + /// Initializes a new instance of the GalleryImageReference class. + /// + public GalleryImageReference() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GalleryImageReference class. + /// + /// The offer of the gallery image. + /// The publisher of the gallery image. + /// The SKU of the gallery image. + /// The OS type of the gallery image. + /// The version of the gallery image. + public GalleryImageReference(string offer = default(string), string publisher = default(string), string sku = default(string), string osType = default(string), string version = default(string)) + { + Offer = offer; + Publisher = publisher; + Sku = sku; + OsType = osType; + Version = version; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the offer of the gallery image. + /// + [JsonProperty(PropertyName = "offer")] + public string Offer { get; set; } + + /// + /// Gets or sets the publisher of the gallery image. + /// + [JsonProperty(PropertyName = "publisher")] + public string Publisher { get; set; } + + /// + /// Gets or sets the SKU of the gallery image. + /// + [JsonProperty(PropertyName = "sku")] + public string Sku { get; set; } + + /// + /// Gets or sets the OS type of the gallery image. + /// + [JsonProperty(PropertyName = "osType")] + public string OsType { get; set; } + + /// + /// Gets or sets the version of the gallery image. + /// + [JsonProperty(PropertyName = "version")] + public string Version { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/GalleryImageReferenceFragment.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/GalleryImageReferenceFragment.cs new file mode 100644 index 000000000000..17aaa0df3794 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/GalleryImageReferenceFragment.cs @@ -0,0 +1,85 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The reference information for an Azure Marketplace image. + /// + public partial class GalleryImageReferenceFragment + { + /// + /// Initializes a new instance of the GalleryImageReferenceFragment + /// class. + /// + public GalleryImageReferenceFragment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GalleryImageReferenceFragment + /// class. + /// + /// The offer of the gallery image. + /// The publisher of the gallery image. + /// The SKU of the gallery image. + /// The OS type of the gallery image. + /// The version of the gallery image. + public GalleryImageReferenceFragment(string offer = default(string), string publisher = default(string), string sku = default(string), string osType = default(string), string version = default(string)) + { + Offer = offer; + Publisher = publisher; + Sku = sku; + OsType = osType; + Version = version; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the offer of the gallery image. + /// + [JsonProperty(PropertyName = "offer")] + public string Offer { get; set; } + + /// + /// Gets or sets the publisher of the gallery image. + /// + [JsonProperty(PropertyName = "publisher")] + public string Publisher { get; set; } + + /// + /// Gets or sets the SKU of the gallery image. + /// + [JsonProperty(PropertyName = "sku")] + public string Sku { get; set; } + + /// + /// Gets or sets the OS type of the gallery image. + /// + [JsonProperty(PropertyName = "osType")] + public string OsType { get; set; } + + /// + /// Gets or sets the version of the gallery image. + /// + [JsonProperty(PropertyName = "version")] + public string Version { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/GetEnvironmentResponse.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/GetEnvironmentResponse.cs new file mode 100644 index 000000000000..ab340303d8ae --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/GetEnvironmentResponse.cs @@ -0,0 +1,51 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents the environments details + /// + public partial class GetEnvironmentResponse + { + /// + /// Initializes a new instance of the GetEnvironmentResponse class. + /// + public GetEnvironmentResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GetEnvironmentResponse class. + /// + /// Details of the environment + public GetEnvironmentResponse(EnvironmentDetails environment = default(EnvironmentDetails)) + { + Environment = environment; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets details of the environment + /// + [JsonProperty(PropertyName = "environment")] + public EnvironmentDetails Environment { get; private set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/GetPersonalPreferencesResponse.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/GetPersonalPreferencesResponse.cs new file mode 100644 index 000000000000..22556ea81636 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/GetPersonalPreferencesResponse.cs @@ -0,0 +1,64 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents the PersonalPreferences for the user + /// + public partial class GetPersonalPreferencesResponse + { + /// + /// Initializes a new instance of the GetPersonalPreferencesResponse + /// class. + /// + public GetPersonalPreferencesResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GetPersonalPreferencesResponse + /// class. + /// + /// Id to be used by the cache orchestrator + /// Array of favorite lab resource + /// ids + public GetPersonalPreferencesResponse(string id = default(string), IList favoriteLabResourceIds = default(IList)) + { + Id = id; + FavoriteLabResourceIds = favoriteLabResourceIds; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets id to be used by the cache orchestrator + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets array of favorite lab resource ids + /// + [JsonProperty(PropertyName = "favoriteLabResourceIds")] + public IList FavoriteLabResourceIds { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/GetRegionalAvailabilityResponse.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/GetRegionalAvailabilityResponse.cs new file mode 100644 index 000000000000..3b1fe9a1c287 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/GetRegionalAvailabilityResponse.cs @@ -0,0 +1,57 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The response model from the GetRegionalAvailability action + /// + public partial class GetRegionalAvailabilityResponse + { + /// + /// Initializes a new instance of the GetRegionalAvailabilityResponse + /// class. + /// + public GetRegionalAvailabilityResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the GetRegionalAvailabilityResponse + /// class. + /// + /// Availability information for + /// different size categories per region + public GetRegionalAvailabilityResponse(IList regionalAvailability = default(IList)) + { + RegionalAvailability = regionalAvailability; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets availability information for different size categories + /// per region + /// + [JsonProperty(PropertyName = "regionalAvailability")] + public IList RegionalAvailability { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/Lab.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/Lab.cs new file mode 100644 index 000000000000..30c000d93cc2 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/Lab.cs @@ -0,0 +1,156 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a lab. + /// + [Rest.Serialization.JsonTransformation] + public partial class Lab : Resource + { + /// + /// Initializes a new instance of the Lab class. + /// + public Lab() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Lab class. + /// + /// The identifier of the resource. + /// The name of the resource. + /// The type of the resource. + /// The location of the resource. + /// The tags of the resource. + /// Maximum number of users allowed in the + /// lab. + /// Maximum value MaxUsersInLab can be set to, + /// as specified by the service + /// Invitation code that users can use to + /// join a lab. + /// Object id of the user that created + /// the lab. + /// Maximum duration a user can use an + /// environment for in the lab. + /// Lab user access mode (open to all vs. + /// restricted to those listed on the lab). Possible values include: + /// 'Restricted', 'Open' + /// Lab creator name + /// Creation date for the lab + /// The provisioning status of the + /// resource. + /// The unique immutable identifier of a + /// resource (Guid). + /// The details of the latest + /// operation. ex: status, error + public Lab(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), int? maxUsersInLab = default(int?), int? userQuota = default(int?), string invitationCode = default(string), string createdByObjectId = default(string), System.TimeSpan? usageQuota = default(System.TimeSpan?), string userAccessMode = default(string), string createdByUserPrincipalName = default(string), System.DateTime? createdDate = default(System.DateTime?), string provisioningState = default(string), string uniqueIdentifier = default(string), LatestOperationResult latestOperationResult = default(LatestOperationResult)) + : base(id, name, type, location, tags) + { + MaxUsersInLab = maxUsersInLab; + UserQuota = userQuota; + InvitationCode = invitationCode; + CreatedByObjectId = createdByObjectId; + UsageQuota = usageQuota; + UserAccessMode = userAccessMode; + CreatedByUserPrincipalName = createdByUserPrincipalName; + CreatedDate = createdDate; + ProvisioningState = provisioningState; + UniqueIdentifier = uniqueIdentifier; + LatestOperationResult = latestOperationResult; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets maximum number of users allowed in the lab. + /// + [JsonProperty(PropertyName = "properties.maxUsersInLab")] + public int? MaxUsersInLab { get; set; } + + /// + /// Gets maximum value MaxUsersInLab can be set to, as specified by the + /// service + /// + [JsonProperty(PropertyName = "properties.userQuota")] + public int? UserQuota { get; private set; } + + /// + /// Gets invitation code that users can use to join a lab. + /// + [JsonProperty(PropertyName = "properties.invitationCode")] + public string InvitationCode { get; private set; } + + /// + /// Gets object id of the user that created the lab. + /// + [JsonProperty(PropertyName = "properties.createdByObjectId")] + public string CreatedByObjectId { get; private set; } + + /// + /// Gets or sets maximum duration a user can use an environment for in + /// the lab. + /// + [JsonProperty(PropertyName = "properties.usageQuota")] + public System.TimeSpan? UsageQuota { get; set; } + + /// + /// Gets or sets lab user access mode (open to all vs. restricted to + /// those listed on the lab). Possible values include: 'Restricted', + /// 'Open' + /// + [JsonProperty(PropertyName = "properties.userAccessMode")] + public string UserAccessMode { get; set; } + + /// + /// Gets lab creator name + /// + [JsonProperty(PropertyName = "properties.createdByUserPrincipalName")] + public string CreatedByUserPrincipalName { get; private set; } + + /// + /// Gets creation date for the lab + /// + [JsonProperty(PropertyName = "properties.createdDate")] + public System.DateTime? CreatedDate { get; private set; } + + /// + /// Gets or sets the provisioning status of the resource. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets the unique immutable identifier of a resource (Guid). + /// + [JsonProperty(PropertyName = "properties.uniqueIdentifier")] + public string UniqueIdentifier { get; set; } + + /// + /// Gets the details of the latest operation. ex: status, error + /// + [JsonProperty(PropertyName = "properties.latestOperationResult")] + public LatestOperationResult LatestOperationResult { get; private set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabAccount.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabAccount.cs new file mode 100644 index 000000000000..80aac0401c1b --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabAccount.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.LabServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a lab account. + /// + [Rest.Serialization.JsonTransformation] + public partial class LabAccount : Resource + { + /// + /// Initializes a new instance of the LabAccount class. + /// + public LabAccount() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LabAccount class. + /// + /// The identifier of the resource. + /// The name of the resource. + /// The type of the resource. + /// The location of the resource. + /// The tags of the resource. + /// Represents the size configuration + /// under the lab account + /// Represents if region selection + /// is enabled + /// The provisioning status of the + /// resource. + /// The unique immutable identifier of a + /// resource (Guid). + /// The details of the latest + /// operation. ex: status, error + public LabAccount(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), SizeConfigurationProperties sizeConfiguration = default(SizeConfigurationProperties), bool? enabledRegionSelection = default(bool?), string provisioningState = default(string), string uniqueIdentifier = default(string), LatestOperationResult latestOperationResult = default(LatestOperationResult)) + : base(id, name, type, location, tags) + { + SizeConfiguration = sizeConfiguration; + EnabledRegionSelection = enabledRegionSelection; + ProvisioningState = provisioningState; + UniqueIdentifier = uniqueIdentifier; + LatestOperationResult = latestOperationResult; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets represents the size configuration under the lab account + /// + [JsonProperty(PropertyName = "properties.sizeConfiguration")] + public SizeConfigurationProperties SizeConfiguration { get; private set; } + + /// + /// Gets or sets represents if region selection is enabled + /// + [JsonProperty(PropertyName = "properties.enabledRegionSelection")] + public bool? EnabledRegionSelection { get; set; } + + /// + /// Gets or sets the provisioning status of the resource. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets the unique immutable identifier of a resource (Guid). + /// + [JsonProperty(PropertyName = "properties.uniqueIdentifier")] + public string UniqueIdentifier { get; set; } + + /// + /// Gets the details of the latest operation. ex: status, error + /// + [JsonProperty(PropertyName = "properties.latestOperationResult")] + public LatestOperationResult LatestOperationResult { get; private set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabAccountFragment.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabAccountFragment.cs new file mode 100644 index 000000000000..ad6f8f58601d --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabAccountFragment.cs @@ -0,0 +1,81 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a lab account. + /// + [Rest.Serialization.JsonTransformation] + public partial class LabAccountFragment : Resource + { + /// + /// Initializes a new instance of the LabAccountFragment class. + /// + public LabAccountFragment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LabAccountFragment class. + /// + /// The identifier of the resource. + /// The name of the resource. + /// The type of the resource. + /// The location of the resource. + /// The tags of the resource. + /// Represents if region selection + /// is enabled + /// The provisioning status of the + /// resource. + /// The unique immutable identifier of a + /// resource (Guid). + public LabAccountFragment(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), bool? enabledRegionSelection = default(bool?), string provisioningState = default(string), string uniqueIdentifier = default(string)) + : base(id, name, type, location, tags) + { + EnabledRegionSelection = enabledRegionSelection; + ProvisioningState = provisioningState; + UniqueIdentifier = uniqueIdentifier; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets represents if region selection is enabled + /// + [JsonProperty(PropertyName = "properties.enabledRegionSelection")] + public bool? EnabledRegionSelection { get; set; } + + /// + /// Gets or sets the provisioning status of the resource. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets the unique immutable identifier of a resource (Guid). + /// + [JsonProperty(PropertyName = "properties.uniqueIdentifier")] + public string UniqueIdentifier { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabCreationParameters.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabCreationParameters.cs new file mode 100644 index 000000000000..24d977e41d2e --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabCreationParameters.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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Settings related to creating a lab + /// + public partial class LabCreationParameters + { + /// + /// Initializes a new instance of the LabCreationParameters class. + /// + public LabCreationParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LabCreationParameters class. + /// + /// Maximum number of users allowed in the + /// lab. + public LabCreationParameters(int? maxUsersInLab = default(int?)) + { + MaxUsersInLab = maxUsersInLab; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets maximum number of users allowed in the lab. + /// + [JsonProperty(PropertyName = "maxUsersInLab")] + public int? MaxUsersInLab { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabDetails.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabDetails.cs new file mode 100644 index 000000000000..895eb2ac87b9 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabDetails.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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// This represents the details about a lab that the User is in, and its + /// state. + /// + public partial class LabDetails + { + /// + /// Initializes a new instance of the LabDetails class. + /// + public LabDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LabDetails class. + /// + /// Name of the lab + /// The provisioning state of the + /// lab. + /// The Id of the lab. + /// The maximum duration a user can use a VM + /// in this lab. + public LabDetails(string name = default(string), string provisioningState = default(string), string id = default(string), System.TimeSpan? usageQuota = default(System.TimeSpan?)) + { + Name = name; + ProvisioningState = provisioningState; + Id = id; + UsageQuota = usageQuota; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets name of the lab + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the provisioning state of the lab. + /// + [JsonProperty(PropertyName = "provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets the Id of the lab. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets the maximum duration a user can use a VM in this lab. + /// + [JsonProperty(PropertyName = "usageQuota")] + public System.TimeSpan? UsageQuota { get; private set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabFragment.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabFragment.cs new file mode 100644 index 000000000000..ac90012ba003 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabFragment.cs @@ -0,0 +1,103 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents a lab. + /// + [Rest.Serialization.JsonTransformation] + public partial class LabFragment : Resource + { + /// + /// Initializes a new instance of the LabFragment class. + /// + public LabFragment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LabFragment class. + /// + /// The identifier of the resource. + /// The name of the resource. + /// The type of the resource. + /// The location of the resource. + /// The tags of the resource. + /// Maximum number of users allowed in the + /// lab. + /// Maximum duration a user can use an + /// environment for in the lab. + /// Lab user access mode (open to all vs. + /// restricted to those listed on the lab). Possible values include: + /// 'Restricted', 'Open' + /// The provisioning status of the + /// resource. + /// The unique immutable identifier of a + /// resource (Guid). + public LabFragment(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), int? maxUsersInLab = default(int?), System.TimeSpan? usageQuota = default(System.TimeSpan?), string userAccessMode = default(string), string provisioningState = default(string), string uniqueIdentifier = default(string)) + : base(id, name, type, location, tags) + { + MaxUsersInLab = maxUsersInLab; + UsageQuota = usageQuota; + UserAccessMode = userAccessMode; + ProvisioningState = provisioningState; + UniqueIdentifier = uniqueIdentifier; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets maximum number of users allowed in the lab. + /// + [JsonProperty(PropertyName = "properties.maxUsersInLab")] + public int? MaxUsersInLab { get; set; } + + /// + /// Gets or sets maximum duration a user can use an environment for in + /// the lab. + /// + [JsonProperty(PropertyName = "properties.usageQuota")] + public System.TimeSpan? UsageQuota { get; set; } + + /// + /// Gets or sets lab user access mode (open to all vs. restricted to + /// those listed on the lab). Possible values include: 'Restricted', + /// 'Open' + /// + [JsonProperty(PropertyName = "properties.userAccessMode")] + public string UserAccessMode { get; set; } + + /// + /// Gets or sets the provisioning status of the resource. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets the unique immutable identifier of a resource (Guid). + /// + [JsonProperty(PropertyName = "properties.uniqueIdentifier")] + public string UniqueIdentifier { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabUserAccessMode.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabUserAccessMode.cs new file mode 100644 index 000000000000..52da5cf473c5 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/LabUserAccessMode.cs @@ -0,0 +1,28 @@ +// +// 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.LabServices.Models +{ + + /// + /// Defines values for LabUserAccessMode. + /// + public static class LabUserAccessMode + { + /// + /// Only users registered with the lab can access VMs. + /// + public const string Restricted = "Restricted"; + /// + /// Any user can register with the lab and access its VMs. + /// + public const string Open = "Open"; + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/LatestOperationResult.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/LatestOperationResult.cs new file mode 100644 index 000000000000..3c2cf8a49d91 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/LatestOperationResult.cs @@ -0,0 +1,93 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Details of the status of an operation. + /// + public partial class LatestOperationResult + { + /// + /// Initializes a new instance of the LatestOperationResult class. + /// + public LatestOperationResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the LatestOperationResult class. + /// + /// The current status of the operation. + /// Error code on failure. + /// The error message. + /// Request URI of the operation. + /// The HttpMethod - PUT/POST/DELETE for the + /// operation. + /// The URL to use to check long-running + /// operation status + public LatestOperationResult(string status = default(string), string errorCode = default(string), string errorMessage = default(string), string requestUri = default(string), string httpMethod = default(string), string operationUrl = default(string)) + { + Status = status; + ErrorCode = errorCode; + ErrorMessage = errorMessage; + RequestUri = requestUri; + HttpMethod = httpMethod; + OperationUrl = operationUrl; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the current status of the operation. + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; private set; } + + /// + /// Gets error code on failure. + /// + [JsonProperty(PropertyName = "errorCode")] + public string ErrorCode { get; private set; } + + /// + /// Gets the error message. + /// + [JsonProperty(PropertyName = "errorMessage")] + public string ErrorMessage { get; private set; } + + /// + /// Gets request URI of the operation. + /// + [JsonProperty(PropertyName = "requestUri")] + public string RequestUri { get; private set; } + + /// + /// Gets the HttpMethod - PUT/POST/DELETE for the operation. + /// + [JsonProperty(PropertyName = "httpMethod")] + public string HttpMethod { get; private set; } + + /// + /// Gets the URL to use to check long-running operation status + /// + [JsonProperty(PropertyName = "operationUrl")] + public string OperationUrl { get; private set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/ListEnvironmentsPayload.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ListEnvironmentsPayload.cs new file mode 100644 index 000000000000..2c82acf17143 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ListEnvironmentsPayload.cs @@ -0,0 +1,51 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents the payload to list environments owned by a user + /// + public partial class ListEnvironmentsPayload + { + /// + /// Initializes a new instance of the ListEnvironmentsPayload class. + /// + public ListEnvironmentsPayload() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ListEnvironmentsPayload class. + /// + /// The resource Id of the lab + public ListEnvironmentsPayload(string labId = default(string)) + { + LabId = labId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource Id of the lab + /// + [JsonProperty(PropertyName = "labId")] + public string LabId { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/ListEnvironmentsResponse.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ListEnvironmentsResponse.cs new file mode 100644 index 000000000000..87685b885d02 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ListEnvironmentsResponse.cs @@ -0,0 +1,53 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents the list of environments owned by a user + /// + public partial class ListEnvironmentsResponse + { + /// + /// Initializes a new instance of the ListEnvironmentsResponse class. + /// + public ListEnvironmentsResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ListEnvironmentsResponse class. + /// + /// List of all the evironments + public ListEnvironmentsResponse(IList environments = default(IList)) + { + Environments = environments; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of all the evironments + /// + [JsonProperty(PropertyName = "environments")] + public IList Environments { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/ListLabsResponse.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ListLabsResponse.cs new file mode 100644 index 000000000000..859e802a6ba0 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ListLabsResponse.cs @@ -0,0 +1,53 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Lists the labs owned by a user + /// + public partial class ListLabsResponse + { + /// + /// Initializes a new instance of the ListLabsResponse class. + /// + public ListLabsResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ListLabsResponse class. + /// + /// List of all the labs + public ListLabsResponse(IList labs = default(IList)) + { + Labs = labs; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets list of all the labs + /// + [JsonProperty(PropertyName = "labs")] + public IList Labs { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/ManagedLabVmSize.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ManagedLabVmSize.cs new file mode 100644 index 000000000000..9e6ddc7ef086 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ManagedLabVmSize.cs @@ -0,0 +1,32 @@ +// +// 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.LabServices.Models +{ + + /// + /// Defines values for ManagedLabVmSize. + /// + public static class ManagedLabVmSize + { + /// + /// The base VM size + /// + public const string Basic = "Basic"; + /// + /// The standard or default VM size + /// + public const string Standard = "Standard"; + /// + /// The most performant VM size + /// + public const string Performance = "Performance"; + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/NetworkInterface.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/NetworkInterface.cs new file mode 100644 index 000000000000..104f15954a9d --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/NetworkInterface.cs @@ -0,0 +1,77 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Network details of the environment + /// + public partial class NetworkInterface + { + /// + /// Initializes a new instance of the NetworkInterface class. + /// + public NetworkInterface() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the NetworkInterface class. + /// + /// PrivateIp address of the Compute + /// VM + /// Connection information for Linux + /// Connection information for + /// Windows + /// Username of the VM + public NetworkInterface(string privateIpAddress = default(string), string sshAuthority = default(string), string rdpAuthority = default(string), string username = default(string)) + { + PrivateIpAddress = privateIpAddress; + SshAuthority = sshAuthority; + RdpAuthority = rdpAuthority; + Username = username; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets privateIp address of the Compute VM + /// + [JsonProperty(PropertyName = "privateIpAddress")] + public string PrivateIpAddress { get; private set; } + + /// + /// Gets connection information for Linux + /// + [JsonProperty(PropertyName = "sshAuthority")] + public string SshAuthority { get; private set; } + + /// + /// Gets connection information for Windows + /// + [JsonProperty(PropertyName = "rdpAuthority")] + public string RdpAuthority { get; private set; } + + /// + /// Gets username of the VM + /// + [JsonProperty(PropertyName = "username")] + public string Username { get; private set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationBatchStatusPayload.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationBatchStatusPayload.cs new file mode 100644 index 000000000000..f909b33140bb --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationBatchStatusPayload.cs @@ -0,0 +1,70 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Payload to get the status of an operation + /// + public partial class OperationBatchStatusPayload + { + /// + /// Initializes a new instance of the OperationBatchStatusPayload + /// class. + /// + public OperationBatchStatusPayload() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationBatchStatusPayload + /// class. + /// + /// The operation url of long running + /// operation + public OperationBatchStatusPayload(IList urls) + { + Urls = urls; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the operation url of long running operation + /// + [JsonProperty(PropertyName = "urls")] + public IList Urls { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Urls == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Urls"); + } + } + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationBatchStatusResponse.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationBatchStatusResponse.cs new file mode 100644 index 000000000000..ac1a3c6e432b --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationBatchStatusResponse.cs @@ -0,0 +1,57 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Status Details of the long running operation for an environment + /// + public partial class OperationBatchStatusResponse + { + /// + /// Initializes a new instance of the OperationBatchStatusResponse + /// class. + /// + public OperationBatchStatusResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationBatchStatusResponse + /// class. + /// + /// Gets a collection of items that contain the + /// operation url and status. + public OperationBatchStatusResponse(IList items = default(IList)) + { + Items = items; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets a collection of items that contain the operation url and + /// status. + /// + [JsonProperty(PropertyName = "items")] + public IList Items { get; private set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationBatchStatusResponseItem.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationBatchStatusResponseItem.cs new file mode 100644 index 000000000000..0d3a52be95e4 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationBatchStatusResponseItem.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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents the status of an operation that used the batch API. + /// + public partial class OperationBatchStatusResponseItem + { + /// + /// Initializes a new instance of the OperationBatchStatusResponseItem + /// class. + /// + public OperationBatchStatusResponseItem() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationBatchStatusResponseItem + /// class. + /// + /// status of the long running operation for + /// an environment + /// status of the long running operation for an + /// environment + public OperationBatchStatusResponseItem(string operationUrl = default(string), string status = default(string)) + { + OperationUrl = operationUrl; + Status = status; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets status of the long running operation for an environment + /// + [JsonProperty(PropertyName = "operationUrl")] + public string OperationUrl { get; private set; } + + /// + /// Gets status of the long running operation for an environment + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; private set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationError.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationError.cs new file mode 100644 index 000000000000..43e7eb721b21 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationError.cs @@ -0,0 +1,60 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Error details for the operation in case of a failure. + /// + public partial class OperationError + { + /// + /// Initializes a new instance of the OperationError class. + /// + public OperationError() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationError class. + /// + /// The error code of the operation error. + /// The error message of the operation + /// error. + public OperationError(string code = default(string), string message = default(string)) + { + Code = code; + Message = message; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the error code of the operation error. + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// Gets or sets the error message of the operation error. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationMetadata.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationMetadata.cs new file mode 100644 index 000000000000..6bf9c00e2c65 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationMetadata.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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The REST API operation supported by ManagedLab ResourceProvider. + /// + public partial class OperationMetadata + { + /// + /// Initializes a new instance of the OperationMetadata class. + /// + public OperationMetadata() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationMetadata class. + /// + /// Operation name: + /// {provider}/{resource}/{operation} + /// The object that describes the + /// operations + public OperationMetadata(string name = default(string), OperationMetadataDisplay display = default(OperationMetadataDisplay)) + { + Name = name; + Display = display; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets operation name: {provider}/{resource}/{operation} + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the object that describes the operations + /// + [JsonProperty(PropertyName = "display")] + public OperationMetadataDisplay Display { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationMetadataDisplay.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationMetadataDisplay.cs new file mode 100644 index 000000000000..8d75c14151e0 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationMetadataDisplay.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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// The object that describes the operations + /// + public partial class OperationMetadataDisplay + { + /// + /// Initializes a new instance of the OperationMetadataDisplay class. + /// + public OperationMetadataDisplay() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationMetadataDisplay class. + /// + /// Friendly name of the resource + /// provider + /// Resource type on which the operation is + /// performed. + /// Operation type: read, write, delete, + /// listKeys/action, etc. + /// Friendly name of the operation + public OperationMetadataDisplay(string provider = default(string), string resource = default(string), string operation = default(string), string description = default(string)) + { + Provider = provider; + Resource = resource; + Operation = operation; + Description = description; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets friendly name of the resource provider + /// + [JsonProperty(PropertyName = "provider")] + public string Provider { get; set; } + + /// + /// Gets or sets resource type on which the operation is performed. + /// + [JsonProperty(PropertyName = "resource")] + public string Resource { get; set; } + + /// + /// Gets or sets operation type: read, write, delete, listKeys/action, + /// etc. + /// + [JsonProperty(PropertyName = "operation")] + public string Operation { get; set; } + + /// + /// Gets or sets friendly name of the operation + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationResult.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationResult.cs new file mode 100644 index 000000000000..0180eb81b326 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationResult.cs @@ -0,0 +1,60 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// An Operation Result + /// + public partial class OperationResult + { + /// + /// Initializes a new instance of the OperationResult class. + /// + public OperationResult() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationResult class. + /// + /// The operation status. + /// Error details for the operation in case of a + /// failure. + public OperationResult(string status = default(string), OperationError error = default(OperationError)) + { + Status = status; + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the operation status. + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; set; } + + /// + /// Gets or sets error details for the operation in case of a failure. + /// + [JsonProperty(PropertyName = "error")] + public OperationError Error { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationStatusPayload.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationStatusPayload.cs new file mode 100644 index 000000000000..b2e20f183049 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationStatusPayload.cs @@ -0,0 +1,66 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Payload to get the status of an operation + /// + public partial class OperationStatusPayload + { + /// + /// Initializes a new instance of the OperationStatusPayload class. + /// + public OperationStatusPayload() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationStatusPayload class. + /// + /// The operation url of long running + /// operation + public OperationStatusPayload(string operationUrl) + { + OperationUrl = operationUrl; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the operation url of long running operation + /// + [JsonProperty(PropertyName = "operationUrl")] + public string OperationUrl { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (OperationUrl == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "OperationUrl"); + } + } + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationStatusResponse.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationStatusResponse.cs new file mode 100644 index 000000000000..2adb751e6d51 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/OperationStatusResponse.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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Status Details of the long running operation for an environment + /// + public partial class OperationStatusResponse + { + /// + /// Initializes a new instance of the OperationStatusResponse class. + /// + public OperationStatusResponse() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationStatusResponse class. + /// + /// status of the long running operation for an + /// environment + public OperationStatusResponse(string status = default(string)) + { + Status = status; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets status of the long running operation for an environment + /// + [JsonProperty(PropertyName = "status")] + public string Status { get; private set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/Page.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/Page.cs new file mode 100644 index 000000000000..461a1a710cdc --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/Page.cs @@ -0,0 +1,53 @@ +// +// 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.LabServices.Models +{ + 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/LabServices/Management.LabServices/Generated/Models/PersonalPerferencesOperationsPayload.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/PersonalPerferencesOperationsPayload.cs new file mode 100644 index 000000000000..9fb40d324c4a --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/PersonalPerferencesOperationsPayload.cs @@ -0,0 +1,76 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents payload for any Environment operations like get, start, + /// stop, connect + /// + public partial class PersonalPerferencesOperationsPayload + { + /// + /// Initializes a new instance of the + /// PersonalPerferencesOperationsPayload class. + /// + public PersonalPerferencesOperationsPayload() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// PersonalPerferencesOperationsPayload class. + /// + /// Resource Id of the lab + /// account + /// Enum indicating if user is adding or + /// removing a favorite lab. Possible values include: 'Add', + /// 'Remove' + /// Resource Id of the lab to add/remove + /// from the favorites list + public PersonalPerferencesOperationsPayload(string labAccountResourceId = default(string), string addRemove = default(string), string labResourceId = default(string)) + { + LabAccountResourceId = labAccountResourceId; + AddRemove = addRemove; + LabResourceId = labResourceId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets resource Id of the lab account + /// + [JsonProperty(PropertyName = "labAccountResourceId")] + public string LabAccountResourceId { get; set; } + + /// + /// Gets or sets enum indicating if user is adding or removing a + /// favorite lab. Possible values include: 'Add', 'Remove' + /// + [JsonProperty(PropertyName = "addRemove")] + public string AddRemove { get; set; } + + /// + /// Gets or sets resource Id of the lab to add/remove from the + /// favorites list + /// + [JsonProperty(PropertyName = "labResourceId")] + public string LabResourceId { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/PublishPayload.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/PublishPayload.cs new file mode 100644 index 000000000000..f1c65bea5516 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/PublishPayload.cs @@ -0,0 +1,53 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Payload for Publish operation on EnvironmentSetting. + /// + public partial class PublishPayload + { + /// + /// Initializes a new instance of the PublishPayload class. + /// + public PublishPayload() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the PublishPayload class. + /// + /// Whether to use existing VM custom + /// image when publishing. + public PublishPayload(bool? useExistingImage = default(bool?)) + { + UseExistingImage = useExistingImage; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets whether to use existing VM custom image when + /// publishing. + /// + [JsonProperty(PropertyName = "useExistingImage")] + public bool? UseExistingImage { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/PublishingState.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/PublishingState.cs new file mode 100644 index 000000000000..98e8612f4a93 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/PublishingState.cs @@ -0,0 +1,40 @@ +// +// 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.LabServices.Models +{ + + /// + /// Defines values for PublishingState. + /// + public static class PublishingState + { + /// + /// Initial state of an environment setting. + /// + public const string Draft = "Draft"; + /// + /// Currently provisioning resources. + /// + public const string Publishing = "Publishing"; + /// + /// All resources are currently provisioned. + /// + public const string Published = "Published"; + /// + /// Failed to provision all the necessary resources. + /// + public const string PublishFailed = "PublishFailed"; + /// + /// Currently provisioning resources without recreating VM image. + /// + public const string Scaling = "Scaling"; + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/ReferenceVm.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ReferenceVm.cs new file mode 100644 index 000000000000..0d36348d4821 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ReferenceVm.cs @@ -0,0 +1,93 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Details of a Reference Vm + /// + public partial class ReferenceVm + { + /// + /// Initializes a new instance of the ReferenceVm class. + /// + public ReferenceVm() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ReferenceVm class. + /// + /// The username of the virtual machine + /// The password of the virtual machine. This + /// will be set to null in GET resource API + /// The state details for the reference + /// virtual machine. + /// VM resource Id for the + /// environment + public ReferenceVm(string userName, string password = default(string), VmStateDetails vmStateDetails = default(VmStateDetails), string vmResourceId = default(string)) + { + UserName = userName; + Password = password; + VmStateDetails = vmStateDetails; + VmResourceId = vmResourceId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the username of the virtual machine + /// + [JsonProperty(PropertyName = "userName")] + public string UserName { get; set; } + + /// + /// Gets or sets the password of the virtual machine. This will be set + /// to null in GET resource API + /// + [JsonProperty(PropertyName = "password")] + public string Password { get; set; } + + /// + /// Gets the state details for the reference virtual machine. + /// + [JsonProperty(PropertyName = "vmStateDetails")] + public VmStateDetails VmStateDetails { get; private set; } + + /// + /// Gets VM resource Id for the environment + /// + [JsonProperty(PropertyName = "vmResourceId")] + public string VmResourceId { get; private set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (UserName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "UserName"); + } + } + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/ReferenceVmCreationParameters.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ReferenceVmCreationParameters.cs new file mode 100644 index 000000000000..704dd43d04d6 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ReferenceVmCreationParameters.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.LabServices.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Creation parameters for Reference Vm + /// + public partial class ReferenceVmCreationParameters + { + /// + /// Initializes a new instance of the ReferenceVmCreationParameters + /// class. + /// + public ReferenceVmCreationParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ReferenceVmCreationParameters + /// class. + /// + /// The username of the virtual machine + /// The password of the virtual machine. + public ReferenceVmCreationParameters(string userName, string password) + { + UserName = userName; + Password = password; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the username of the virtual machine + /// + [JsonProperty(PropertyName = "userName")] + public string UserName { get; set; } + + /// + /// Gets or sets the password of the virtual machine. + /// + [JsonProperty(PropertyName = "password")] + public string Password { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (UserName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "UserName"); + } + if (Password == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Password"); + } + } + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/ReferenceVmFragment.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ReferenceVmFragment.cs new file mode 100644 index 000000000000..241f533417a3 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ReferenceVmFragment.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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Details of a Reference Vm + /// + public partial class ReferenceVmFragment + { + /// + /// Initializes a new instance of the ReferenceVmFragment class. + /// + public ReferenceVmFragment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ReferenceVmFragment class. + /// + /// The username of the virtual machine + /// The password of the virtual machine. This + /// will be set to null in GET resource API + public ReferenceVmFragment(string userName = default(string), string password = default(string)) + { + UserName = userName; + Password = password; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the username of the virtual machine + /// + [JsonProperty(PropertyName = "userName")] + public string UserName { get; set; } + + /// + /// Gets or sets the password of the virtual machine. This will be set + /// to null in GET resource API + /// + [JsonProperty(PropertyName = "password")] + public string Password { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/RegionalAvailability.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/RegionalAvailability.cs new file mode 100644 index 000000000000..35cf9a42a72a --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/RegionalAvailability.cs @@ -0,0 +1,62 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The availability information of sizes across regions + /// + public partial class RegionalAvailability + { + /// + /// Initializes a new instance of the RegionalAvailability class. + /// + public RegionalAvailability() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RegionalAvailability class. + /// + /// Corresponding region + /// List of all the size information + /// for the region + public RegionalAvailability(string region = default(string), IList sizeAvailabilities = default(IList)) + { + Region = region; + SizeAvailabilities = sizeAvailabilities; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets corresponding region + /// + [JsonProperty(PropertyName = "region")] + public string Region { get; set; } + + /// + /// Gets or sets list of all the size information for the region + /// + [JsonProperty(PropertyName = "sizeAvailabilities")] + public IList SizeAvailabilities { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/RegisterPayload.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/RegisterPayload.cs new file mode 100644 index 000000000000..74808148f3aa --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/RegisterPayload.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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents payload for Register action. + /// + public partial class RegisterPayload + { + /// + /// Initializes a new instance of the RegisterPayload class. + /// + public RegisterPayload() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the RegisterPayload class. + /// + /// The registration code of the + /// lab. + public RegisterPayload(string registrationCode = default(string)) + { + RegistrationCode = registrationCode; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the registration code of the lab. + /// + [JsonProperty(PropertyName = "registrationCode")] + public string RegistrationCode { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResetPasswordPayload.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResetPasswordPayload.cs new file mode 100644 index 000000000000..73ed26d3c0db --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResetPasswordPayload.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.LabServices.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents the payload for resetting passwords. + /// + public partial class ResetPasswordPayload + { + /// + /// Initializes a new instance of the ResetPasswordPayload class. + /// + public ResetPasswordPayload() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResetPasswordPayload class. + /// + /// The resourceId of the + /// environment + /// The username for which the password will be + /// reset. + /// The password to assign to the user specified + /// in + public ResetPasswordPayload(string environmentId, string username = default(string), string password = default(string)) + { + EnvironmentId = environmentId; + Username = username; + Password = password; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resourceId of the environment + /// + [JsonProperty(PropertyName = "environmentId")] + public string EnvironmentId { get; set; } + + /// + /// Gets or sets the username for which the password will be reset. + /// + [JsonProperty(PropertyName = "username")] + public string Username { get; set; } + + /// + /// Gets or sets the password to assign to the user specified in + /// + [JsonProperty(PropertyName = "password")] + public string Password { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (EnvironmentId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "EnvironmentId"); + } + } + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/Resource.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/Resource.cs new file mode 100644 index 000000000000..8c09b7bf4a2e --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/Resource.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.LabServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// An Azure resource. + /// + public partial class Resource : IResource + { + /// + /// Initializes a new instance of the Resource class. + /// + public Resource() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Resource class. + /// + /// The identifier of the resource. + /// The name of the resource. + /// The type of the resource. + /// The location of the resource. + /// The tags of the resource. + public Resource(string id = default(string), string name = default(string), string type = default(string), string location = 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 the identifier of the resource. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets the name of the resource. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; private set; } + + /// + /// Gets the type of the resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; private set; } + + /// + /// Gets or sets the location of the resource. + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the tags of the resource. + /// + [JsonProperty(PropertyName = "tags")] + public IDictionary Tags { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResourceSet.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResourceSet.cs new file mode 100644 index 000000000000..29d329eb4a18 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResourceSet.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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a VM and the setting Id it was created for. + /// + public partial class ResourceSet + { + /// + /// Initializes a new instance of the ResourceSet class. + /// + public ResourceSet() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceSet class. + /// + /// VM resource Id for the + /// environment + /// resourceSettingId for the + /// environment + public ResourceSet(string vmResourceId = default(string), string resourceSettingId = default(string)) + { + VmResourceId = vmResourceId; + ResourceSettingId = resourceSettingId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets VM resource Id for the environment + /// + [JsonProperty(PropertyName = "vmResourceId")] + public string VmResourceId { get; set; } + + /// + /// Gets or sets resourceSettingId for the environment + /// + [JsonProperty(PropertyName = "resourceSettingId")] + public string ResourceSettingId { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResourceSetFragment.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResourceSetFragment.cs new file mode 100644 index 000000000000..ee9653ff60ac --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResourceSetFragment.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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents a VM and the setting Id it was created for. + /// + public partial class ResourceSetFragment + { + /// + /// Initializes a new instance of the ResourceSetFragment class. + /// + public ResourceSetFragment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceSetFragment class. + /// + /// VM resource Id for the + /// environment + /// resourceSettingId for the + /// environment + public ResourceSetFragment(string vmResourceId = default(string), string resourceSettingId = default(string)) + { + VmResourceId = vmResourceId; + ResourceSettingId = resourceSettingId; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets VM resource Id for the environment + /// + [JsonProperty(PropertyName = "vmResourceId")] + public string VmResourceId { get; set; } + + /// + /// Gets or sets resourceSettingId for the environment + /// + [JsonProperty(PropertyName = "resourceSettingId")] + public string ResourceSettingId { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResourceSettingCreationParameters.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResourceSettingCreationParameters.cs new file mode 100644 index 000000000000..d634923bf613 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResourceSettingCreationParameters.cs @@ -0,0 +1,113 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents resource specific settings + /// + public partial class ResourceSettingCreationParameters + { + /// + /// Initializes a new instance of the ResourceSettingCreationParameters + /// class. + /// + public ResourceSettingCreationParameters() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceSettingCreationParameters + /// class. + /// + /// The resource id of the gallery + /// image used for creating the virtual machine + /// Creation parameters for + /// Reference Vm + /// The location where the virtual machine will + /// live + /// The name of the resource setting + /// The size of the virtual machine. Possible values + /// include: 'Basic', 'Standard', 'Performance' + public ResourceSettingCreationParameters(string galleryImageResourceId, ReferenceVmCreationParameters referenceVmCreationParameters, string location = default(string), string name = default(string), string size = default(string)) + { + Location = location; + Name = name; + GalleryImageResourceId = galleryImageResourceId; + Size = size; + ReferenceVmCreationParameters = referenceVmCreationParameters; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the location where the virtual machine will live + /// + [JsonProperty(PropertyName = "location")] + public string Location { get; set; } + + /// + /// Gets or sets the name of the resource setting + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets the resource id of the gallery image used for creating + /// the virtual machine + /// + [JsonProperty(PropertyName = "galleryImageResourceId")] + public string GalleryImageResourceId { get; set; } + + /// + /// Gets or sets the size of the virtual machine. Possible values + /// include: 'Basic', 'Standard', 'Performance' + /// + [JsonProperty(PropertyName = "size")] + public string Size { get; set; } + + /// + /// Gets or sets creation parameters for Reference Vm + /// + [JsonProperty(PropertyName = "referenceVmCreationParameters")] + public ReferenceVmCreationParameters ReferenceVmCreationParameters { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (GalleryImageResourceId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "GalleryImageResourceId"); + } + if (ReferenceVmCreationParameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ReferenceVmCreationParameters"); + } + if (ReferenceVmCreationParameters != null) + { + ReferenceVmCreationParameters.Validate(); + } + } + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResourceSettings.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResourceSettings.cs new file mode 100644 index 000000000000..ad394d60d069 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResourceSettings.cs @@ -0,0 +1,115 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents resource specific settings + /// + public partial class ResourceSettings + { + /// + /// Initializes a new instance of the ResourceSettings class. + /// + public ResourceSettings() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceSettings class. + /// + /// Details specific to Reference Vm + /// The unique id of the resource setting + /// The resource id of the gallery + /// image used for creating the virtual machine + /// The name of the image used to created the + /// environment setting + /// The size of the virtual machine. Possible values + /// include: 'Basic', 'Standard', 'Performance' + /// The translated compute cores of the virtual + /// machine + public ResourceSettings(ReferenceVm referenceVm, string id = default(string), string galleryImageResourceId = default(string), string imageName = default(string), string size = default(string), int? cores = default(int?)) + { + Id = id; + GalleryImageResourceId = galleryImageResourceId; + ImageName = imageName; + Size = size; + Cores = cores; + ReferenceVm = referenceVm; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the unique id of the resource setting + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; private set; } + + /// + /// Gets or sets the resource id of the gallery image used for creating + /// the virtual machine + /// + [JsonProperty(PropertyName = "galleryImageResourceId")] + public string GalleryImageResourceId { get; set; } + + /// + /// Gets the name of the image used to created the environment setting + /// + [JsonProperty(PropertyName = "imageName")] + public string ImageName { get; private set; } + + /// + /// Gets or sets the size of the virtual machine. Possible values + /// include: 'Basic', 'Standard', 'Performance' + /// + [JsonProperty(PropertyName = "size")] + public string Size { get; set; } + + /// + /// Gets the translated compute cores of the virtual machine + /// + [JsonProperty(PropertyName = "cores")] + public int? Cores { get; private set; } + + /// + /// Gets or sets details specific to Reference Vm + /// + [JsonProperty(PropertyName = "referenceVm")] + public ReferenceVm ReferenceVm { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (ReferenceVm == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "ReferenceVm"); + } + if (ReferenceVm != null) + { + ReferenceVm.Validate(); + } + } + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResourceSettingsFragment.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResourceSettingsFragment.cs new file mode 100644 index 000000000000..3729af59794c --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/ResourceSettingsFragment.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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents resource specific settings + /// + public partial class ResourceSettingsFragment + { + /// + /// Initializes a new instance of the ResourceSettingsFragment class. + /// + public ResourceSettingsFragment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the ResourceSettingsFragment class. + /// + /// The resource id of the gallery + /// image used for creating the virtual machine + /// The size of the virtual machine. Possible values + /// include: 'Basic', 'Standard', 'Performance' + /// Details specific to Reference Vm + public ResourceSettingsFragment(string galleryImageResourceId = default(string), string size = default(string), ReferenceVmFragment referenceVm = default(ReferenceVmFragment)) + { + GalleryImageResourceId = galleryImageResourceId; + Size = size; + ReferenceVm = referenceVm; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the resource id of the gallery image used for creating + /// the virtual machine + /// + [JsonProperty(PropertyName = "galleryImageResourceId")] + public string GalleryImageResourceId { get; set; } + + /// + /// Gets or sets the size of the virtual machine. Possible values + /// include: 'Basic', 'Standard', 'Performance' + /// + [JsonProperty(PropertyName = "size")] + public string Size { get; set; } + + /// + /// Gets or sets details specific to Reference Vm + /// + [JsonProperty(PropertyName = "referenceVm")] + public ReferenceVmFragment ReferenceVm { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/SizeAvailability.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/SizeAvailability.cs new file mode 100644 index 000000000000..a307410f44f1 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/SizeAvailability.cs @@ -0,0 +1,64 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Represents the size information + /// + public partial class SizeAvailability + { + /// + /// Initializes a new instance of the SizeAvailability class. + /// + public SizeAvailability() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SizeAvailability class. + /// + /// The category of the size (Basic, + /// Standard, Performance). Possible values include: 'Basic', + /// 'Standard', 'Performance' + /// Whether or not this size category is + /// available + public SizeAvailability(string sizeCategory = default(string), bool? isAvailable = default(bool?)) + { + SizeCategory = sizeCategory; + IsAvailable = isAvailable; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the category of the size (Basic, Standard, + /// Performance). Possible values include: 'Basic', 'Standard', + /// 'Performance' + /// + [JsonProperty(PropertyName = "sizeCategory")] + public string SizeCategory { get; set; } + + /// + /// Gets or sets whether or not this size category is available + /// + [JsonProperty(PropertyName = "isAvailable")] + public bool? IsAvailable { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/SizeConfigurationProperties.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/SizeConfigurationProperties.cs new file mode 100644 index 000000000000..956c74745ca4 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/SizeConfigurationProperties.cs @@ -0,0 +1,57 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents the size configuration under the lab account + /// + public partial class SizeConfigurationProperties + { + /// + /// Initializes a new instance of the SizeConfigurationProperties + /// class. + /// + public SizeConfigurationProperties() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SizeConfigurationProperties + /// class. + /// + /// Represents a list of size categories + /// supported by this Lab Account (Small, Medium, Large) + public SizeConfigurationProperties(IList environmentSizes = default(IList)) + { + EnvironmentSizes = environmentSizes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets represents a list of size categories supported by this + /// Lab Account (Small, Medium, Large) + /// + [JsonProperty(PropertyName = "environmentSizes")] + public IList EnvironmentSizes { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/SizeConfigurationPropertiesFragment.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/SizeConfigurationPropertiesFragment.cs new file mode 100644 index 000000000000..db0f9815796b --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/SizeConfigurationPropertiesFragment.cs @@ -0,0 +1,57 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// Represents the size configuration under the lab account + /// + public partial class SizeConfigurationPropertiesFragment + { + /// + /// Initializes a new instance of the + /// SizeConfigurationPropertiesFragment class. + /// + public SizeConfigurationPropertiesFragment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the + /// SizeConfigurationPropertiesFragment class. + /// + /// Represents a list of size categories + /// supported by this Lab Account (Small, Medium, Large) + public SizeConfigurationPropertiesFragment(IList environmentSizes = default(IList)) + { + EnvironmentSizes = environmentSizes; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets represents a list of size categories supported by this + /// Lab Account (Small, Medium, Large) + /// + [JsonProperty(PropertyName = "environmentSizes")] + public IList EnvironmentSizes { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/SizeInfo.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/SizeInfo.cs new file mode 100644 index 000000000000..b7d7021f4c34 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/SizeInfo.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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Contains detailed information about a size + /// + public partial class SizeInfo + { + /// + /// Initializes a new instance of the SizeInfo class. + /// + public SizeInfo() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SizeInfo class. + /// + /// Represents the actual compute size, e.g. + /// Standard_A2_v2. + /// The pay-as-you-go price per hour this size will + /// cost. It does not include discounts and may not reflect the actual + /// price the size will cost. + /// The number of cores a VM of this size + /// has. + /// The amount of memory available (in + /// GB). + public SizeInfo(string computeSize = default(string), decimal? price = default(decimal?), int? numberOfCores = default(int?), double? memory = default(double?)) + { + ComputeSize = computeSize; + Price = price; + NumberOfCores = numberOfCores; + Memory = memory; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets represents the actual compute size, e.g. + /// Standard_A2_v2. + /// + [JsonProperty(PropertyName = "computeSize")] + public string ComputeSize { get; set; } + + /// + /// Gets or sets the pay-as-you-go price per hour this size will cost. + /// It does not include discounts and may not reflect the actual price + /// the size will cost. + /// + [JsonProperty(PropertyName = "price")] + public decimal? Price { get; set; } + + /// + /// Gets or sets the number of cores a VM of this size has. + /// + [JsonProperty(PropertyName = "numberOfCores")] + public int? NumberOfCores { get; set; } + + /// + /// Gets or sets the amount of memory available (in GB). + /// + [JsonProperty(PropertyName = "memory")] + public double? Memory { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/SizeInfoFragment.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/SizeInfoFragment.cs new file mode 100644 index 000000000000..052f958a81fa --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/SizeInfoFragment.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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Contains detailed information about a size + /// + public partial class SizeInfoFragment + { + /// + /// Initializes a new instance of the SizeInfoFragment class. + /// + public SizeInfoFragment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the SizeInfoFragment class. + /// + /// Represents the actual compute size, e.g. + /// Standard_A2_v2. + /// The pay-as-you-go price per hour this size will + /// cost. It does not include discounts and may not reflect the actual + /// price the size will cost. + /// The number of cores a VM of this size + /// has. + /// The amount of memory available (in + /// GB). + public SizeInfoFragment(string computeSize = default(string), decimal? price = default(decimal?), int? numberOfCores = default(int?), double? memory = default(double?)) + { + ComputeSize = computeSize; + Price = price; + NumberOfCores = numberOfCores; + Memory = memory; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets represents the actual compute size, e.g. + /// Standard_A2_v2. + /// + [JsonProperty(PropertyName = "computeSize")] + public string ComputeSize { get; set; } + + /// + /// Gets or sets the pay-as-you-go price per hour this size will cost. + /// It does not include discounts and may not reflect the actual price + /// the size will cost. + /// + [JsonProperty(PropertyName = "price")] + public decimal? Price { get; set; } + + /// + /// Gets or sets the number of cores a VM of this size has. + /// + [JsonProperty(PropertyName = "numberOfCores")] + public int? NumberOfCores { get; set; } + + /// + /// Gets or sets the amount of memory available (in GB). + /// + [JsonProperty(PropertyName = "memory")] + public double? Memory { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/User.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/User.cs new file mode 100644 index 000000000000..cc58c4a26363 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/User.cs @@ -0,0 +1,127 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The User registered to a lab + /// + [Rest.Serialization.JsonTransformation] + public partial class User : Resource + { + /// + /// Initializes a new instance of the User class. + /// + public User() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the User class. + /// + /// The identifier of the resource. + /// The name of the resource. + /// The type of the resource. + /// The location of the resource. + /// The tags of the resource. + /// The user email address, as it was specified + /// during registration. + /// The user family name, as it was specified + /// during registration. + /// The user given name, as it was specified + /// during registration. + /// The user tenant ID, as it was specified + /// during registration. + /// How long the user has used his VMs in this + /// lab + /// The provisioning status of the + /// resource. + /// The unique immutable identifier of a + /// resource (Guid). + /// The details of the latest + /// operation. ex: status, error + public User(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string email = default(string), string familyName = default(string), string givenName = default(string), string tenantId = default(string), System.TimeSpan? totalUsage = default(System.TimeSpan?), string provisioningState = default(string), string uniqueIdentifier = default(string), LatestOperationResult latestOperationResult = default(LatestOperationResult)) + : base(id, name, type, location, tags) + { + Email = email; + FamilyName = familyName; + GivenName = givenName; + TenantId = tenantId; + TotalUsage = totalUsage; + ProvisioningState = provisioningState; + UniqueIdentifier = uniqueIdentifier; + LatestOperationResult = latestOperationResult; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the user email address, as it was specified during + /// registration. + /// + [JsonProperty(PropertyName = "properties.email")] + public string Email { get; private set; } + + /// + /// Gets the user family name, as it was specified during registration. + /// + [JsonProperty(PropertyName = "properties.familyName")] + public string FamilyName { get; private set; } + + /// + /// Gets the user given name, as it was specified during registration. + /// + [JsonProperty(PropertyName = "properties.givenName")] + public string GivenName { get; private set; } + + /// + /// Gets the user tenant ID, as it was specified during registration. + /// + [JsonProperty(PropertyName = "properties.tenantId")] + public string TenantId { get; private set; } + + /// + /// Gets how long the user has used his VMs in this lab + /// + [JsonProperty(PropertyName = "properties.totalUsage")] + public System.TimeSpan? TotalUsage { get; private set; } + + /// + /// Gets or sets the provisioning status of the resource. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets the unique immutable identifier of a resource (Guid). + /// + [JsonProperty(PropertyName = "properties.uniqueIdentifier")] + public string UniqueIdentifier { get; set; } + + /// + /// Gets the details of the latest operation. ex: status, error + /// + [JsonProperty(PropertyName = "properties.latestOperationResult")] + public LatestOperationResult LatestOperationResult { get; private set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/UserFragment.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/UserFragment.cs new file mode 100644 index 000000000000..45ee8a6c9cb9 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/UserFragment.cs @@ -0,0 +1,72 @@ +// +// 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.LabServices.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + /// + /// The User registered to a lab + /// + [Rest.Serialization.JsonTransformation] + public partial class UserFragment : Resource + { + /// + /// Initializes a new instance of the UserFragment class. + /// + public UserFragment() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the UserFragment class. + /// + /// The identifier of the resource. + /// The name of the resource. + /// The type of the resource. + /// The location of the resource. + /// The tags of the resource. + /// The provisioning status of the + /// resource. + /// The unique immutable identifier of a + /// resource (Guid). + public UserFragment(string id = default(string), string name = default(string), string type = default(string), string location = default(string), IDictionary tags = default(IDictionary), string provisioningState = default(string), string uniqueIdentifier = default(string)) + : base(id, name, type, location, tags) + { + ProvisioningState = provisioningState; + UniqueIdentifier = uniqueIdentifier; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets the provisioning status of the resource. + /// + [JsonProperty(PropertyName = "properties.provisioningState")] + public string ProvisioningState { get; set; } + + /// + /// Gets or sets the unique immutable identifier of a resource (Guid). + /// + [JsonProperty(PropertyName = "properties.uniqueIdentifier")] + public string UniqueIdentifier { get; set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/VirtualMachineDetails.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/VirtualMachineDetails.cs new file mode 100644 index 000000000000..e0c0b8bfec18 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/VirtualMachineDetails.cs @@ -0,0 +1,95 @@ +// +// 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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Details of the backing virtual machine. + /// + public partial class VirtualMachineDetails + { + /// + /// Initializes a new instance of the VirtualMachineDetails class. + /// + public VirtualMachineDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VirtualMachineDetails class. + /// + /// Provisioning state of the Dtl + /// VM + /// Connection information for + /// Windows + /// Connection information for Linux + /// PrivateIp address of the compute + /// VM + /// Compute VM login user name + /// Last known compute power state + /// captured in DTL + public VirtualMachineDetails(string provisioningState = default(string), string rdpAuthority = default(string), string sshAuthority = default(string), string privateIpAddress = default(string), string userName = default(string), string lastKnownPowerState = default(string)) + { + ProvisioningState = provisioningState; + RdpAuthority = rdpAuthority; + SshAuthority = sshAuthority; + PrivateIpAddress = privateIpAddress; + UserName = userName; + LastKnownPowerState = lastKnownPowerState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets provisioning state of the Dtl VM + /// + [JsonProperty(PropertyName = "provisioningState")] + public string ProvisioningState { get; private set; } + + /// + /// Gets connection information for Windows + /// + [JsonProperty(PropertyName = "rdpAuthority")] + public string RdpAuthority { get; private set; } + + /// + /// Gets connection information for Linux + /// + [JsonProperty(PropertyName = "sshAuthority")] + public string SshAuthority { get; private set; } + + /// + /// Gets privateIp address of the compute VM + /// + [JsonProperty(PropertyName = "privateIpAddress")] + public string PrivateIpAddress { get; private set; } + + /// + /// Gets compute VM login user name + /// + [JsonProperty(PropertyName = "userName")] + public string UserName { get; private set; } + + /// + /// Gets last known compute power state captured in DTL + /// + [JsonProperty(PropertyName = "lastKnownPowerState")] + public string LastKnownPowerState { get; private set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Models/VmStateDetails.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Models/VmStateDetails.cs new file mode 100644 index 000000000000..277fa1b01fd0 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Models/VmStateDetails.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.LabServices.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Details about the state of the reference virtual machine. + /// + public partial class VmStateDetails + { + /// + /// Initializes a new instance of the VmStateDetails class. + /// + public VmStateDetails() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the VmStateDetails class. + /// + /// The RdpAuthority property is a server + /// DNS host name or IP address followed by the service port number for + /// RDP (Remote Desktop Protocol). + /// The SshAuthority property is a server + /// DNS host name or IP address followed by the service port number for + /// SSH. + /// The power state of the reference virtual + /// machine. + /// Last known compute power state + /// captured in DTL + public VmStateDetails(string rdpAuthority = default(string), string sshAuthority = default(string), string powerState = default(string), string lastKnownPowerState = default(string)) + { + RdpAuthority = rdpAuthority; + SshAuthority = sshAuthority; + PowerState = powerState; + LastKnownPowerState = lastKnownPowerState; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets the RdpAuthority property is a server DNS host name or IP + /// address followed by the service port number for RDP (Remote Desktop + /// Protocol). + /// + [JsonProperty(PropertyName = "rdpAuthority")] + public string RdpAuthority { get; private set; } + + /// + /// Gets the SshAuthority property is a server DNS host name or IP + /// address followed by the service port number for SSH. + /// + [JsonProperty(PropertyName = "sshAuthority")] + public string SshAuthority { get; private set; } + + /// + /// Gets the power state of the reference virtual machine. + /// + [JsonProperty(PropertyName = "powerState")] + public string PowerState { get; private set; } + + /// + /// Gets last known compute power state captured in DTL + /// + [JsonProperty(PropertyName = "lastKnownPowerState")] + public string LastKnownPowerState { get; private set; } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/Operations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/Operations.cs new file mode 100644 index 000000000000..371cf5532382 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/Operations.cs @@ -0,0 +1,250 @@ +// +// 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.LabServices +{ + 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; + + /// + /// Operations operations. + /// + internal partial class Operations : IServiceOperations, IOperations + { + /// + /// Initializes a new instance of the Operations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal Operations(ManagedLabsClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagedLabsClient + /// + public ManagedLabsClient Client { get; private set; } + + /// + /// Get operation + /// + /// + /// The name of the location. + /// + /// + /// The name of the 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> GetWithHttpMessagesAsync(string locationName, string operationName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (locationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "locationName"); + } + if (operationName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "operationName"); + } + 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("locationName", locationName); + tracingParameters.Add("operationName", operationName); + 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}/providers/Microsoft.LabServices/locations/{locationName}/operations/{operationName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{locationName}", System.Uri.EscapeDataString(locationName)); + _url = _url.Replace("{operationName}", System.Uri.EscapeDataString(operationName)); + 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; + } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/OperationsExtensions.cs b/src/SDKs/LabServices/Management.LabServices/Generated/OperationsExtensions.cs new file mode 100644 index 000000000000..ae944d70a046 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/OperationsExtensions.cs @@ -0,0 +1,65 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for Operations. + /// + public static partial class OperationsExtensions + { + /// + /// Get operation + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the location. + /// + /// + /// The name of the operation. + /// + public static OperationResult Get(this IOperations operations, string locationName, string operationName) + { + return operations.GetAsync(locationName, operationName).GetAwaiter().GetResult(); + } + + /// + /// Get operation + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the location. + /// + /// + /// The name of the operation. + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IOperations operations, string locationName, string operationName, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(locationName, operationName, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/ProviderOperations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/ProviderOperations.cs new file mode 100644 index 000000000000..aa7a3f0900a6 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/ProviderOperations.cs @@ -0,0 +1,400 @@ +// +// 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.LabServices +{ + 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; + + /// + /// ProviderOperations operations. + /// + internal partial class ProviderOperations : IServiceOperations, IProviderOperations + { + /// + /// Initializes a new instance of the ProviderOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal ProviderOperations(ManagedLabsClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagedLabsClient + /// + public ManagedLabsClient Client { get; private set; } + + /// + /// Result of the request to list REST API operations + /// + /// + /// 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.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("/") ? "" : "/")), "providers/Microsoft.LabServices/operations").ToString(); + 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; + } + + /// + /// Result of the request to list REST API operations + /// + /// + /// 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; + } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/ProviderOperationsExtensions.cs b/src/SDKs/LabServices/Management.LabServices/Generated/ProviderOperationsExtensions.cs new file mode 100644 index 000000000000..9898e292a2f7 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/ProviderOperationsExtensions.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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for ProviderOperations. + /// + public static partial class ProviderOperationsExtensions + { + /// + /// Result of the request to list REST API operations + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IProviderOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Result of the request to list REST API operations + /// + /// + /// The operations group for this extension method. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IProviderOperations operations, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Result of the request to list REST API operations + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IProviderOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Result of the request to list REST API operations + /// + /// + /// 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 IProviderOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/SdkInfo_ManagedLabsClient.cs b/src/SDKs/LabServices/Management.LabServices/Generated/SdkInfo_ManagedLabsClient.cs new file mode 100644 index 000000000000..f01441782eed --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/SdkInfo_ManagedLabsClient.cs @@ -0,0 +1,46 @@ + +// +// 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.LabServices +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_ManagedLabsClient + { + get + { + return new Tuple[] + { + new Tuple("LabServices", "EnvironmentSettings", "2018-10-15"), + new Tuple("LabServices", "Environments", "2018-10-15"), + new Tuple("LabServices", "GalleryImages", "2018-10-15"), + new Tuple("LabServices", "GlobalUsers", "2018-10-15"), + new Tuple("LabServices", "LabAccounts", "2018-10-15"), + new Tuple("LabServices", "Labs", "2018-10-15"), + new Tuple("LabServices", "Operations", "2018-10-15"), + new Tuple("LabServices", "ProviderOperations", "2018-10-15"), + new Tuple("LabServices", "Users", "2018-10-15"), + }.AsEnumerable(); + } + } + // BEGIN: Code Generation Metadata Section + public static readonly String AutoRestVersion = "latest"; + public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4283"; + public static readonly String AutoRestCmdExecuted = "cmd.exe /c autorest.cmd https://github.com/Azure/azure-rest-api-specs/blob/master/specification/labservices/resource-manager/readme.md --csharp --version=latest --reflect-api-versions --csharp-sdks-folder=D:\\git\\azure-sdk-for-net\\src\\SDKs"; + public static readonly String GithubForkName = "Azure"; + public static readonly String GithubBranchName = "master"; + public static readonly String GithubCommidId = "d02b8b65bf8ce5d8322c92530bf6b2e6dd3b9aab"; + public static readonly String CodeGenerationErrors = ""; + public static readonly String GithubRepoName = "azure-rest-api-specs"; + // END: Code Generation Metadata Section + } +} + diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/UsersOperations.cs b/src/SDKs/LabServices/Management.LabServices/Generated/UsersOperations.cs new file mode 100644 index 000000000000..e80d19e59b02 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/UsersOperations.cs @@ -0,0 +1,1362 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + 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; + + /// + /// UsersOperations operations. + /// + internal partial class UsersOperations : IServiceOperations, IUsersOperations + { + /// + /// Initializes a new instance of the UsersOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal UsersOperations(ManagedLabsClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the ManagedLabsClient + /// + public ManagedLabsClient Client { get; private set; } + + /// + /// List users in a given lab. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// OData parameters to apply to the 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>> ListWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, ODataQuery odataQuery = default(ODataQuery), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + 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("odataQuery", odataQuery); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/users").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + List _queryParameters = new List(); + if (odataQuery != null) + { + var _odataFilter = odataQuery.ToString(); + if (!string.IsNullOrEmpty(_odataFilter)) + { + _queryParameters.Add(_odataFilter); + } + } + 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 user + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// Specify the $expand query. Example: 'properties($select=email)' + /// + /// + /// 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 labAccountName, string labName, string userName, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (userName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("userName", userName); + tracingParameters.Add("expand", expand); + 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/users/{userName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{userName}", System.Uri.EscapeDataString(userName)); + List _queryParameters = new List(); + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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 replace an existing User. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// The User registered to a lab + /// + /// + /// 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 labAccountName, string labName, string userName, User user, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (userName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userName"); + } + if (user == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "user"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("userName", userName); + tracingParameters.Add("user", user); + 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/users/{userName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{userName}", System.Uri.EscapeDataString(userName)); + 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(user != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(user, 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 user. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task DeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string userName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // Send request + AzureOperationResponse _response = await BeginDeleteWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, userName, customHeaders, cancellationToken).ConfigureAwait(false); + return await Client.GetPostOrDeleteOperationResultAsync(_response, customHeaders, cancellationToken).ConfigureAwait(false); + } + + /// + /// Modify properties of users. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// The User registered to a lab + /// + /// + /// 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> UpdateWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string userName, UserFragment user, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (userName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userName"); + } + if (user == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "user"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("userName", userName); + tracingParameters.Add("user", user); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Update", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/users/{userName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{userName}", System.Uri.EscapeDataString(userName)); + 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("PATCH"); + _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(user != null) + { + _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(user, 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) + { + 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; + } + + /// + /// Delete user. This operation can take a while to complete + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + /// + /// Thrown when the operation returned an invalid status code + /// + /// + /// 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 BeginDeleteWithHttpMessagesAsync(string resourceGroupName, string labAccountName, string labName, string userName, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (Client.SubscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SubscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (labAccountName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labAccountName"); + } + if (labName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "labName"); + } + if (userName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "userName"); + } + 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("resourceGroupName", resourceGroupName); + tracingParameters.Add("labAccountName", labAccountName); + tracingParameters.Add("labName", labName); + tracingParameters.Add("userName", userName); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "BeginDelete", 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.LabServices/labaccounts/{labAccountName}/labs/{labName}/users/{userName}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(Client.SubscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{labAccountName}", System.Uri.EscapeDataString(labAccountName)); + _url = _url.Replace("{labName}", System.Uri.EscapeDataString(labName)); + _url = _url.Replace("{userName}", System.Uri.EscapeDataString(userName)); + 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 != 202 && (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(); + } + if (_shouldTrace) + { + ServiceClientTracing.Exit(_invocationId, _result); + } + return _result; + } + + /// + /// List users in a given lab. + /// + /// + /// 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; + } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Generated/UsersOperationsExtensions.cs b/src/SDKs/LabServices/Management.LabServices/Generated/UsersOperationsExtensions.cs new file mode 100644 index 000000000000..33cc61e851d9 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Generated/UsersOperationsExtensions.cs @@ -0,0 +1,384 @@ +// +// 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.LabServices +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Microsoft.Rest.Azure.OData; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for UsersOperations. + /// + public static partial class UsersOperationsExtensions + { + /// + /// List users in a given lab. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// OData parameters to apply to the operation. + /// + public static IPage List(this IUsersOperations operations, string resourceGroupName, string labAccountName, string labName, ODataQuery odataQuery = default(ODataQuery)) + { + return operations.ListAsync(resourceGroupName, labAccountName, labName, odataQuery).GetAwaiter().GetResult(); + } + + /// + /// List users in a given lab. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// OData parameters to apply to the operation. + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IUsersOperations operations, string resourceGroupName, string labAccountName, string labName, ODataQuery odataQuery = default(ODataQuery), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, odataQuery, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get user + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// Specify the $expand query. Example: 'properties($select=email)' + /// + public static User Get(this IUsersOperations operations, string resourceGroupName, string labAccountName, string labName, string userName, string expand = default(string)) + { + return operations.GetAsync(resourceGroupName, labAccountName, labName, userName, expand).GetAwaiter().GetResult(); + } + + /// + /// Get user + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// Specify the $expand query. Example: 'properties($select=email)' + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IUsersOperations operations, string resourceGroupName, string labAccountName, string labName, string userName, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, userName, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Create or replace an existing User. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// The User registered to a lab + /// + public static User CreateOrUpdate(this IUsersOperations operations, string resourceGroupName, string labAccountName, string labName, string userName, User user) + { + return operations.CreateOrUpdateAsync(resourceGroupName, labAccountName, labName, userName, user).GetAwaiter().GetResult(); + } + + /// + /// Create or replace an existing User. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// The User registered to a lab + /// + /// + /// The cancellation token. + /// + public static async Task CreateOrUpdateAsync(this IUsersOperations operations, string resourceGroupName, string labAccountName, string labName, string userName, User user, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, userName, user, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete user. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + public static void Delete(this IUsersOperations operations, string resourceGroupName, string labAccountName, string labName, string userName) + { + operations.DeleteAsync(resourceGroupName, labAccountName, labName, userName).GetAwaiter().GetResult(); + } + + /// + /// Delete user. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// The cancellation token. + /// + public static async Task DeleteAsync(this IUsersOperations operations, string resourceGroupName, string labAccountName, string labName, string userName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.DeleteWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, userName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// Modify properties of users. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// The User registered to a lab + /// + public static User Update(this IUsersOperations operations, string resourceGroupName, string labAccountName, string labName, string userName, UserFragment user) + { + return operations.UpdateAsync(resourceGroupName, labAccountName, labName, userName, user).GetAwaiter().GetResult(); + } + + /// + /// Modify properties of users. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// The User registered to a lab + /// + /// + /// The cancellation token. + /// + public static async Task UpdateAsync(this IUsersOperations operations, string resourceGroupName, string labAccountName, string labName, string userName, UserFragment user, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.UpdateWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, userName, user, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Delete user. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + public static void BeginDelete(this IUsersOperations operations, string resourceGroupName, string labAccountName, string labName, string userName) + { + operations.BeginDeleteAsync(resourceGroupName, labAccountName, labName, userName).GetAwaiter().GetResult(); + } + + /// + /// Delete user. This operation can take a while to complete + /// + /// + /// The operations group for this extension method. + /// + /// + /// The name of the resource group. + /// + /// + /// The name of the lab Account. + /// + /// + /// The name of the lab. + /// + /// + /// The name of the user. + /// + /// + /// The cancellation token. + /// + public static async Task BeginDeleteAsync(this IUsersOperations operations, string resourceGroupName, string labAccountName, string labName, string userName, CancellationToken cancellationToken = default(CancellationToken)) + { + (await operations.BeginDeleteWithHttpMessagesAsync(resourceGroupName, labAccountName, labName, userName, null, cancellationToken).ConfigureAwait(false)).Dispose(); + } + + /// + /// List users in a given lab. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IUsersOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// List users in a given lab. + /// + /// + /// 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 IUsersOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/src/SDKs/LabServices/Management.LabServices/Microsoft.Azure.Management.LabServices.csproj b/src/SDKs/LabServices/Management.LabServices/Microsoft.Azure.Management.LabServices.csproj new file mode 100644 index 000000000000..360888bda7ad --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Microsoft.Azure.Management.LabServices.csproj @@ -0,0 +1,22 @@ + + + + + + + 3.0.0 + Microsoft.Azure.Management.LabServices + Microsoft.Azure.Management.LabServices + Microsoft.Azure.Management.LabServices + LabServices; + Release api version 2018-10-15. + {B2143F8C-A1B8-4042-ACAB-CB7797E24C9F} + + + net452;netstandard1.4 + + + + + + diff --git a/src/SDKs/LabServices/Management.LabServices/Properties/AssemblyInfo.cs b/src/SDKs/LabServices/Management.LabServices/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..de8bb730ada8 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/Properties/AssemblyInfo.cs @@ -0,0 +1,17 @@ +// 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 Lab Services Management Library")] +[assembly: AssemblyDescription("Provides management functionality for Microsoft Azure Lab Services Resources.")] +[assembly: AssemblyVersion("3.0.0.0")] +[assembly: AssemblyFileVersion("3.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")] diff --git a/src/SDKs/LabServices/Management.LabServices/generate.ps1 b/src/SDKs/LabServices/Management.LabServices/generate.ps1 new file mode 100644 index 000000000000..bf1fad951920 --- /dev/null +++ b/src/SDKs/LabServices/Management.LabServices/generate.ps1 @@ -0,0 +1 @@ +Start-AutoRestCodeGeneration -ResourceProvider "labservices/resource-manager" -AutoRestVersion "latest"