From afc63c1b8bd0022d9af2b8ab986ddcc549057e87 Mon Sep 17 00:00:00 2001 From: ogail Date: Fri, 2 Oct 2015 15:32:19 -0700 Subject: [PATCH 1/6] Adding automatic RP registration handler. --- .../packages.config | 1 - .../Commands.Automation.Test/packages.config | 1 - .../Commands.ResourceManager.Common.csproj | 1 + .../ModelExtensions.cs | 20 +- .../RPRegistrationDelegatingHandler.cs | 93 +++++++++ .../Commands.Profile.Test.csproj | 1 + .../RPRegistrationDelegatingHandlerTests.cs | 191 ++++++++++++++++++ 7 files changed, 301 insertions(+), 7 deletions(-) create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/RPRegistrationDelegatingHandler.cs create mode 100644 src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs diff --git a/src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/packages.config b/src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/packages.config index 40d4a4883355..4f684d6e7023 100644 --- a/src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/packages.config +++ b/src/ResourceManager/ApiManagement/Commands.ApiManagement.Test/packages.config @@ -5,7 +5,6 @@ - diff --git a/src/ResourceManager/Automation/Commands.Automation.Test/packages.config b/src/ResourceManager/Automation/Commands.Automation.Test/packages.config index 8b5713e969f3..e32bb274dccd 100644 --- a/src/ResourceManager/Automation/Commands.Automation.Test/packages.config +++ b/src/ResourceManager/Automation/Commands.Automation.Test/packages.config @@ -19,5 +19,4 @@ - \ No newline at end of file diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Commands.ResourceManager.Common.csproj b/src/ResourceManager/Common/Commands.ResourceManager.Common/Commands.ResourceManager.Common.csproj index aaf987173ae0..1fb750c9f014 100644 --- a/src/ResourceManager/Common/Commands.ResourceManager.Common/Commands.ResourceManager.Common.csproj +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Commands.ResourceManager.Common.csproj @@ -150,6 +150,7 @@ Resources.resx + Designer diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/ModelExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/ModelExtensions.cs index e5731fc7120e..4fc3182aafbe 100644 --- a/src/ResourceManager/Common/Commands.ResourceManager.Common/ModelExtensions.cs +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/ModelExtensions.cs @@ -1,8 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; using Microsoft.Azure.Common.Authentication.Models; using Microsoft.Azure.Subscriptions.Models; diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/RPRegistrationDelegatingHandler.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/RPRegistrationDelegatingHandler.cs new file mode 100644 index 000000000000..af58231edbaa --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/RPRegistrationDelegatingHandler.cs @@ -0,0 +1,93 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Common.Authentication; +using Microsoft.Azure.Common.Authentication.Models; +using Microsoft.Azure.Management.Resources; + +namespace Microsoft.Azure.Common.Authentication.Models +{ + public class RPRegistrationDelegatingHandler : DelegatingHandler + { + /// + /// Contains all providers we have attempted to register + /// + private HashSet registeredProviders; + + private ResourceManagementClient client; + + private Action writeVerbose; + + public RPRegistrationDelegatingHandler(IClientFactory clientFactory, AzureContext context, Action writeVerbose) + { + client = clientFactory.CreateClient(context, AzureEnvironment.Endpoint.ResourceManager); + registeredProviders = new HashSet(); + this.writeVerbose = writeVerbose; + } + + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + HttpResponseMessage responseMessage = await base.SendAsync(request, cancellationToken).ConfigureAwait(false); + if (IsProviderNotRegistereError(responseMessage)) + { + var providerName = GetProviderName(request.RequestUri); + if (!string.IsNullOrEmpty(providerName) && !registeredProviders.Contains(providerName)) + { + registeredProviders.Add(providerName); + try + { + writeVerbose(string.Format("Attempting to register resource provider '{0}'", providerName)); + // Assume registration is instantanuous. + client.Providers.Register(providerName); + writeVerbose(string.Format("Succeeded to register resource provider '{0}'", providerName)); + } + catch + { + writeVerbose(string.Format("Failed to register resource provider '{0}'", providerName)); + // Ignore RP registration errors. + } + + responseMessage = await base.SendAsync(request, cancellationToken).ConfigureAwait(false); + } + } + return responseMessage; + } + + private bool IsProviderNotRegistereError(HttpResponseMessage responseMessage) + { + return responseMessage.StatusCode == System.Net.HttpStatusCode.Conflict && + responseMessage.Content.ReadAsStringAsync().Result.Contains("registered to use namespace"); + } + + /// + /// Extract provider name from request uri such as + /// "https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider-name}" + /// We analyze the uri's segments and check the index of 5 is "providers/" and return the next segment. + /// + /// request uri to extract provider out + /// provider name, or null on unexpected format + private string GetProviderName(Uri requestUri) + { + return (requestUri.Segments.Length > 7 && requestUri.Segments[5].ToLower() == "providers/") ? + requestUri.Segments[6].ToLower().Trim('/') : null; + } + } +} diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj b/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj index b4720ea3a1ab..8a9b532f0ee3 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj +++ b/src/ResourceManager/Profile/Commands.Profile.Test/Commands.Profile.Test.csproj @@ -180,6 +180,7 @@ + diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs b/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs new file mode 100644 index 000000000000..331e1c4dcfe1 --- /dev/null +++ b/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs @@ -0,0 +1,191 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- + +using System.Collections.Generic; +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Common.Authentication.Models; +using Microsoft.Azure.Management.Resources; +using Microsoft.WindowsAzure.Commands.Common.Test.Mocks; +using Moq; +using Xunit; +using System.Linq; +using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; +using Microsoft.Azure.Commands.ResourceManager.Common; + +namespace Microsoft.Azure.Commands.Profile.Test +{ + public class RPRegistrationDelegatingHandlerTests : RMTestBase + { + private const string compatibleUri = "https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}?validating={true|false}&api-version={api-version}"; + + private const string incompatibleUri = "https://management.core.windows.net/"; + + [Fact] + public void InvokeRegistrationForUnregisteredResourceProviders() + { + // Setup + Mock mockClient = new Mock(); + Mock mockProvidersOperations = new Mock(); + mockClient.Setup(f => f.Providers).Returns(mockProvidersOperations.Object); + HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, compatibleUri); + Dictionary> mapping = new Dictionary> + { + { + request, new List + { + new HttpResponseMessage(HttpStatusCode.Conflict) { Content = new StringContent("registered to use namespace") }, + new HttpResponseMessage(HttpStatusCode.Accepted) { Content = new StringContent("Azure works!") } + } + } + }; + List msgs = new List(); + RPRegistrationDelegatingHandler rpHandler = new RPRegistrationDelegatingHandler(new MockClientFactory(new List { mockClient.Object }) { MoqClients = true }, AzureRMCmdlet.DefaultProfile.Context, s => msgs.Add(s)) + { + InnerHandler = new MockResponseDelegatingHandler(mapping) + }; + HttpClient httpClient = new HttpClient(rpHandler); + + // Test + HttpResponseMessage response = httpClient.SendAsync(request).Result; + + // Assert + Assert.True(msgs.Any(s => s.Equals("Succeeded to register resource provider 'microsoft.compute'"))); + Assert.Equal(response.StatusCode, HttpStatusCode.Accepted); + Assert.Equal(response.Content.ReadAsStringAsync().Result, "Azure works!"); + } + + [Fact] + public void DoesNotInvokeRegistrationForRegisteredResourceProviders() + { + // Setup + Mock mockClient = new Mock(); + Mock mockProvidersOperations = new Mock(); + mockClient.Setup(f => f.Providers).Returns(mockProvidersOperations.Object); + HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, compatibleUri); + Dictionary> mapping = new Dictionary> + { + { + request, new List + { + new HttpResponseMessage(HttpStatusCode.Accepted) { Content = new StringContent("Azure works!") } + } + } + }; + List msgs = new List(); + RPRegistrationDelegatingHandler rpHandler = new RPRegistrationDelegatingHandler(new MockClientFactory(new List { mockClient.Object }) { MoqClients = true }, AzureRMCmdlet.DefaultProfile.Context, s => msgs.Add(s)) + { + InnerHandler = new MockResponseDelegatingHandler(mapping) + }; + HttpClient httpClient = new HttpClient(rpHandler); + + // Test + HttpResponseMessage response = httpClient.SendAsync(request).Result; + + // Assert + Assert.Equal(0, msgs.Count); + Assert.Equal(response.StatusCode, HttpStatusCode.Accepted); + Assert.Equal(response.Content.ReadAsStringAsync().Result, "Azure works!"); + } + + [Fact] + public void DoesNotInvokeRegistrationForUnrelatedStatusCode() + { + // Setup + Mock mockClient = new Mock(); + Mock mockProvidersOperations = new Mock(); + mockClient.Setup(f => f.Providers).Returns(mockProvidersOperations.Object); + HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, compatibleUri); + Dictionary> mapping = new Dictionary> + { + { + request, new List + { + new HttpResponseMessage(HttpStatusCode.Forbidden) { Content = new StringContent("auth error!") } + } + } + }; + List msgs = new List(); + RPRegistrationDelegatingHandler rpHandler = new RPRegistrationDelegatingHandler(new MockClientFactory(new List { mockClient.Object }) { MoqClients = true }, AzureRMCmdlet.DefaultProfile.Context, s => msgs.Add(s)) + { + InnerHandler = new MockResponseDelegatingHandler(mapping) + }; + HttpClient httpClient = new HttpClient(rpHandler); + + // Test + HttpResponseMessage response = httpClient.SendAsync(request).Result; + + // Assert + Assert.Equal(0, msgs.Count); + Assert.Equal(response.StatusCode, HttpStatusCode.Forbidden); + Assert.Equal(response.Content.ReadAsStringAsync().Result, "auth error!"); + } + + [Fact] + public void DoesNotInvokeRegistrationForIncompatibleUri() + { + // Setup + Mock mockClient = new Mock(); + Mock mockProvidersOperations = new Mock(); + mockClient.Setup(f => f.Providers).Returns(mockProvidersOperations.Object); + HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, incompatibleUri); + Dictionary> mapping = new Dictionary> + { + { + request, new List + { + new HttpResponseMessage(HttpStatusCode.Conflict) { Content = new StringContent("registered to use namespace") } + } + } + }; + List msgs = new List(); + RPRegistrationDelegatingHandler rpHandler = new RPRegistrationDelegatingHandler(new MockClientFactory(new List { mockClient.Object }) { MoqClients = true }, AzureRMCmdlet.DefaultProfile.Context, s => msgs.Add(s)) + { + InnerHandler = new MockResponseDelegatingHandler(mapping) + }; + HttpClient httpClient = new HttpClient(rpHandler); + + // Test + HttpResponseMessage response = httpClient.SendAsync(request).Result; + + // Assert + Assert.Equal(0, msgs.Count); + Assert.Equal(response.StatusCode, HttpStatusCode.Conflict); + Assert.Equal(response.Content.ReadAsStringAsync().Result, "registered to use namespace"); + } + } + + public class MockResponseDelegatingHandler : DelegatingHandler + { + Dictionary> mapping; + + public MockResponseDelegatingHandler(Dictionary> mapping) + { + this.mapping = mapping; + } + + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + return await Task.Run(() => + { + var response = mapping[request].First(); + mapping[request].Remove(response); + return response; + }); + } + + } +} From 244c6f8a631f105255115fcb5ab0ca0cb75ff376 Mon Sep 17 00:00:00 2001 From: ogail Date: Fri, 2 Oct 2015 18:50:09 -0700 Subject: [PATCH 2/6] Automatic RP registration --- src/Common/Commands.Common/AzurePSCmdlet.cs | 2 +- .../Properties/Resources.Designer.cs | 2 +- .../AzureRMCmdlet.cs | 9 +++++++++ .../RPRegistrationDelegatingHandler.cs | 20 ++++++++++++++----- .../RPRegistrationDelegatingHandlerTests.cs | 8 ++++---- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/Common/Commands.Common/AzurePSCmdlet.cs b/src/Common/Commands.Common/AzurePSCmdlet.cs index ee511f64831e..57fa41b98c9f 100644 --- a/src/Common/Commands.Common/AzurePSCmdlet.cs +++ b/src/Common/Commands.Common/AzurePSCmdlet.cs @@ -34,7 +34,7 @@ namespace Microsoft.WindowsAzure.Commands.Utilities.Common /// public abstract class AzurePSCmdlet : PSCmdlet, IDisposable { - private readonly ConcurrentQueue _debugMessages; + protected readonly ConcurrentQueue _debugMessages; private RecordingTracingInterceptor _httpTracingInterceptor; diff --git a/src/ResourceManager/AzureBatch/Commands.Batch/Properties/Resources.Designer.cs b/src/ResourceManager/AzureBatch/Commands.Batch/Properties/Resources.Designer.cs index 4de1b59c3c07..3f9edbcd8e80 100644 --- a/src/ResourceManager/AzureBatch/Commands.Batch/Properties/Resources.Designer.cs +++ b/src/ResourceManager/AzureBatch/Commands.Batch/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34209 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/AzureRMCmdlet.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/AzureRMCmdlet.cs index d56502265d01..cc4207d4a4ba 100644 --- a/src/ResourceManager/Common/Commands.ResourceManager.Common/AzureRMCmdlet.cs +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/AzureRMCmdlet.cs @@ -23,6 +23,7 @@ using System.Threading; using System.Management.Automation.Host; using Microsoft.WindowsAzure.Commands.Common; +using Microsoft.Azure.Management.Resources; namespace Microsoft.Azure.Commands.ResourceManager.Common { @@ -39,6 +40,14 @@ static AzureRMCmdlet() AzureSession.DataStore = new DiskDataStore(); } + public AzureRMCmdlet() + { + AzureSession.ClientFactory.RemoveHandler(typeof(RPRegistrationDelegatingHandler)); + AzureSession.ClientFactory.AddHandler(new RPRegistrationDelegatingHandler( + () => AzureSession.ClientFactory.CreateClient(DefaultContext, AzureEnvironment.Endpoint.ResourceManager), + s => _debugMessages.Enqueue(s))); + } + /// /// Gets or sets the global profile for ARM cmdlets. /// diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/RPRegistrationDelegatingHandler.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/RPRegistrationDelegatingHandler.cs index af58231edbaa..448e0566f6b7 100644 --- a/src/ResourceManager/Common/Commands.ResourceManager.Common/RPRegistrationDelegatingHandler.cs +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/RPRegistrationDelegatingHandler.cs @@ -22,6 +22,7 @@ using Microsoft.Azure.Common.Authentication; using Microsoft.Azure.Common.Authentication.Models; using Microsoft.Azure.Management.Resources; +using Microsoft.Azure.Management.Resources.Models; namespace Microsoft.Azure.Common.Authentication.Models { @@ -32,19 +33,24 @@ public class RPRegistrationDelegatingHandler : DelegatingHandler /// private HashSet registeredProviders; - private ResourceManagementClient client; + private Func createClient; private Action writeVerbose; - public RPRegistrationDelegatingHandler(IClientFactory clientFactory, AzureContext context, Action writeVerbose) + + public ResourceManagementClient ResourceManagementClient { get; set; } + + public RPRegistrationDelegatingHandler(Func createClient, Action writeVerbose) { - client = clientFactory.CreateClient(context, AzureEnvironment.Endpoint.ResourceManager); registeredProviders = new HashSet(); this.writeVerbose = writeVerbose; + this.createClient = createClient; } protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { + ResourceManagementClient = createClient(); + HttpResponseMessage responseMessage = await base.SendAsync(request, cancellationToken).ConfigureAwait(false); if (IsProviderNotRegistereError(responseMessage)) { @@ -55,8 +61,12 @@ protected override async Task SendAsync(HttpRequestMessage try { writeVerbose(string.Format("Attempting to register resource provider '{0}'", providerName)); - // Assume registration is instantanuous. - client.Providers.Register(providerName); + ResourceManagementClient.Providers.Register(providerName); + Provider provider = null; + do + { + provider = ResourceManagementClient.Providers.Get(providerName).Provider; + } while (provider.RegistrationState != RegistrationState.Registered.ToString()); writeVerbose(string.Format("Succeeded to register resource provider '{0}'", providerName)); } catch diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs b/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs index 331e1c4dcfe1..22e50100d643 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs +++ b/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs @@ -53,7 +53,7 @@ public void InvokeRegistrationForUnregisteredResourceProviders() } }; List msgs = new List(); - RPRegistrationDelegatingHandler rpHandler = new RPRegistrationDelegatingHandler(new MockClientFactory(new List { mockClient.Object }) { MoqClients = true }, AzureRMCmdlet.DefaultProfile.Context, s => msgs.Add(s)) + RPRegistrationDelegatingHandler rpHandler = new RPRegistrationDelegatingHandler(() => mockClient.Object, s => msgs.Add(s)) { InnerHandler = new MockResponseDelegatingHandler(mapping) }; @@ -86,7 +86,7 @@ public void DoesNotInvokeRegistrationForRegisteredResourceProviders() } }; List msgs = new List(); - RPRegistrationDelegatingHandler rpHandler = new RPRegistrationDelegatingHandler(new MockClientFactory(new List { mockClient.Object }) { MoqClients = true }, AzureRMCmdlet.DefaultProfile.Context, s => msgs.Add(s)) + RPRegistrationDelegatingHandler rpHandler = new RPRegistrationDelegatingHandler(() => mockClient.Object, s => msgs.Add(s)) { InnerHandler = new MockResponseDelegatingHandler(mapping) }; @@ -119,7 +119,7 @@ public void DoesNotInvokeRegistrationForUnrelatedStatusCode() } }; List msgs = new List(); - RPRegistrationDelegatingHandler rpHandler = new RPRegistrationDelegatingHandler(new MockClientFactory(new List { mockClient.Object }) { MoqClients = true }, AzureRMCmdlet.DefaultProfile.Context, s => msgs.Add(s)) + RPRegistrationDelegatingHandler rpHandler = new RPRegistrationDelegatingHandler(() => mockClient.Object, s => msgs.Add(s)) { InnerHandler = new MockResponseDelegatingHandler(mapping) }; @@ -152,7 +152,7 @@ public void DoesNotInvokeRegistrationForIncompatibleUri() } }; List msgs = new List(); - RPRegistrationDelegatingHandler rpHandler = new RPRegistrationDelegatingHandler(new MockClientFactory(new List { mockClient.Object }) { MoqClients = true }, AzureRMCmdlet.DefaultProfile.Context, s => msgs.Add(s)) + RPRegistrationDelegatingHandler rpHandler = new RPRegistrationDelegatingHandler(() => mockClient.Object, s => msgs.Add(s)) { InnerHandler = new MockResponseDelegatingHandler(mapping) }; From 485b9fdc08ebfdf24f5b0aec4d297c6d614307da Mon Sep 17 00:00:00 2001 From: ogail Date: Sat, 3 Oct 2015 08:27:33 -0700 Subject: [PATCH 3/6] Fix UT --- .../RPRegistrationDelegatingHandlerTests.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs b/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs index 22e50100d643..8159dadce367 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs +++ b/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs @@ -25,6 +25,7 @@ using System.Linq; using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; using Microsoft.Azure.Commands.ResourceManager.Common; +using Microsoft.Azure.Management.Resources.Models; namespace Microsoft.Azure.Commands.Profile.Test { @@ -41,6 +42,20 @@ public void InvokeRegistrationForUnregisteredResourceProviders() Mock mockClient = new Mock(); Mock mockProvidersOperations = new Mock(); mockClient.Setup(f => f.Providers).Returns(mockProvidersOperations.Object); + mockProvidersOperations.Setup(f => f.GetAsync(It.IsAny(), It.IsAny())).Returns( + (string rp, CancellationToken token) => + { + ProviderGetResult r = new ProviderGetResult + { + Provider = new Provider + { + RegistrationState = RegistrationState.Registered.ToString() + } + }; + + return Task.FromResult(r); + } + ); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, compatibleUri); Dictionary> mapping = new Dictionary> { From 6397bb33cc94c1787f445539a85403f898c2a4ee Mon Sep 17 00:00:00 2001 From: ogail Date: Mon, 5 Oct 2015 16:47:42 -0700 Subject: [PATCH 4/6] Address CR comments --- .../Properties/Resources.Designer.cs | 29 +++++++++- .../Properties/Resources.resx | 11 +++- .../RPRegistrationDelegatingHandler.cs | 34 ++++++++--- .../RMTestBase.cs | 2 + .../RPRegistrationDelegatingHandlerTests.cs | 56 ++++++++++++++++++- 5 files changed, 119 insertions(+), 13 deletions(-) diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Properties/Resources.Designer.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Properties/Resources.Designer.cs index 8d2426d80988..201a60db30d6 100644 --- a/src/ResourceManager/Common/Commands.ResourceManager.Common/Properties/Resources.Designer.cs +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Properties/Resources.Designer.cs @@ -135,6 +135,33 @@ public static string NoSubscriptionFound { } } + /// + /// Looks up a localized string similar to Attempting to register resource provider '{0}'. + /// + public static string ResourceProviderRegisterAttempt { + get { + return ResourceManager.GetString("ResourceProviderRegisterAttempt", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Failed to register resource provider '{0}'.Details: '{1}'. + /// + public static string ResourceProviderRegisterFailure { + get { + return ResourceManager.GetString("ResourceProviderRegisterFailure", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Succeeded to register resource provider '{0}'. + /// + public static string ResourceProviderRegisterSuccessful { + get { + return ResourceManager.GetString("ResourceProviderRegisterSuccessful", resourceCulture); + } + } + /// /// Looks up a localized string similar to The provided account {0} does not have access to subscription ID "{1}". Please try logging in with different credentials not a different subscription ID.. /// @@ -145,7 +172,7 @@ public static string SubscriptionIdNotFound { } /// - /// Looks up a localized string similar to SubscriptionIdNotFound The provided account {0} does not have access to subscription name "{1}". Please try logging in with different credentials not a different subscription name.. + /// Looks up a localized string similar to The provided account {0} does not have access to subscription name "{1}". Please try logging in with different credentials not a different subscription name.. /// public static string SubscriptionNameNotFound { get { diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Properties/Resources.resx b/src/ResourceManager/Common/Commands.ResourceManager.Common/Properties/Resources.resx index 93b591600071..f1be5d7daeec 100644 --- a/src/ResourceManager/Common/Commands.ResourceManager.Common/Properties/Resources.resx +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Properties/Resources.resx @@ -151,6 +151,15 @@ Select Y to enable data collection [Y/N]: The provided account {0} does not have access to any subscriptions. Please try logging in with different credentials. + + Attempting to register resource provider '{0}' + + + Failed to register resource provider '{0}'.Details: '{1}' + + + Succeeded to register resource provider '{0}' + The provided account {0} does not have access to subscription ID "{1}". Please try logging in with different credentials not a different subscription ID. @@ -160,4 +169,4 @@ Select Y to enable data collection [Y/N]: Tenant '{0}' was not found. Please verify that your account has access to this tenant. - + \ No newline at end of file diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/RPRegistrationDelegatingHandler.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/RPRegistrationDelegatingHandler.cs index 448e0566f6b7..1e1f89834bef 100644 --- a/src/ResourceManager/Common/Commands.ResourceManager.Common/RPRegistrationDelegatingHandler.cs +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/RPRegistrationDelegatingHandler.cs @@ -19,15 +19,19 @@ using System.Text; using System.Threading; using System.Threading.Tasks; +using Microsoft.Azure.Commands.ResourceManager.Common.Properties; using Microsoft.Azure.Common.Authentication; using Microsoft.Azure.Common.Authentication.Models; using Microsoft.Azure.Management.Resources; using Microsoft.Azure.Management.Resources.Models; +using Microsoft.WindowsAzure.Commands.Utilities.Common; namespace Microsoft.Azure.Common.Authentication.Models { - public class RPRegistrationDelegatingHandler : DelegatingHandler + public class RPRegistrationDelegatingHandler : DelegatingHandler, ICloneable { + private const short RetryCount = 3; + /// /// Contains all providers we have attempted to register /// @@ -35,15 +39,14 @@ public class RPRegistrationDelegatingHandler : DelegatingHandler private Func createClient; - private Action writeVerbose; - + private Action writeDebug; public ResourceManagementClient ResourceManagementClient { get; set; } - public RPRegistrationDelegatingHandler(Func createClient, Action writeVerbose) + public RPRegistrationDelegatingHandler(Func createClient, Action writeDebug) { registeredProviders = new HashSet(); - this.writeVerbose = writeVerbose; + this.writeDebug = writeDebug; this.createClient = createClient; } @@ -57,21 +60,29 @@ protected override async Task SendAsync(HttpRequestMessage var providerName = GetProviderName(request.RequestUri); if (!string.IsNullOrEmpty(providerName) && !registeredProviders.Contains(providerName)) { + // Force dispose for response messages to reclaim the used socket connection. + responseMessage.Dispose(); registeredProviders.Add(providerName); try { - writeVerbose(string.Format("Attempting to register resource provider '{0}'", providerName)); + writeDebug(string.Format(Resources.ResourceProviderRegisterAttempt, providerName)); ResourceManagementClient.Providers.Register(providerName); Provider provider = null; + short retryCount = 0; do { + if (retryCount++ > RetryCount) + { + throw new TimeoutException(); + } provider = ResourceManagementClient.Providers.Get(providerName).Provider; + TestMockSupport.Delay(1000); } while (provider.RegistrationState != RegistrationState.Registered.ToString()); - writeVerbose(string.Format("Succeeded to register resource provider '{0}'", providerName)); + writeDebug(string.Format(Resources.ResourceProviderRegisterSuccessful, providerName)); } - catch + catch (Exception e) { - writeVerbose(string.Format("Failed to register resource provider '{0}'", providerName)); + writeDebug(string.Format(Resources.ResourceProviderRegisterFailure, providerName, e.Message)); // Ignore RP registration errors. } @@ -99,5 +110,10 @@ private string GetProviderName(Uri requestUri) return (requestUri.Segments.Length > 7 && requestUri.Segments[5].ToLower() == "providers/") ? requestUri.Segments[6].ToLower().Trim('/') : null; } + + public object Clone() + { + return new RPRegistrationDelegatingHandler(createClient, writeDebug); + } } } diff --git a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/RMTestBase.cs b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/RMTestBase.cs index 4230f65ea99f..1a36deb52779 100644 --- a/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/RMTestBase.cs +++ b/src/ResourceManager/Common/Commands.ScenarioTests.ResourceManager.Common/RMTestBase.cs @@ -19,6 +19,7 @@ using Microsoft.Azure.Common.Authentication; using Microsoft.Azure.Commands.ResourceManager.Common; using Microsoft.WindowsAzure.Commands.Common; +using Microsoft.WindowsAzure.Commands.Utilities.Common; namespace Microsoft.WindowsAzure.Commands.Test.Utilities.Common { @@ -64,6 +65,7 @@ public void BaseSetup() } AzureSession.AuthenticationFactory = new MockTokenAuthenticationFactory(); + TestMockSupport.RunningMocked = true; } } } diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs b/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs index 8159dadce367..358efd617afb 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs +++ b/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs @@ -181,15 +181,67 @@ public void DoesNotInvokeRegistrationForIncompatibleUri() Assert.Equal(response.StatusCode, HttpStatusCode.Conflict); Assert.Equal(response.Content.ReadAsStringAsync().Result, "registered to use namespace"); } + + [Fact] + public void DoesNotHangForLongRegistrationCalls() + { + // Setup + Mock mockClient = new Mock(); + Mock mockProvidersOperations = new Mock(); + mockClient.Setup(f => f.Providers).Returns(mockProvidersOperations.Object); + mockProvidersOperations.Setup(f => f.GetAsync(It.IsAny(), It.IsAny())).Returns( + (string rp, CancellationToken token) => + { + ProviderGetResult r = new ProviderGetResult + { + Provider = new Provider + { + RegistrationState = RegistrationState.Pending.ToString() + } + }; + + return Task.FromResult(r); + } + ); + HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, compatibleUri); + Dictionary> mapping = new Dictionary> + { + { + request, new List + { + new HttpResponseMessage(HttpStatusCode.Conflict) { Content = new StringContent("registered to use namespace") }, + new HttpResponseMessage(HttpStatusCode.Conflict) { Content = new StringContent("registered to use namespace") } + } + } + }; + List msgs = new List(); + RPRegistrationDelegatingHandler rpHandler = new RPRegistrationDelegatingHandler(() => mockClient.Object, s => msgs.Add(s)) + { + InnerHandler = new MockResponseDelegatingHandler(mapping) + }; + HttpClient httpClient = new HttpClient(rpHandler); + + // Test + HttpResponseMessage response = httpClient.SendAsync(request).Result; + + // Assert + Assert.True(msgs.Any(s => s.Equals("Failed to register resource provider 'microsoft.compute'.Details: 'The operation has timed out.'"))); + Assert.Equal(response.StatusCode, HttpStatusCode.Conflict); + Assert.Equal(response.Content.ReadAsStringAsync().Result, "registered to use namespace"); + mockProvidersOperations.Verify(f => f.RegisterAsync("microsoft.compute", It.IsAny()), Times.AtMost(4)); + } } public class MockResponseDelegatingHandler : DelegatingHandler { Dictionary> mapping; + public int RequestsCount { get; set; } + public MockResponseDelegatingHandler(Dictionary> mapping) { this.mapping = mapping; + this.RequestsCount = 0; } protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) @@ -198,9 +250,9 @@ protected override async Task SendAsync(HttpRequestMessage { var response = mapping[request].First(); mapping[request].Remove(response); + RequestsCount++; return response; }); } - } -} +} \ No newline at end of file From a50858c36ef75131f2b4502bda0f47aebad3bc6e Mon Sep 17 00:00:00 2001 From: ogail Date: Tue, 6 Oct 2015 11:01:53 -0700 Subject: [PATCH 5/6] Remove dep. on ARM client package and add extra test --- .../AccessTokenExtensions.cs | 7 +- .../AzureRMCmdlet.cs | 14 +- .../Commands.ResourceManager.Common.csproj | 136 +- .../Generated/AuthorizationClient.cs | 254 ++ .../AuthorizationClientExtensions.cs | 28 + .../DeploymentOperationOperations.cs | 805 +++++ ...DeploymentOperationOperationsExtensions.cs | 180 + .../Generated/DeploymentOperations.cs | 2907 +++++++++++++++++ .../DeploymentOperationsExtensions.cs | 478 +++ .../Generated/FeatureClient.cs | 254 ++ .../Generated/FeatureClientExtensions.cs | 28 + .../Generated/Features.cs | 1186 +++++++ .../Generated/FeaturesExtensions.cs | 270 ++ .../Generated/IAuthorizationClient.cs | 78 + .../IDeploymentOperationOperations.cs | 87 + .../Generated/IDeploymentOperations.cs | 195 ++ .../Generated/IFeatureClient.cs | 78 + .../Generated/IFeatures.cs | 121 + .../Generated/IManagementLockOperations.cs | 233 ++ .../Generated/IProviderOperations.cs | 103 + .../IProviderOperationsMetadataOperations.cs | 58 + .../Generated/IResourceGroupOperations.cs | 163 + .../Generated/IResourceManagementClient.cs | 154 + .../Generated/IResourceOperations.cs | 170 + ...ourceProviderOperationDetailsOperations.cs | 47 + .../Generated/ISubscriptionClient.cs | 85 + .../Generated/ISubscriptionOperations.cs | 72 + .../Generated/ITagOperations.cs | 122 + .../Generated/ITenantOperations.cs | 44 + .../Generated/ManagementLockOperations.cs | 2314 +++++++++++++ .../ManagementLockOperationsExtensions.cs | 566 ++++ .../Generated/Models/BasicDependency.cs | 70 + .../Generated/Models/Dependency.cs | 51 + .../Generated/Models/Deployment.cs | 48 + .../Models/DeploymentExistsResult.cs | 49 + .../Generated/Models/DeploymentExtended.cs | 85 + .../Generated/Models/DeploymentGetResult.cs | 48 + .../Models/DeploymentListParameters.cs | 59 + .../Generated/Models/DeploymentListResult.cs | 62 + .../Generated/Models/DeploymentMode.cs | 34 + .../Generated/Models/DeploymentOperation.cs | 70 + .../Models/DeploymentOperationProperties.cs | 94 + .../DeploymentOperationsCreateResult.cs | 49 + .../Models/DeploymentOperationsGetResult.cs | 49 + .../DeploymentOperationsListParameters.cs | 49 + .../Models/DeploymentOperationsListResult.cs | 63 + .../Generated/Models/DeploymentProperties.cs | 96 + .../Models/DeploymentPropertiesExtended.cs | 111 + .../Models/DeploymentValidateResponse.cs | 71 + .../Models/FeatureOperationsListResult.cs | 62 + .../Generated/Models/FeatureProperties.cs | 48 + .../Generated/Models/FeatureResponse.cs | 81 + .../Generated/Models/GenericResource.cs | 85 + .../Models/GenericResourceExtended.cs | 85 + .../Generated/Models/GetSubscriptionResult.cs | 48 + .../Generated/Models/Location.cs | 104 + .../Generated/Models/LocationListResult.cs | 51 + .../Generated/Models/LockLevel.cs | 45 + .../Models/LongRunningOperationResponse.cs | 82 + .../Models/ManagementLockGetQueryParameter.cs | 51 + .../Models/ManagementLockListResult.cs | 62 + .../Generated/Models/ManagementLockObject.cs | 81 + .../Models/ManagementLockProperties.cs | 59 + .../Models/ManagementLockReturnResult.cs | 48 + .../Generated/Models/Operation.cs | 92 + .../Generated/Models/ParametersLink.cs | 75 + .../Generated/Models/Plan.cs | 81 + .../Generated/Models/Provider.cs | 84 + .../Generated/Models/ProviderGetResult.cs | 48 + .../Models/ProviderListParameters.cs | 48 + .../Generated/Models/ProviderListResult.cs | 62 + .../Models/ProviderOperationsMetadata.cs | 107 + .../ProviderOperationsMetadataGetResult.cs | 49 + .../ProviderOperationsMetadataListResult.cs | 52 + .../Models/ProviderRegistionResult.cs | 48 + .../Models/ProviderRegistrationState.cs | 50 + .../Generated/Models/ProviderResourceType.cs | 87 + .../Models/ProviderUnregistionResult.cs | 48 + .../Generated/Models/ProvisioningState.cs | 85 + .../Generated/Models/RegistrationState.cs | 50 + .../Models/ResourceCreateOrUpdateResult.cs | 49 + .../Generated/Models/ResourceExistsResult.cs | 49 + .../Generated/Models/ResourceGetResult.cs | 48 + .../Generated/Models/ResourceGroup.cs | 102 + .../ResourceGroupCreateOrUpdateResult.cs | 49 + .../Models/ResourceGroupExistsResult.cs | 49 + .../Generated/Models/ResourceGroupExtended.cs | 74 + .../Models/ResourceGroupGetResult.cs | 48 + .../Models/ResourceGroupListParameters.cs | 72 + .../Models/ResourceGroupListResult.cs | 77 + .../Models/ResourceGroupPatchResult.cs | 48 + .../Models/ResourceListParameters.cs | 96 + .../Generated/Models/ResourceListResult.cs | 77 + .../Models/ResourceManagementError.cs | 87 + .../ResourceManagementErrorWithDetails.cs | 69 + .../ResourceProviderOperationDefinition.cs | 61 + ...sourceProviderOperationDetailListResult.cs | 52 + ...ourceProviderOperationDisplayProperties.cs | 93 + .../Generated/Models/ResourceType.cs | 73 + .../Generated/Models/ResourcesMoveInfo.cs | 62 + .../Generated/Models/Subscription.cs | 82 + .../Models/SubscriptionListResult.cs | 51 + .../Generated/Models/TagCount.cs | 59 + .../Generated/Models/TagCreateResult.cs | 48 + .../Generated/Models/TagCreateValueResult.cs | 48 + .../Generated/Models/TagDetails.cs | 84 + .../Generated/Models/TagValue.cs | 70 + .../Generated/Models/TagsListResult.cs | 77 + .../Generated/Models/TargetResource.cs | 70 + .../Generated/Models/TemplateLink.cs | 75 + .../Generated/Models/TenantIdDescription.cs | 59 + .../Generated/Models/TenantListResult.cs | 51 + .../Generated/ProviderOperations.cs | 1150 +++++++ .../Generated/ProviderOperationsExtensions.cs | 234 ++ .../ProviderOperationsMetadataOperations.cs | 635 ++++ ...rOperationsMetadataOperationsExtensions.cs | 104 + .../Generated/ResourceGroupOperations.cs | 1615 +++++++++ .../ResourceGroupOperationsExtensions.cs | 392 +++ .../Generated/ResourceManagementClient.cs | 469 +++ .../ResourceManagementClientExtensions.cs | 76 + .../Generated/ResourceOperations.cs | 1847 +++++++++++ .../Generated/ResourceOperationsExtensions.cs | 412 +++ ...ourceProviderOperationDetailsOperations.cs | 280 ++ ...derOperationDetailsOperationsExtensions.cs | 70 + .../Generated/SubscriptionClient.cs | 257 ++ .../Generated/SubscriptionClientExtensions.cs | 28 + .../Generated/SubscriptionOperations.cs | 598 ++++ .../SubscriptionOperationsExtensions.cs | 144 + .../Generated/TagOperations.cs | 1216 +++++++ .../Generated/TagOperationsExtensions.cs | 282 ++ .../Generated/TenantOperations.cs | 218 ++ .../Generated/TenantOperationsExtensions.cs | 62 + .../Properties/AssemblyInfo.cs | 8 +- .../Properties/Resources.Designer.cs | 8 +- .../RPRegistrationDelegatingHandler.cs | 8 +- .../packages.config | 1 - .../RPRegistrationDelegatingHandlerTests.cs | 49 +- .../Commands.Profile/Commands.Profile.csproj | 2 + .../Models}/ModelExtensions.cs | 5 +- .../Models}/RMProfileClient.cs | 0 140 files changed, 26691 insertions(+), 41 deletions(-) create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/AuthorizationClient.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/AuthorizationClientExtensions.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/DeploymentOperationOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/DeploymentOperationOperationsExtensions.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/DeploymentOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/DeploymentOperationsExtensions.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/FeatureClient.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/FeatureClientExtensions.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Features.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/FeaturesExtensions.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IAuthorizationClient.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IDeploymentOperationOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IDeploymentOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IFeatureClient.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IFeatures.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IManagementLockOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IProviderOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IProviderOperationsMetadataOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IResourceGroupOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IResourceManagementClient.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IResourceOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IResourceProviderOperationDetailsOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ISubscriptionClient.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ISubscriptionOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ITagOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ITenantOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ManagementLockOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ManagementLockOperationsExtensions.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/BasicDependency.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Dependency.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Deployment.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentExistsResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentExtended.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentGetResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentListParameters.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentListResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentMode.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperation.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationProperties.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationsCreateResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationsGetResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationsListParameters.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationsListResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentProperties.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentPropertiesExtended.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentValidateResponse.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/FeatureOperationsListResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/FeatureProperties.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/FeatureResponse.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/GenericResource.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/GenericResourceExtended.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/GetSubscriptionResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Location.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/LocationListResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/LockLevel.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/LongRunningOperationResponse.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockGetQueryParameter.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockListResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockObject.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockProperties.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockReturnResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Operation.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ParametersLink.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Plan.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Provider.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderGetResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderListParameters.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderListResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderOperationsMetadata.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderOperationsMetadataGetResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderOperationsMetadataListResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderRegistionResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderRegistrationState.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderResourceType.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderUnregistionResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProvisioningState.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/RegistrationState.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceCreateOrUpdateResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceExistsResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGetResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroup.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupCreateOrUpdateResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupExistsResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupExtended.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupGetResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupListParameters.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupListResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupPatchResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceListParameters.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceListResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceManagementError.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceManagementErrorWithDetails.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceProviderOperationDefinition.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceProviderOperationDetailListResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceProviderOperationDisplayProperties.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceType.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourcesMoveInfo.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Subscription.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/SubscriptionListResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagCount.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagCreateResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagCreateValueResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagDetails.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagValue.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagsListResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TargetResource.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TemplateLink.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TenantIdDescription.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TenantListResult.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ProviderOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ProviderOperationsExtensions.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ProviderOperationsMetadataOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ProviderOperationsMetadataOperationsExtensions.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceGroupOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceGroupOperationsExtensions.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceManagementClient.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceManagementClientExtensions.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceOperationsExtensions.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceProviderOperationDetailsOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceProviderOperationDetailsOperationsExtensions.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/SubscriptionClient.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/SubscriptionClientExtensions.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/SubscriptionOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/SubscriptionOperationsExtensions.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/TagOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/TagOperationsExtensions.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/TenantOperations.cs create mode 100644 src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/TenantOperationsExtensions.cs rename src/ResourceManager/{Common/Commands.ResourceManager.Common => Profile/Commands.Profile/Models}/ModelExtensions.cs (90%) rename src/ResourceManager/{Common/Commands.ResourceManager.Common => Profile/Commands.Profile/Models}/RMProfileClient.cs (100%) diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/AccessTokenExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/AccessTokenExtensions.cs index 86c79b1061f9..b0d2563c5d43 100644 --- a/src/ResourceManager/Common/Commands.ResourceManager.Common/AccessTokenExtensions.cs +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/AccessTokenExtensions.cs @@ -1,9 +1,6 @@ -using Microsoft.Azure.Common.Authentication; -using System; -using System.Collections.Generic; +using System; using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Microsoft.Azure.Common.Authentication; namespace Microsoft.Azure.Commands.ResourceManager.Common { diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/AzureRMCmdlet.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/AzureRMCmdlet.cs index 9c913d868339..cfdd74df9587 100644 --- a/src/ResourceManager/Common/Commands.ResourceManager.Common/AzureRMCmdlet.cs +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/AzureRMCmdlet.cs @@ -12,18 +12,18 @@ // limitations under the License. // ---------------------------------------------------------------------------------- +using System; +using System.IO; using System.Management.Automation; +using System.Management.Automation.Host; +using System.Threading; +using Microsoft.Azure.Commands.ResourceManager.Common.Properties; using Microsoft.Azure.Common.Authentication; using Microsoft.Azure.Common.Authentication.Models; +using Microsoft.Azure.Management.Internal.Resources; +using Microsoft.WindowsAzure.Commands.Common; using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System.IO; using Newtonsoft.Json; -using Microsoft.Azure.Commands.ResourceManager.Common.Properties; -using System; -using System.Threading; -using System.Management.Automation.Host; -using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.Azure.Management.Resources; namespace Microsoft.Azure.Commands.ResourceManager.Common { diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Commands.ResourceManager.Common.csproj b/src/ResourceManager/Common/Commands.ResourceManager.Common/Commands.ResourceManager.Common.csproj index e9b28cf8fa68..ddd95a47cda3 100644 --- a/src/ResourceManager/Common/Commands.ResourceManager.Common/Commands.ResourceManager.Common.csproj +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Commands.ResourceManager.Common.csproj @@ -68,10 +68,6 @@ False ..\..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.NetFramework.dll - - False - ..\..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll - False ..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.dll @@ -142,15 +138,143 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + True True Resources.resx - + Designer diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/AuthorizationClient.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/AuthorizationClient.cs new file mode 100644 index 000000000000..4a25ef52c217 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/AuthorizationClient.cs @@ -0,0 +1,254 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Net.Http; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public partial class AuthorizationClient : ServiceClient, IAuthorizationClient + { + private string _apiVersion; + + /// + /// Gets the API version. + /// + public string ApiVersion + { + get { return this._apiVersion; } + } + + private Uri _baseUri; + + /// + /// Gets the URI used as the base for all cloud service requests. + /// + public Uri BaseUri + { + get { return this._baseUri; } + } + + private SubscriptionCloudCredentials _credentials; + + /// + /// Gets subscription credentials which uniquely identify Microsoft + /// Azure subscription. The subscription ID forms part of the URI for + /// every service call. + /// + public SubscriptionCloudCredentials Credentials + { + get { return this._credentials; } + } + + private int _longRunningOperationInitialTimeout; + + /// + /// Gets or sets the initial timeout for Long Running Operations. + /// + public int LongRunningOperationInitialTimeout + { + get { return this._longRunningOperationInitialTimeout; } + set { this._longRunningOperationInitialTimeout = value; } + } + + private int _longRunningOperationRetryTimeout; + + /// + /// Gets or sets the retry timeout for Long Running Operations. + /// + public int LongRunningOperationRetryTimeout + { + get { return this._longRunningOperationRetryTimeout; } + set { this._longRunningOperationRetryTimeout = value; } + } + + private IManagementLockOperations _managementLocks; + + /// + /// Operations for managing locks. + /// + public virtual IManagementLockOperations ManagementLocks + { + get { return this._managementLocks; } + } + + /// + /// Initializes a new instance of the AuthorizationClient class. + /// + public AuthorizationClient() + : base() + { + this._managementLocks = new ManagementLockOperations(this); + this._apiVersion = "2015-01-01"; + this._longRunningOperationInitialTimeout = -1; + this._longRunningOperationRetryTimeout = -1; + this.HttpClient.Timeout = TimeSpan.FromSeconds(300); + } + + /// + /// Initializes a new instance of the AuthorizationClient class. + /// + /// + /// Required. Gets subscription credentials which uniquely identify + /// Microsoft Azure subscription. The subscription ID forms part of + /// the URI for every service call. + /// + /// + /// Optional. Gets the URI used as the base for all cloud service + /// requests. + /// + public AuthorizationClient(SubscriptionCloudCredentials credentials, Uri baseUri) + : this() + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + this._credentials = credentials; + this._baseUri = baseUri; + + this.Credentials.InitializeServiceClient(this); + } + + /// + /// Initializes a new instance of the AuthorizationClient class. + /// + /// + /// Required. Gets subscription credentials which uniquely identify + /// Microsoft Azure subscription. The subscription ID forms part of + /// the URI for every service call. + /// + public AuthorizationClient(SubscriptionCloudCredentials credentials) + : this() + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this._credentials = credentials; + this._baseUri = new Uri("https://management.azure.com/"); + + this.Credentials.InitializeServiceClient(this); + } + + /// + /// Initializes a new instance of the AuthorizationClient class. + /// + /// + /// The Http client + /// + public AuthorizationClient(HttpClient httpClient) + : base(httpClient) + { + this._managementLocks = new ManagementLockOperations(this); + this._apiVersion = "2015-01-01"; + this._longRunningOperationInitialTimeout = -1; + this._longRunningOperationRetryTimeout = -1; + this.HttpClient.Timeout = TimeSpan.FromSeconds(300); + } + + /// + /// Initializes a new instance of the AuthorizationClient class. + /// + /// + /// Required. Gets subscription credentials which uniquely identify + /// Microsoft Azure subscription. The subscription ID forms part of + /// the URI for every service call. + /// + /// + /// Optional. Gets the URI used as the base for all cloud service + /// requests. + /// + /// + /// The Http client + /// + public AuthorizationClient(SubscriptionCloudCredentials credentials, Uri baseUri, HttpClient httpClient) + : this(httpClient) + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + this._credentials = credentials; + this._baseUri = baseUri; + + this.Credentials.InitializeServiceClient(this); + } + + /// + /// Initializes a new instance of the AuthorizationClient class. + /// + /// + /// Required. Gets subscription credentials which uniquely identify + /// Microsoft Azure subscription. The subscription ID forms part of + /// the URI for every service call. + /// + /// + /// The Http client + /// + public AuthorizationClient(SubscriptionCloudCredentials credentials, HttpClient httpClient) + : this(httpClient) + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this._credentials = credentials; + this._baseUri = new Uri("https://management.azure.com/"); + + this.Credentials.InitializeServiceClient(this); + } + + /// + /// Clones properties from current instance to another + /// AuthorizationClient instance + /// + /// + /// Instance of AuthorizationClient to clone to + /// + protected override void Clone(ServiceClient client) + { + base.Clone(client); + + if (client is AuthorizationClient) + { + AuthorizationClient clonedClient = ((AuthorizationClient)client); + + clonedClient._credentials = this._credentials; + clonedClient._baseUri = this._baseUri; + clonedClient._apiVersion = this._apiVersion; + clonedClient._longRunningOperationInitialTimeout = this._longRunningOperationInitialTimeout; + clonedClient._longRunningOperationRetryTimeout = this._longRunningOperationRetryTimeout; + + clonedClient.Credentials.InitializeServiceClient(clonedClient); + } + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/AuthorizationClientExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/AuthorizationClientExtensions.cs new file mode 100644 index 000000000000..a36e7a598a85 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/AuthorizationClientExtensions.cs @@ -0,0 +1,28 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public static partial class AuthorizationClientExtensions + { + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/DeploymentOperationOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/DeploymentOperationOperations.cs new file mode 100644 index 000000000000..873a47a640b8 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/DeploymentOperationOperations.cs @@ -0,0 +1,805 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using Hyak.Common; +using Microsoft.Azure.Management.Internal.Resources.Models; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing deployment operations. + /// + internal partial class DeploymentOperationOperations : IServiceOperations, IDeploymentOperationOperations + { + /// + /// Initializes a new instance of the DeploymentOperationOperations + /// class. + /// + /// + /// Reference to the service client. + /// + internal DeploymentOperationOperations(ResourceManagementClient client) + { + this._client = client; + } + + private ResourceManagementClient _client; + + /// + /// Gets a reference to the + /// Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient. + /// + public ResourceManagementClient Client + { + get { return this._client; } + } + + /// + /// Get a list of deployments operations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Required. Operation Id. + /// + /// + /// Cancellation token. + /// + /// + /// Deployment operation. + /// + public async Task GetAsync(string resourceGroupName, string deploymentName, string operationId, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (deploymentName == null) + { + throw new ArgumentNullException("deploymentName"); + } + if (operationId == null) + { + throw new ArgumentNullException("operationId"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("operationId", operationId); + TracingAdapter.Enter(invocationId, this, "GetAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + url = url + "/deployments/"; + url = url + Uri.EscapeDataString(deploymentName); + url = url + "/operations/"; + url = url + Uri.EscapeDataString(operationId); + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + DeploymentOperationsGetResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new DeploymentOperationsGetResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + DeploymentOperation operationInstance = new DeploymentOperation(); + result.Operation = operationInstance; + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + operationInstance.Id = idInstance; + } + + JToken operationIdValue = responseDoc["operationId"]; + if (operationIdValue != null && operationIdValue.Type != JTokenType.Null) + { + string operationIdInstance = ((string)operationIdValue); + operationInstance.OperationId = operationIdInstance; + } + + JToken propertiesValue = responseDoc["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + DeploymentOperationProperties propertiesInstance = new DeploymentOperationProperties(); + operationInstance.Properties = propertiesInstance; + + JToken provisioningStateValue = propertiesValue["provisioningState"]; + if (provisioningStateValue != null && provisioningStateValue.Type != JTokenType.Null) + { + string provisioningStateInstance = ((string)provisioningStateValue); + propertiesInstance.ProvisioningState = provisioningStateInstance; + } + + JToken timestampValue = propertiesValue["timestamp"]; + if (timestampValue != null && timestampValue.Type != JTokenType.Null) + { + DateTime timestampInstance = ((DateTime)timestampValue); + propertiesInstance.Timestamp = timestampInstance; + } + + JToken statusCodeValue = propertiesValue["statusCode"]; + if (statusCodeValue != null && statusCodeValue.Type != JTokenType.Null) + { + string statusCodeInstance = ((string)statusCodeValue); + propertiesInstance.StatusCode = statusCodeInstance; + } + + JToken statusMessageValue = propertiesValue["statusMessage"]; + if (statusMessageValue != null && statusMessageValue.Type != JTokenType.Null) + { + string statusMessageInstance = statusMessageValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.StatusMessage = statusMessageInstance; + } + + JToken targetResourceValue = propertiesValue["targetResource"]; + if (targetResourceValue != null && targetResourceValue.Type != JTokenType.Null) + { + TargetResource targetResourceInstance = new TargetResource(); + propertiesInstance.TargetResource = targetResourceInstance; + + JToken idValue2 = targetResourceValue["id"]; + if (idValue2 != null && idValue2.Type != JTokenType.Null) + { + string idInstance2 = ((string)idValue2); + targetResourceInstance.Id = idInstance2; + } + + JToken resourceNameValue = targetResourceValue["resourceName"]; + if (resourceNameValue != null && resourceNameValue.Type != JTokenType.Null) + { + string resourceNameInstance = ((string)resourceNameValue); + targetResourceInstance.ResourceName = resourceNameInstance; + } + + JToken resourceTypeValue = targetResourceValue["resourceType"]; + if (resourceTypeValue != null && resourceTypeValue.Type != JTokenType.Null) + { + string resourceTypeInstance = ((string)resourceTypeValue); + targetResourceInstance.ResourceType = resourceTypeInstance; + } + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Gets a list of deployments operations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Optional. Query parameters. + /// + /// + /// Cancellation token. + /// + /// + /// List of deployment operations. + /// + public async Task ListAsync(string resourceGroupName, string deploymentName, DeploymentOperationsListParameters parameters, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (deploymentName == null) + { + throw new ArgumentNullException("deploymentName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "ListAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + url = url + "/deployments/"; + url = url + Uri.EscapeDataString(deploymentName); + url = url + "/operations"; + List queryParameters = new List(); + if (parameters != null && parameters.Top != null) + { + queryParameters.Add("$top=" + Uri.EscapeDataString(parameters.Top.Value.ToString())); + } + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + DeploymentOperationsListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new DeploymentOperationsListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + DeploymentOperation deploymentOperationInstance = new DeploymentOperation(); + result.Operations.Add(deploymentOperationInstance); + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + deploymentOperationInstance.Id = idInstance; + } + + JToken operationIdValue = valueValue["operationId"]; + if (operationIdValue != null && operationIdValue.Type != JTokenType.Null) + { + string operationIdInstance = ((string)operationIdValue); + deploymentOperationInstance.OperationId = operationIdInstance; + } + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + DeploymentOperationProperties propertiesInstance = new DeploymentOperationProperties(); + deploymentOperationInstance.Properties = propertiesInstance; + + JToken provisioningStateValue = propertiesValue["provisioningState"]; + if (provisioningStateValue != null && provisioningStateValue.Type != JTokenType.Null) + { + string provisioningStateInstance = ((string)provisioningStateValue); + propertiesInstance.ProvisioningState = provisioningStateInstance; + } + + JToken timestampValue = propertiesValue["timestamp"]; + if (timestampValue != null && timestampValue.Type != JTokenType.Null) + { + DateTime timestampInstance = ((DateTime)timestampValue); + propertiesInstance.Timestamp = timestampInstance; + } + + JToken statusCodeValue = propertiesValue["statusCode"]; + if (statusCodeValue != null && statusCodeValue.Type != JTokenType.Null) + { + string statusCodeInstance = ((string)statusCodeValue); + propertiesInstance.StatusCode = statusCodeInstance; + } + + JToken statusMessageValue = propertiesValue["statusMessage"]; + if (statusMessageValue != null && statusMessageValue.Type != JTokenType.Null) + { + string statusMessageInstance = statusMessageValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.StatusMessage = statusMessageInstance; + } + + JToken targetResourceValue = propertiesValue["targetResource"]; + if (targetResourceValue != null && targetResourceValue.Type != JTokenType.Null) + { + TargetResource targetResourceInstance = new TargetResource(); + propertiesInstance.TargetResource = targetResourceInstance; + + JToken idValue2 = targetResourceValue["id"]; + if (idValue2 != null && idValue2.Type != JTokenType.Null) + { + string idInstance2 = ((string)idValue2); + targetResourceInstance.Id = idInstance2; + } + + JToken resourceNameValue = targetResourceValue["resourceName"]; + if (resourceNameValue != null && resourceNameValue.Type != JTokenType.Null) + { + string resourceNameInstance = ((string)resourceNameValue); + targetResourceInstance.ResourceName = resourceNameInstance; + } + + JToken resourceTypeValue = targetResourceValue["resourceType"]; + if (resourceTypeValue != null && resourceTypeValue.Type != JTokenType.Null) + { + string resourceTypeInstance = ((string)resourceTypeValue); + targetResourceInstance.ResourceType = resourceTypeInstance; + } + } + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Gets a next list of deployments operations. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of deployment operations. + /// + public async Task ListNextAsync(string nextLink, CancellationToken cancellationToken) + { + // Validate + if (nextLink == null) + { + throw new ArgumentNullException("nextLink"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextLink", nextLink); + TracingAdapter.Enter(invocationId, this, "ListNextAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + nextLink; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + DeploymentOperationsListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new DeploymentOperationsListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + DeploymentOperation deploymentOperationInstance = new DeploymentOperation(); + result.Operations.Add(deploymentOperationInstance); + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + deploymentOperationInstance.Id = idInstance; + } + + JToken operationIdValue = valueValue["operationId"]; + if (operationIdValue != null && operationIdValue.Type != JTokenType.Null) + { + string operationIdInstance = ((string)operationIdValue); + deploymentOperationInstance.OperationId = operationIdInstance; + } + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + DeploymentOperationProperties propertiesInstance = new DeploymentOperationProperties(); + deploymentOperationInstance.Properties = propertiesInstance; + + JToken provisioningStateValue = propertiesValue["provisioningState"]; + if (provisioningStateValue != null && provisioningStateValue.Type != JTokenType.Null) + { + string provisioningStateInstance = ((string)provisioningStateValue); + propertiesInstance.ProvisioningState = provisioningStateInstance; + } + + JToken timestampValue = propertiesValue["timestamp"]; + if (timestampValue != null && timestampValue.Type != JTokenType.Null) + { + DateTime timestampInstance = ((DateTime)timestampValue); + propertiesInstance.Timestamp = timestampInstance; + } + + JToken statusCodeValue = propertiesValue["statusCode"]; + if (statusCodeValue != null && statusCodeValue.Type != JTokenType.Null) + { + string statusCodeInstance = ((string)statusCodeValue); + propertiesInstance.StatusCode = statusCodeInstance; + } + + JToken statusMessageValue = propertiesValue["statusMessage"]; + if (statusMessageValue != null && statusMessageValue.Type != JTokenType.Null) + { + string statusMessageInstance = statusMessageValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.StatusMessage = statusMessageInstance; + } + + JToken targetResourceValue = propertiesValue["targetResource"]; + if (targetResourceValue != null && targetResourceValue.Type != JTokenType.Null) + { + TargetResource targetResourceInstance = new TargetResource(); + propertiesInstance.TargetResource = targetResourceInstance; + + JToken idValue2 = targetResourceValue["id"]; + if (idValue2 != null && idValue2.Type != JTokenType.Null) + { + string idInstance2 = ((string)idValue2); + targetResourceInstance.Id = idInstance2; + } + + JToken resourceNameValue = targetResourceValue["resourceName"]; + if (resourceNameValue != null && resourceNameValue.Type != JTokenType.Null) + { + string resourceNameInstance = ((string)resourceNameValue); + targetResourceInstance.ResourceName = resourceNameInstance; + } + + JToken resourceTypeValue = targetResourceValue["resourceType"]; + if (resourceTypeValue != null && resourceTypeValue.Type != JTokenType.Null) + { + string resourceTypeInstance = ((string)resourceTypeValue); + targetResourceInstance.ResourceType = resourceTypeInstance; + } + } + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/DeploymentOperationOperationsExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/DeploymentOperationOperationsExtensions.cs new file mode 100644 index 000000000000..301cc5d665ee --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/DeploymentOperationOperationsExtensions.cs @@ -0,0 +1,180 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public static partial class DeploymentOperationOperationsExtensions + { + /// + /// Get a list of deployments operations. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperationOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Required. Operation Id. + /// + /// + /// Deployment operation. + /// + public static DeploymentOperationsGetResult Get(this IDeploymentOperationOperations operations, string resourceGroupName, string deploymentName, string operationId) + { + return Task.Factory.StartNew((object s) => + { + return ((IDeploymentOperationOperations)s).GetAsync(resourceGroupName, deploymentName, operationId); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get a list of deployments operations. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperationOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Required. Operation Id. + /// + /// + /// Deployment operation. + /// + public static Task GetAsync(this IDeploymentOperationOperations operations, string resourceGroupName, string deploymentName, string operationId) + { + return operations.GetAsync(resourceGroupName, deploymentName, operationId, CancellationToken.None); + } + + /// + /// Gets a list of deployments operations. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperationOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Optional. Query parameters. + /// + /// + /// List of deployment operations. + /// + public static DeploymentOperationsListResult List(this IDeploymentOperationOperations operations, string resourceGroupName, string deploymentName, DeploymentOperationsListParameters parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IDeploymentOperationOperations)s).ListAsync(resourceGroupName, deploymentName, parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets a list of deployments operations. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperationOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Optional. Query parameters. + /// + /// + /// List of deployment operations. + /// + public static Task ListAsync(this IDeploymentOperationOperations operations, string resourceGroupName, string deploymentName, DeploymentOperationsListParameters parameters) + { + return operations.ListAsync(resourceGroupName, deploymentName, parameters, CancellationToken.None); + } + + /// + /// Gets a next list of deployments operations. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperationOperations. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of deployment operations. + /// + public static DeploymentOperationsListResult ListNext(this IDeploymentOperationOperations operations, string nextLink) + { + return Task.Factory.StartNew((object s) => + { + return ((IDeploymentOperationOperations)s).ListNextAsync(nextLink); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets a next list of deployments operations. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperationOperations. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of deployment operations. + /// + public static Task ListNextAsync(this IDeploymentOperationOperations operations, string nextLink) + { + return operations.ListNextAsync(nextLink, CancellationToken.None); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/DeploymentOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/DeploymentOperations.cs new file mode 100644 index 000000000000..efcb058f5abf --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/DeploymentOperations.cs @@ -0,0 +1,2907 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using Hyak.Common; +using Hyak.Common.Internals; +using Microsoft.Azure.Management.Internal.Resources.Models; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing deployments. + /// + internal partial class DeploymentOperations : IServiceOperations, IDeploymentOperations + { + /// + /// Initializes a new instance of the DeploymentOperations class. + /// + /// + /// Reference to the service client. + /// + internal DeploymentOperations(ResourceManagementClient client) + { + this._client = client; + } + + private ResourceManagementClient _client; + + /// + /// Gets a reference to the + /// Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient. + /// + public ResourceManagementClient Client + { + get { return this._client; } + } + + /// + /// Begin deleting deployment.To determine whether the operation has + /// finished processing the request, call + /// GetLongRunningOperationStatus. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment to be deleted. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response for long running operations. + /// + public async Task BeginDeletingAsync(string resourceGroupName, string deploymentName, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (deploymentName == null) + { + throw new ArgumentNullException("deploymentName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + TracingAdapter.Enter(invocationId, this, "BeginDeletingAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + url = url + "/deployments/"; + url = url + Uri.EscapeDataString(deploymentName); + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Delete; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.Accepted && statusCode != HttpStatusCode.NoContent) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + LongRunningOperationResponse result = null; + // Deserialize Response + result = new LongRunningOperationResponse(); + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("Location")) + { + result.OperationStatusLink = httpResponse.Headers.GetValues("Location").FirstOrDefault(); + } + if (httpResponse.Headers.Contains("Retry-After")) + { + result.RetryAfter = int.Parse(httpResponse.Headers.GetValues("Retry-After").FirstOrDefault(), CultureInfo.InvariantCulture); + } + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (statusCode == HttpStatusCode.Conflict) + { + result.Status = OperationStatus.Failed; + } + if (statusCode == HttpStatusCode.Accepted) + { + result.Status = OperationStatus.InProgress; + } + if (statusCode == HttpStatusCode.NoContent) + { + result.Status = OperationStatus.Succeeded; + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Cancel a currently running template deployment. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public async Task CancelAsync(string resourceGroupName, string deploymentName, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (deploymentName == null) + { + throw new ArgumentNullException("deploymentName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + TracingAdapter.Enter(invocationId, this, "CancelAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + url = url + "/deployments/"; + url = url + Uri.EscapeDataString(deploymentName); + url = url + "/cancel"; + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Post; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.NoContent) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + AzureOperationResponse result = null; + // Deserialize Response + result = new AzureOperationResponse(); + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Checks whether deployment exists. + /// + /// + /// Required. The name of the resource group to check. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Cancellation token. + /// + /// + /// Deployment information. + /// + public async Task CheckExistenceAsync(string resourceGroupName, string deploymentName, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (deploymentName == null) + { + throw new ArgumentNullException("deploymentName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + TracingAdapter.Enter(invocationId, this, "CheckExistenceAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + url = url + "/deployments/"; + url = url + Uri.EscapeDataString(deploymentName); + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Head; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.NoContent && statusCode != HttpStatusCode.NotFound) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + DeploymentExistsResult result = null; + // Deserialize Response + result = new DeploymentExistsResult(); + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (statusCode == HttpStatusCode.NoContent) + { + result.Exists = true; + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Create a named template deployment using a template. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Required. Additional parameters supplied to the operation. + /// + /// + /// Cancellation token. + /// + /// + /// Template deployment operation create result. + /// + public async Task CreateOrUpdateAsync(string resourceGroupName, string deploymentName, Deployment parameters, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (deploymentName == null) + { + throw new ArgumentNullException("deploymentName"); + } + if (parameters == null) + { + throw new ArgumentNullException("parameters"); + } + if (parameters.Properties != null) + { + if (parameters.Properties.ParametersLink != null) + { + if (parameters.Properties.ParametersLink.Uri == null) + { + throw new ArgumentNullException("parameters.Properties.ParametersLink.Uri"); + } + } + if (parameters.Properties.TemplateLink != null) + { + if (parameters.Properties.TemplateLink.Uri == null) + { + throw new ArgumentNullException("parameters.Properties.TemplateLink.Uri"); + } + } + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "CreateOrUpdateAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + url = url + "/deployments/"; + url = url + Uri.EscapeDataString(deploymentName); + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Put; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Serialize Request + string requestContent = null; + JToken requestDoc = null; + + JObject deploymentValue = new JObject(); + requestDoc = deploymentValue; + + if (parameters.Properties != null) + { + JObject propertiesValue = new JObject(); + deploymentValue["properties"] = propertiesValue; + + if (parameters.Properties.Template != null) + { + propertiesValue["template"] = JObject.Parse(parameters.Properties.Template); + } + + if (parameters.Properties.TemplateLink != null) + { + JObject templateLinkValue = new JObject(); + propertiesValue["templateLink"] = templateLinkValue; + + templateLinkValue["uri"] = parameters.Properties.TemplateLink.Uri.AbsoluteUri; + + if (parameters.Properties.TemplateLink.ContentVersion != null) + { + templateLinkValue["contentVersion"] = parameters.Properties.TemplateLink.ContentVersion; + } + } + + if (parameters.Properties.Parameters != null) + { + propertiesValue["parameters"] = JObject.Parse(parameters.Properties.Parameters); + } + + if (parameters.Properties.ParametersLink != null) + { + JObject parametersLinkValue = new JObject(); + propertiesValue["parametersLink"] = parametersLinkValue; + + parametersLinkValue["uri"] = parameters.Properties.ParametersLink.Uri.AbsoluteUri; + + if (parameters.Properties.ParametersLink.ContentVersion != null) + { + parametersLinkValue["contentVersion"] = parameters.Properties.ParametersLink.ContentVersion; + } + } + + propertiesValue["mode"] = parameters.Properties.Mode.ToString(); + } + + requestContent = requestDoc.ToString(Newtonsoft.Json.Formatting.Indented); + httpRequest.Content = new StringContent(requestContent, Encoding.UTF8); + httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.Created) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, requestContent, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + DeploymentOperationsCreateResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.Created) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new DeploymentOperationsCreateResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + DeploymentExtended deploymentInstance = new DeploymentExtended(); + result.Deployment = deploymentInstance; + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + deploymentInstance.Id = idInstance; + } + + JToken nameValue = responseDoc["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + deploymentInstance.Name = nameInstance; + } + + JToken propertiesValue2 = responseDoc["properties"]; + if (propertiesValue2 != null && propertiesValue2.Type != JTokenType.Null) + { + DeploymentPropertiesExtended propertiesInstance = new DeploymentPropertiesExtended(); + deploymentInstance.Properties = propertiesInstance; + + JToken provisioningStateValue = propertiesValue2["provisioningState"]; + if (provisioningStateValue != null && provisioningStateValue.Type != JTokenType.Null) + { + string provisioningStateInstance = ((string)provisioningStateValue); + propertiesInstance.ProvisioningState = provisioningStateInstance; + } + + JToken correlationIdValue = propertiesValue2["correlationId"]; + if (correlationIdValue != null && correlationIdValue.Type != JTokenType.Null) + { + string correlationIdInstance = ((string)correlationIdValue); + propertiesInstance.CorrelationId = correlationIdInstance; + } + + JToken timestampValue = propertiesValue2["timestamp"]; + if (timestampValue != null && timestampValue.Type != JTokenType.Null) + { + DateTime timestampInstance = ((DateTime)timestampValue); + propertiesInstance.Timestamp = timestampInstance; + } + + JToken outputsValue = propertiesValue2["outputs"]; + if (outputsValue != null && outputsValue.Type != JTokenType.Null) + { + string outputsInstance = outputsValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.Outputs = outputsInstance; + } + + JToken providersArray = propertiesValue2["providers"]; + if (providersArray != null && providersArray.Type != JTokenType.Null) + { + foreach (JToken providersValue in ((JArray)providersArray)) + { + Provider providerInstance = new Provider(); + propertiesInstance.Providers.Add(providerInstance); + + JToken idValue2 = providersValue["id"]; + if (idValue2 != null && idValue2.Type != JTokenType.Null) + { + string idInstance2 = ((string)idValue2); + providerInstance.Id = idInstance2; + } + + JToken namespaceValue = providersValue["namespace"]; + if (namespaceValue != null && namespaceValue.Type != JTokenType.Null) + { + string namespaceInstance = ((string)namespaceValue); + providerInstance.Namespace = namespaceInstance; + } + + JToken registrationStateValue = providersValue["registrationState"]; + if (registrationStateValue != null && registrationStateValue.Type != JTokenType.Null) + { + string registrationStateInstance = ((string)registrationStateValue); + providerInstance.RegistrationState = registrationStateInstance; + } + + JToken resourceTypesArray = providersValue["resourceTypes"]; + if (resourceTypesArray != null && resourceTypesArray.Type != JTokenType.Null) + { + foreach (JToken resourceTypesValue in ((JArray)resourceTypesArray)) + { + ProviderResourceType providerResourceTypeInstance = new ProviderResourceType(); + providerInstance.ResourceTypes.Add(providerResourceTypeInstance); + + JToken resourceTypeValue = resourceTypesValue["resourceType"]; + if (resourceTypeValue != null && resourceTypeValue.Type != JTokenType.Null) + { + string resourceTypeInstance = ((string)resourceTypeValue); + providerResourceTypeInstance.Name = resourceTypeInstance; + } + + JToken locationsArray = resourceTypesValue["locations"]; + if (locationsArray != null && locationsArray.Type != JTokenType.Null) + { + foreach (JToken locationsValue in ((JArray)locationsArray)) + { + providerResourceTypeInstance.Locations.Add(((string)locationsValue)); + } + } + + JToken apiVersionsArray = resourceTypesValue["apiVersions"]; + if (apiVersionsArray != null && apiVersionsArray.Type != JTokenType.Null) + { + foreach (JToken apiVersionsValue in ((JArray)apiVersionsArray)) + { + providerResourceTypeInstance.ApiVersions.Add(((string)apiVersionsValue)); + } + } + + JToken propertiesSequenceElement = ((JToken)resourceTypesValue["properties"]); + if (propertiesSequenceElement != null && propertiesSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in propertiesSequenceElement) + { + string propertiesKey = ((string)property.Name); + string propertiesValue3 = ((string)property.Value); + providerResourceTypeInstance.Properties.Add(propertiesKey, propertiesValue3); + } + } + } + } + } + } + + JToken dependenciesArray = propertiesValue2["dependencies"]; + if (dependenciesArray != null && dependenciesArray.Type != JTokenType.Null) + { + foreach (JToken dependenciesValue in ((JArray)dependenciesArray)) + { + Dependency dependencyInstance = new Dependency(); + propertiesInstance.Dependencies.Add(dependencyInstance); + + JToken dependsOnArray = dependenciesValue["dependsOn"]; + if (dependsOnArray != null && dependsOnArray.Type != JTokenType.Null) + { + foreach (JToken dependsOnValue in ((JArray)dependsOnArray)) + { + BasicDependency basicDependencyInstance = new BasicDependency(); + dependencyInstance.DependsOn.Add(basicDependencyInstance); + + JToken idValue3 = dependsOnValue["id"]; + if (idValue3 != null && idValue3.Type != JTokenType.Null) + { + string idInstance3 = ((string)idValue3); + basicDependencyInstance.Id = idInstance3; + } + + JToken resourceTypeValue2 = dependsOnValue["resourceType"]; + if (resourceTypeValue2 != null && resourceTypeValue2.Type != JTokenType.Null) + { + string resourceTypeInstance2 = ((string)resourceTypeValue2); + basicDependencyInstance.ResourceType = resourceTypeInstance2; + } + + JToken resourceNameValue = dependsOnValue["resourceName"]; + if (resourceNameValue != null && resourceNameValue.Type != JTokenType.Null) + { + string resourceNameInstance = ((string)resourceNameValue); + basicDependencyInstance.ResourceName = resourceNameInstance; + } + } + } + + JToken idValue4 = dependenciesValue["id"]; + if (idValue4 != null && idValue4.Type != JTokenType.Null) + { + string idInstance4 = ((string)idValue4); + dependencyInstance.Id = idInstance4; + } + + JToken resourceTypeValue3 = dependenciesValue["resourceType"]; + if (resourceTypeValue3 != null && resourceTypeValue3.Type != JTokenType.Null) + { + string resourceTypeInstance3 = ((string)resourceTypeValue3); + dependencyInstance.ResourceType = resourceTypeInstance3; + } + + JToken resourceNameValue2 = dependenciesValue["resourceName"]; + if (resourceNameValue2 != null && resourceNameValue2.Type != JTokenType.Null) + { + string resourceNameInstance2 = ((string)resourceNameValue2); + dependencyInstance.ResourceName = resourceNameInstance2; + } + } + } + + JToken templateValue = propertiesValue2["template"]; + if (templateValue != null && templateValue.Type != JTokenType.Null) + { + string templateInstance = templateValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.Template = templateInstance; + } + + JToken templateLinkValue2 = propertiesValue2["templateLink"]; + if (templateLinkValue2 != null && templateLinkValue2.Type != JTokenType.Null) + { + TemplateLink templateLinkInstance = new TemplateLink(); + propertiesInstance.TemplateLink = templateLinkInstance; + + JToken uriValue = templateLinkValue2["uri"]; + if (uriValue != null && uriValue.Type != JTokenType.Null) + { + Uri uriInstance = TypeConversion.TryParseUri(((string)uriValue)); + templateLinkInstance.Uri = uriInstance; + } + + JToken contentVersionValue = templateLinkValue2["contentVersion"]; + if (contentVersionValue != null && contentVersionValue.Type != JTokenType.Null) + { + string contentVersionInstance = ((string)contentVersionValue); + templateLinkInstance.ContentVersion = contentVersionInstance; + } + } + + JToken parametersValue = propertiesValue2["parameters"]; + if (parametersValue != null && parametersValue.Type != JTokenType.Null) + { + string parametersInstance = parametersValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.Parameters = parametersInstance; + } + + JToken parametersLinkValue2 = propertiesValue2["parametersLink"]; + if (parametersLinkValue2 != null && parametersLinkValue2.Type != JTokenType.Null) + { + ParametersLink parametersLinkInstance = new ParametersLink(); + propertiesInstance.ParametersLink = parametersLinkInstance; + + JToken uriValue2 = parametersLinkValue2["uri"]; + if (uriValue2 != null && uriValue2.Type != JTokenType.Null) + { + Uri uriInstance2 = TypeConversion.TryParseUri(((string)uriValue2)); + parametersLinkInstance.Uri = uriInstance2; + } + + JToken contentVersionValue2 = parametersLinkValue2["contentVersion"]; + if (contentVersionValue2 != null && contentVersionValue2.Type != JTokenType.Null) + { + string contentVersionInstance2 = ((string)contentVersionValue2); + parametersLinkInstance.ContentVersion = contentVersionInstance2; + } + } + + JToken modeValue = propertiesValue2["mode"]; + if (modeValue != null && modeValue.Type != JTokenType.Null) + { + DeploymentMode modeInstance = ((DeploymentMode)Enum.Parse(typeof(DeploymentMode), ((string)modeValue), true)); + propertiesInstance.Mode = modeInstance; + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Delete deployment and all of its resources. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment to be deleted. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public async Task DeleteAsync(string resourceGroupName, string deploymentName, CancellationToken cancellationToken) + { + ResourceManagementClient client = this.Client; + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + TracingAdapter.Enter(invocationId, this, "DeleteAsync", tracingParameters); + } + + cancellationToken.ThrowIfCancellationRequested(); + LongRunningOperationResponse response = await client.Deployments.BeginDeletingAsync(resourceGroupName, deploymentName, cancellationToken).ConfigureAwait(false); + cancellationToken.ThrowIfCancellationRequested(); + LongRunningOperationResponse result = await client.GetLongRunningOperationStatusAsync(response.OperationStatusLink, cancellationToken).ConfigureAwait(false); + int delayInSeconds = response.RetryAfter; + if (delayInSeconds == 0) + { + delayInSeconds = 30; + } + if (client.LongRunningOperationInitialTimeout >= 0) + { + delayInSeconds = client.LongRunningOperationInitialTimeout; + } + while ((result.Status != Microsoft.Azure.OperationStatus.InProgress) == false) + { + cancellationToken.ThrowIfCancellationRequested(); + await TaskEx.Delay(delayInSeconds * 1000, cancellationToken).ConfigureAwait(false); + cancellationToken.ThrowIfCancellationRequested(); + result = await client.GetLongRunningOperationStatusAsync(response.OperationStatusLink, cancellationToken).ConfigureAwait(false); + delayInSeconds = result.RetryAfter; + if (delayInSeconds == 0) + { + delayInSeconds = 15; + } + if (client.LongRunningOperationRetryTimeout >= 0) + { + delayInSeconds = client.LongRunningOperationRetryTimeout; + } + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + + return result; + } + + /// + /// Get a deployment. + /// + /// + /// Required. The name of the resource group to get. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Cancellation token. + /// + /// + /// Template deployment information. + /// + public async Task GetAsync(string resourceGroupName, string deploymentName, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (deploymentName == null) + { + throw new ArgumentNullException("deploymentName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + TracingAdapter.Enter(invocationId, this, "GetAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + url = url + "/deployments/"; + url = url + Uri.EscapeDataString(deploymentName); + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + DeploymentGetResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new DeploymentGetResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + DeploymentExtended deploymentInstance = new DeploymentExtended(); + result.Deployment = deploymentInstance; + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + deploymentInstance.Id = idInstance; + } + + JToken nameValue = responseDoc["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + deploymentInstance.Name = nameInstance; + } + + JToken propertiesValue = responseDoc["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + DeploymentPropertiesExtended propertiesInstance = new DeploymentPropertiesExtended(); + deploymentInstance.Properties = propertiesInstance; + + JToken provisioningStateValue = propertiesValue["provisioningState"]; + if (provisioningStateValue != null && provisioningStateValue.Type != JTokenType.Null) + { + string provisioningStateInstance = ((string)provisioningStateValue); + propertiesInstance.ProvisioningState = provisioningStateInstance; + } + + JToken correlationIdValue = propertiesValue["correlationId"]; + if (correlationIdValue != null && correlationIdValue.Type != JTokenType.Null) + { + string correlationIdInstance = ((string)correlationIdValue); + propertiesInstance.CorrelationId = correlationIdInstance; + } + + JToken timestampValue = propertiesValue["timestamp"]; + if (timestampValue != null && timestampValue.Type != JTokenType.Null) + { + DateTime timestampInstance = ((DateTime)timestampValue); + propertiesInstance.Timestamp = timestampInstance; + } + + JToken outputsValue = propertiesValue["outputs"]; + if (outputsValue != null && outputsValue.Type != JTokenType.Null) + { + string outputsInstance = outputsValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.Outputs = outputsInstance; + } + + JToken providersArray = propertiesValue["providers"]; + if (providersArray != null && providersArray.Type != JTokenType.Null) + { + foreach (JToken providersValue in ((JArray)providersArray)) + { + Provider providerInstance = new Provider(); + propertiesInstance.Providers.Add(providerInstance); + + JToken idValue2 = providersValue["id"]; + if (idValue2 != null && idValue2.Type != JTokenType.Null) + { + string idInstance2 = ((string)idValue2); + providerInstance.Id = idInstance2; + } + + JToken namespaceValue = providersValue["namespace"]; + if (namespaceValue != null && namespaceValue.Type != JTokenType.Null) + { + string namespaceInstance = ((string)namespaceValue); + providerInstance.Namespace = namespaceInstance; + } + + JToken registrationStateValue = providersValue["registrationState"]; + if (registrationStateValue != null && registrationStateValue.Type != JTokenType.Null) + { + string registrationStateInstance = ((string)registrationStateValue); + providerInstance.RegistrationState = registrationStateInstance; + } + + JToken resourceTypesArray = providersValue["resourceTypes"]; + if (resourceTypesArray != null && resourceTypesArray.Type != JTokenType.Null) + { + foreach (JToken resourceTypesValue in ((JArray)resourceTypesArray)) + { + ProviderResourceType providerResourceTypeInstance = new ProviderResourceType(); + providerInstance.ResourceTypes.Add(providerResourceTypeInstance); + + JToken resourceTypeValue = resourceTypesValue["resourceType"]; + if (resourceTypeValue != null && resourceTypeValue.Type != JTokenType.Null) + { + string resourceTypeInstance = ((string)resourceTypeValue); + providerResourceTypeInstance.Name = resourceTypeInstance; + } + + JToken locationsArray = resourceTypesValue["locations"]; + if (locationsArray != null && locationsArray.Type != JTokenType.Null) + { + foreach (JToken locationsValue in ((JArray)locationsArray)) + { + providerResourceTypeInstance.Locations.Add(((string)locationsValue)); + } + } + + JToken apiVersionsArray = resourceTypesValue["apiVersions"]; + if (apiVersionsArray != null && apiVersionsArray.Type != JTokenType.Null) + { + foreach (JToken apiVersionsValue in ((JArray)apiVersionsArray)) + { + providerResourceTypeInstance.ApiVersions.Add(((string)apiVersionsValue)); + } + } + + JToken propertiesSequenceElement = ((JToken)resourceTypesValue["properties"]); + if (propertiesSequenceElement != null && propertiesSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in propertiesSequenceElement) + { + string propertiesKey = ((string)property.Name); + string propertiesValue2 = ((string)property.Value); + providerResourceTypeInstance.Properties.Add(propertiesKey, propertiesValue2); + } + } + } + } + } + } + + JToken dependenciesArray = propertiesValue["dependencies"]; + if (dependenciesArray != null && dependenciesArray.Type != JTokenType.Null) + { + foreach (JToken dependenciesValue in ((JArray)dependenciesArray)) + { + Dependency dependencyInstance = new Dependency(); + propertiesInstance.Dependencies.Add(dependencyInstance); + + JToken dependsOnArray = dependenciesValue["dependsOn"]; + if (dependsOnArray != null && dependsOnArray.Type != JTokenType.Null) + { + foreach (JToken dependsOnValue in ((JArray)dependsOnArray)) + { + BasicDependency basicDependencyInstance = new BasicDependency(); + dependencyInstance.DependsOn.Add(basicDependencyInstance); + + JToken idValue3 = dependsOnValue["id"]; + if (idValue3 != null && idValue3.Type != JTokenType.Null) + { + string idInstance3 = ((string)idValue3); + basicDependencyInstance.Id = idInstance3; + } + + JToken resourceTypeValue2 = dependsOnValue["resourceType"]; + if (resourceTypeValue2 != null && resourceTypeValue2.Type != JTokenType.Null) + { + string resourceTypeInstance2 = ((string)resourceTypeValue2); + basicDependencyInstance.ResourceType = resourceTypeInstance2; + } + + JToken resourceNameValue = dependsOnValue["resourceName"]; + if (resourceNameValue != null && resourceNameValue.Type != JTokenType.Null) + { + string resourceNameInstance = ((string)resourceNameValue); + basicDependencyInstance.ResourceName = resourceNameInstance; + } + } + } + + JToken idValue4 = dependenciesValue["id"]; + if (idValue4 != null && idValue4.Type != JTokenType.Null) + { + string idInstance4 = ((string)idValue4); + dependencyInstance.Id = idInstance4; + } + + JToken resourceTypeValue3 = dependenciesValue["resourceType"]; + if (resourceTypeValue3 != null && resourceTypeValue3.Type != JTokenType.Null) + { + string resourceTypeInstance3 = ((string)resourceTypeValue3); + dependencyInstance.ResourceType = resourceTypeInstance3; + } + + JToken resourceNameValue2 = dependenciesValue["resourceName"]; + if (resourceNameValue2 != null && resourceNameValue2.Type != JTokenType.Null) + { + string resourceNameInstance2 = ((string)resourceNameValue2); + dependencyInstance.ResourceName = resourceNameInstance2; + } + } + } + + JToken templateValue = propertiesValue["template"]; + if (templateValue != null && templateValue.Type != JTokenType.Null) + { + string templateInstance = templateValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.Template = templateInstance; + } + + JToken templateLinkValue = propertiesValue["templateLink"]; + if (templateLinkValue != null && templateLinkValue.Type != JTokenType.Null) + { + TemplateLink templateLinkInstance = new TemplateLink(); + propertiesInstance.TemplateLink = templateLinkInstance; + + JToken uriValue = templateLinkValue["uri"]; + if (uriValue != null && uriValue.Type != JTokenType.Null) + { + Uri uriInstance = TypeConversion.TryParseUri(((string)uriValue)); + templateLinkInstance.Uri = uriInstance; + } + + JToken contentVersionValue = templateLinkValue["contentVersion"]; + if (contentVersionValue != null && contentVersionValue.Type != JTokenType.Null) + { + string contentVersionInstance = ((string)contentVersionValue); + templateLinkInstance.ContentVersion = contentVersionInstance; + } + } + + JToken parametersValue = propertiesValue["parameters"]; + if (parametersValue != null && parametersValue.Type != JTokenType.Null) + { + string parametersInstance = parametersValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.Parameters = parametersInstance; + } + + JToken parametersLinkValue = propertiesValue["parametersLink"]; + if (parametersLinkValue != null && parametersLinkValue.Type != JTokenType.Null) + { + ParametersLink parametersLinkInstance = new ParametersLink(); + propertiesInstance.ParametersLink = parametersLinkInstance; + + JToken uriValue2 = parametersLinkValue["uri"]; + if (uriValue2 != null && uriValue2.Type != JTokenType.Null) + { + Uri uriInstance2 = TypeConversion.TryParseUri(((string)uriValue2)); + parametersLinkInstance.Uri = uriInstance2; + } + + JToken contentVersionValue2 = parametersLinkValue["contentVersion"]; + if (contentVersionValue2 != null && contentVersionValue2.Type != JTokenType.Null) + { + string contentVersionInstance2 = ((string)contentVersionValue2); + parametersLinkInstance.ContentVersion = contentVersionInstance2; + } + } + + JToken modeValue = propertiesValue["mode"]; + if (modeValue != null && modeValue.Type != JTokenType.Null) + { + DeploymentMode modeInstance = ((DeploymentMode)Enum.Parse(typeof(DeploymentMode), ((string)modeValue), true)); + propertiesInstance.Mode = modeInstance; + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Get a list of deployments. + /// + /// + /// Required. The name of the resource group to filter by. The name is + /// case insensitive. + /// + /// + /// Optional. Query parameters. If null is passed returns all + /// deployments. + /// + /// + /// Cancellation token. + /// + /// + /// List of deployments. + /// + public async Task ListAsync(string resourceGroupName, DeploymentListParameters parameters, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "ListAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/"; + url = url + "resourcegroups/" + Uri.EscapeDataString(resourceGroupName) + "/"; + url = url + "deployments/"; + List queryParameters = new List(); + List odataFilter = new List(); + if (parameters != null && parameters.ProvisioningState != null) + { + odataFilter.Add("provisioningState eq '" + Uri.EscapeDataString(parameters.ProvisioningState) + "'"); + } + if (odataFilter.Count > 0) + { + queryParameters.Add("$filter=" + string.Join(null, odataFilter)); + } + if (parameters != null && parameters.Top != null) + { + queryParameters.Add("$top=" + Uri.EscapeDataString(parameters.Top.Value.ToString())); + } + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + DeploymentListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new DeploymentListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + DeploymentExtended deploymentExtendedInstance = new DeploymentExtended(); + result.Deployments.Add(deploymentExtendedInstance); + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + deploymentExtendedInstance.Id = idInstance; + } + + JToken nameValue = valueValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + deploymentExtendedInstance.Name = nameInstance; + } + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + DeploymentPropertiesExtended propertiesInstance = new DeploymentPropertiesExtended(); + deploymentExtendedInstance.Properties = propertiesInstance; + + JToken provisioningStateValue = propertiesValue["provisioningState"]; + if (provisioningStateValue != null && provisioningStateValue.Type != JTokenType.Null) + { + string provisioningStateInstance = ((string)provisioningStateValue); + propertiesInstance.ProvisioningState = provisioningStateInstance; + } + + JToken correlationIdValue = propertiesValue["correlationId"]; + if (correlationIdValue != null && correlationIdValue.Type != JTokenType.Null) + { + string correlationIdInstance = ((string)correlationIdValue); + propertiesInstance.CorrelationId = correlationIdInstance; + } + + JToken timestampValue = propertiesValue["timestamp"]; + if (timestampValue != null && timestampValue.Type != JTokenType.Null) + { + DateTime timestampInstance = ((DateTime)timestampValue); + propertiesInstance.Timestamp = timestampInstance; + } + + JToken outputsValue = propertiesValue["outputs"]; + if (outputsValue != null && outputsValue.Type != JTokenType.Null) + { + string outputsInstance = outputsValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.Outputs = outputsInstance; + } + + JToken providersArray = propertiesValue["providers"]; + if (providersArray != null && providersArray.Type != JTokenType.Null) + { + foreach (JToken providersValue in ((JArray)providersArray)) + { + Provider providerInstance = new Provider(); + propertiesInstance.Providers.Add(providerInstance); + + JToken idValue2 = providersValue["id"]; + if (idValue2 != null && idValue2.Type != JTokenType.Null) + { + string idInstance2 = ((string)idValue2); + providerInstance.Id = idInstance2; + } + + JToken namespaceValue = providersValue["namespace"]; + if (namespaceValue != null && namespaceValue.Type != JTokenType.Null) + { + string namespaceInstance = ((string)namespaceValue); + providerInstance.Namespace = namespaceInstance; + } + + JToken registrationStateValue = providersValue["registrationState"]; + if (registrationStateValue != null && registrationStateValue.Type != JTokenType.Null) + { + string registrationStateInstance = ((string)registrationStateValue); + providerInstance.RegistrationState = registrationStateInstance; + } + + JToken resourceTypesArray = providersValue["resourceTypes"]; + if (resourceTypesArray != null && resourceTypesArray.Type != JTokenType.Null) + { + foreach (JToken resourceTypesValue in ((JArray)resourceTypesArray)) + { + ProviderResourceType providerResourceTypeInstance = new ProviderResourceType(); + providerInstance.ResourceTypes.Add(providerResourceTypeInstance); + + JToken resourceTypeValue = resourceTypesValue["resourceType"]; + if (resourceTypeValue != null && resourceTypeValue.Type != JTokenType.Null) + { + string resourceTypeInstance = ((string)resourceTypeValue); + providerResourceTypeInstance.Name = resourceTypeInstance; + } + + JToken locationsArray = resourceTypesValue["locations"]; + if (locationsArray != null && locationsArray.Type != JTokenType.Null) + { + foreach (JToken locationsValue in ((JArray)locationsArray)) + { + providerResourceTypeInstance.Locations.Add(((string)locationsValue)); + } + } + + JToken apiVersionsArray = resourceTypesValue["apiVersions"]; + if (apiVersionsArray != null && apiVersionsArray.Type != JTokenType.Null) + { + foreach (JToken apiVersionsValue in ((JArray)apiVersionsArray)) + { + providerResourceTypeInstance.ApiVersions.Add(((string)apiVersionsValue)); + } + } + + JToken propertiesSequenceElement = ((JToken)resourceTypesValue["properties"]); + if (propertiesSequenceElement != null && propertiesSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in propertiesSequenceElement) + { + string propertiesKey = ((string)property.Name); + string propertiesValue2 = ((string)property.Value); + providerResourceTypeInstance.Properties.Add(propertiesKey, propertiesValue2); + } + } + } + } + } + } + + JToken dependenciesArray = propertiesValue["dependencies"]; + if (dependenciesArray != null && dependenciesArray.Type != JTokenType.Null) + { + foreach (JToken dependenciesValue in ((JArray)dependenciesArray)) + { + Dependency dependencyInstance = new Dependency(); + propertiesInstance.Dependencies.Add(dependencyInstance); + + JToken dependsOnArray = dependenciesValue["dependsOn"]; + if (dependsOnArray != null && dependsOnArray.Type != JTokenType.Null) + { + foreach (JToken dependsOnValue in ((JArray)dependsOnArray)) + { + BasicDependency basicDependencyInstance = new BasicDependency(); + dependencyInstance.DependsOn.Add(basicDependencyInstance); + + JToken idValue3 = dependsOnValue["id"]; + if (idValue3 != null && idValue3.Type != JTokenType.Null) + { + string idInstance3 = ((string)idValue3); + basicDependencyInstance.Id = idInstance3; + } + + JToken resourceTypeValue2 = dependsOnValue["resourceType"]; + if (resourceTypeValue2 != null && resourceTypeValue2.Type != JTokenType.Null) + { + string resourceTypeInstance2 = ((string)resourceTypeValue2); + basicDependencyInstance.ResourceType = resourceTypeInstance2; + } + + JToken resourceNameValue = dependsOnValue["resourceName"]; + if (resourceNameValue != null && resourceNameValue.Type != JTokenType.Null) + { + string resourceNameInstance = ((string)resourceNameValue); + basicDependencyInstance.ResourceName = resourceNameInstance; + } + } + } + + JToken idValue4 = dependenciesValue["id"]; + if (idValue4 != null && idValue4.Type != JTokenType.Null) + { + string idInstance4 = ((string)idValue4); + dependencyInstance.Id = idInstance4; + } + + JToken resourceTypeValue3 = dependenciesValue["resourceType"]; + if (resourceTypeValue3 != null && resourceTypeValue3.Type != JTokenType.Null) + { + string resourceTypeInstance3 = ((string)resourceTypeValue3); + dependencyInstance.ResourceType = resourceTypeInstance3; + } + + JToken resourceNameValue2 = dependenciesValue["resourceName"]; + if (resourceNameValue2 != null && resourceNameValue2.Type != JTokenType.Null) + { + string resourceNameInstance2 = ((string)resourceNameValue2); + dependencyInstance.ResourceName = resourceNameInstance2; + } + } + } + + JToken templateValue = propertiesValue["template"]; + if (templateValue != null && templateValue.Type != JTokenType.Null) + { + string templateInstance = templateValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.Template = templateInstance; + } + + JToken templateLinkValue = propertiesValue["templateLink"]; + if (templateLinkValue != null && templateLinkValue.Type != JTokenType.Null) + { + TemplateLink templateLinkInstance = new TemplateLink(); + propertiesInstance.TemplateLink = templateLinkInstance; + + JToken uriValue = templateLinkValue["uri"]; + if (uriValue != null && uriValue.Type != JTokenType.Null) + { + Uri uriInstance = TypeConversion.TryParseUri(((string)uriValue)); + templateLinkInstance.Uri = uriInstance; + } + + JToken contentVersionValue = templateLinkValue["contentVersion"]; + if (contentVersionValue != null && contentVersionValue.Type != JTokenType.Null) + { + string contentVersionInstance = ((string)contentVersionValue); + templateLinkInstance.ContentVersion = contentVersionInstance; + } + } + + JToken parametersValue = propertiesValue["parameters"]; + if (parametersValue != null && parametersValue.Type != JTokenType.Null) + { + string parametersInstance = parametersValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.Parameters = parametersInstance; + } + + JToken parametersLinkValue = propertiesValue["parametersLink"]; + if (parametersLinkValue != null && parametersLinkValue.Type != JTokenType.Null) + { + ParametersLink parametersLinkInstance = new ParametersLink(); + propertiesInstance.ParametersLink = parametersLinkInstance; + + JToken uriValue2 = parametersLinkValue["uri"]; + if (uriValue2 != null && uriValue2.Type != JTokenType.Null) + { + Uri uriInstance2 = TypeConversion.TryParseUri(((string)uriValue2)); + parametersLinkInstance.Uri = uriInstance2; + } + + JToken contentVersionValue2 = parametersLinkValue["contentVersion"]; + if (contentVersionValue2 != null && contentVersionValue2.Type != JTokenType.Null) + { + string contentVersionInstance2 = ((string)contentVersionValue2); + parametersLinkInstance.ContentVersion = contentVersionInstance2; + } + } + + JToken modeValue = propertiesValue["mode"]; + if (modeValue != null && modeValue.Type != JTokenType.Null) + { + DeploymentMode modeInstance = ((DeploymentMode)Enum.Parse(typeof(DeploymentMode), ((string)modeValue), true)); + propertiesInstance.Mode = modeInstance; + } + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Get a list of deployments. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of deployments. + /// + public async Task ListNextAsync(string nextLink, CancellationToken cancellationToken) + { + // Validate + if (nextLink == null) + { + throw new ArgumentNullException("nextLink"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextLink", nextLink); + TracingAdapter.Enter(invocationId, this, "ListNextAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + nextLink; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + DeploymentListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new DeploymentListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + DeploymentExtended deploymentExtendedInstance = new DeploymentExtended(); + result.Deployments.Add(deploymentExtendedInstance); + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + deploymentExtendedInstance.Id = idInstance; + } + + JToken nameValue = valueValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + deploymentExtendedInstance.Name = nameInstance; + } + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + DeploymentPropertiesExtended propertiesInstance = new DeploymentPropertiesExtended(); + deploymentExtendedInstance.Properties = propertiesInstance; + + JToken provisioningStateValue = propertiesValue["provisioningState"]; + if (provisioningStateValue != null && provisioningStateValue.Type != JTokenType.Null) + { + string provisioningStateInstance = ((string)provisioningStateValue); + propertiesInstance.ProvisioningState = provisioningStateInstance; + } + + JToken correlationIdValue = propertiesValue["correlationId"]; + if (correlationIdValue != null && correlationIdValue.Type != JTokenType.Null) + { + string correlationIdInstance = ((string)correlationIdValue); + propertiesInstance.CorrelationId = correlationIdInstance; + } + + JToken timestampValue = propertiesValue["timestamp"]; + if (timestampValue != null && timestampValue.Type != JTokenType.Null) + { + DateTime timestampInstance = ((DateTime)timestampValue); + propertiesInstance.Timestamp = timestampInstance; + } + + JToken outputsValue = propertiesValue["outputs"]; + if (outputsValue != null && outputsValue.Type != JTokenType.Null) + { + string outputsInstance = outputsValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.Outputs = outputsInstance; + } + + JToken providersArray = propertiesValue["providers"]; + if (providersArray != null && providersArray.Type != JTokenType.Null) + { + foreach (JToken providersValue in ((JArray)providersArray)) + { + Provider providerInstance = new Provider(); + propertiesInstance.Providers.Add(providerInstance); + + JToken idValue2 = providersValue["id"]; + if (idValue2 != null && idValue2.Type != JTokenType.Null) + { + string idInstance2 = ((string)idValue2); + providerInstance.Id = idInstance2; + } + + JToken namespaceValue = providersValue["namespace"]; + if (namespaceValue != null && namespaceValue.Type != JTokenType.Null) + { + string namespaceInstance = ((string)namespaceValue); + providerInstance.Namespace = namespaceInstance; + } + + JToken registrationStateValue = providersValue["registrationState"]; + if (registrationStateValue != null && registrationStateValue.Type != JTokenType.Null) + { + string registrationStateInstance = ((string)registrationStateValue); + providerInstance.RegistrationState = registrationStateInstance; + } + + JToken resourceTypesArray = providersValue["resourceTypes"]; + if (resourceTypesArray != null && resourceTypesArray.Type != JTokenType.Null) + { + foreach (JToken resourceTypesValue in ((JArray)resourceTypesArray)) + { + ProviderResourceType providerResourceTypeInstance = new ProviderResourceType(); + providerInstance.ResourceTypes.Add(providerResourceTypeInstance); + + JToken resourceTypeValue = resourceTypesValue["resourceType"]; + if (resourceTypeValue != null && resourceTypeValue.Type != JTokenType.Null) + { + string resourceTypeInstance = ((string)resourceTypeValue); + providerResourceTypeInstance.Name = resourceTypeInstance; + } + + JToken locationsArray = resourceTypesValue["locations"]; + if (locationsArray != null && locationsArray.Type != JTokenType.Null) + { + foreach (JToken locationsValue in ((JArray)locationsArray)) + { + providerResourceTypeInstance.Locations.Add(((string)locationsValue)); + } + } + + JToken apiVersionsArray = resourceTypesValue["apiVersions"]; + if (apiVersionsArray != null && apiVersionsArray.Type != JTokenType.Null) + { + foreach (JToken apiVersionsValue in ((JArray)apiVersionsArray)) + { + providerResourceTypeInstance.ApiVersions.Add(((string)apiVersionsValue)); + } + } + + JToken propertiesSequenceElement = ((JToken)resourceTypesValue["properties"]); + if (propertiesSequenceElement != null && propertiesSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in propertiesSequenceElement) + { + string propertiesKey = ((string)property.Name); + string propertiesValue2 = ((string)property.Value); + providerResourceTypeInstance.Properties.Add(propertiesKey, propertiesValue2); + } + } + } + } + } + } + + JToken dependenciesArray = propertiesValue["dependencies"]; + if (dependenciesArray != null && dependenciesArray.Type != JTokenType.Null) + { + foreach (JToken dependenciesValue in ((JArray)dependenciesArray)) + { + Dependency dependencyInstance = new Dependency(); + propertiesInstance.Dependencies.Add(dependencyInstance); + + JToken dependsOnArray = dependenciesValue["dependsOn"]; + if (dependsOnArray != null && dependsOnArray.Type != JTokenType.Null) + { + foreach (JToken dependsOnValue in ((JArray)dependsOnArray)) + { + BasicDependency basicDependencyInstance = new BasicDependency(); + dependencyInstance.DependsOn.Add(basicDependencyInstance); + + JToken idValue3 = dependsOnValue["id"]; + if (idValue3 != null && idValue3.Type != JTokenType.Null) + { + string idInstance3 = ((string)idValue3); + basicDependencyInstance.Id = idInstance3; + } + + JToken resourceTypeValue2 = dependsOnValue["resourceType"]; + if (resourceTypeValue2 != null && resourceTypeValue2.Type != JTokenType.Null) + { + string resourceTypeInstance2 = ((string)resourceTypeValue2); + basicDependencyInstance.ResourceType = resourceTypeInstance2; + } + + JToken resourceNameValue = dependsOnValue["resourceName"]; + if (resourceNameValue != null && resourceNameValue.Type != JTokenType.Null) + { + string resourceNameInstance = ((string)resourceNameValue); + basicDependencyInstance.ResourceName = resourceNameInstance; + } + } + } + + JToken idValue4 = dependenciesValue["id"]; + if (idValue4 != null && idValue4.Type != JTokenType.Null) + { + string idInstance4 = ((string)idValue4); + dependencyInstance.Id = idInstance4; + } + + JToken resourceTypeValue3 = dependenciesValue["resourceType"]; + if (resourceTypeValue3 != null && resourceTypeValue3.Type != JTokenType.Null) + { + string resourceTypeInstance3 = ((string)resourceTypeValue3); + dependencyInstance.ResourceType = resourceTypeInstance3; + } + + JToken resourceNameValue2 = dependenciesValue["resourceName"]; + if (resourceNameValue2 != null && resourceNameValue2.Type != JTokenType.Null) + { + string resourceNameInstance2 = ((string)resourceNameValue2); + dependencyInstance.ResourceName = resourceNameInstance2; + } + } + } + + JToken templateValue = propertiesValue["template"]; + if (templateValue != null && templateValue.Type != JTokenType.Null) + { + string templateInstance = templateValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.Template = templateInstance; + } + + JToken templateLinkValue = propertiesValue["templateLink"]; + if (templateLinkValue != null && templateLinkValue.Type != JTokenType.Null) + { + TemplateLink templateLinkInstance = new TemplateLink(); + propertiesInstance.TemplateLink = templateLinkInstance; + + JToken uriValue = templateLinkValue["uri"]; + if (uriValue != null && uriValue.Type != JTokenType.Null) + { + Uri uriInstance = TypeConversion.TryParseUri(((string)uriValue)); + templateLinkInstance.Uri = uriInstance; + } + + JToken contentVersionValue = templateLinkValue["contentVersion"]; + if (contentVersionValue != null && contentVersionValue.Type != JTokenType.Null) + { + string contentVersionInstance = ((string)contentVersionValue); + templateLinkInstance.ContentVersion = contentVersionInstance; + } + } + + JToken parametersValue = propertiesValue["parameters"]; + if (parametersValue != null && parametersValue.Type != JTokenType.Null) + { + string parametersInstance = parametersValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.Parameters = parametersInstance; + } + + JToken parametersLinkValue = propertiesValue["parametersLink"]; + if (parametersLinkValue != null && parametersLinkValue.Type != JTokenType.Null) + { + ParametersLink parametersLinkInstance = new ParametersLink(); + propertiesInstance.ParametersLink = parametersLinkInstance; + + JToken uriValue2 = parametersLinkValue["uri"]; + if (uriValue2 != null && uriValue2.Type != JTokenType.Null) + { + Uri uriInstance2 = TypeConversion.TryParseUri(((string)uriValue2)); + parametersLinkInstance.Uri = uriInstance2; + } + + JToken contentVersionValue2 = parametersLinkValue["contentVersion"]; + if (contentVersionValue2 != null && contentVersionValue2.Type != JTokenType.Null) + { + string contentVersionInstance2 = ((string)contentVersionValue2); + parametersLinkInstance.ContentVersion = contentVersionInstance2; + } + } + + JToken modeValue = propertiesValue["mode"]; + if (modeValue != null && modeValue.Type != JTokenType.Null) + { + DeploymentMode modeInstance = ((DeploymentMode)Enum.Parse(typeof(DeploymentMode), ((string)modeValue), true)); + propertiesInstance.Mode = modeInstance; + } + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Validate a deployment template. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Required. Deployment to validate. + /// + /// + /// Cancellation token. + /// + /// + /// Information from validate template deployment response. + /// + public async Task ValidateAsync(string resourceGroupName, string deploymentName, Deployment parameters, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (deploymentName == null) + { + throw new ArgumentNullException("deploymentName"); + } + if (parameters == null) + { + throw new ArgumentNullException("parameters"); + } + if (parameters.Properties != null) + { + if (parameters.Properties.ParametersLink != null) + { + if (parameters.Properties.ParametersLink.Uri == null) + { + throw new ArgumentNullException("parameters.Properties.ParametersLink.Uri"); + } + } + if (parameters.Properties.TemplateLink != null) + { + if (parameters.Properties.TemplateLink.Uri == null) + { + throw new ArgumentNullException("parameters.Properties.TemplateLink.Uri"); + } + } + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("deploymentName", deploymentName); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "ValidateAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + url = url + "/providers/microsoft.resources/deployments/"; + url = url + Uri.EscapeDataString(deploymentName); + url = url + "/validate"; + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Post; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Serialize Request + string requestContent = null; + JToken requestDoc = null; + + JObject deploymentValue = new JObject(); + requestDoc = deploymentValue; + + if (parameters.Properties != null) + { + JObject propertiesValue = new JObject(); + deploymentValue["properties"] = propertiesValue; + + if (parameters.Properties.Template != null) + { + propertiesValue["template"] = JObject.Parse(parameters.Properties.Template); + } + + if (parameters.Properties.TemplateLink != null) + { + JObject templateLinkValue = new JObject(); + propertiesValue["templateLink"] = templateLinkValue; + + templateLinkValue["uri"] = parameters.Properties.TemplateLink.Uri.AbsoluteUri; + + if (parameters.Properties.TemplateLink.ContentVersion != null) + { + templateLinkValue["contentVersion"] = parameters.Properties.TemplateLink.ContentVersion; + } + } + + if (parameters.Properties.Parameters != null) + { + propertiesValue["parameters"] = JObject.Parse(parameters.Properties.Parameters); + } + + if (parameters.Properties.ParametersLink != null) + { + JObject parametersLinkValue = new JObject(); + propertiesValue["parametersLink"] = parametersLinkValue; + + parametersLinkValue["uri"] = parameters.Properties.ParametersLink.Uri.AbsoluteUri; + + if (parameters.Properties.ParametersLink.ContentVersion != null) + { + parametersLinkValue["contentVersion"] = parameters.Properties.ParametersLink.ContentVersion; + } + } + + propertiesValue["mode"] = parameters.Properties.Mode.ToString(); + } + + requestContent = requestDoc.ToString(Newtonsoft.Json.Formatting.Indented); + httpRequest.Content = new StringContent(requestContent, Encoding.UTF8); + httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.BadRequest) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, requestContent, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + DeploymentValidateResponse result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.BadRequest) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new DeploymentValidateResponse(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken errorValue = responseDoc["error"]; + if (errorValue != null && errorValue.Type != JTokenType.Null) + { + ResourceManagementErrorWithDetails errorInstance = new ResourceManagementErrorWithDetails(); + result.Error = errorInstance; + + JToken detailsArray = errorValue["details"]; + if (detailsArray != null && detailsArray.Type != JTokenType.Null) + { + foreach (JToken detailsValue in ((JArray)detailsArray)) + { + ResourceManagementError resourceManagementErrorInstance = new ResourceManagementError(); + errorInstance.Details.Add(resourceManagementErrorInstance); + + JToken codeValue = detailsValue["code"]; + if (codeValue != null && codeValue.Type != JTokenType.Null) + { + string codeInstance = ((string)codeValue); + resourceManagementErrorInstance.Code = codeInstance; + } + + JToken messageValue = detailsValue["message"]; + if (messageValue != null && messageValue.Type != JTokenType.Null) + { + string messageInstance = ((string)messageValue); + resourceManagementErrorInstance.Message = messageInstance; + } + + JToken targetValue = detailsValue["target"]; + if (targetValue != null && targetValue.Type != JTokenType.Null) + { + string targetInstance = ((string)targetValue); + resourceManagementErrorInstance.Target = targetInstance; + } + } + } + + JToken codeValue2 = errorValue["code"]; + if (codeValue2 != null && codeValue2.Type != JTokenType.Null) + { + string codeInstance2 = ((string)codeValue2); + errorInstance.Code = codeInstance2; + } + + JToken messageValue2 = errorValue["message"]; + if (messageValue2 != null && messageValue2.Type != JTokenType.Null) + { + string messageInstance2 = ((string)messageValue2); + errorInstance.Message = messageInstance2; + } + + JToken targetValue2 = errorValue["target"]; + if (targetValue2 != null && targetValue2.Type != JTokenType.Null) + { + string targetInstance2 = ((string)targetValue2); + errorInstance.Target = targetInstance2; + } + } + + JToken propertiesValue2 = responseDoc["properties"]; + if (propertiesValue2 != null && propertiesValue2.Type != JTokenType.Null) + { + DeploymentPropertiesExtended propertiesInstance = new DeploymentPropertiesExtended(); + result.Properties = propertiesInstance; + + JToken provisioningStateValue = propertiesValue2["provisioningState"]; + if (provisioningStateValue != null && provisioningStateValue.Type != JTokenType.Null) + { + string provisioningStateInstance = ((string)provisioningStateValue); + propertiesInstance.ProvisioningState = provisioningStateInstance; + } + + JToken correlationIdValue = propertiesValue2["correlationId"]; + if (correlationIdValue != null && correlationIdValue.Type != JTokenType.Null) + { + string correlationIdInstance = ((string)correlationIdValue); + propertiesInstance.CorrelationId = correlationIdInstance; + } + + JToken timestampValue = propertiesValue2["timestamp"]; + if (timestampValue != null && timestampValue.Type != JTokenType.Null) + { + DateTime timestampInstance = ((DateTime)timestampValue); + propertiesInstance.Timestamp = timestampInstance; + } + + JToken outputsValue = propertiesValue2["outputs"]; + if (outputsValue != null && outputsValue.Type != JTokenType.Null) + { + string outputsInstance = outputsValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.Outputs = outputsInstance; + } + + JToken providersArray = propertiesValue2["providers"]; + if (providersArray != null && providersArray.Type != JTokenType.Null) + { + foreach (JToken providersValue in ((JArray)providersArray)) + { + Provider providerInstance = new Provider(); + propertiesInstance.Providers.Add(providerInstance); + + JToken idValue = providersValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + providerInstance.Id = idInstance; + } + + JToken namespaceValue = providersValue["namespace"]; + if (namespaceValue != null && namespaceValue.Type != JTokenType.Null) + { + string namespaceInstance = ((string)namespaceValue); + providerInstance.Namespace = namespaceInstance; + } + + JToken registrationStateValue = providersValue["registrationState"]; + if (registrationStateValue != null && registrationStateValue.Type != JTokenType.Null) + { + string registrationStateInstance = ((string)registrationStateValue); + providerInstance.RegistrationState = registrationStateInstance; + } + + JToken resourceTypesArray = providersValue["resourceTypes"]; + if (resourceTypesArray != null && resourceTypesArray.Type != JTokenType.Null) + { + foreach (JToken resourceTypesValue in ((JArray)resourceTypesArray)) + { + ProviderResourceType providerResourceTypeInstance = new ProviderResourceType(); + providerInstance.ResourceTypes.Add(providerResourceTypeInstance); + + JToken resourceTypeValue = resourceTypesValue["resourceType"]; + if (resourceTypeValue != null && resourceTypeValue.Type != JTokenType.Null) + { + string resourceTypeInstance = ((string)resourceTypeValue); + providerResourceTypeInstance.Name = resourceTypeInstance; + } + + JToken locationsArray = resourceTypesValue["locations"]; + if (locationsArray != null && locationsArray.Type != JTokenType.Null) + { + foreach (JToken locationsValue in ((JArray)locationsArray)) + { + providerResourceTypeInstance.Locations.Add(((string)locationsValue)); + } + } + + JToken apiVersionsArray = resourceTypesValue["apiVersions"]; + if (apiVersionsArray != null && apiVersionsArray.Type != JTokenType.Null) + { + foreach (JToken apiVersionsValue in ((JArray)apiVersionsArray)) + { + providerResourceTypeInstance.ApiVersions.Add(((string)apiVersionsValue)); + } + } + + JToken propertiesSequenceElement = ((JToken)resourceTypesValue["properties"]); + if (propertiesSequenceElement != null && propertiesSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in propertiesSequenceElement) + { + string propertiesKey = ((string)property.Name); + string propertiesValue3 = ((string)property.Value); + providerResourceTypeInstance.Properties.Add(propertiesKey, propertiesValue3); + } + } + } + } + } + } + + JToken dependenciesArray = propertiesValue2["dependencies"]; + if (dependenciesArray != null && dependenciesArray.Type != JTokenType.Null) + { + foreach (JToken dependenciesValue in ((JArray)dependenciesArray)) + { + Dependency dependencyInstance = new Dependency(); + propertiesInstance.Dependencies.Add(dependencyInstance); + + JToken dependsOnArray = dependenciesValue["dependsOn"]; + if (dependsOnArray != null && dependsOnArray.Type != JTokenType.Null) + { + foreach (JToken dependsOnValue in ((JArray)dependsOnArray)) + { + BasicDependency basicDependencyInstance = new BasicDependency(); + dependencyInstance.DependsOn.Add(basicDependencyInstance); + + JToken idValue2 = dependsOnValue["id"]; + if (idValue2 != null && idValue2.Type != JTokenType.Null) + { + string idInstance2 = ((string)idValue2); + basicDependencyInstance.Id = idInstance2; + } + + JToken resourceTypeValue2 = dependsOnValue["resourceType"]; + if (resourceTypeValue2 != null && resourceTypeValue2.Type != JTokenType.Null) + { + string resourceTypeInstance2 = ((string)resourceTypeValue2); + basicDependencyInstance.ResourceType = resourceTypeInstance2; + } + + JToken resourceNameValue = dependsOnValue["resourceName"]; + if (resourceNameValue != null && resourceNameValue.Type != JTokenType.Null) + { + string resourceNameInstance = ((string)resourceNameValue); + basicDependencyInstance.ResourceName = resourceNameInstance; + } + } + } + + JToken idValue3 = dependenciesValue["id"]; + if (idValue3 != null && idValue3.Type != JTokenType.Null) + { + string idInstance3 = ((string)idValue3); + dependencyInstance.Id = idInstance3; + } + + JToken resourceTypeValue3 = dependenciesValue["resourceType"]; + if (resourceTypeValue3 != null && resourceTypeValue3.Type != JTokenType.Null) + { + string resourceTypeInstance3 = ((string)resourceTypeValue3); + dependencyInstance.ResourceType = resourceTypeInstance3; + } + + JToken resourceNameValue2 = dependenciesValue["resourceName"]; + if (resourceNameValue2 != null && resourceNameValue2.Type != JTokenType.Null) + { + string resourceNameInstance2 = ((string)resourceNameValue2); + dependencyInstance.ResourceName = resourceNameInstance2; + } + } + } + + JToken templateValue = propertiesValue2["template"]; + if (templateValue != null && templateValue.Type != JTokenType.Null) + { + string templateInstance = templateValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.Template = templateInstance; + } + + JToken templateLinkValue2 = propertiesValue2["templateLink"]; + if (templateLinkValue2 != null && templateLinkValue2.Type != JTokenType.Null) + { + TemplateLink templateLinkInstance = new TemplateLink(); + propertiesInstance.TemplateLink = templateLinkInstance; + + JToken uriValue = templateLinkValue2["uri"]; + if (uriValue != null && uriValue.Type != JTokenType.Null) + { + Uri uriInstance = TypeConversion.TryParseUri(((string)uriValue)); + templateLinkInstance.Uri = uriInstance; + } + + JToken contentVersionValue = templateLinkValue2["contentVersion"]; + if (contentVersionValue != null && contentVersionValue.Type != JTokenType.Null) + { + string contentVersionInstance = ((string)contentVersionValue); + templateLinkInstance.ContentVersion = contentVersionInstance; + } + } + + JToken parametersValue = propertiesValue2["parameters"]; + if (parametersValue != null && parametersValue.Type != JTokenType.Null) + { + string parametersInstance = parametersValue.ToString(Newtonsoft.Json.Formatting.Indented); + propertiesInstance.Parameters = parametersInstance; + } + + JToken parametersLinkValue2 = propertiesValue2["parametersLink"]; + if (parametersLinkValue2 != null && parametersLinkValue2.Type != JTokenType.Null) + { + ParametersLink parametersLinkInstance = new ParametersLink(); + propertiesInstance.ParametersLink = parametersLinkInstance; + + JToken uriValue2 = parametersLinkValue2["uri"]; + if (uriValue2 != null && uriValue2.Type != JTokenType.Null) + { + Uri uriInstance2 = TypeConversion.TryParseUri(((string)uriValue2)); + parametersLinkInstance.Uri = uriInstance2; + } + + JToken contentVersionValue2 = parametersLinkValue2["contentVersion"]; + if (contentVersionValue2 != null && contentVersionValue2.Type != JTokenType.Null) + { + string contentVersionInstance2 = ((string)contentVersionValue2); + parametersLinkInstance.ContentVersion = contentVersionInstance2; + } + } + + JToken modeValue = propertiesValue2["mode"]; + if (modeValue != null && modeValue.Type != JTokenType.Null) + { + DeploymentMode modeInstance = ((DeploymentMode)Enum.Parse(typeof(DeploymentMode), ((string)modeValue), true)); + propertiesInstance.Mode = modeInstance; + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (statusCode == HttpStatusCode.OK) + { + result.IsValid = true; + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/DeploymentOperationsExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/DeploymentOperationsExtensions.cs new file mode 100644 index 000000000000..663340b361c7 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/DeploymentOperationsExtensions.cs @@ -0,0 +1,478 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public static partial class DeploymentOperationsExtensions + { + /// + /// Begin deleting deployment.To determine whether the operation has + /// finished processing the request, call + /// GetLongRunningOperationStatus. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment to be deleted. + /// + /// + /// A standard service response for long running operations. + /// + public static LongRunningOperationResponse BeginDeleting(this IDeploymentOperations operations, string resourceGroupName, string deploymentName) + { + return Task.Factory.StartNew((object s) => + { + return ((IDeploymentOperations)s).BeginDeletingAsync(resourceGroupName, deploymentName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Begin deleting deployment.To determine whether the operation has + /// finished processing the request, call + /// GetLongRunningOperationStatus. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment to be deleted. + /// + /// + /// A standard service response for long running operations. + /// + public static Task BeginDeletingAsync(this IDeploymentOperations operations, string resourceGroupName, string deploymentName) + { + return operations.BeginDeletingAsync(resourceGroupName, deploymentName, CancellationToken.None); + } + + /// + /// Cancel a currently running template deployment. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static AzureOperationResponse Cancel(this IDeploymentOperations operations, string resourceGroupName, string deploymentName) + { + return Task.Factory.StartNew((object s) => + { + return ((IDeploymentOperations)s).CancelAsync(resourceGroupName, deploymentName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Cancel a currently running template deployment. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static Task CancelAsync(this IDeploymentOperations operations, string resourceGroupName, string deploymentName) + { + return operations.CancelAsync(resourceGroupName, deploymentName, CancellationToken.None); + } + + /// + /// Checks whether deployment exists. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. The name of the resource group to check. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Deployment information. + /// + public static DeploymentExistsResult CheckExistence(this IDeploymentOperations operations, string resourceGroupName, string deploymentName) + { + return Task.Factory.StartNew((object s) => + { + return ((IDeploymentOperations)s).CheckExistenceAsync(resourceGroupName, deploymentName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Checks whether deployment exists. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. The name of the resource group to check. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Deployment information. + /// + public static Task CheckExistenceAsync(this IDeploymentOperations operations, string resourceGroupName, string deploymentName) + { + return operations.CheckExistenceAsync(resourceGroupName, deploymentName, CancellationToken.None); + } + + /// + /// Create a named template deployment using a template. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Required. Additional parameters supplied to the operation. + /// + /// + /// Template deployment operation create result. + /// + public static DeploymentOperationsCreateResult CreateOrUpdate(this IDeploymentOperations operations, string resourceGroupName, string deploymentName, Deployment parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IDeploymentOperations)s).CreateOrUpdateAsync(resourceGroupName, deploymentName, parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Create a named template deployment using a template. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Required. Additional parameters supplied to the operation. + /// + /// + /// Template deployment operation create result. + /// + public static Task CreateOrUpdateAsync(this IDeploymentOperations operations, string resourceGroupName, string deploymentName, Deployment parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, deploymentName, parameters, CancellationToken.None); + } + + /// + /// Delete deployment and all of its resources. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment to be deleted. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static AzureOperationResponse Delete(this IDeploymentOperations operations, string resourceGroupName, string deploymentName) + { + return Task.Factory.StartNew((object s) => + { + return ((IDeploymentOperations)s).DeleteAsync(resourceGroupName, deploymentName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Delete deployment and all of its resources. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment to be deleted. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static Task DeleteAsync(this IDeploymentOperations operations, string resourceGroupName, string deploymentName) + { + return operations.DeleteAsync(resourceGroupName, deploymentName, CancellationToken.None); + } + + /// + /// Get a deployment. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. The name of the resource group to get. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Template deployment information. + /// + public static DeploymentGetResult Get(this IDeploymentOperations operations, string resourceGroupName, string deploymentName) + { + return Task.Factory.StartNew((object s) => + { + return ((IDeploymentOperations)s).GetAsync(resourceGroupName, deploymentName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get a deployment. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. The name of the resource group to get. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Template deployment information. + /// + public static Task GetAsync(this IDeploymentOperations operations, string resourceGroupName, string deploymentName) + { + return operations.GetAsync(resourceGroupName, deploymentName, CancellationToken.None); + } + + /// + /// Get a list of deployments. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. The name of the resource group to filter by. The name is + /// case insensitive. + /// + /// + /// Optional. Query parameters. If null is passed returns all + /// deployments. + /// + /// + /// List of deployments. + /// + public static DeploymentListResult List(this IDeploymentOperations operations, string resourceGroupName, DeploymentListParameters parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IDeploymentOperations)s).ListAsync(resourceGroupName, parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get a list of deployments. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. The name of the resource group to filter by. The name is + /// case insensitive. + /// + /// + /// Optional. Query parameters. If null is passed returns all + /// deployments. + /// + /// + /// List of deployments. + /// + public static Task ListAsync(this IDeploymentOperations operations, string resourceGroupName, DeploymentListParameters parameters) + { + return operations.ListAsync(resourceGroupName, parameters, CancellationToken.None); + } + + /// + /// Get a list of deployments. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of deployments. + /// + public static DeploymentListResult ListNext(this IDeploymentOperations operations, string nextLink) + { + return Task.Factory.StartNew((object s) => + { + return ((IDeploymentOperations)s).ListNextAsync(nextLink); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get a list of deployments. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of deployments. + /// + public static Task ListNextAsync(this IDeploymentOperations operations, string nextLink) + { + return operations.ListNextAsync(nextLink, CancellationToken.None); + } + + /// + /// Validate a deployment template. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Required. Deployment to validate. + /// + /// + /// Information from validate template deployment response. + /// + public static DeploymentValidateResponse Validate(this IDeploymentOperations operations, string resourceGroupName, string deploymentName, Deployment parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IDeploymentOperations)s).ValidateAsync(resourceGroupName, deploymentName, parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Validate a deployment template. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IDeploymentOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. The name of the deployment. + /// + /// + /// Required. Deployment to validate. + /// + /// + /// Information from validate template deployment response. + /// + public static Task ValidateAsync(this IDeploymentOperations operations, string resourceGroupName, string deploymentName, Deployment parameters) + { + return operations.ValidateAsync(resourceGroupName, deploymentName, parameters, CancellationToken.None); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/FeatureClient.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/FeatureClient.cs new file mode 100644 index 000000000000..21726e84eec4 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/FeatureClient.cs @@ -0,0 +1,254 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Net.Http; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public partial class FeatureClient : ServiceClient, IFeatureClient + { + private string _apiVersion; + + /// + /// Gets the API version. + /// + public string ApiVersion + { + get { return this._apiVersion; } + } + + private Uri _baseUri; + + /// + /// Gets the URI used as the base for all cloud service requests. + /// + public Uri BaseUri + { + get { return this._baseUri; } + } + + private SubscriptionCloudCredentials _credentials; + + /// + /// Gets subscription credentials which uniquely identify Microsoft + /// Azure subscription. The subscription ID forms part of the URI for + /// every service call. + /// + public SubscriptionCloudCredentials Credentials + { + get { return this._credentials; } + } + + private int _longRunningOperationInitialTimeout; + + /// + /// Gets or sets the initial timeout for Long Running Operations. + /// + public int LongRunningOperationInitialTimeout + { + get { return this._longRunningOperationInitialTimeout; } + set { this._longRunningOperationInitialTimeout = value; } + } + + private int _longRunningOperationRetryTimeout; + + /// + /// Gets or sets the retry timeout for Long Running Operations. + /// + public int LongRunningOperationRetryTimeout + { + get { return this._longRunningOperationRetryTimeout; } + set { this._longRunningOperationRetryTimeout = value; } + } + + private IFeatures _features; + + /// + /// Operations for managing preview features. + /// + public virtual IFeatures Features + { + get { return this._features; } + } + + /// + /// Initializes a new instance of the FeatureClient class. + /// + public FeatureClient() + : base() + { + this._features = new Features(this); + this._apiVersion = "2014-08-01-preview"; + this._longRunningOperationInitialTimeout = -1; + this._longRunningOperationRetryTimeout = -1; + this.HttpClient.Timeout = TimeSpan.FromSeconds(300); + } + + /// + /// Initializes a new instance of the FeatureClient class. + /// + /// + /// Required. Gets subscription credentials which uniquely identify + /// Microsoft Azure subscription. The subscription ID forms part of + /// the URI for every service call. + /// + /// + /// Optional. Gets the URI used as the base for all cloud service + /// requests. + /// + public FeatureClient(SubscriptionCloudCredentials credentials, Uri baseUri) + : this() + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + this._credentials = credentials; + this._baseUri = baseUri; + + this.Credentials.InitializeServiceClient(this); + } + + /// + /// Initializes a new instance of the FeatureClient class. + /// + /// + /// Required. Gets subscription credentials which uniquely identify + /// Microsoft Azure subscription. The subscription ID forms part of + /// the URI for every service call. + /// + public FeatureClient(SubscriptionCloudCredentials credentials) + : this() + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this._credentials = credentials; + this._baseUri = new Uri("https://management.azure.com/"); + + this.Credentials.InitializeServiceClient(this); + } + + /// + /// Initializes a new instance of the FeatureClient class. + /// + /// + /// The Http client + /// + public FeatureClient(HttpClient httpClient) + : base(httpClient) + { + this._features = new Features(this); + this._apiVersion = "2014-08-01-preview"; + this._longRunningOperationInitialTimeout = -1; + this._longRunningOperationRetryTimeout = -1; + this.HttpClient.Timeout = TimeSpan.FromSeconds(300); + } + + /// + /// Initializes a new instance of the FeatureClient class. + /// + /// + /// Required. Gets subscription credentials which uniquely identify + /// Microsoft Azure subscription. The subscription ID forms part of + /// the URI for every service call. + /// + /// + /// Optional. Gets the URI used as the base for all cloud service + /// requests. + /// + /// + /// The Http client + /// + public FeatureClient(SubscriptionCloudCredentials credentials, Uri baseUri, HttpClient httpClient) + : this(httpClient) + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + this._credentials = credentials; + this._baseUri = baseUri; + + this.Credentials.InitializeServiceClient(this); + } + + /// + /// Initializes a new instance of the FeatureClient class. + /// + /// + /// Required. Gets subscription credentials which uniquely identify + /// Microsoft Azure subscription. The subscription ID forms part of + /// the URI for every service call. + /// + /// + /// The Http client + /// + public FeatureClient(SubscriptionCloudCredentials credentials, HttpClient httpClient) + : this(httpClient) + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this._credentials = credentials; + this._baseUri = new Uri("https://management.azure.com/"); + + this.Credentials.InitializeServiceClient(this); + } + + /// + /// Clones properties from current instance to another FeatureClient + /// instance + /// + /// + /// Instance of FeatureClient to clone to + /// + protected override void Clone(ServiceClient client) + { + base.Clone(client); + + if (client is FeatureClient) + { + FeatureClient clonedClient = ((FeatureClient)client); + + clonedClient._credentials = this._credentials; + clonedClient._baseUri = this._baseUri; + clonedClient._apiVersion = this._apiVersion; + clonedClient._longRunningOperationInitialTimeout = this._longRunningOperationInitialTimeout; + clonedClient._longRunningOperationRetryTimeout = this._longRunningOperationRetryTimeout; + + clonedClient.Credentials.InitializeServiceClient(clonedClient); + } + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/FeatureClientExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/FeatureClientExtensions.cs new file mode 100644 index 000000000000..2ea760b91aa7 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/FeatureClientExtensions.cs @@ -0,0 +1,28 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public static partial class FeatureClientExtensions + { + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Features.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Features.cs new file mode 100644 index 000000000000..69d6b1aa5c98 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Features.cs @@ -0,0 +1,1186 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Hyak.Common; +using Microsoft.Azure.Management.Internal.Resources.Models; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing preview features. + /// + internal partial class Features : IServiceOperations, IFeatures + { + /// + /// Initializes a new instance of the Features class. + /// + /// + /// Reference to the service client. + /// + internal Features(FeatureClient client) + { + this._client = client; + } + + private FeatureClient _client; + + /// + /// Gets a reference to the + /// Microsoft.Azure.Management.Internal.Resources.FeatureClient. + /// + public FeatureClient Client + { + get { return this._client; } + } + + /// + /// Get all features under the subscription. + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Required. Previewed feature name in the resource provider. + /// + /// + /// Cancellation token. + /// + /// + /// Previewed feature information. + /// + public async Task GetAsync(string resourceProviderNamespace, string featureName, CancellationToken cancellationToken) + { + // Validate + if (resourceProviderNamespace == null) + { + throw new ArgumentNullException("resourceProviderNamespace"); + } + if (featureName == null) + { + throw new ArgumentNullException("featureName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("featureName", featureName); + TracingAdapter.Enter(invocationId, this, "GetAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/providers/Microsoft.Features/providers/"; + url = url + Uri.EscapeDataString(resourceProviderNamespace); + url = url + "/features/"; + url = url + Uri.EscapeDataString(featureName); + List queryParameters = new List(); + queryParameters.Add("api-version=2014-08-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + FeatureResponse result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new FeatureResponse(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken nameValue = responseDoc["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + result.Name = nameInstance; + } + + JToken propertiesValue = responseDoc["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + FeatureProperties propertiesInstance = new FeatureProperties(); + result.Properties = propertiesInstance; + + JToken stateValue = propertiesValue["state"]; + if (stateValue != null && stateValue.Type != JTokenType.Null) + { + string stateInstance = ((string)stateValue); + propertiesInstance.State = stateInstance; + } + } + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + result.Id = idInstance; + } + + JToken typeValue = responseDoc["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + result.Type = typeInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Gets a list of previewed features of a resource provider. + /// + /// + /// Required. The namespace of the resource provider. + /// + /// + /// Cancellation token. + /// + /// + /// List of previewed features. + /// + public async Task ListAsync(string resourceProviderNamespace, CancellationToken cancellationToken) + { + // Validate + if (resourceProviderNamespace == null) + { + throw new ArgumentNullException("resourceProviderNamespace"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + TracingAdapter.Enter(invocationId, this, "ListAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/providers/Microsoft.Features/providers/"; + url = url + Uri.EscapeDataString(resourceProviderNamespace); + url = url + "/features"; + List queryParameters = new List(); + queryParameters.Add("api-version=2014-08-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + FeatureOperationsListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new FeatureOperationsListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + FeatureResponse featureResponseInstance = new FeatureResponse(); + result.Features.Add(featureResponseInstance); + + JToken nameValue = valueValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + featureResponseInstance.Name = nameInstance; + } + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + FeatureProperties propertiesInstance = new FeatureProperties(); + featureResponseInstance.Properties = propertiesInstance; + + JToken stateValue = propertiesValue["state"]; + if (stateValue != null && stateValue.Type != JTokenType.Null) + { + string stateInstance = ((string)stateValue); + propertiesInstance.State = stateInstance; + } + } + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + featureResponseInstance.Id = idInstance; + } + + JToken typeValue = valueValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + featureResponseInstance.Type = typeInstance; + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Gets a list of previewed features for all the providers in the + /// current subscription. + /// + /// + /// Cancellation token. + /// + /// + /// List of previewed features. + /// + public async Task ListAllAsync(CancellationToken cancellationToken) + { + // Validate + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + TracingAdapter.Enter(invocationId, this, "ListAllAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/providers/Microsoft.Features/features"; + List queryParameters = new List(); + queryParameters.Add("api-version=2014-08-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + FeatureOperationsListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new FeatureOperationsListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + FeatureResponse featureResponseInstance = new FeatureResponse(); + result.Features.Add(featureResponseInstance); + + JToken nameValue = valueValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + featureResponseInstance.Name = nameInstance; + } + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + FeatureProperties propertiesInstance = new FeatureProperties(); + featureResponseInstance.Properties = propertiesInstance; + + JToken stateValue = propertiesValue["state"]; + if (stateValue != null && stateValue.Type != JTokenType.Null) + { + string stateInstance = ((string)stateValue); + propertiesInstance.State = stateInstance; + } + } + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + featureResponseInstance.Id = idInstance; + } + + JToken typeValue = valueValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + featureResponseInstance.Type = typeInstance; + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Gets a list of previewed features of a subscription. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of previewed features. + /// + public async Task ListAllNextAsync(string nextLink, CancellationToken cancellationToken) + { + // Validate + if (nextLink == null) + { + throw new ArgumentNullException("nextLink"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextLink", nextLink); + TracingAdapter.Enter(invocationId, this, "ListAllNextAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + nextLink; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + FeatureOperationsListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new FeatureOperationsListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + FeatureResponse featureResponseInstance = new FeatureResponse(); + result.Features.Add(featureResponseInstance); + + JToken nameValue = valueValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + featureResponseInstance.Name = nameInstance; + } + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + FeatureProperties propertiesInstance = new FeatureProperties(); + featureResponseInstance.Properties = propertiesInstance; + + JToken stateValue = propertiesValue["state"]; + if (stateValue != null && stateValue.Type != JTokenType.Null) + { + string stateInstance = ((string)stateValue); + propertiesInstance.State = stateInstance; + } + } + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + featureResponseInstance.Id = idInstance; + } + + JToken typeValue = valueValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + featureResponseInstance.Type = typeInstance; + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Gets a list of previewed features of a resource provider. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of previewed features. + /// + public async Task ListNextAsync(string nextLink, CancellationToken cancellationToken) + { + // Validate + if (nextLink == null) + { + throw new ArgumentNullException("nextLink"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextLink", nextLink); + TracingAdapter.Enter(invocationId, this, "ListNextAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + nextLink; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + FeatureOperationsListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new FeatureOperationsListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + FeatureResponse featureResponseInstance = new FeatureResponse(); + result.Features.Add(featureResponseInstance); + + JToken nameValue = valueValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + featureResponseInstance.Name = nameInstance; + } + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + FeatureProperties propertiesInstance = new FeatureProperties(); + featureResponseInstance.Properties = propertiesInstance; + + JToken stateValue = propertiesValue["state"]; + if (stateValue != null && stateValue.Type != JTokenType.Null) + { + string stateInstance = ((string)stateValue); + propertiesInstance.State = stateInstance; + } + } + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + featureResponseInstance.Id = idInstance; + } + + JToken typeValue = valueValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + featureResponseInstance.Type = typeInstance; + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Registers for a previewed feature of a resource provider. + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Required. Previewed feature name in the resource provider. + /// + /// + /// Cancellation token. + /// + /// + /// Previewed feature information. + /// + public async Task RegisterAsync(string resourceProviderNamespace, string featureName, CancellationToken cancellationToken) + { + // Validate + if (resourceProviderNamespace == null) + { + throw new ArgumentNullException("resourceProviderNamespace"); + } + if (featureName == null) + { + throw new ArgumentNullException("featureName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + tracingParameters.Add("featureName", featureName); + TracingAdapter.Enter(invocationId, this, "RegisterAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/providers/Microsoft.Features/providers/"; + url = url + Uri.EscapeDataString(resourceProviderNamespace); + url = url + "/features/"; + url = url + Uri.EscapeDataString(featureName); + url = url + "/register"; + List queryParameters = new List(); + queryParameters.Add("api-version=2014-08-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Post; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + FeatureResponse result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new FeatureResponse(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken nameValue = responseDoc["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + result.Name = nameInstance; + } + + JToken propertiesValue = responseDoc["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + FeatureProperties propertiesInstance = new FeatureProperties(); + result.Properties = propertiesInstance; + + JToken stateValue = propertiesValue["state"]; + if (stateValue != null && stateValue.Type != JTokenType.Null) + { + string stateInstance = ((string)stateValue); + propertiesInstance.State = stateInstance; + } + } + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + result.Id = idInstance; + } + + JToken typeValue = responseDoc["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + result.Type = typeInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/FeaturesExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/FeaturesExtensions.cs new file mode 100644 index 000000000000..7e6df8bc8625 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/FeaturesExtensions.cs @@ -0,0 +1,270 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public static partial class FeaturesExtensions + { + /// + /// Get all features under the subscription. + /// + /// + /// Reference to the Microsoft.Azure.Management.Internal.Resources.IFeatures. + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Required. Previewed feature name in the resource provider. + /// + /// + /// Previewed feature information. + /// + public static FeatureResponse Get(this IFeatures operations, string resourceProviderNamespace, string featureName) + { + return Task.Factory.StartNew((object s) => + { + return ((IFeatures)s).GetAsync(resourceProviderNamespace, featureName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get all features under the subscription. + /// + /// + /// Reference to the Microsoft.Azure.Management.Internal.Resources.IFeatures. + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Required. Previewed feature name in the resource provider. + /// + /// + /// Previewed feature information. + /// + public static Task GetAsync(this IFeatures operations, string resourceProviderNamespace, string featureName) + { + return operations.GetAsync(resourceProviderNamespace, featureName, CancellationToken.None); + } + + /// + /// Gets a list of previewed features of a resource provider. + /// + /// + /// Reference to the Microsoft.Azure.Management.Internal.Resources.IFeatures. + /// + /// + /// Required. The namespace of the resource provider. + /// + /// + /// List of previewed features. + /// + public static FeatureOperationsListResult List(this IFeatures operations, string resourceProviderNamespace) + { + return Task.Factory.StartNew((object s) => + { + return ((IFeatures)s).ListAsync(resourceProviderNamespace); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets a list of previewed features of a resource provider. + /// + /// + /// Reference to the Microsoft.Azure.Management.Internal.Resources.IFeatures. + /// + /// + /// Required. The namespace of the resource provider. + /// + /// + /// List of previewed features. + /// + public static Task ListAsync(this IFeatures operations, string resourceProviderNamespace) + { + return operations.ListAsync(resourceProviderNamespace, CancellationToken.None); + } + + /// + /// Gets a list of previewed features for all the providers in the + /// current subscription. + /// + /// + /// Reference to the Microsoft.Azure.Management.Internal.Resources.IFeatures. + /// + /// + /// List of previewed features. + /// + public static FeatureOperationsListResult ListAll(this IFeatures operations) + { + return Task.Factory.StartNew((object s) => + { + return ((IFeatures)s).ListAllAsync(); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets a list of previewed features for all the providers in the + /// current subscription. + /// + /// + /// Reference to the Microsoft.Azure.Management.Internal.Resources.IFeatures. + /// + /// + /// List of previewed features. + /// + public static Task ListAllAsync(this IFeatures operations) + { + return operations.ListAllAsync(CancellationToken.None); + } + + /// + /// Gets a list of previewed features of a subscription. + /// + /// + /// Reference to the Microsoft.Azure.Management.Internal.Resources.IFeatures. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of previewed features. + /// + public static FeatureOperationsListResult ListAllNext(this IFeatures operations, string nextLink) + { + return Task.Factory.StartNew((object s) => + { + return ((IFeatures)s).ListAllNextAsync(nextLink); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets a list of previewed features of a subscription. + /// + /// + /// Reference to the Microsoft.Azure.Management.Internal.Resources.IFeatures. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of previewed features. + /// + public static Task ListAllNextAsync(this IFeatures operations, string nextLink) + { + return operations.ListAllNextAsync(nextLink, CancellationToken.None); + } + + /// + /// Gets a list of previewed features of a resource provider. + /// + /// + /// Reference to the Microsoft.Azure.Management.Internal.Resources.IFeatures. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of previewed features. + /// + public static FeatureOperationsListResult ListNext(this IFeatures operations, string nextLink) + { + return Task.Factory.StartNew((object s) => + { + return ((IFeatures)s).ListNextAsync(nextLink); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets a list of previewed features of a resource provider. + /// + /// + /// Reference to the Microsoft.Azure.Management.Internal.Resources.IFeatures. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of previewed features. + /// + public static Task ListNextAsync(this IFeatures operations, string nextLink) + { + return operations.ListNextAsync(nextLink, CancellationToken.None); + } + + /// + /// Registers for a previewed feature of a resource provider. + /// + /// + /// Reference to the Microsoft.Azure.Management.Internal.Resources.IFeatures. + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Required. Previewed feature name in the resource provider. + /// + /// + /// Previewed feature information. + /// + public static FeatureResponse Register(this IFeatures operations, string resourceProviderNamespace, string featureName) + { + return Task.Factory.StartNew((object s) => + { + return ((IFeatures)s).RegisterAsync(resourceProviderNamespace, featureName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Registers for a previewed feature of a resource provider. + /// + /// + /// Reference to the Microsoft.Azure.Management.Internal.Resources.IFeatures. + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Required. Previewed feature name in the resource provider. + /// + /// + /// Previewed feature information. + /// + public static Task RegisterAsync(this IFeatures operations, string resourceProviderNamespace, string featureName) + { + return operations.RegisterAsync(resourceProviderNamespace, featureName, CancellationToken.None); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IAuthorizationClient.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IAuthorizationClient.cs new file mode 100644 index 000000000000..29a694791616 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IAuthorizationClient.cs @@ -0,0 +1,78 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public partial interface IAuthorizationClient : IDisposable + { + /// + /// Gets the API version. + /// + string ApiVersion + { + get; + } + + /// + /// Gets the URI used as the base for all cloud service requests. + /// + Uri BaseUri + { + get; + } + + /// + /// Gets subscription credentials which uniquely identify Microsoft + /// Azure subscription. The subscription ID forms part of the URI for + /// every service call. + /// + SubscriptionCloudCredentials Credentials + { + get; + } + + /// + /// Gets or sets the initial timeout for Long Running Operations. + /// + int LongRunningOperationInitialTimeout + { + get; set; + } + + /// + /// Gets or sets the retry timeout for Long Running Operations. + /// + int LongRunningOperationRetryTimeout + { + get; set; + } + + /// + /// Operations for managing locks. + /// + IManagementLockOperations ManagementLocks + { + get; + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IDeploymentOperationOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IDeploymentOperationOperations.cs new file mode 100644 index 000000000000..bdef7da66fd8 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IDeploymentOperationOperations.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing deployment operations. + /// + public partial interface IDeploymentOperationOperations + { + /// + /// Get a list of deployments operations. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Operation Id. + /// + /// + /// Cancellation token. + /// + /// + /// Deployment operation. + /// + Task GetAsync(string resourceGroupName, string deploymentName, string operationId, CancellationToken cancellationToken); + + /// + /// Gets a list of deployments operations. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Query parameters. + /// + /// + /// Cancellation token. + /// + /// + /// List of deployment operations. + /// + Task ListAsync(string resourceGroupName, string deploymentName, DeploymentOperationsListParameters parameters, CancellationToken cancellationToken); + + /// + /// Gets a next list of deployments operations. + /// + /// + /// NextLink from the previous successful call to List operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of deployment operations. + /// + Task ListNextAsync(string nextLink, CancellationToken cancellationToken); + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IDeploymentOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IDeploymentOperations.cs new file mode 100644 index 000000000000..c95feb84533b --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IDeploymentOperations.cs @@ -0,0 +1,195 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing deployments. + /// + public partial interface IDeploymentOperations + { + /// + /// Begin deleting deployment.To determine whether the operation has + /// finished processing the request, call + /// GetLongRunningOperationStatus. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment to be deleted. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response for long running operations. + /// + Task BeginDeletingAsync(string resourceGroupName, string deploymentName, CancellationToken cancellationToken); + + /// + /// Cancel a currently running template deployment. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + Task CancelAsync(string resourceGroupName, string deploymentName, CancellationToken cancellationToken); + + /// + /// Checks whether deployment exists. + /// + /// + /// The name of the resource group to check. The name is case + /// insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Cancellation token. + /// + /// + /// Deployment information. + /// + Task CheckExistenceAsync(string resourceGroupName, string deploymentName, CancellationToken cancellationToken); + + /// + /// Create a named template deployment using a template. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Additional parameters supplied to the operation. + /// + /// + /// Cancellation token. + /// + /// + /// Template deployment operation create result. + /// + Task CreateOrUpdateAsync(string resourceGroupName, string deploymentName, Deployment parameters, CancellationToken cancellationToken); + + /// + /// Delete deployment and all of its resources. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment to be deleted. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + Task DeleteAsync(string resourceGroupName, string deploymentName, CancellationToken cancellationToken); + + /// + /// Get a deployment. + /// + /// + /// The name of the resource group to get. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Cancellation token. + /// + /// + /// Template deployment information. + /// + Task GetAsync(string resourceGroupName, string deploymentName, CancellationToken cancellationToken); + + /// + /// Get a list of deployments. + /// + /// + /// The name of the resource group to filter by. The name is case + /// insensitive. + /// + /// + /// Query parameters. If null is passed returns all deployments. + /// + /// + /// Cancellation token. + /// + /// + /// List of deployments. + /// + Task ListAsync(string resourceGroupName, DeploymentListParameters parameters, CancellationToken cancellationToken); + + /// + /// Get a list of deployments. + /// + /// + /// NextLink from the previous successful call to List operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of deployments. + /// + Task ListNextAsync(string nextLink, CancellationToken cancellationToken); + + /// + /// Validate a deployment template. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// The name of the deployment. + /// + /// + /// Deployment to validate. + /// + /// + /// Cancellation token. + /// + /// + /// Information from validate template deployment response. + /// + Task ValidateAsync(string resourceGroupName, string deploymentName, Deployment parameters, CancellationToken cancellationToken); + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IFeatureClient.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IFeatureClient.cs new file mode 100644 index 000000000000..95049d66b825 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IFeatureClient.cs @@ -0,0 +1,78 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public partial interface IFeatureClient : IDisposable + { + /// + /// Gets the API version. + /// + string ApiVersion + { + get; + } + + /// + /// Gets the URI used as the base for all cloud service requests. + /// + Uri BaseUri + { + get; + } + + /// + /// Gets subscription credentials which uniquely identify Microsoft + /// Azure subscription. The subscription ID forms part of the URI for + /// every service call. + /// + SubscriptionCloudCredentials Credentials + { + get; + } + + /// + /// Gets or sets the initial timeout for Long Running Operations. + /// + int LongRunningOperationInitialTimeout + { + get; set; + } + + /// + /// Gets or sets the retry timeout for Long Running Operations. + /// + int LongRunningOperationRetryTimeout + { + get; set; + } + + /// + /// Operations for managing preview features. + /// + IFeatures Features + { + get; + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IFeatures.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IFeatures.cs new file mode 100644 index 000000000000..0043bb23594b --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IFeatures.cs @@ -0,0 +1,121 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing preview features. + /// + public partial interface IFeatures + { + /// + /// Get all features under the subscription. + /// + /// + /// Namespace of the resource provider. + /// + /// + /// Previewed feature name in the resource provider. + /// + /// + /// Cancellation token. + /// + /// + /// Previewed feature information. + /// + Task GetAsync(string resourceProviderNamespace, string featureName, CancellationToken cancellationToken); + + /// + /// Gets a list of previewed features of a resource provider. + /// + /// + /// The namespace of the resource provider. + /// + /// + /// Cancellation token. + /// + /// + /// List of previewed features. + /// + Task ListAsync(string resourceProviderNamespace, CancellationToken cancellationToken); + + /// + /// Gets a list of previewed features for all the providers in the + /// current subscription. + /// + /// + /// Cancellation token. + /// + /// + /// List of previewed features. + /// + Task ListAllAsync(CancellationToken cancellationToken); + + /// + /// Gets a list of previewed features of a subscription. + /// + /// + /// NextLink from the previous successful call to List operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of previewed features. + /// + Task ListAllNextAsync(string nextLink, CancellationToken cancellationToken); + + /// + /// Gets a list of previewed features of a resource provider. + /// + /// + /// NextLink from the previous successful call to List operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of previewed features. + /// + Task ListNextAsync(string nextLink, CancellationToken cancellationToken); + + /// + /// Registers for a previewed feature of a resource provider. + /// + /// + /// Namespace of the resource provider. + /// + /// + /// Previewed feature name in the resource provider. + /// + /// + /// Cancellation token. + /// + /// + /// Previewed feature information. + /// + Task RegisterAsync(string resourceProviderNamespace, string featureName, CancellationToken cancellationToken); + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IManagementLockOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IManagementLockOperations.cs new file mode 100644 index 000000000000..0fbfdef68a72 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IManagementLockOperations.cs @@ -0,0 +1,233 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing locks. + /// + public partial interface IManagementLockOperations + { + /// + /// Create or update a management lock at the resource group level. + /// + /// + /// The resource group name. + /// + /// + /// The lock name. + /// + /// + /// The management lock parameters. + /// + /// + /// Cancellation token. + /// + /// + /// Management lock information. + /// + Task CreateOrUpdateAtResourceGroupLevelAsync(string resourceGroupName, string lockName, ManagementLockProperties parameters, CancellationToken cancellationToken); + + /// + /// Create or update a management lock at the resource level or any + /// level below resource. + /// + /// + /// The name of the resource group. + /// + /// + /// Resource identity. + /// + /// + /// The name of lock. + /// + /// + /// Create or update management lock parameters. + /// + /// + /// Cancellation token. + /// + /// + /// Management lock information. + /// + Task CreateOrUpdateAtResourceLevelAsync(string resourceGroupName, ResourceIdentity identity, string lockName, ManagementLockProperties parameters, CancellationToken cancellationToken); + + /// + /// Create or update a management lock at the subscription level. + /// + /// + /// The name of lock. + /// + /// + /// The management lock parameters. + /// + /// + /// Cancellation token. + /// + /// + /// Management lock information. + /// + Task CreateOrUpdateAtSubscriptionLevelAsync(string lockName, ManagementLockProperties parameters, CancellationToken cancellationToken); + + /// + /// Deletes the management lock of a resource group. + /// + /// + /// The resource group names. + /// + /// + /// The name of lock. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + Task DeleteAtResourceGroupLevelAsync(string resourceGroup, string lockName, CancellationToken cancellationToken); + + /// + /// Deletes the management lock of a resource or any level below + /// resource. + /// + /// + /// The name of the resource group. + /// + /// + /// Resource identity. + /// + /// + /// The name of lock. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + Task DeleteAtResourceLevelAsync(string resourceGroupName, ResourceIdentity identity, string lockName, CancellationToken cancellationToken); + + /// + /// Deletes the management lock of a subscription. + /// + /// + /// The name of lock. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + Task DeleteAtSubscriptionLevelAsync(string lockName, CancellationToken cancellationToken); + + /// + /// Gets the management lock of a scope. + /// + /// + /// Name of the management lock. + /// + /// + /// Cancellation token. + /// + /// + /// Management lock information. + /// + Task GetAsync(string lockName, CancellationToken cancellationToken); + + /// + /// Gets all the management locks of a resource group. + /// + /// + /// Resource group name. + /// + /// + /// Query parameters. If empty is passed returns all locks at, above or + /// below the resource group. + /// + /// + /// Cancellation token. + /// + /// + /// List of management locks. + /// + Task ListAtResourceGroupLevelAsync(string resourceGroupName, ManagementLockGetQueryParameter parameters, CancellationToken cancellationToken); + + /// + /// Gets all the management locks of a resource or any level below + /// resource. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Resource identity. + /// + /// + /// Query parameters. If empty is passed returns all locks at or below + /// the resource.If atScope() is passed returns all locks at the + /// resource level. + /// + /// + /// Cancellation token. + /// + /// + /// List of management locks. + /// + Task ListAtResourceLevelAsync(string resourceGroupName, ResourceIdentity identity, ManagementLockGetQueryParameter parameters, CancellationToken cancellationToken); + + /// + /// Gets all the management locks of a subscription. + /// + /// + /// Query parameters. If empty is passed returns all locks at, above or + /// below the subscription. + /// + /// + /// Cancellation token. + /// + /// + /// List of management locks. + /// + Task ListAtSubscriptionLevelAsync(ManagementLockGetQueryParameter parameters, CancellationToken cancellationToken); + + /// + /// Get a list of management locks at resource level or below. + /// + /// + /// NextLink from the previous successful call to List operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of management locks. + /// + Task ListNextAsync(string nextLink, CancellationToken cancellationToken); + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IProviderOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IProviderOperations.cs new file mode 100644 index 000000000000..eed72529159f --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IProviderOperations.cs @@ -0,0 +1,103 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing providers. + /// + public partial interface IProviderOperations + { + /// + /// Gets a resource provider. + /// + /// + /// Namespace of the resource provider. + /// + /// + /// Cancellation token. + /// + /// + /// Resource provider information. + /// + Task GetAsync(string resourceProviderNamespace, CancellationToken cancellationToken); + + /// + /// Gets a list of resource providers. + /// + /// + /// Query parameters. If null is passed returns all deployments. + /// + /// + /// Cancellation token. + /// + /// + /// List of resource providers. + /// + Task ListAsync(ProviderListParameters parameters, CancellationToken cancellationToken); + + /// + /// Get a list of deployments. + /// + /// + /// NextLink from the previous successful call to List operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of resource providers. + /// + Task ListNextAsync(string nextLink, CancellationToken cancellationToken); + + /// + /// Registers provider to be used with a subscription. + /// + /// + /// Namespace of the resource provider. + /// + /// + /// Cancellation token. + /// + /// + /// Resource provider registration information. + /// + Task RegisterAsync(string resourceProviderNamespace, CancellationToken cancellationToken); + + /// + /// Unregisters provider from a subscription. + /// + /// + /// Namespace of the resource provider. + /// + /// + /// Cancellation token. + /// + /// + /// Resource provider registration information. + /// + Task UnregisterAsync(string resourceProviderNamespace, CancellationToken cancellationToken); + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IProviderOperationsMetadataOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IProviderOperationsMetadataOperations.cs new file mode 100644 index 000000000000..6ab1a1fd0316 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IProviderOperationsMetadataOperations.cs @@ -0,0 +1,58 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for getting provider operations metadata. + /// + public partial interface IProviderOperationsMetadataOperations + { + /// + /// Gets provider operations metadata + /// + /// + /// Namespace of the resource provider. + /// + /// + /// Cancellation token. + /// + /// + /// Provider operations metadata + /// + Task GetAsync(string resourceProviderNamespace, CancellationToken cancellationToken); + + /// + /// Gets provider operations metadata list + /// + /// + /// Cancellation token. + /// + /// + /// Provider operations metadata list + /// + Task ListAsync(CancellationToken cancellationToken); + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IResourceGroupOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IResourceGroupOperations.cs new file mode 100644 index 000000000000..97441cf706cf --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IResourceGroupOperations.cs @@ -0,0 +1,163 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing resource groups. + /// + public partial interface IResourceGroupOperations + { + /// + /// Begin deleting resource group.To determine whether the operation + /// has finished processing the request, call + /// GetLongRunningOperationStatus. + /// + /// + /// The name of the resource group to be deleted. The name is case + /// insensitive. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response for long running operations. + /// + Task BeginDeletingAsync(string resourceGroupName, CancellationToken cancellationToken); + + /// + /// Checks whether resource group exists. + /// + /// + /// The name of the resource group to check. The name is case + /// insensitive. + /// + /// + /// Cancellation token. + /// + /// + /// Resource group information. + /// + Task CheckExistenceAsync(string resourceGroupName, CancellationToken cancellationToken); + + /// + /// Create a resource group. + /// + /// + /// The name of the resource group to be created or updated. + /// + /// + /// Parameters supplied to the create or update resource group service + /// operation. + /// + /// + /// Cancellation token. + /// + /// + /// Resource group information. + /// + Task CreateOrUpdateAsync(string resourceGroupName, ResourceGroup parameters, CancellationToken cancellationToken); + + /// + /// Delete resource group and all of its resources. + /// + /// + /// The name of the resource group to be deleted. The name is case + /// insensitive. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + Task DeleteAsync(string resourceGroupName, CancellationToken cancellationToken); + + /// + /// Get a resource group. + /// + /// + /// The name of the resource group to get. The name is case insensitive. + /// + /// + /// Cancellation token. + /// + /// + /// Resource group information. + /// + Task GetAsync(string resourceGroupName, CancellationToken cancellationToken); + + /// + /// Gets a collection of resource groups. + /// + /// + /// Query parameters. If null is passed returns all resource groups. + /// + /// + /// Cancellation token. + /// + /// + /// List of resource groups. + /// + Task ListAsync(ResourceGroupListParameters parameters, CancellationToken cancellationToken); + + /// + /// Get a list of deployments. + /// + /// + /// NextLink from the previous successful call to List operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of resource groups. + /// + Task ListNextAsync(string nextLink, CancellationToken cancellationToken); + + /// + /// Resource groups can be updated through a simple PATCH operation to + /// a group address. The format of the request is the same as that for + /// creating a resource groups, though if a field is unspecified + /// current value will be carried over. + /// + /// + /// The name of the resource group to be created or updated. The name + /// is case insensitive. + /// + /// + /// Parameters supplied to the update state resource group service + /// operation. + /// + /// + /// Cancellation token. + /// + /// + /// Resource group information. + /// + Task PatchAsync(string resourceGroupName, ResourceGroup parameters, CancellationToken cancellationToken); + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IResourceManagementClient.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IResourceManagementClient.cs new file mode 100644 index 000000000000..09fc4399bf29 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IResourceManagementClient.cs @@ -0,0 +1,154 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public partial interface IResourceManagementClient : IDisposable + { + /// + /// Gets the API version. + /// + string ApiVersion + { + get; + } + + /// + /// Gets the URI used as the base for all cloud service requests. + /// + Uri BaseUri + { + get; + } + + /// + /// Gets subscription credentials which uniquely identify Microsoft + /// Azure subscription. The subscription ID forms part of the URI for + /// every service call. + /// + SubscriptionCloudCredentials Credentials + { + get; + } + + /// + /// Gets or sets the initial timeout for Long Running Operations. + /// + int LongRunningOperationInitialTimeout + { + get; set; + } + + /// + /// Gets or sets the retry timeout for Long Running Operations. + /// + int LongRunningOperationRetryTimeout + { + get; set; + } + + /// + /// Operations for managing deployment operations. + /// + IDeploymentOperationOperations DeploymentOperations + { + get; + } + + /// + /// Operations for managing deployments. + /// + IDeploymentOperations Deployments + { + get; + } + + /// + /// Operations for managing providers. + /// + IProviderOperations Providers + { + get; + } + + /// + /// Operations for getting provider operations metadata. + /// + IProviderOperationsMetadataOperations ProviderOperationsMetadata + { + get; + } + + /// + /// Operations for managing resource groups. + /// + IResourceGroupOperations ResourceGroups + { + get; + } + + /// + /// Operations for managing resources. + /// + IResourceOperations Resources + { + get; + } + + /// + /// Operations for managing Resource provider operations. + /// + IResourceProviderOperationDetailsOperations ResourceProviderOperationDetails + { + get; + } + + /// + /// Operations for managing tags. + /// + ITagOperations Tags + { + get; + } + + /// + /// The Get Operation Status operation returns the status of the + /// specified operation. After calling an asynchronous operation, you + /// can call Get Operation Status to determine whether the operation + /// has succeeded, failed, or is still in progress. + /// + /// + /// Location value returned by the Begin operation. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response for long running operations. + /// + Task GetLongRunningOperationStatusAsync(string operationStatusLink, CancellationToken cancellationToken); + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IResourceOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IResourceOperations.cs new file mode 100644 index 000000000000..93a1747a6cb3 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IResourceOperations.cs @@ -0,0 +1,170 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing resources. + /// + public partial interface IResourceOperations + { + /// + /// Begin moving resources.To determine whether the operation has + /// finished processing the request, call + /// GetLongRunningOperationStatus. + /// + /// + /// Source resource group name. + /// + /// + /// move resources' parameters. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response for long running operations. + /// + Task BeginMovingAsync(string sourceResourceGroupName, ResourcesMoveInfo parameters, CancellationToken cancellationToken); + + /// + /// Checks whether resource exists. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Resource identity. + /// + /// + /// Cancellation token. + /// + /// + /// Resource group information. + /// + Task CheckExistenceAsync(string resourceGroupName, ResourceIdentity identity, CancellationToken cancellationToken); + + /// + /// Create a resource. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Resource identity. + /// + /// + /// Create or update resource parameters. + /// + /// + /// Cancellation token. + /// + /// + /// Resource information. + /// + Task CreateOrUpdateAsync(string resourceGroupName, ResourceIdentity identity, GenericResource parameters, CancellationToken cancellationToken); + + /// + /// Delete resource and all of its resources. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Resource identity. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + Task DeleteAsync(string resourceGroupName, ResourceIdentity identity, CancellationToken cancellationToken); + + /// + /// Returns a resource belonging to a resource group. + /// + /// + /// The name of the resource group. The name is case insensitive. + /// + /// + /// Resource identity. + /// + /// + /// Cancellation token. + /// + /// + /// Resource information. + /// + Task GetAsync(string resourceGroupName, ResourceIdentity identity, CancellationToken cancellationToken); + + /// + /// Get all of the resources under a subscription. + /// + /// + /// Query parameters. If null is passed returns all resource groups. + /// + /// + /// Cancellation token. + /// + /// + /// List of resource groups. + /// + Task ListAsync(ResourceListParameters parameters, CancellationToken cancellationToken); + + /// + /// Get a list of deployments. + /// + /// + /// NextLink from the previous successful call to List operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of resource groups. + /// + Task ListNextAsync(string nextLink, CancellationToken cancellationToken); + + /// + /// Move resources within or across subscriptions. + /// + /// + /// Source resource group name. + /// + /// + /// move resources' parameters. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + Task MoveResourcesAsync(string sourceResourceGroupName, ResourcesMoveInfo parameters, CancellationToken cancellationToken); + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IResourceProviderOperationDetailsOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IResourceProviderOperationDetailsOperations.cs new file mode 100644 index 000000000000..ddeda5c8bbe1 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/IResourceProviderOperationDetailsOperations.cs @@ -0,0 +1,47 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing Resource provider operations. + /// + public partial interface IResourceProviderOperationDetailsOperations + { + /// + /// Gets a list of resource providers. + /// + /// + /// Resource identity. + /// + /// + /// Cancellation token. + /// + /// + /// List of resource provider operations. + /// + Task ListAsync(ResourceIdentity identity, CancellationToken cancellationToken); + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ISubscriptionClient.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ISubscriptionClient.cs new file mode 100644 index 000000000000..3e83097b50b3 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ISubscriptionClient.cs @@ -0,0 +1,85 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using Hyak.Common; + +namespace Microsoft.Azure.Internal.Subscriptions +{ + public partial interface ISubscriptionClient : IDisposable + { + /// + /// Gets the API version. + /// + string ApiVersion + { + get; + } + + /// + /// Gets the URI used as the base for all cloud service requests. + /// + Uri BaseUri + { + get; + } + + /// + /// Credentials used to authenticate requests. + /// + CloudCredentials Credentials + { + get; set; + } + + /// + /// Gets or sets the initial timeout for Long Running Operations. + /// + int LongRunningOperationInitialTimeout + { + get; set; + } + + /// + /// Gets or sets the retry timeout for Long Running Operations. + /// + int LongRunningOperationRetryTimeout + { + get; set; + } + + /// + /// Operations for managing subscriptions. + /// + ISubscriptionOperations Subscriptions + { + get; + } + + /// + /// Operations for managing tenants. + /// + ITenantOperations Tenants + { + get; + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ISubscriptionOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ISubscriptionOperations.cs new file mode 100644 index 000000000000..e5129917b1d8 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ISubscriptionOperations.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Internal.Subscriptions.Models; + +namespace Microsoft.Azure.Internal.Subscriptions +{ + /// + /// Operations for managing subscriptions. + /// + public partial interface ISubscriptionOperations + { + /// + /// Gets details about particular subscription. + /// + /// + /// Id of the subscription. + /// + /// + /// Cancellation token. + /// + /// + /// Subscription detailed information. + /// + Task GetAsync(string subscriptionId, CancellationToken cancellationToken); + + /// + /// Gets a list of the subscriptionIds. + /// + /// + /// Cancellation token. + /// + /// + /// Subscription list operation response. + /// + Task ListAsync(CancellationToken cancellationToken); + + /// + /// Gets a list of the subscription locations. + /// + /// + /// Id of the subscription + /// + /// + /// Cancellation token. + /// + /// + /// Location list operation response. + /// + Task ListLocationsAsync(string subscriptionId, CancellationToken cancellationToken); + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ITagOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ITagOperations.cs new file mode 100644 index 000000000000..dab46e41bc02 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ITagOperations.cs @@ -0,0 +1,122 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing tags. + /// + public partial interface ITagOperations + { + /// + /// Create a subscription resource tag. + /// + /// + /// The name of the tag. + /// + /// + /// Cancellation token. + /// + /// + /// Tag information. + /// + Task CreateOrUpdateAsync(string tagName, CancellationToken cancellationToken); + + /// + /// Create a subscription resource tag value. + /// + /// + /// The name of the tag. + /// + /// + /// The value of the tag. + /// + /// + /// Cancellation token. + /// + /// + /// Tag information. + /// + Task CreateOrUpdateValueAsync(string tagName, string tagValue, CancellationToken cancellationToken); + + /// + /// Delete a subscription resource tag. + /// + /// + /// The name of the tag. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + Task DeleteAsync(string tagName, CancellationToken cancellationToken); + + /// + /// Delete a subscription resource tag value. + /// + /// + /// The name of the tag. + /// + /// + /// The value of the tag. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + Task DeleteValueAsync(string tagName, string tagValue, CancellationToken cancellationToken); + + /// + /// Get a list of subscription resource tags. + /// + /// + /// Cancellation token. + /// + /// + /// List of subscription tags. + /// + Task ListAsync(CancellationToken cancellationToken); + + /// + /// Get a list of tags under a subscription. + /// + /// + /// NextLink from the previous successful call to List operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of subscription tags. + /// + Task ListNextAsync(string nextLink, CancellationToken cancellationToken); + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ITenantOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ITenantOperations.cs new file mode 100644 index 000000000000..4e647b594d33 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ITenantOperations.cs @@ -0,0 +1,44 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Internal.Subscriptions.Models; + +namespace Microsoft.Azure.Internal.Subscriptions +{ + /// + /// Operations for managing tenants. + /// + public partial interface ITenantOperations + { + /// + /// Gets a list of the tenantIds. + /// + /// + /// Cancellation token. + /// + /// + /// Tenant Ids information. + /// + Task ListAsync(CancellationToken cancellationToken); + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ManagementLockOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ManagementLockOperations.cs new file mode 100644 index 000000000000..63900beea4ca --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ManagementLockOperations.cs @@ -0,0 +1,2314 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using Hyak.Common; +using Microsoft.Azure.Management.Internal.Resources.Models; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing locks. + /// + internal partial class ManagementLockOperations : IServiceOperations, IManagementLockOperations + { + /// + /// Initializes a new instance of the ManagementLockOperations class. + /// + /// + /// Reference to the service client. + /// + internal ManagementLockOperations(AuthorizationClient client) + { + this._client = client; + } + + private AuthorizationClient _client; + + /// + /// Gets a reference to the + /// Microsoft.Azure.Management.Internal.Resources.AuthorizationClient. + /// + public AuthorizationClient Client + { + get { return this._client; } + } + + /// + /// Create or update a management lock at the resource group level. + /// + /// + /// Required. The resource group name. + /// + /// + /// Required. The lock name. + /// + /// + /// Required. The management lock parameters. + /// + /// + /// Cancellation token. + /// + /// + /// Management lock information. + /// + public async Task CreateOrUpdateAtResourceGroupLevelAsync(string resourceGroupName, string lockName, ManagementLockProperties parameters, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (lockName == null) + { + throw new ArgumentNullException("lockName"); + } + if (parameters == null) + { + throw new ArgumentNullException("parameters"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("lockName", lockName); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "CreateOrUpdateAtResourceGroupLevelAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourceGroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + url = url + "/providers/Microsoft.Authorization/locks/"; + url = url + Uri.EscapeDataString(lockName); + List queryParameters = new List(); + queryParameters.Add("api-version=2015-01-01"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Put; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Serialize Request + string requestContent = null; + JToken requestDoc = null; + + JObject propertiesValue = new JObject(); + requestDoc = propertiesValue; + + if (parameters.Level != null) + { + propertiesValue["level"] = parameters.Level; + } + + if (parameters.Notes != null) + { + propertiesValue["notes"] = parameters.Notes; + } + + requestContent = requestDoc.ToString(Newtonsoft.Json.Formatting.Indented); + httpRequest.Content = new StringContent(requestContent, Encoding.UTF8); + httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.Created) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, requestContent, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ManagementLockReturnResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.Created) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ManagementLockReturnResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + ManagementLockObject managementLockInstance = new ManagementLockObject(); + result.ManagementLock = managementLockInstance; + + JToken propertiesValue2 = responseDoc["properties"]; + if (propertiesValue2 != null && propertiesValue2.Type != JTokenType.Null) + { + ManagementLockProperties propertiesInstance = new ManagementLockProperties(); + managementLockInstance.Properties = propertiesInstance; + + JToken levelValue = propertiesValue2["level"]; + if (levelValue != null && levelValue.Type != JTokenType.Null) + { + string levelInstance = ((string)levelValue); + propertiesInstance.Level = levelInstance; + } + + JToken notesValue = propertiesValue2["notes"]; + if (notesValue != null && notesValue.Type != JTokenType.Null) + { + string notesInstance = ((string)notesValue); + propertiesInstance.Notes = notesInstance; + } + } + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + managementLockInstance.Id = idInstance; + } + + JToken typeValue = responseDoc["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + managementLockInstance.Type = typeInstance; + } + + JToken nameValue = responseDoc["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + managementLockInstance.Name = nameInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Create or update a management lock at the resource level or any + /// level below resource. + /// + /// + /// Required. The name of the resource group. + /// + /// + /// Required. Resource identity. + /// + /// + /// Required. The name of lock. + /// + /// + /// Required. Create or update management lock parameters. + /// + /// + /// Cancellation token. + /// + /// + /// Management lock information. + /// + public async Task CreateOrUpdateAtResourceLevelAsync(string resourceGroupName, ResourceIdentity identity, string lockName, ManagementLockProperties parameters, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (identity == null) + { + throw new ArgumentNullException("identity"); + } + if (identity.ResourceName == null) + { + throw new ArgumentNullException("identity.ResourceName"); + } + if (identity.ResourceProviderApiVersion == null) + { + throw new ArgumentNullException("identity.ResourceProviderApiVersion"); + } + if (identity.ResourceProviderNamespace == null) + { + throw new ArgumentNullException("identity.ResourceProviderNamespace"); + } + if (identity.ResourceType == null) + { + throw new ArgumentNullException("identity.ResourceType"); + } + if (lockName == null) + { + throw new ArgumentNullException("lockName"); + } + if (parameters == null) + { + throw new ArgumentNullException("parameters"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("identity", identity); + tracingParameters.Add("lockName", lockName); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "CreateOrUpdateAtResourceLevelAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + url = url + "/providers/"; + url = url + Uri.EscapeDataString(identity.ResourceProviderNamespace); + url = url + "/"; + if (identity.ParentResourcePath != null) + { + url = url + identity.ParentResourcePath; + } + url = url + "/"; + url = url + identity.ResourceType; + url = url + "/"; + url = url + Uri.EscapeDataString(identity.ResourceName); + url = url + "/providers/Microsoft.Authorization/locks/"; + url = url + Uri.EscapeDataString(lockName); + List queryParameters = new List(); + queryParameters.Add("api-version=2015-01-01"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Put; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Serialize Request + string requestContent = null; + JToken requestDoc = null; + + JObject propertiesValue = new JObject(); + requestDoc = propertiesValue; + + if (parameters.Level != null) + { + propertiesValue["level"] = parameters.Level; + } + + if (parameters.Notes != null) + { + propertiesValue["notes"] = parameters.Notes; + } + + requestContent = requestDoc.ToString(Newtonsoft.Json.Formatting.Indented); + httpRequest.Content = new StringContent(requestContent, Encoding.UTF8); + httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.Created) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, requestContent, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ManagementLockReturnResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.Created) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ManagementLockReturnResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + ManagementLockObject managementLockInstance = new ManagementLockObject(); + result.ManagementLock = managementLockInstance; + + JToken propertiesValue2 = responseDoc["properties"]; + if (propertiesValue2 != null && propertiesValue2.Type != JTokenType.Null) + { + ManagementLockProperties propertiesInstance = new ManagementLockProperties(); + managementLockInstance.Properties = propertiesInstance; + + JToken levelValue = propertiesValue2["level"]; + if (levelValue != null && levelValue.Type != JTokenType.Null) + { + string levelInstance = ((string)levelValue); + propertiesInstance.Level = levelInstance; + } + + JToken notesValue = propertiesValue2["notes"]; + if (notesValue != null && notesValue.Type != JTokenType.Null) + { + string notesInstance = ((string)notesValue); + propertiesInstance.Notes = notesInstance; + } + } + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + managementLockInstance.Id = idInstance; + } + + JToken typeValue = responseDoc["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + managementLockInstance.Type = typeInstance; + } + + JToken nameValue = responseDoc["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + managementLockInstance.Name = nameInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Create or update a management lock at the subscription level. + /// + /// + /// Required. The name of lock. + /// + /// + /// Required. The management lock parameters. + /// + /// + /// Cancellation token. + /// + /// + /// Management lock information. + /// + public async Task CreateOrUpdateAtSubscriptionLevelAsync(string lockName, ManagementLockProperties parameters, CancellationToken cancellationToken) + { + // Validate + if (lockName == null) + { + throw new ArgumentNullException("lockName"); + } + if (parameters == null) + { + throw new ArgumentNullException("parameters"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("lockName", lockName); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "CreateOrUpdateAtSubscriptionLevelAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/providers/Microsoft.Authorization/locks/"; + url = url + Uri.EscapeDataString(lockName); + List queryParameters = new List(); + queryParameters.Add("api-version=2015-01-01"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Put; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Serialize Request + string requestContent = null; + JToken requestDoc = null; + + JObject propertiesValue = new JObject(); + requestDoc = propertiesValue; + + if (parameters.Level != null) + { + propertiesValue["level"] = parameters.Level; + } + + if (parameters.Notes != null) + { + propertiesValue["notes"] = parameters.Notes; + } + + requestContent = requestDoc.ToString(Newtonsoft.Json.Formatting.Indented); + httpRequest.Content = new StringContent(requestContent, Encoding.UTF8); + httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.Created) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, requestContent, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ManagementLockReturnResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.Created) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ManagementLockReturnResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + ManagementLockObject managementLockInstance = new ManagementLockObject(); + result.ManagementLock = managementLockInstance; + + JToken propertiesValue2 = responseDoc["properties"]; + if (propertiesValue2 != null && propertiesValue2.Type != JTokenType.Null) + { + ManagementLockProperties propertiesInstance = new ManagementLockProperties(); + managementLockInstance.Properties = propertiesInstance; + + JToken levelValue = propertiesValue2["level"]; + if (levelValue != null && levelValue.Type != JTokenType.Null) + { + string levelInstance = ((string)levelValue); + propertiesInstance.Level = levelInstance; + } + + JToken notesValue = propertiesValue2["notes"]; + if (notesValue != null && notesValue.Type != JTokenType.Null) + { + string notesInstance = ((string)notesValue); + propertiesInstance.Notes = notesInstance; + } + } + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + managementLockInstance.Id = idInstance; + } + + JToken typeValue = responseDoc["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + managementLockInstance.Type = typeInstance; + } + + JToken nameValue = responseDoc["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + managementLockInstance.Name = nameInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Deletes the management lock of a resource group. + /// + /// + /// Required. The resource group names. + /// + /// + /// Required. The name of lock. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public async Task DeleteAtResourceGroupLevelAsync(string resourceGroup, string lockName, CancellationToken cancellationToken) + { + // Validate + if (resourceGroup == null) + { + throw new ArgumentNullException("resourceGroup"); + } + if (lockName == null) + { + throw new ArgumentNullException("lockName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroup", resourceGroup); + tracingParameters.Add("lockName", lockName); + TracingAdapter.Enter(invocationId, this, "DeleteAtResourceGroupLevelAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourceGroups/"; + url = url + Uri.EscapeDataString(resourceGroup); + url = url + "/providers/Microsoft.Authorization/locks/"; + url = url + Uri.EscapeDataString(lockName); + List queryParameters = new List(); + queryParameters.Add("api-version=2015-01-01"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Delete; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.Accepted && statusCode != HttpStatusCode.NoContent) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + AzureOperationResponse result = null; + // Deserialize Response + result = new AzureOperationResponse(); + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Deletes the management lock of a resource or any level below + /// resource. + /// + /// + /// Required. The name of the resource group. + /// + /// + /// Required. Resource identity. + /// + /// + /// Required. The name of lock. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public async Task DeleteAtResourceLevelAsync(string resourceGroupName, ResourceIdentity identity, string lockName, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (identity == null) + { + throw new ArgumentNullException("identity"); + } + if (identity.ResourceName == null) + { + throw new ArgumentNullException("identity.ResourceName"); + } + if (identity.ResourceProviderApiVersion == null) + { + throw new ArgumentNullException("identity.ResourceProviderApiVersion"); + } + if (identity.ResourceProviderNamespace == null) + { + throw new ArgumentNullException("identity.ResourceProviderNamespace"); + } + if (identity.ResourceType == null) + { + throw new ArgumentNullException("identity.ResourceType"); + } + if (lockName == null) + { + throw new ArgumentNullException("lockName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("identity", identity); + tracingParameters.Add("lockName", lockName); + TracingAdapter.Enter(invocationId, this, "DeleteAtResourceLevelAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + url = url + "/providers/"; + url = url + Uri.EscapeDataString(identity.ResourceProviderNamespace); + url = url + "/"; + if (identity.ParentResourcePath != null) + { + url = url + identity.ParentResourcePath; + } + url = url + "/"; + url = url + identity.ResourceType; + url = url + "/"; + url = url + Uri.EscapeDataString(identity.ResourceName); + url = url + "/providers/Microsoft.Authorization/locks/"; + url = url + Uri.EscapeDataString(lockName); + List queryParameters = new List(); + queryParameters.Add("api-version=2015-01-01"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Delete; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.Accepted && statusCode != HttpStatusCode.NoContent) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + AzureOperationResponse result = null; + // Deserialize Response + result = new AzureOperationResponse(); + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Deletes the management lock of a subscription. + /// + /// + /// Required. The name of lock. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public async Task DeleteAtSubscriptionLevelAsync(string lockName, CancellationToken cancellationToken) + { + // Validate + if (lockName == null) + { + throw new ArgumentNullException("lockName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("lockName", lockName); + TracingAdapter.Enter(invocationId, this, "DeleteAtSubscriptionLevelAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/providers/Microsoft.Authorization/locks/"; + url = url + Uri.EscapeDataString(lockName); + List queryParameters = new List(); + queryParameters.Add("api-version=2015-01-01"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Delete; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.Accepted && statusCode != HttpStatusCode.NoContent) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + AzureOperationResponse result = null; + // Deserialize Response + result = new AzureOperationResponse(); + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Gets the management lock of a scope. + /// + /// + /// Required. Name of the management lock. + /// + /// + /// Cancellation token. + /// + /// + /// Management lock information. + /// + public async Task GetAsync(string lockName, CancellationToken cancellationToken) + { + // Validate + if (lockName == null) + { + throw new ArgumentNullException("lockName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("lockName", lockName); + TracingAdapter.Enter(invocationId, this, "GetAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/providers/Microsoft.Authorization/locks/"; + url = url + Uri.EscapeDataString(lockName); + List queryParameters = new List(); + queryParameters.Add("api-version=2015-01-01"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.NoContent) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ManagementLockReturnResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.NoContent) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ManagementLockReturnResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + ManagementLockObject managementLockInstance = new ManagementLockObject(); + result.ManagementLock = managementLockInstance; + + JToken propertiesValue = responseDoc["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + ManagementLockProperties propertiesInstance = new ManagementLockProperties(); + managementLockInstance.Properties = propertiesInstance; + + JToken levelValue = propertiesValue["level"]; + if (levelValue != null && levelValue.Type != JTokenType.Null) + { + string levelInstance = ((string)levelValue); + propertiesInstance.Level = levelInstance; + } + + JToken notesValue = propertiesValue["notes"]; + if (notesValue != null && notesValue.Type != JTokenType.Null) + { + string notesInstance = ((string)notesValue); + propertiesInstance.Notes = notesInstance; + } + } + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + managementLockInstance.Id = idInstance; + } + + JToken typeValue = responseDoc["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + managementLockInstance.Type = typeInstance; + } + + JToken nameValue = responseDoc["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + managementLockInstance.Name = nameInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Gets all the management locks of a resource group. + /// + /// + /// Required. Resource group name. + /// + /// + /// Optional. Query parameters. If empty is passed returns all locks + /// at, above or below the resource group. + /// + /// + /// Cancellation token. + /// + /// + /// List of management locks. + /// + public async Task ListAtResourceGroupLevelAsync(string resourceGroupName, ManagementLockGetQueryParameter parameters, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "ListAtResourceGroupLevelAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourceGroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + url = url + "/providers/Microsoft.Authorization/locks"; + List queryParameters = new List(); + queryParameters.Add("api-version=2015-01-01"); + List odataFilter = new List(); + if (parameters != null && parameters.AtScope != null) + { + odataFilter.Add(Uri.EscapeDataString(parameters.AtScope)); + } + if (odataFilter.Count > 0) + { + queryParameters.Add("$filter=" + string.Join(null, odataFilter)); + } + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ManagementLockListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ManagementLockListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + ManagementLockObject managementLockObjectInstance = new ManagementLockObject(); + result.Lock.Add(managementLockObjectInstance); + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + ManagementLockProperties propertiesInstance = new ManagementLockProperties(); + managementLockObjectInstance.Properties = propertiesInstance; + + JToken levelValue = propertiesValue["level"]; + if (levelValue != null && levelValue.Type != JTokenType.Null) + { + string levelInstance = ((string)levelValue); + propertiesInstance.Level = levelInstance; + } + + JToken notesValue = propertiesValue["notes"]; + if (notesValue != null && notesValue.Type != JTokenType.Null) + { + string notesInstance = ((string)notesValue); + propertiesInstance.Notes = notesInstance; + } + } + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + managementLockObjectInstance.Id = idInstance; + } + + JToken typeValue = valueValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + managementLockObjectInstance.Type = typeInstance; + } + + JToken nameValue = valueValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + managementLockObjectInstance.Name = nameInstance; + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Gets all the management locks of a resource or any level below + /// resource. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. Resource identity. + /// + /// + /// Optional. Query parameters. If empty is passed returns all locks at + /// or below the resource.If atScope() is passed returns all locks at + /// the resource level. + /// + /// + /// Cancellation token. + /// + /// + /// List of management locks. + /// + public async Task ListAtResourceLevelAsync(string resourceGroupName, ResourceIdentity identity, ManagementLockGetQueryParameter parameters, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (identity == null) + { + throw new ArgumentNullException("identity"); + } + if (identity.ResourceName == null) + { + throw new ArgumentNullException("identity.ResourceName"); + } + if (identity.ResourceProviderApiVersion == null) + { + throw new ArgumentNullException("identity.ResourceProviderApiVersion"); + } + if (identity.ResourceProviderNamespace == null) + { + throw new ArgumentNullException("identity.ResourceProviderNamespace"); + } + if (identity.ResourceType == null) + { + throw new ArgumentNullException("identity.ResourceType"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("identity", identity); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "ListAtResourceLevelAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + url = url + "/providers/"; + url = url + Uri.EscapeDataString(identity.ResourceProviderNamespace); + url = url + "/"; + if (identity.ParentResourcePath != null) + { + url = url + identity.ParentResourcePath; + } + url = url + "/"; + url = url + identity.ResourceType; + url = url + "/"; + url = url + Uri.EscapeDataString(identity.ResourceName); + url = url + "/providers/Microsoft.Authorization/locks"; + List queryParameters = new List(); + queryParameters.Add("api-version=2015-01-01"); + List odataFilter = new List(); + if (parameters != null && parameters.AtScope != null) + { + odataFilter.Add(Uri.EscapeDataString(parameters.AtScope)); + } + if (odataFilter.Count > 0) + { + queryParameters.Add("$filter=" + string.Join(null, odataFilter)); + } + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ManagementLockListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ManagementLockListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + ManagementLockObject managementLockObjectInstance = new ManagementLockObject(); + result.Lock.Add(managementLockObjectInstance); + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + ManagementLockProperties propertiesInstance = new ManagementLockProperties(); + managementLockObjectInstance.Properties = propertiesInstance; + + JToken levelValue = propertiesValue["level"]; + if (levelValue != null && levelValue.Type != JTokenType.Null) + { + string levelInstance = ((string)levelValue); + propertiesInstance.Level = levelInstance; + } + + JToken notesValue = propertiesValue["notes"]; + if (notesValue != null && notesValue.Type != JTokenType.Null) + { + string notesInstance = ((string)notesValue); + propertiesInstance.Notes = notesInstance; + } + } + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + managementLockObjectInstance.Id = idInstance; + } + + JToken typeValue = valueValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + managementLockObjectInstance.Type = typeInstance; + } + + JToken nameValue = valueValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + managementLockObjectInstance.Name = nameInstance; + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Gets all the management locks of a subscription. + /// + /// + /// Optional. Query parameters. If empty is passed returns all locks + /// at, above or below the subscription. + /// + /// + /// Cancellation token. + /// + /// + /// List of management locks. + /// + public async Task ListAtSubscriptionLevelAsync(ManagementLockGetQueryParameter parameters, CancellationToken cancellationToken) + { + // Validate + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "ListAtSubscriptionLevelAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/providers/Microsoft.Authorization/locks"; + List queryParameters = new List(); + queryParameters.Add("api-version=2015-01-01"); + List odataFilter = new List(); + if (parameters != null && parameters.AtScope != null) + { + odataFilter.Add(Uri.EscapeDataString(parameters.AtScope)); + } + if (odataFilter.Count > 0) + { + queryParameters.Add("$filter=" + string.Join(null, odataFilter)); + } + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ManagementLockListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ManagementLockListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + ManagementLockObject managementLockObjectInstance = new ManagementLockObject(); + result.Lock.Add(managementLockObjectInstance); + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + ManagementLockProperties propertiesInstance = new ManagementLockProperties(); + managementLockObjectInstance.Properties = propertiesInstance; + + JToken levelValue = propertiesValue["level"]; + if (levelValue != null && levelValue.Type != JTokenType.Null) + { + string levelInstance = ((string)levelValue); + propertiesInstance.Level = levelInstance; + } + + JToken notesValue = propertiesValue["notes"]; + if (notesValue != null && notesValue.Type != JTokenType.Null) + { + string notesInstance = ((string)notesValue); + propertiesInstance.Notes = notesInstance; + } + } + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + managementLockObjectInstance.Id = idInstance; + } + + JToken typeValue = valueValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + managementLockObjectInstance.Type = typeInstance; + } + + JToken nameValue = valueValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + managementLockObjectInstance.Name = nameInstance; + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Get a list of management locks at resource level or below. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of management locks. + /// + public async Task ListNextAsync(string nextLink, CancellationToken cancellationToken) + { + // Validate + if (nextLink == null) + { + throw new ArgumentNullException("nextLink"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextLink", nextLink); + TracingAdapter.Enter(invocationId, this, "ListNextAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + nextLink; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ManagementLockListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ManagementLockListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + ManagementLockObject managementLockObjectInstance = new ManagementLockObject(); + result.Lock.Add(managementLockObjectInstance); + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + ManagementLockProperties propertiesInstance = new ManagementLockProperties(); + managementLockObjectInstance.Properties = propertiesInstance; + + JToken levelValue = propertiesValue["level"]; + if (levelValue != null && levelValue.Type != JTokenType.Null) + { + string levelInstance = ((string)levelValue); + propertiesInstance.Level = levelInstance; + } + + JToken notesValue = propertiesValue["notes"]; + if (notesValue != null && notesValue.Type != JTokenType.Null) + { + string notesInstance = ((string)notesValue); + propertiesInstance.Notes = notesInstance; + } + } + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + managementLockObjectInstance.Id = idInstance; + } + + JToken typeValue = valueValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + managementLockObjectInstance.Type = typeInstance; + } + + JToken nameValue = valueValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + managementLockObjectInstance.Name = nameInstance; + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ManagementLockOperationsExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ManagementLockOperationsExtensions.cs new file mode 100644 index 000000000000..823618a7ef6a --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ManagementLockOperationsExtensions.cs @@ -0,0 +1,566 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public static partial class ManagementLockOperationsExtensions + { + /// + /// Create or update a management lock at the resource group level. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. The resource group name. + /// + /// + /// Required. The lock name. + /// + /// + /// Required. The management lock parameters. + /// + /// + /// Management lock information. + /// + public static ManagementLockReturnResult CreateOrUpdateAtResourceGroupLevel(this IManagementLockOperations operations, string resourceGroupName, string lockName, ManagementLockProperties parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IManagementLockOperations)s).CreateOrUpdateAtResourceGroupLevelAsync(resourceGroupName, lockName, parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Create or update a management lock at the resource group level. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. The resource group name. + /// + /// + /// Required. The lock name. + /// + /// + /// Required. The management lock parameters. + /// + /// + /// Management lock information. + /// + public static Task CreateOrUpdateAtResourceGroupLevelAsync(this IManagementLockOperations operations, string resourceGroupName, string lockName, ManagementLockProperties parameters) + { + return operations.CreateOrUpdateAtResourceGroupLevelAsync(resourceGroupName, lockName, parameters, CancellationToken.None); + } + + /// + /// Create or update a management lock at the resource level or any + /// level below resource. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. The name of the resource group. + /// + /// + /// Required. Resource identity. + /// + /// + /// Required. The name of lock. + /// + /// + /// Required. Create or update management lock parameters. + /// + /// + /// Management lock information. + /// + public static ManagementLockReturnResult CreateOrUpdateAtResourceLevel(this IManagementLockOperations operations, string resourceGroupName, ResourceIdentity identity, string lockName, ManagementLockProperties parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IManagementLockOperations)s).CreateOrUpdateAtResourceLevelAsync(resourceGroupName, identity, lockName, parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Create or update a management lock at the resource level or any + /// level below resource. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. The name of the resource group. + /// + /// + /// Required. Resource identity. + /// + /// + /// Required. The name of lock. + /// + /// + /// Required. Create or update management lock parameters. + /// + /// + /// Management lock information. + /// + public static Task CreateOrUpdateAtResourceLevelAsync(this IManagementLockOperations operations, string resourceGroupName, ResourceIdentity identity, string lockName, ManagementLockProperties parameters) + { + return operations.CreateOrUpdateAtResourceLevelAsync(resourceGroupName, identity, lockName, parameters, CancellationToken.None); + } + + /// + /// Create or update a management lock at the subscription level. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. The name of lock. + /// + /// + /// Required. The management lock parameters. + /// + /// + /// Management lock information. + /// + public static ManagementLockReturnResult CreateOrUpdateAtSubscriptionLevel(this IManagementLockOperations operations, string lockName, ManagementLockProperties parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IManagementLockOperations)s).CreateOrUpdateAtSubscriptionLevelAsync(lockName, parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Create or update a management lock at the subscription level. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. The name of lock. + /// + /// + /// Required. The management lock parameters. + /// + /// + /// Management lock information. + /// + public static Task CreateOrUpdateAtSubscriptionLevelAsync(this IManagementLockOperations operations, string lockName, ManagementLockProperties parameters) + { + return operations.CreateOrUpdateAtSubscriptionLevelAsync(lockName, parameters, CancellationToken.None); + } + + /// + /// Deletes the management lock of a resource group. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. The resource group names. + /// + /// + /// Required. The name of lock. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static AzureOperationResponse DeleteAtResourceGroupLevel(this IManagementLockOperations operations, string resourceGroup, string lockName) + { + return Task.Factory.StartNew((object s) => + { + return ((IManagementLockOperations)s).DeleteAtResourceGroupLevelAsync(resourceGroup, lockName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Deletes the management lock of a resource group. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. The resource group names. + /// + /// + /// Required. The name of lock. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static Task DeleteAtResourceGroupLevelAsync(this IManagementLockOperations operations, string resourceGroup, string lockName) + { + return operations.DeleteAtResourceGroupLevelAsync(resourceGroup, lockName, CancellationToken.None); + } + + /// + /// Deletes the management lock of a resource or any level below + /// resource. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. The name of the resource group. + /// + /// + /// Required. Resource identity. + /// + /// + /// Required. The name of lock. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static AzureOperationResponse DeleteAtResourceLevel(this IManagementLockOperations operations, string resourceGroupName, ResourceIdentity identity, string lockName) + { + return Task.Factory.StartNew((object s) => + { + return ((IManagementLockOperations)s).DeleteAtResourceLevelAsync(resourceGroupName, identity, lockName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Deletes the management lock of a resource or any level below + /// resource. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. The name of the resource group. + /// + /// + /// Required. Resource identity. + /// + /// + /// Required. The name of lock. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static Task DeleteAtResourceLevelAsync(this IManagementLockOperations operations, string resourceGroupName, ResourceIdentity identity, string lockName) + { + return operations.DeleteAtResourceLevelAsync(resourceGroupName, identity, lockName, CancellationToken.None); + } + + /// + /// Deletes the management lock of a subscription. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. The name of lock. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static AzureOperationResponse DeleteAtSubscriptionLevel(this IManagementLockOperations operations, string lockName) + { + return Task.Factory.StartNew((object s) => + { + return ((IManagementLockOperations)s).DeleteAtSubscriptionLevelAsync(lockName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Deletes the management lock of a subscription. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. The name of lock. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static Task DeleteAtSubscriptionLevelAsync(this IManagementLockOperations operations, string lockName) + { + return operations.DeleteAtSubscriptionLevelAsync(lockName, CancellationToken.None); + } + + /// + /// Gets the management lock of a scope. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. Name of the management lock. + /// + /// + /// Management lock information. + /// + public static ManagementLockReturnResult Get(this IManagementLockOperations operations, string lockName) + { + return Task.Factory.StartNew((object s) => + { + return ((IManagementLockOperations)s).GetAsync(lockName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets the management lock of a scope. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. Name of the management lock. + /// + /// + /// Management lock information. + /// + public static Task GetAsync(this IManagementLockOperations operations, string lockName) + { + return operations.GetAsync(lockName, CancellationToken.None); + } + + /// + /// Gets all the management locks of a resource group. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. Resource group name. + /// + /// + /// Optional. Query parameters. If empty is passed returns all locks + /// at, above or below the resource group. + /// + /// + /// List of management locks. + /// + public static ManagementLockListResult ListAtResourceGroupLevel(this IManagementLockOperations operations, string resourceGroupName, ManagementLockGetQueryParameter parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IManagementLockOperations)s).ListAtResourceGroupLevelAsync(resourceGroupName, parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets all the management locks of a resource group. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. Resource group name. + /// + /// + /// Optional. Query parameters. If empty is passed returns all locks + /// at, above or below the resource group. + /// + /// + /// List of management locks. + /// + public static Task ListAtResourceGroupLevelAsync(this IManagementLockOperations operations, string resourceGroupName, ManagementLockGetQueryParameter parameters) + { + return operations.ListAtResourceGroupLevelAsync(resourceGroupName, parameters, CancellationToken.None); + } + + /// + /// Gets all the management locks of a resource or any level below + /// resource. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. Resource identity. + /// + /// + /// Optional. Query parameters. If empty is passed returns all locks at + /// or below the resource.If atScope() is passed returns all locks at + /// the resource level. + /// + /// + /// List of management locks. + /// + public static ManagementLockListResult ListAtResourceLevel(this IManagementLockOperations operations, string resourceGroupName, ResourceIdentity identity, ManagementLockGetQueryParameter parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IManagementLockOperations)s).ListAtResourceLevelAsync(resourceGroupName, identity, parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets all the management locks of a resource or any level below + /// resource. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. Resource identity. + /// + /// + /// Optional. Query parameters. If empty is passed returns all locks at + /// or below the resource.If atScope() is passed returns all locks at + /// the resource level. + /// + /// + /// List of management locks. + /// + public static Task ListAtResourceLevelAsync(this IManagementLockOperations operations, string resourceGroupName, ResourceIdentity identity, ManagementLockGetQueryParameter parameters) + { + return operations.ListAtResourceLevelAsync(resourceGroupName, identity, parameters, CancellationToken.None); + } + + /// + /// Gets all the management locks of a subscription. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Optional. Query parameters. If empty is passed returns all locks + /// at, above or below the subscription. + /// + /// + /// List of management locks. + /// + public static ManagementLockListResult ListAtSubscriptionLevel(this IManagementLockOperations operations, ManagementLockGetQueryParameter parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IManagementLockOperations)s).ListAtSubscriptionLevelAsync(parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets all the management locks of a subscription. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Optional. Query parameters. If empty is passed returns all locks + /// at, above or below the subscription. + /// + /// + /// List of management locks. + /// + public static Task ListAtSubscriptionLevelAsync(this IManagementLockOperations operations, ManagementLockGetQueryParameter parameters) + { + return operations.ListAtSubscriptionLevelAsync(parameters, CancellationToken.None); + } + + /// + /// Get a list of management locks at resource level or below. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of management locks. + /// + public static ManagementLockListResult ListNext(this IManagementLockOperations operations, string nextLink) + { + return Task.Factory.StartNew((object s) => + { + return ((IManagementLockOperations)s).ListNextAsync(nextLink); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get a list of management locks at resource level or below. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IManagementLockOperations. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of management locks. + /// + public static Task ListNextAsync(this IManagementLockOperations operations, string nextLink) + { + return operations.ListNextAsync(nextLink, CancellationToken.None); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/BasicDependency.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/BasicDependency.cs new file mode 100644 index 000000000000..9cff5f4e86f6 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/BasicDependency.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Deployment dependency information. + /// + public partial class BasicDependency + { + private string _id; + + /// + /// Optional. Gets or sets the ID of the dependency. + /// + public string Id + { + get { return this._id; } + set { this._id = value; } + } + + private string _resourceName; + + /// + /// Optional. Gets or sets the dependency resource name. + /// + public string ResourceName + { + get { return this._resourceName; } + set { this._resourceName = value; } + } + + private string _resourceType; + + /// + /// Optional. Gets or sets the dependency resource type. + /// + public string ResourceType + { + get { return this._resourceType; } + set { this._resourceType = value; } + } + + /// + /// Initializes a new instance of the BasicDependency class. + /// + public BasicDependency() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Dependency.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Dependency.cs new file mode 100644 index 000000000000..bed498b657c9 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Dependency.cs @@ -0,0 +1,51 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Deployment dependency information. + /// + public partial class Dependency : BasicDependency + { + private IList _dependsOn; + + /// + /// Optional. Gets the list of dependencies. + /// + public IList DependsOn + { + get { return this._dependsOn; } + set { this._dependsOn = value; } + } + + /// + /// Initializes a new instance of the Dependency class. + /// + public Dependency() + { + this.DependsOn = new LazyList(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Deployment.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Deployment.cs new file mode 100644 index 000000000000..a2e4f7add496 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Deployment.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Deployment operation parameters. + /// + public partial class Deployment + { + private DeploymentProperties _properties; + + /// + /// Optional. Gets or sets the deployment properties. + /// + public DeploymentProperties Properties + { + get { return this._properties; } + set { this._properties = value; } + } + + /// + /// Initializes a new instance of the Deployment class. + /// + public Deployment() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentExistsResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentExistsResult.cs new file mode 100644 index 000000000000..5606c62c5efb --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentExistsResult.cs @@ -0,0 +1,49 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Deployment information. + /// + public partial class DeploymentExistsResult : AzureOperationResponse + { + private bool _exists; + + /// + /// Optional. Gets or sets the value indicating whether the deployment + /// exists. + /// + public bool Exists + { + get { return this._exists; } + set { this._exists = value; } + } + + /// + /// Initializes a new instance of the DeploymentExistsResult class. + /// + public DeploymentExistsResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentExtended.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentExtended.cs new file mode 100644 index 000000000000..1fd6d6eff509 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentExtended.cs @@ -0,0 +1,85 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Deployment information. + /// + public partial class DeploymentExtended + { + private string _id; + + /// + /// Optional. Gets or sets the ID of the deployment. + /// + public string Id + { + get { return this._id; } + set { this._id = value; } + } + + private string _name; + + /// + /// Required. Gets or sets the name of the deployment. + /// + public string Name + { + get { return this._name; } + set { this._name = value; } + } + + private DeploymentPropertiesExtended _properties; + + /// + /// Optional. Gets or sets deployment properties. + /// + public DeploymentPropertiesExtended Properties + { + get { return this._properties; } + set { this._properties = value; } + } + + /// + /// Initializes a new instance of the DeploymentExtended class. + /// + public DeploymentExtended() + { + } + + /// + /// Initializes a new instance of the DeploymentExtended class with + /// required arguments. + /// + public DeploymentExtended(string name) + : this() + { + if (name == null) + { + throw new ArgumentNullException("name"); + } + this.Name = name; + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentGetResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentGetResult.cs new file mode 100644 index 000000000000..84c68e17ea05 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentGetResult.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Template deployment information. + /// + public partial class DeploymentGetResult : AzureOperationResponse + { + private DeploymentExtended _deployment; + + /// + /// Optional. Gets or sets the deployment. + /// + public DeploymentExtended Deployment + { + get { return this._deployment; } + set { this._deployment = value; } + } + + /// + /// Initializes a new instance of the DeploymentGetResult class. + /// + public DeploymentGetResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentListParameters.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentListParameters.cs new file mode 100644 index 000000000000..589f2f9d0891 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentListParameters.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Deployment list operation parameters. + /// + public partial class DeploymentListParameters + { + private string _provisioningState; + + /// + /// Optional. Get or sets the provisioning state to filer by. Optional. + /// + public string ProvisioningState + { + get { return this._provisioningState; } + set { this._provisioningState = value; } + } + + private int? _top; + + /// + /// Optional. Get or sets the number of records to return. Optional. + /// + public int? Top + { + get { return this._top; } + set { this._top = value; } + } + + /// + /// Initializes a new instance of the DeploymentListParameters class. + /// + public DeploymentListParameters() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentListResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentListResult.cs new file mode 100644 index 000000000000..f67c72aead71 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentListResult.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// List of deployments. + /// + public partial class DeploymentListResult : AzureOperationResponse + { + private IList _deployments; + + /// + /// Optional. Gets or sets the list of deployments. + /// + public IList Deployments + { + get { return this._deployments; } + set { this._deployments = value; } + } + + private string _nextLink; + + /// + /// Optional. Gets or sets the URL to get the next set of results. + /// + public string NextLink + { + get { return this._nextLink; } + set { this._nextLink = value; } + } + + /// + /// Initializes a new instance of the DeploymentListResult class. + /// + public DeploymentListResult() + { + this.Deployments = new LazyList(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentMode.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentMode.cs new file mode 100644 index 000000000000..b3c020db596a --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentMode.cs @@ -0,0 +1,34 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Specifies the deployment type for the deployment operations. + /// + public enum DeploymentMode + { + Incremental = 0, + + Complete = 1, + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperation.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperation.cs new file mode 100644 index 000000000000..94a3e3232530 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperation.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Deployment operation information. + /// + public partial class DeploymentOperation + { + private string _id; + + /// + /// Optional. Gets or sets full deployment operation id. + /// + public string Id + { + get { return this._id; } + set { this._id = value; } + } + + private string _operationId; + + /// + /// Optional. Gets or sets deployment operation id. + /// + public string OperationId + { + get { return this._operationId; } + set { this._operationId = value; } + } + + private DeploymentOperationProperties _properties; + + /// + /// Optional. Gets or sets deployment properties. + /// + public DeploymentOperationProperties Properties + { + get { return this._properties; } + set { this._properties = value; } + } + + /// + /// Initializes a new instance of the DeploymentOperation class. + /// + public DeploymentOperation() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationProperties.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationProperties.cs new file mode 100644 index 000000000000..1aaed9214e59 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationProperties.cs @@ -0,0 +1,94 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Deployment operation properties. + /// + public partial class DeploymentOperationProperties + { + private string _provisioningState; + + /// + /// Optional. Gets or sets the state of the provisioning. + /// + public string ProvisioningState + { + get { return this._provisioningState; } + set { this._provisioningState = value; } + } + + private string _statusCode; + + /// + /// Optional. Gets or sets operation status code. + /// + public string StatusCode + { + get { return this._statusCode; } + set { this._statusCode = value; } + } + + private string _statusMessage; + + /// + /// Optional. Gets or sets operation status message. + /// + public string StatusMessage + { + get { return this._statusMessage; } + set { this._statusMessage = value; } + } + + private TargetResource _targetResource; + + /// + /// Optional. Gets or sets the target resource. + /// + public TargetResource TargetResource + { + get { return this._targetResource; } + set { this._targetResource = value; } + } + + private DateTime _timestamp; + + /// + /// Optional. Gets or sets the date and time of the operation. + /// + public DateTime Timestamp + { + get { return this._timestamp; } + set { this._timestamp = value; } + } + + /// + /// Initializes a new instance of the DeploymentOperationProperties + /// class. + /// + public DeploymentOperationProperties() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationsCreateResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationsCreateResult.cs new file mode 100644 index 000000000000..1ecbeaec6faa --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationsCreateResult.cs @@ -0,0 +1,49 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Template deployment operation create result. + /// + public partial class DeploymentOperationsCreateResult : AzureOperationResponse + { + private DeploymentExtended _deployment; + + /// + /// Optional. Gets or sets the deployment. + /// + public DeploymentExtended Deployment + { + get { return this._deployment; } + set { this._deployment = value; } + } + + /// + /// Initializes a new instance of the DeploymentOperationsCreateResult + /// class. + /// + public DeploymentOperationsCreateResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationsGetResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationsGetResult.cs new file mode 100644 index 000000000000..bbf4f492366a --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationsGetResult.cs @@ -0,0 +1,49 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Deployment operation. + /// + public partial class DeploymentOperationsGetResult : AzureOperationResponse + { + private DeploymentOperation _operation; + + /// + /// Optional. Gets or sets the deployment operation. + /// + public DeploymentOperation Operation + { + get { return this._operation; } + set { this._operation = value; } + } + + /// + /// Initializes a new instance of the DeploymentOperationsGetResult + /// class. + /// + public DeploymentOperationsGetResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationsListParameters.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationsListParameters.cs new file mode 100644 index 000000000000..36249b710578 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationsListParameters.cs @@ -0,0 +1,49 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Deployment operation list parameters. + /// + public partial class DeploymentOperationsListParameters + { + private int? _top; + + /// + /// Optional. Get or sets the number of records to return. Optional. + /// + public int? Top + { + get { return this._top; } + set { this._top = value; } + } + + /// + /// Initializes a new instance of the + /// DeploymentOperationsListParameters class. + /// + public DeploymentOperationsListParameters() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationsListResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationsListResult.cs new file mode 100644 index 000000000000..5b8330651ff2 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentOperationsListResult.cs @@ -0,0 +1,63 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// List of deployment operations. + /// + public partial class DeploymentOperationsListResult : AzureOperationResponse + { + private string _nextLink; + + /// + /// Optional. Gets or sets the URL to get the next set of results. + /// + public string NextLink + { + get { return this._nextLink; } + set { this._nextLink = value; } + } + + private IList _operations; + + /// + /// Optional. Gets or sets the list of deployments. + /// + public IList Operations + { + get { return this._operations; } + set { this._operations = value; } + } + + /// + /// Initializes a new instance of the DeploymentOperationsListResult + /// class. + /// + public DeploymentOperationsListResult() + { + this.Operations = new LazyList(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentProperties.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentProperties.cs new file mode 100644 index 000000000000..1b8620642f84 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentProperties.cs @@ -0,0 +1,96 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Deployment properties. + /// + public partial class DeploymentProperties + { + private DeploymentMode _mode; + + /// + /// Optional. Gets or sets the deployment mode. + /// + public DeploymentMode Mode + { + get { return this._mode; } + set { this._mode = value; } + } + + private string _parameters; + + /// + /// Optional. Deployment parameters. Use only one of Parameters or + /// ParametersLink. + /// + public string Parameters + { + get { return this._parameters; } + set { this._parameters = value; } + } + + private ParametersLink _parametersLink; + + /// + /// Optional. Gets or sets the URI referencing the parameters. Use only + /// one of Parameters or ParametersLink. + /// + public ParametersLink ParametersLink + { + get { return this._parametersLink; } + set { this._parametersLink = value; } + } + + private string _template; + + /// + /// Optional. Gets or sets the template content. Use only one of + /// Template or TemplateLink. + /// + public string Template + { + get { return this._template; } + set { this._template = value; } + } + + private TemplateLink _templateLink; + + /// + /// Optional. Gets or sets the URI referencing the template. Use only + /// one of Template or TemplateLink. + /// + public TemplateLink TemplateLink + { + get { return this._templateLink; } + set { this._templateLink = value; } + } + + /// + /// Initializes a new instance of the DeploymentProperties class. + /// + public DeploymentProperties() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentPropertiesExtended.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentPropertiesExtended.cs new file mode 100644 index 000000000000..a33d3c21a3f7 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentPropertiesExtended.cs @@ -0,0 +1,111 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Deployment properties with additional details. + /// + public partial class DeploymentPropertiesExtended : DeploymentProperties + { + private string _correlationId; + + /// + /// Optional. Gets or sets the correlation ID of the deployment. + /// + public string CorrelationId + { + get { return this._correlationId; } + set { this._correlationId = value; } + } + + private IList _dependencies; + + /// + /// Optional. Gets the list of deployment dependencies. + /// + public IList Dependencies + { + get { return this._dependencies; } + set { this._dependencies = value; } + } + + private string _outputs; + + /// + /// Optional. Gets or sets key/value pairs that represent + /// deploymentoutput. + /// + public string Outputs + { + get { return this._outputs; } + set { this._outputs = value; } + } + + private IList _providers; + + /// + /// Optional. Gets the list of resource providers needed for the + /// deployment. + /// + public IList Providers + { + get { return this._providers; } + set { this._providers = value; } + } + + private string _provisioningState; + + /// + /// Optional. Gets or sets the state of the provisioning. + /// + public string ProvisioningState + { + get { return this._provisioningState; } + set { this._provisioningState = value; } + } + + private DateTime _timestamp; + + /// + /// Optional. Gets or sets the timestamp of the template deployment. + /// + public DateTime Timestamp + { + get { return this._timestamp; } + set { this._timestamp = value; } + } + + /// + /// Initializes a new instance of the DeploymentPropertiesExtended + /// class. + /// + public DeploymentPropertiesExtended() + { + this.Dependencies = new LazyList(); + this.Providers = new LazyList(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentValidateResponse.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentValidateResponse.cs new file mode 100644 index 000000000000..0fa615b9ff61 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/DeploymentValidateResponse.cs @@ -0,0 +1,71 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Information from validate template deployment response. + /// + public partial class DeploymentValidateResponse : AzureOperationResponse + { + private ResourceManagementErrorWithDetails _error; + + /// + /// Optional. Gets or sets validation error. + /// + public ResourceManagementErrorWithDetails Error + { + get { return this._error; } + set { this._error = value; } + } + + private bool _isValid; + + /// + /// Optional. Gets or sets the value indicating whether the template is + /// valid or not. + /// + public bool IsValid + { + get { return this._isValid; } + set { this._isValid = value; } + } + + private DeploymentPropertiesExtended _properties; + + /// + /// Optional. Gets or sets the template deployment properties. + /// + public DeploymentPropertiesExtended Properties + { + get { return this._properties; } + set { this._properties = value; } + } + + /// + /// Initializes a new instance of the DeploymentValidateResponse class. + /// + public DeploymentValidateResponse() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/FeatureOperationsListResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/FeatureOperationsListResult.cs new file mode 100644 index 000000000000..108f5fe3e0d5 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/FeatureOperationsListResult.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// List of previewed features. + /// + public partial class FeatureOperationsListResult : AzureOperationResponse + { + private IList _features; + + /// + /// Optional. Gets or sets the list of Features. + /// + public IList Features + { + get { return this._features; } + set { this._features = value; } + } + + private string _nextLink; + + /// + /// Optional. Gets or sets the URL to get the next set of results. + /// + public string NextLink + { + get { return this._nextLink; } + set { this._nextLink = value; } + } + + /// + /// Initializes a new instance of the FeatureOperationsListResult class. + /// + public FeatureOperationsListResult() + { + this.Features = new LazyList(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/FeatureProperties.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/FeatureProperties.cs new file mode 100644 index 000000000000..3c0b1c71bf7e --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/FeatureProperties.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Previewed feature information. + /// + public partial class FeatureProperties + { + private string _state; + + /// + /// Optional. Gets or sets the state of the previewed feature. + /// + public string State + { + get { return this._state; } + set { this._state = value; } + } + + /// + /// Initializes a new instance of the FeatureProperties class. + /// + public FeatureProperties() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/FeatureResponse.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/FeatureResponse.cs new file mode 100644 index 000000000000..f66cce9d1ba4 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/FeatureResponse.cs @@ -0,0 +1,81 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Previewed feature information. + /// + public partial class FeatureResponse : AzureOperationResponse + { + private string _id; + + /// + /// Optional. Gets or sets the Id of the feature. + /// + public string Id + { + get { return this._id; } + set { this._id = value; } + } + + private string _name; + + /// + /// Optional. Gets or sets the name of the feature. + /// + public string Name + { + get { return this._name; } + set { this._name = value; } + } + + private FeatureProperties _properties; + + /// + /// Optional. Gets or sets the properties of the previewed feature. + /// + public FeatureProperties Properties + { + get { return this._properties; } + set { this._properties = value; } + } + + private string _type; + + /// + /// Optional. Gets or sets the type of the feature. + /// + public string Type + { + get { return this._type; } + set { this._type = value; } + } + + /// + /// Initializes a new instance of the FeatureResponse class. + /// + public FeatureResponse() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/GenericResource.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/GenericResource.cs new file mode 100644 index 000000000000..5bdfcfcbf46a --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/GenericResource.cs @@ -0,0 +1,85 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource information. + /// + public partial class GenericResource : ResourceBase + { + private Plan _plan; + + /// + /// Optional. Gets or sets the plan of the resource. + /// + public Plan Plan + { + get { return this._plan; } + set { this._plan = value; } + } + + private string _properties; + + /// + /// Optional. Gets or sets the resource properties. + /// + public string Properties + { + get { return this._properties; } + set { this._properties = value; } + } + + private string _provisioningState; + + /// + /// Optional. Gets or sets resource provisioning state. + /// + public string ProvisioningState + { + get { return this._provisioningState; } + set { this._provisioningState = value; } + } + + /// + /// Initializes a new instance of the GenericResource class. + /// + public GenericResource() + { + } + + /// + /// Initializes a new instance of the GenericResource class with + /// required arguments. + /// + public GenericResource(string location) + : this() + { + if (location == null) + { + throw new ArgumentNullException("location"); + } + this.Location = location; + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/GenericResourceExtended.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/GenericResourceExtended.cs new file mode 100644 index 000000000000..44f7c432dc08 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/GenericResourceExtended.cs @@ -0,0 +1,85 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource information. + /// + public partial class GenericResourceExtended : ResourceBaseExtended + { + private Plan _plan; + + /// + /// Optional. Gets or sets the plan of the resource. + /// + public Plan Plan + { + get { return this._plan; } + set { this._plan = value; } + } + + private string _properties; + + /// + /// Optional. Gets or sets the resource properties. + /// + public string Properties + { + get { return this._properties; } + set { this._properties = value; } + } + + private string _provisioningState; + + /// + /// Optional. Gets or sets resource provisioning state. + /// + public string ProvisioningState + { + get { return this._provisioningState; } + set { this._provisioningState = value; } + } + + /// + /// Initializes a new instance of the GenericResourceExtended class. + /// + public GenericResourceExtended() + { + } + + /// + /// Initializes a new instance of the GenericResourceExtended class + /// with required arguments. + /// + public GenericResourceExtended(string location) + : this() + { + if (location == null) + { + throw new ArgumentNullException("location"); + } + this.Location = location; + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/GetSubscriptionResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/GetSubscriptionResult.cs new file mode 100644 index 000000000000..166c15ec627f --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/GetSubscriptionResult.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Internal.Subscriptions.Models +{ + /// + /// Subscription detailed information. + /// + public partial class GetSubscriptionResult : AzureOperationResponse + { + private Subscription _subscription; + + /// + /// Optional. Gets or sets the resource. + /// + public Subscription Subscription + { + get { return this._subscription; } + set { this._subscription = value; } + } + + /// + /// Initializes a new instance of the GetSubscriptionResult class. + /// + public GetSubscriptionResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Location.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Location.cs new file mode 100644 index 000000000000..50462246ed7e --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Location.cs @@ -0,0 +1,104 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Internal.Subscriptions.Models +{ + /// + /// Location information. + /// + public partial class Location + { + private string _displayName; + + /// + /// Optional. Gets or sets the display name of the location + /// + public string DisplayName + { + get { return this._displayName; } + set { this._displayName = value; } + } + + private string _id; + + /// + /// Optional. Gets or sets the ID of the resource + /// (/subscriptions/SubscriptionId). + /// + public string Id + { + get { return this._id; } + set { this._id = value; } + } + + private string _latitude; + + /// + /// Optional. Gets or sets the latitude of the location + /// + public string Latitude + { + get { return this._latitude; } + set { this._latitude = value; } + } + + private string _longitude; + + /// + /// Optional. Gets or sets the longitude of the location + /// + public string Longitude + { + get { return this._longitude; } + set { this._longitude = value; } + } + + private string _name; + + /// + /// Optional. Gets or sets the location name + /// + public string Name + { + get { return this._name; } + set { this._name = value; } + } + + private string _subscriptionId; + + /// + /// Optional. Gets or sets the subscription Id. + /// + public string SubscriptionId + { + get { return this._subscriptionId; } + set { this._subscriptionId = value; } + } + + /// + /// Initializes a new instance of the Location class. + /// + public Location() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/LocationListResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/LocationListResult.cs new file mode 100644 index 000000000000..49f20403e62b --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/LocationListResult.cs @@ -0,0 +1,51 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Internal.Subscriptions.Models +{ + /// + /// Location list operation response. + /// + public partial class LocationListResult : AzureOperationResponse + { + private IList _locations; + + /// + /// Optional. Gets the locations. + /// + public IList Locations + { + get { return this._locations; } + set { this._locations = value; } + } + + /// + /// Initializes a new instance of the LocationListResult class. + /// + public LocationListResult() + { + this.Locations = new LazyList(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/LockLevel.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/LockLevel.cs new file mode 100644 index 000000000000..7e6b7b4bf736 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/LockLevel.cs @@ -0,0 +1,45 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Lock level states. + /// + public static partial class LockLevel + { + /// + /// The lock level is not specified. + /// + public const string NotSpecified = "NotSpecified"; + + /// + /// The lock blocks delete. + /// + public const string CanNotDelete = "CanNotDelete"; + + /// + /// The lock blocks all updates and delete. + /// + public const string ReadOnly = "ReadOnly"; + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/LongRunningOperationResponse.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/LongRunningOperationResponse.cs new file mode 100644 index 000000000000..56d89083974d --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/LongRunningOperationResponse.cs @@ -0,0 +1,82 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// A standard service response for long running operations. + /// + public partial class LongRunningOperationResponse : AzureOperationResponse + { + private ResourceManagementError _error; + + /// + /// Optional. + /// + public ResourceManagementError Error + { + get { return this._error; } + set { this._error = value; } + } + + private string _operationStatusLink; + + /// + /// Optional. + /// + public string OperationStatusLink + { + get { return this._operationStatusLink; } + set { this._operationStatusLink = value; } + } + + private int _retryAfter; + + /// + /// Optional. + /// + public int RetryAfter + { + get { return this._retryAfter; } + set { this._retryAfter = value; } + } + + private OperationStatus _status; + + /// + /// Optional. + /// + public OperationStatus Status + { + get { return this._status; } + set { this._status = value; } + } + + /// + /// Initializes a new instance of the LongRunningOperationResponse + /// class. + /// + public LongRunningOperationResponse() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockGetQueryParameter.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockGetQueryParameter.cs new file mode 100644 index 000000000000..c7ea711c1e87 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockGetQueryParameter.cs @@ -0,0 +1,51 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Management lock get operation scope filter parameters. + /// + public partial class ManagementLockGetQueryParameter + { + private string _atScope; + + /// + /// Optional. Get or sets the atScope parameter. If empty is passed + /// returns all locks at, above or below the scope. Otherwise, returns + /// locks at or above the scope. + /// + public string AtScope + { + get { return this._atScope; } + set { this._atScope = value; } + } + + /// + /// Initializes a new instance of the ManagementLockGetQueryParameter + /// class. + /// + public ManagementLockGetQueryParameter() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockListResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockListResult.cs new file mode 100644 index 000000000000..e91acbeb82e3 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockListResult.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// List of management locks. + /// + public partial class ManagementLockListResult : AzureOperationResponse + { + private IList _lock; + + /// + /// Optional. Gets or sets the list of locks. + /// + public IList Lock + { + get { return this._lock; } + set { this._lock = value; } + } + + private string _nextLink; + + /// + /// Optional. Gets or sets the URL to get the next set of results. + /// + public string NextLink + { + get { return this._nextLink; } + set { this._nextLink = value; } + } + + /// + /// Initializes a new instance of the ManagementLockListResult class. + /// + public ManagementLockListResult() + { + this.Lock = new LazyList(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockObject.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockObject.cs new file mode 100644 index 000000000000..b9b3b14fdb9e --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockObject.cs @@ -0,0 +1,81 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Management lock information. + /// + public partial class ManagementLockObject + { + private string _id; + + /// + /// Optional. Gets or sets the Id of the lock. + /// + public string Id + { + get { return this._id; } + set { this._id = value; } + } + + private string _name; + + /// + /// Optional. Gets or sets the name of the lock. + /// + public string Name + { + get { return this._name; } + set { this._name = value; } + } + + private ManagementLockProperties _properties; + + /// + /// Optional. Gets or sets the properties of the lock. + /// + public ManagementLockProperties Properties + { + get { return this._properties; } + set { this._properties = value; } + } + + private string _type; + + /// + /// Optional. Gets or sets the type of the lock. + /// + public string Type + { + get { return this._type; } + set { this._type = value; } + } + + /// + /// Initializes a new instance of the ManagementLockObject class. + /// + public ManagementLockObject() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockProperties.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockProperties.cs new file mode 100644 index 000000000000..2a70219421cd --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockProperties.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// The management lock properties. + /// + public partial class ManagementLockProperties + { + private string _level; + + /// + /// Optional. Gets or sets the lock level of the management lock. + /// + public string Level + { + get { return this._level; } + set { this._level = value; } + } + + private string _notes; + + /// + /// Optional. Gets or sets the notes of the management lock. + /// + public string Notes + { + get { return this._notes; } + set { this._notes = value; } + } + + /// + /// Initializes a new instance of the ManagementLockProperties class. + /// + public ManagementLockProperties() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockReturnResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockReturnResult.cs new file mode 100644 index 000000000000..dc85e24bacf3 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ManagementLockReturnResult.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Management lock information. + /// + public partial class ManagementLockReturnResult : AzureOperationResponse + { + private ManagementLockObject _managementLock; + + /// + /// Optional. Gets or sets the management lock. + /// + public ManagementLockObject ManagementLock + { + get { return this._managementLock; } + set { this._managementLock = value; } + } + + /// + /// Initializes a new instance of the ManagementLockReturnResult class. + /// + public ManagementLockReturnResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Operation.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Operation.cs new file mode 100644 index 000000000000..e63874d9b5d3 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Operation.cs @@ -0,0 +1,92 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Operation + /// + public partial class Operation + { + private string _description; + + /// + /// Optional. Gets or sets the operation description + /// + public string Description + { + get { return this._description; } + set { this._description = value; } + } + + private string _displayName; + + /// + /// Optional. Gets or sets the operation display name + /// + public string DisplayName + { + get { return this._displayName; } + set { this._displayName = value; } + } + + private string _name; + + /// + /// Optional. Gets or sets the operation name + /// + public string Name + { + get { return this._name; } + set { this._name = value; } + } + + private string _origin; + + /// + /// Optional. Gets or sets the operation origin + /// + public string Origin + { + get { return this._origin; } + set { this._origin = value; } + } + + private object _properties; + + /// + /// Optional. Gets or sets the operation properties + /// + public object Properties + { + get { return this._properties; } + set { this._properties = value; } + } + + /// + /// Initializes a new instance of the Operation class. + /// + public Operation() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ParametersLink.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ParametersLink.cs new file mode 100644 index 000000000000..100f14704df2 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ParametersLink.cs @@ -0,0 +1,75 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Entity representing the reference to the deployment paramaters. + /// + public partial class ParametersLink + { + private string _contentVersion; + + /// + /// Optional. If included it must match the ContentVersion in the + /// template. + /// + public string ContentVersion + { + get { return this._contentVersion; } + set { this._contentVersion = value; } + } + + private Uri _uri; + + /// + /// Required. URI referencing the template. + /// + public Uri Uri + { + get { return this._uri; } + set { this._uri = value; } + } + + /// + /// Initializes a new instance of the ParametersLink class. + /// + public ParametersLink() + { + } + + /// + /// Initializes a new instance of the ParametersLink class with + /// required arguments. + /// + public ParametersLink(Uri uri) + : this() + { + if (uri == null) + { + throw new ArgumentNullException("uri"); + } + this.Uri = uri; + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Plan.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Plan.cs new file mode 100644 index 000000000000..27970b3be691 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Plan.cs @@ -0,0 +1,81 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Plan for the resource. + /// + public partial class Plan + { + private string _name; + + /// + /// Optional. Gets or sets the plan ID. + /// + public string Name + { + get { return this._name; } + set { this._name = value; } + } + + private string _product; + + /// + /// Optional. Gets or sets the offer ID. + /// + public string Product + { + get { return this._product; } + set { this._product = value; } + } + + private string _promotionCode; + + /// + /// Optional. Gets or sets the promotion code. + /// + public string PromotionCode + { + get { return this._promotionCode; } + set { this._promotionCode = value; } + } + + private string _publisher; + + /// + /// Optional. Gets or sets the publisher ID. + /// + public string Publisher + { + get { return this._publisher; } + set { this._publisher = value; } + } + + /// + /// Initializes a new instance of the Plan class. + /// + public Plan() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Provider.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Provider.cs new file mode 100644 index 000000000000..bd1e965067c0 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Provider.cs @@ -0,0 +1,84 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource provider information. + /// + public partial class Provider : AzureOperationResponse + { + private string _id; + + /// + /// Optional. Gets or sets the provider id. + /// + public string Id + { + get { return this._id; } + set { this._id = value; } + } + + private string _namespace; + + /// + /// Optional. Gets or sets the namespace of the provider. + /// + public string Namespace + { + get { return this._namespace; } + set { this._namespace = value; } + } + + private string _registrationState; + + /// + /// Optional. Gets or sets the registration state of the provider. + /// + public string RegistrationState + { + get { return this._registrationState; } + set { this._registrationState = value; } + } + + private IList _resourceTypes; + + /// + /// Optional. Gets or sets the collection of provider resource types. + /// + public IList ResourceTypes + { + get { return this._resourceTypes; } + set { this._resourceTypes = value; } + } + + /// + /// Initializes a new instance of the Provider class. + /// + public Provider() + { + this.ResourceTypes = new LazyList(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderGetResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderGetResult.cs new file mode 100644 index 000000000000..63577fb40a97 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderGetResult.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource provider information. + /// + public partial class ProviderGetResult : AzureOperationResponse + { + private Provider _provider; + + /// + /// Optional. Gets or sets the resource provider. + /// + public Provider Provider + { + get { return this._provider; } + set { this._provider = value; } + } + + /// + /// Initializes a new instance of the ProviderGetResult class. + /// + public ProviderGetResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderListParameters.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderListParameters.cs new file mode 100644 index 000000000000..4bb96537fb5b --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderListParameters.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Deployment list operation parameters. + /// + public partial class ProviderListParameters + { + private int? _top; + + /// + /// Optional. Get or sets the number of records to return. Optional. + /// + public int? Top + { + get { return this._top; } + set { this._top = value; } + } + + /// + /// Initializes a new instance of the ProviderListParameters class. + /// + public ProviderListParameters() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderListResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderListResult.cs new file mode 100644 index 000000000000..f908d90dbd8f --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderListResult.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// List of resource providers. + /// + public partial class ProviderListResult : AzureOperationResponse + { + private string _nextLink; + + /// + /// Optional. Gets or sets the URL to get the next set of results. + /// + public string NextLink + { + get { return this._nextLink; } + set { this._nextLink = value; } + } + + private IList _providers; + + /// + /// Optional. Gets or sets the list of resource providers. + /// + public IList Providers + { + get { return this._providers; } + set { this._providers = value; } + } + + /// + /// Initializes a new instance of the ProviderListResult class. + /// + public ProviderListResult() + { + this.Providers = new LazyList(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderOperationsMetadata.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderOperationsMetadata.cs new file mode 100644 index 000000000000..d8e446d42263 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderOperationsMetadata.cs @@ -0,0 +1,107 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Provider Operations metadata + /// + public partial class ProviderOperationsMetadata + { + private string _displayName; + + /// + /// Optional. Gets or sets the provider display name + /// + public string DisplayName + { + get { return this._displayName; } + set { this._displayName = value; } + } + + private string _id; + + /// + /// Optional. Gets or sets the provider id. + /// + public string Id + { + get { return this._id; } + set { this._id = value; } + } + + private string _name; + + /// + /// Optional. Gets or sets the provider name + /// + public string Name + { + get { return this._name; } + set { this._name = value; } + } + + private IList _operations; + + /// + /// Optional. Gets or sets the provider operations + /// + public IList Operations + { + get { return this._operations; } + set { this._operations = value; } + } + + private IList _resourceTypes; + + /// + /// Optional. Gets or sets the provider resource types + /// + public IList ResourceTypes + { + get { return this._resourceTypes; } + set { this._resourceTypes = value; } + } + + private string _type; + + /// + /// Optional. Gets or sets the provider type + /// + public string Type + { + get { return this._type; } + set { this._type = value; } + } + + /// + /// Initializes a new instance of the ProviderOperationsMetadata class. + /// + public ProviderOperationsMetadata() + { + this.Operations = new LazyList(); + this.ResourceTypes = new LazyList(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderOperationsMetadataGetResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderOperationsMetadataGetResult.cs new file mode 100644 index 000000000000..4982af3c93fb --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderOperationsMetadataGetResult.cs @@ -0,0 +1,49 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Provider operations metadata + /// + public partial class ProviderOperationsMetadataGetResult : AzureOperationResponse + { + private ProviderOperationsMetadata _provider; + + /// + /// Optional. Gets or sets the provider. + /// + public ProviderOperationsMetadata Provider + { + get { return this._provider; } + set { this._provider = value; } + } + + /// + /// Initializes a new instance of the + /// ProviderOperationsMetadataGetResult class. + /// + public ProviderOperationsMetadataGetResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderOperationsMetadataListResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderOperationsMetadataListResult.cs new file mode 100644 index 000000000000..b78f5bf6e6b8 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderOperationsMetadataListResult.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Provider operations metadata list + /// + public partial class ProviderOperationsMetadataListResult : AzureOperationResponse + { + private IList _providers; + + /// + /// Optional. Gets or sets the list of providers. + /// + public IList Providers + { + get { return this._providers; } + set { this._providers = value; } + } + + /// + /// Initializes a new instance of the + /// ProviderOperationsMetadataListResult class. + /// + public ProviderOperationsMetadataListResult() + { + this.Providers = new LazyList(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderRegistionResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderRegistionResult.cs new file mode 100644 index 000000000000..0ae82440bfdf --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderRegistionResult.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource provider registration information. + /// + public partial class ProviderRegistionResult : AzureOperationResponse + { + private Provider _provider; + + /// + /// Optional. Gets or sets the resource provider. + /// + public Provider Provider + { + get { return this._provider; } + set { this._provider = value; } + } + + /// + /// Initializes a new instance of the ProviderRegistionResult class. + /// + public ProviderRegistionResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderRegistrationState.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderRegistrationState.cs new file mode 100644 index 000000000000..ca692ef63953 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderRegistrationState.cs @@ -0,0 +1,50 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Provider registration states. + /// + public static partial class ProviderRegistrationState + { + /// + /// Provider registration state is not registered. + /// + public const string NotRegistered = "NotRegistered"; + + /// + /// Provider registration state is unregistering. + /// + public const string Unregistering = "Unregistering"; + + /// + /// Provider registration state is registering. + /// + public const string Registering = "Registering"; + + /// + /// Provider registration state is registered. + /// + public const string Registered = "Registered"; + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderResourceType.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderResourceType.cs new file mode 100644 index 000000000000..2844705da4d0 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderResourceType.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource type managed by the resource provider. + /// + public partial class ProviderResourceType + { + private IList _apiVersions; + + /// + /// Optional. Gets or sets the api version. + /// + public IList ApiVersions + { + get { return this._apiVersions; } + set { this._apiVersions = value; } + } + + private IList _locations; + + /// + /// Optional. Gets or sets the collection of locations where this + /// resource type can be created in. + /// + public IList Locations + { + get { return this._locations; } + set { this._locations = value; } + } + + private string _name; + + /// + /// Optional. Gets or sets the resource type. + /// + public string Name + { + get { return this._name; } + set { this._name = value; } + } + + private IDictionary _properties; + + /// + /// Optional. Gets or sets the properties. + /// + public IDictionary Properties + { + get { return this._properties; } + set { this._properties = value; } + } + + /// + /// Initializes a new instance of the ProviderResourceType class. + /// + public ProviderResourceType() + { + this.ApiVersions = new LazyList(); + this.Locations = new LazyList(); + this.Properties = new LazyDictionary(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderUnregistionResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderUnregistionResult.cs new file mode 100644 index 000000000000..330775fafccb --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProviderUnregistionResult.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource provider registration information. + /// + public partial class ProviderUnregistionResult : AzureOperationResponse + { + private Provider _provider; + + /// + /// Optional. Gets or sets the resource provider. + /// + public Provider Provider + { + get { return this._provider; } + set { this._provider = value; } + } + + /// + /// Initializes a new instance of the ProviderUnregistionResult class. + /// + public ProviderUnregistionResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProvisioningState.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProvisioningState.cs new file mode 100644 index 000000000000..7e0ffd3366d7 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ProvisioningState.cs @@ -0,0 +1,85 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Common provisioning states. + /// + public static partial class ProvisioningState + { + /// + /// The provisioning state is not specified. + /// + public const string NotSpecified = "NotSpecified"; + + /// + /// The provisioning state is accepted. + /// + public const string Accepted = "Accepted"; + + /// + /// The provisioning state is running. + /// + public const string Running = "Running"; + + /// + /// The provisioning state is registering. + /// + public const string Registering = "Registering"; + + /// + /// The provisioning state is creating. + /// + public const string Creating = "Creating"; + + /// + /// The provisioning state is created. + /// + public const string Created = "Created"; + + /// + /// The provisioning state is deleting. + /// + public const string Deleting = "Deleting"; + + /// + /// The provisioning state is deleted. + /// + public const string Deleted = "Deleted"; + + /// + /// The provisioning state is canceled. + /// + public const string Canceled = "Canceled"; + + /// + /// The provisioning state is failed. + /// + public const string Failed = "Failed"; + + /// + /// The provisioning state is succeeded. + /// + public const string Succeeded = "Succeeded"; + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/RegistrationState.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/RegistrationState.cs new file mode 100644 index 000000000000..85aef8cc4536 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/RegistrationState.cs @@ -0,0 +1,50 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Common registration states. + /// + public static partial class RegistrationState + { + /// + /// The registration state is not specified. + /// + public const string NotSpecified = "NotSpecified"; + + /// + /// The registration state is not registered. + /// + public const string NotRegistered = "NotRegistered"; + + /// + /// The registration state is not Pending. + /// + public const string Pending = "Pending"; + + /// + /// The registration state is Registered. + /// + public const string Registered = "Registered"; + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceCreateOrUpdateResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceCreateOrUpdateResult.cs new file mode 100644 index 000000000000..427af8fd47a3 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceCreateOrUpdateResult.cs @@ -0,0 +1,49 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource information. + /// + public partial class ResourceCreateOrUpdateResult : AzureOperationResponse + { + private GenericResourceExtended _resource; + + /// + /// Optional. Gets or sets the resource. + /// + public GenericResourceExtended Resource + { + get { return this._resource; } + set { this._resource = value; } + } + + /// + /// Initializes a new instance of the ResourceCreateOrUpdateResult + /// class. + /// + public ResourceCreateOrUpdateResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceExistsResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceExistsResult.cs new file mode 100644 index 000000000000..f89a2f43d8c4 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceExistsResult.cs @@ -0,0 +1,49 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource group information. + /// + public partial class ResourceExistsResult : AzureOperationResponse + { + private bool _exists; + + /// + /// Optional. Gets or sets the value indicating whether the resource + /// group exists. + /// + public bool Exists + { + get { return this._exists; } + set { this._exists = value; } + } + + /// + /// Initializes a new instance of the ResourceExistsResult class. + /// + public ResourceExistsResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGetResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGetResult.cs new file mode 100644 index 000000000000..2636153988aa --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGetResult.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource information. + /// + public partial class ResourceGetResult : AzureOperationResponse + { + private GenericResourceExtended _resource; + + /// + /// Optional. Gets or sets the resource. + /// + public GenericResourceExtended Resource + { + get { return this._resource; } + set { this._resource = value; } + } + + /// + /// Initializes a new instance of the ResourceGetResult class. + /// + public ResourceGetResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroup.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroup.cs new file mode 100644 index 000000000000..6672fc459777 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroup.cs @@ -0,0 +1,102 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource group information. + /// + public partial class ResourceGroup + { + private string _location; + + /// + /// Required. Gets or sets the location of the resource group. It + /// cannot be changed after the resource group has been created. Has + /// to be one of the supported Azure Locations, such as West US, East + /// US, West Europe, East Asia, etc. + /// + public string Location + { + get { return this._location; } + set { this._location = value; } + } + + private string _properties; + + /// + /// Optional. Gets or sets the resource group properties. + /// + public string Properties + { + get { return this._properties; } + set { this._properties = value; } + } + + private string _provisioningState; + + /// + /// Optional. Gets or sets resource group provisioning state. + /// + public string ProvisioningState + { + get { return this._provisioningState; } + set { this._provisioningState = value; } + } + + private IDictionary _tags; + + /// + /// Optional. Gets or sets the tags attached to the resource group. + /// + public IDictionary Tags + { + get { return this._tags; } + set { this._tags = value; } + } + + /// + /// Initializes a new instance of the ResourceGroup class. + /// + public ResourceGroup() + { + this.Tags = new LazyDictionary(); + } + + /// + /// Initializes a new instance of the ResourceGroup class with required + /// arguments. + /// + public ResourceGroup(string location) + : this() + { + if (location == null) + { + throw new ArgumentNullException("location"); + } + this.Location = location; + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupCreateOrUpdateResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupCreateOrUpdateResult.cs new file mode 100644 index 000000000000..8d54772e829a --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupCreateOrUpdateResult.cs @@ -0,0 +1,49 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource group information. + /// + public partial class ResourceGroupCreateOrUpdateResult : AzureOperationResponse + { + private ResourceGroupExtended _resourceGroup; + + /// + /// Optional. Gets or sets the resource group. + /// + public ResourceGroupExtended ResourceGroup + { + get { return this._resourceGroup; } + set { this._resourceGroup = value; } + } + + /// + /// Initializes a new instance of the ResourceGroupCreateOrUpdateResult + /// class. + /// + public ResourceGroupCreateOrUpdateResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupExistsResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupExistsResult.cs new file mode 100644 index 000000000000..7c89c9863c3c --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupExistsResult.cs @@ -0,0 +1,49 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource group information. + /// + public partial class ResourceGroupExistsResult : AzureOperationResponse + { + private bool _exists; + + /// + /// Optional. Gets or sets the value indicating whether the resource + /// group exists. + /// + public bool Exists + { + get { return this._exists; } + set { this._exists = value; } + } + + /// + /// Initializes a new instance of the ResourceGroupExistsResult class. + /// + public ResourceGroupExistsResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupExtended.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupExtended.cs new file mode 100644 index 000000000000..1851909fcaee --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupExtended.cs @@ -0,0 +1,74 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource group information. + /// + public partial class ResourceGroupExtended : ResourceGroup + { + private string _id; + + /// + /// Optional. Gets or sets the ID of the resource group. + /// + public string Id + { + get { return this._id; } + set { this._id = value; } + } + + private string _name; + + /// + /// Optional. Gets or sets the Name of the resource group. + /// + public string Name + { + get { return this._name; } + set { this._name = value; } + } + + /// + /// Initializes a new instance of the ResourceGroupExtended class. + /// + public ResourceGroupExtended() + { + } + + /// + /// Initializes a new instance of the ResourceGroupExtended class with + /// required arguments. + /// + public ResourceGroupExtended(string location) + : this() + { + if (location == null) + { + throw new ArgumentNullException("location"); + } + this.Location = location; + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupGetResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupGetResult.cs new file mode 100644 index 000000000000..6482b0775e3f --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupGetResult.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource group information. + /// + public partial class ResourceGroupGetResult : AzureOperationResponse + { + private ResourceGroupExtended _resourceGroup; + + /// + /// Optional. Gets or sets the resource group. + /// + public ResourceGroupExtended ResourceGroup + { + get { return this._resourceGroup; } + set { this._resourceGroup = value; } + } + + /// + /// Initializes a new instance of the ResourceGroupGetResult class. + /// + public ResourceGroupGetResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupListParameters.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupListParameters.cs new file mode 100644 index 000000000000..f9cc2c5c4187 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupListParameters.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource group information. + /// + public partial class ResourceGroupListParameters + { + private string _tagName; + + /// + /// Optional. Filter the results based on a particular tag name. + /// Optional. + /// + public string TagName + { + get { return this._tagName; } + set { this._tagName = value; } + } + + private string _tagValue; + + /// + /// Optional. Filter the results for a tag name along with a particular + /// tag value. Optional. + /// + public string TagValue + { + get { return this._tagValue; } + set { this._tagValue = value; } + } + + private int? _top; + + /// + /// Optional. Number of records to return. Optional. + /// + public int? Top + { + get { return this._top; } + set { this._top = value; } + } + + /// + /// Initializes a new instance of the ResourceGroupListParameters class. + /// + public ResourceGroupListParameters() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupListResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupListResult.cs new file mode 100644 index 000000000000..b66dc9936b60 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupListResult.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// List of resource groups. + /// + public partial class ResourceGroupListResult : AzureOperationResponse + { + private string _nextLink; + + /// + /// Required. Gets or sets the URL to get the next set of results. + /// + public string NextLink + { + get { return this._nextLink; } + set { this._nextLink = value; } + } + + private IList _resourceGroups; + + /// + /// Optional. Gets or sets the list of resource groups. + /// + public IList ResourceGroups + { + get { return this._resourceGroups; } + set { this._resourceGroups = value; } + } + + /// + /// Initializes a new instance of the ResourceGroupListResult class. + /// + public ResourceGroupListResult() + { + this.ResourceGroups = new LazyList(); + } + + /// + /// Initializes a new instance of the ResourceGroupListResult class + /// with required arguments. + /// + public ResourceGroupListResult(string nextLink) + : this() + { + if (nextLink == null) + { + throw new ArgumentNullException("nextLink"); + } + this.NextLink = nextLink; + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupPatchResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupPatchResult.cs new file mode 100644 index 000000000000..4de5cee958d8 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceGroupPatchResult.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource group information. + /// + public partial class ResourceGroupPatchResult : AzureOperationResponse + { + private ResourceGroupExtended _resourceGroup; + + /// + /// Optional. Gets or sets the resource group. + /// + public ResourceGroupExtended ResourceGroup + { + get { return this._resourceGroup; } + set { this._resourceGroup = value; } + } + + /// + /// Initializes a new instance of the ResourceGroupPatchResult class. + /// + public ResourceGroupPatchResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceListParameters.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceListParameters.cs new file mode 100644 index 000000000000..d6b5ff3b51d8 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceListParameters.cs @@ -0,0 +1,96 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource group information. + /// + public partial class ResourceListParameters + { + private string _resourceGroupName; + + /// + /// Optional. Gets or sets resource resource group to filter by. + /// Optional. + /// + public string ResourceGroupName + { + get { return this._resourceGroupName; } + set { this._resourceGroupName = value; } + } + + private string _resourceType; + + /// + /// Optional. Filter the results for a particular resource type. + /// Optional. + /// + public string ResourceType + { + get { return this._resourceType; } + set { this._resourceType = value; } + } + + private string _tagName; + + /// + /// Optional. Filter the results based on a particular tag name. + /// Optional. + /// + public string TagName + { + get { return this._tagName; } + set { this._tagName = value; } + } + + private string _tagValue; + + /// + /// Optional. Filter the results for a tag name along with a particular + /// tag value. Optional. + /// + public string TagValue + { + get { return this._tagValue; } + set { this._tagValue = value; } + } + + private int? _top; + + /// + /// Optional. Number of records to return. Optional. + /// + public int? Top + { + get { return this._top; } + set { this._top = value; } + } + + /// + /// Initializes a new instance of the ResourceListParameters class. + /// + public ResourceListParameters() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceListResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceListResult.cs new file mode 100644 index 000000000000..ed6a63019a4b --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceListResult.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// List of resource groups. + /// + public partial class ResourceListResult : AzureOperationResponse + { + private string _nextLink; + + /// + /// Required. Gets or sets the URL to get the next set of results. + /// + public string NextLink + { + get { return this._nextLink; } + set { this._nextLink = value; } + } + + private IList _resources; + + /// + /// Optional. Gets or sets the list of resource groups. + /// + public IList Resources + { + get { return this._resources; } + set { this._resources = value; } + } + + /// + /// Initializes a new instance of the ResourceListResult class. + /// + public ResourceListResult() + { + this.Resources = new LazyList(); + } + + /// + /// Initializes a new instance of the ResourceListResult class with + /// required arguments. + /// + public ResourceListResult(string nextLink) + : this() + { + if (nextLink == null) + { + throw new ArgumentNullException("nextLink"); + } + this.NextLink = nextLink; + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceManagementError.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceManagementError.cs new file mode 100644 index 000000000000..e24c0493816a --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceManagementError.cs @@ -0,0 +1,87 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + public partial class ResourceManagementError + { + private string _code; + + /// + /// Required. Gets or sets the error code returned from the server. + /// + public string Code + { + get { return this._code; } + set { this._code = value; } + } + + private string _message; + + /// + /// Required. Gets or sets the error message returned from the server. + /// + public string Message + { + get { return this._message; } + set { this._message = value; } + } + + private string _target; + + /// + /// Optional. Gets or sets the target of the error. + /// + public string Target + { + get { return this._target; } + set { this._target = value; } + } + + /// + /// Initializes a new instance of the ResourceManagementError class. + /// + public ResourceManagementError() + { + } + + /// + /// Initializes a new instance of the ResourceManagementError class + /// with required arguments. + /// + public ResourceManagementError(string code, string message) + : this() + { + if (code == null) + { + throw new ArgumentNullException("code"); + } + if (message == null) + { + throw new ArgumentNullException("message"); + } + this.Code = code; + this.Message = message; + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceManagementErrorWithDetails.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceManagementErrorWithDetails.cs new file mode 100644 index 000000000000..b3aa9ad0da33 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceManagementErrorWithDetails.cs @@ -0,0 +1,69 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + public partial class ResourceManagementErrorWithDetails : ResourceManagementError + { + private IList _details; + + /// + /// Optional. Gets or sets validation error. + /// + public IList Details + { + get { return this._details; } + set { this._details = value; } + } + + /// + /// Initializes a new instance of the + /// ResourceManagementErrorWithDetails class. + /// + public ResourceManagementErrorWithDetails() + { + this.Details = new LazyList(); + } + + /// + /// Initializes a new instance of the + /// ResourceManagementErrorWithDetails class with required arguments. + /// + public ResourceManagementErrorWithDetails(string code, string message) + : this() + { + if (code == null) + { + throw new ArgumentNullException("code"); + } + if (message == null) + { + throw new ArgumentNullException("message"); + } + this.Code = code; + this.Message = message; + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceProviderOperationDefinition.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceProviderOperationDefinition.cs new file mode 100644 index 000000000000..f3bd8ff0e3ab --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceProviderOperationDefinition.cs @@ -0,0 +1,61 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource provider operation information. + /// + public partial class ResourceProviderOperationDefinition + { + private string _name; + + /// + /// Optional. Gets or sets the provider operation name. + /// + public string Name + { + get { return this._name; } + set { this._name = value; } + } + + private ResourceProviderOperationDisplayProperties _resourceProviderOperationDisplayProperties; + + /// + /// Optional. Gets or sets the display property of the provider + /// operation. + /// + public ResourceProviderOperationDisplayProperties ResourceProviderOperationDisplayProperties + { + get { return this._resourceProviderOperationDisplayProperties; } + set { this._resourceProviderOperationDisplayProperties = value; } + } + + /// + /// Initializes a new instance of the + /// ResourceProviderOperationDefinition class. + /// + public ResourceProviderOperationDefinition() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceProviderOperationDetailListResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceProviderOperationDetailListResult.cs new file mode 100644 index 000000000000..e7cd825e4dff --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceProviderOperationDetailListResult.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// List of resource provider operations. + /// + public partial class ResourceProviderOperationDetailListResult : AzureOperationResponse + { + private IList _resourceProviderOperationDetails; + + /// + /// Optional. Gets or sets the list of resource provider operations. + /// + public IList ResourceProviderOperationDetails + { + get { return this._resourceProviderOperationDetails; } + set { this._resourceProviderOperationDetails = value; } + } + + /// + /// Initializes a new instance of the + /// ResourceProviderOperationDetailListResult class. + /// + public ResourceProviderOperationDetailListResult() + { + this.ResourceProviderOperationDetails = new LazyList(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceProviderOperationDisplayProperties.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceProviderOperationDisplayProperties.cs new file mode 100644 index 000000000000..ee8eb5555779 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceProviderOperationDisplayProperties.cs @@ -0,0 +1,93 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource provider operation's display properties. + /// + public partial class ResourceProviderOperationDisplayProperties + { + private string _description; + + /// + /// Optional. Gets or sets operation description. + /// + public string Description + { + get { return this._description; } + set { this._description = value; } + } + + private string _operation; + + /// + /// Optional. Gets or sets operation. + /// + public string Operation + { + get { return this._operation; } + set { this._operation = value; } + } + + private string _provider; + + /// + /// Optional. Gets or sets operation provider. + /// + public string Provider + { + get { return this._provider; } + set { this._provider = value; } + } + + private string _publisher; + + /// + /// Optional. Gets or sets operation description. + /// + public string Publisher + { + get { return this._publisher; } + set { this._publisher = value; } + } + + private string _resource; + + /// + /// Optional. Gets or sets operation resource. + /// + public string Resource + { + get { return this._resource; } + set { this._resource = value; } + } + + /// + /// Initializes a new instance of the + /// ResourceProviderOperationDisplayProperties class. + /// + public ResourceProviderOperationDisplayProperties() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceType.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceType.cs new file mode 100644 index 000000000000..b6f02c02ec4d --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourceType.cs @@ -0,0 +1,73 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Resource Type + /// + public partial class ResourceType + { + private string _displayName; + + /// + /// Optional. Gets or sets the resource type display name + /// + public string DisplayName + { + get { return this._displayName; } + set { this._displayName = value; } + } + + private string _name; + + /// + /// Optional. Gets or sets the resource type name + /// + public string Name + { + get { return this._name; } + set { this._name = value; } + } + + private IList _operations; + + /// + /// Optional. Gets or sets the resource type operations + /// + public IList Operations + { + get { return this._operations; } + set { this._operations = value; } + } + + /// + /// Initializes a new instance of the ResourceType class. + /// + public ResourceType() + { + this.Operations = new LazyList(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourcesMoveInfo.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourcesMoveInfo.cs new file mode 100644 index 000000000000..89130fd38f09 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/ResourcesMoveInfo.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Parameters of move resources. + /// + public partial class ResourcesMoveInfo + { + private IList _resources; + + /// + /// Optional. Gets or sets the ids of the resources. + /// + public IList Resources + { + get { return this._resources; } + set { this._resources = value; } + } + + private string _targetResourceGroup; + + /// + /// Optional. The target resource group. + /// + public string TargetResourceGroup + { + get { return this._targetResourceGroup; } + set { this._targetResourceGroup = value; } + } + + /// + /// Initializes a new instance of the ResourcesMoveInfo class. + /// + public ResourcesMoveInfo() + { + this.Resources = new LazyList(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Subscription.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Subscription.cs new file mode 100644 index 000000000000..ec98c7f0f795 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/Subscription.cs @@ -0,0 +1,82 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Internal.Subscriptions.Models +{ + /// + /// Subscription information. + /// + public partial class Subscription + { + private string _displayName; + + /// + /// Optional. Gets or sets the subscription display name + /// + public string DisplayName + { + get { return this._displayName; } + set { this._displayName = value; } + } + + private string _id; + + /// + /// Optional. Gets or sets the ID of the resource + /// (/subscriptions/SubscriptionId). + /// + public string Id + { + get { return this._id; } + set { this._id = value; } + } + + private string _state; + + /// + /// Optional. Gets or sets the subscription state + /// + public string State + { + get { return this._state; } + set { this._state = value; } + } + + private string _subscriptionId; + + /// + /// Optional. Gets or sets the subscription Id. + /// + public string SubscriptionId + { + get { return this._subscriptionId; } + set { this._subscriptionId = value; } + } + + /// + /// Initializes a new instance of the Subscription class. + /// + public Subscription() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/SubscriptionListResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/SubscriptionListResult.cs new file mode 100644 index 000000000000..8286b31e70a1 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/SubscriptionListResult.cs @@ -0,0 +1,51 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Internal.Subscriptions.Models +{ + /// + /// Subscription list operation response. + /// + public partial class SubscriptionListResult : AzureOperationResponse + { + private IList _subscriptions; + + /// + /// Optional. Gets or sets subscriptions. + /// + public IList Subscriptions + { + get { return this._subscriptions; } + set { this._subscriptions = value; } + } + + /// + /// Initializes a new instance of the SubscriptionListResult class. + /// + public SubscriptionListResult() + { + this.Subscriptions = new LazyList(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagCount.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagCount.cs new file mode 100644 index 000000000000..200421d852e3 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagCount.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Tag count. + /// + public partial class TagCount + { + private string _type; + + /// + /// Optional. Type of count. + /// + public string Type + { + get { return this._type; } + set { this._type = value; } + } + + private string _value; + + /// + /// Optional. Value of count. + /// + public string Value + { + get { return this._value; } + set { this._value = value; } + } + + /// + /// Initializes a new instance of the TagCount class. + /// + public TagCount() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagCreateResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagCreateResult.cs new file mode 100644 index 000000000000..93e8120ce483 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagCreateResult.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Tag information. + /// + public partial class TagCreateResult : AzureOperationResponse + { + private TagDetails _tag; + + /// + /// Optional. Gets or sets the tag. + /// + public TagDetails Tag + { + get { return this._tag; } + set { this._tag = value; } + } + + /// + /// Initializes a new instance of the TagCreateResult class. + /// + public TagCreateResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagCreateValueResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagCreateValueResult.cs new file mode 100644 index 000000000000..96fd46504df5 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagCreateValueResult.cs @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Tag information. + /// + public partial class TagCreateValueResult : AzureOperationResponse + { + private TagValue _value; + + /// + /// Optional. Gets or sets the tag value. + /// + public TagValue Value + { + get { return this._value; } + set { this._value = value; } + } + + /// + /// Initializes a new instance of the TagCreateValueResult class. + /// + public TagCreateValueResult() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagDetails.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagDetails.cs new file mode 100644 index 000000000000..ffca9984a419 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagDetails.cs @@ -0,0 +1,84 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Tag details. + /// + public partial class TagDetails + { + private TagCount _count; + + /// + /// Optional. Gets or sets the tag count. + /// + public TagCount Count + { + get { return this._count; } + set { this._count = value; } + } + + private string _id; + + /// + /// Optional. Gets or sets the tag ID. + /// + public string Id + { + get { return this._id; } + set { this._id = value; } + } + + private string _name; + + /// + /// Optional. Gets or sets the tag name. + /// + public string Name + { + get { return this._name; } + set { this._name = value; } + } + + private IList _values; + + /// + /// Optional. Gets or sets the list of tag values. + /// + public IList Values + { + get { return this._values; } + set { this._values = value; } + } + + /// + /// Initializes a new instance of the TagDetails class. + /// + public TagDetails() + { + this.Values = new LazyList(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagValue.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagValue.cs new file mode 100644 index 000000000000..f93d2343c5e4 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagValue.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Tag information. + /// + public partial class TagValue + { + private TagCount _count; + + /// + /// Optional. Gets or sets the tag value count. + /// + public TagCount Count + { + get { return this._count; } + set { this._count = value; } + } + + private string _id; + + /// + /// Optional. Gets or sets the tag ID. + /// + public string Id + { + get { return this._id; } + set { this._id = value; } + } + + private string _value; + + /// + /// Optional. Gets or sets the tag value. + /// + public string Value + { + get { return this._value; } + set { this._value = value; } + } + + /// + /// Initializes a new instance of the TagValue class. + /// + public TagValue() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagsListResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagsListResult.cs new file mode 100644 index 000000000000..69df087555ef --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TagsListResult.cs @@ -0,0 +1,77 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// List of subscription tags. + /// + public partial class TagsListResult : AzureOperationResponse + { + private string _nextLink; + + /// + /// Required. Gets or sets the URL to get the next set of results. + /// + public string NextLink + { + get { return this._nextLink; } + set { this._nextLink = value; } + } + + private IList _tags; + + /// + /// Optional. Gets or sets the list of tags. + /// + public IList Tags + { + get { return this._tags; } + set { this._tags = value; } + } + + /// + /// Initializes a new instance of the TagsListResult class. + /// + public TagsListResult() + { + this.Tags = new LazyList(); + } + + /// + /// Initializes a new instance of the TagsListResult class with + /// required arguments. + /// + public TagsListResult(string nextLink) + : this() + { + if (nextLink == null) + { + throw new ArgumentNullException("nextLink"); + } + this.NextLink = nextLink; + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TargetResource.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TargetResource.cs new file mode 100644 index 000000000000..71b2425840d2 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TargetResource.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Target resource. + /// + public partial class TargetResource + { + private string _id; + + /// + /// Optional. Gets or sets the ID of the resource. + /// + public string Id + { + get { return this._id; } + set { this._id = value; } + } + + private string _resourceName; + + /// + /// Optional. Gets or sets the name of the resource. + /// + public string ResourceName + { + get { return this._resourceName; } + set { this._resourceName = value; } + } + + private string _resourceType; + + /// + /// Optional. Gets or sets the type of the resource. + /// + public string ResourceType + { + get { return this._resourceType; } + set { this._resourceType = value; } + } + + /// + /// Initializes a new instance of the TargetResource class. + /// + public TargetResource() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TemplateLink.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TemplateLink.cs new file mode 100644 index 000000000000..7a15997ea9ab --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TemplateLink.cs @@ -0,0 +1,75 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; + +namespace Microsoft.Azure.Management.Internal.Resources.Models +{ + /// + /// Entity representing the reference to the template. + /// + public partial class TemplateLink + { + private string _contentVersion; + + /// + /// Optional. If included it must match the ContentVersion in the + /// template. + /// + public string ContentVersion + { + get { return this._contentVersion; } + set { this._contentVersion = value; } + } + + private Uri _uri; + + /// + /// Required. URI referencing the template. + /// + public Uri Uri + { + get { return this._uri; } + set { this._uri = value; } + } + + /// + /// Initializes a new instance of the TemplateLink class. + /// + public TemplateLink() + { + } + + /// + /// Initializes a new instance of the TemplateLink class with required + /// arguments. + /// + public TemplateLink(Uri uri) + : this() + { + if (uri == null) + { + throw new ArgumentNullException("uri"); + } + this.Uri = uri; + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TenantIdDescription.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TenantIdDescription.cs new file mode 100644 index 000000000000..2e42b05b2c41 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TenantIdDescription.cs @@ -0,0 +1,59 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Internal.Subscriptions.Models +{ + /// + /// Tenant Id information + /// + public partial class TenantIdDescription + { + private string _id; + + /// + /// Optional. Gets or sets Id + /// + public string Id + { + get { return this._id; } + set { this._id = value; } + } + + private string _tenantId; + + /// + /// Optional. Gets or sets tenantId + /// + public string TenantId + { + get { return this._tenantId; } + set { this._tenantId = value; } + } + + /// + /// Initializes a new instance of the TenantIdDescription class. + /// + public TenantIdDescription() + { + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TenantListResult.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TenantListResult.cs new file mode 100644 index 000000000000..df25db3748c3 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/Models/TenantListResult.cs @@ -0,0 +1,51 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Collections.Generic; +using Hyak.Common; + +namespace Microsoft.Azure.Internal.Subscriptions.Models +{ + /// + /// Tenant Ids information. + /// + public partial class TenantListResult : AzureOperationResponse + { + private IList _tenantIds; + + /// + /// Optional. Gets or sets tenant Ids. + /// + public IList TenantIds + { + get { return this._tenantIds; } + set { this._tenantIds = value; } + } + + /// + /// Initializes a new instance of the TenantListResult class. + /// + public TenantListResult() + { + this.TenantIds = new LazyList(); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ProviderOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ProviderOperations.cs new file mode 100644 index 000000000000..0b5fcb74ca1c --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ProviderOperations.cs @@ -0,0 +1,1150 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Hyak.Common; +using Microsoft.Azure.Management.Internal.Resources.Models; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing providers. + /// + internal partial class ProviderOperations : IServiceOperations, IProviderOperations + { + /// + /// Initializes a new instance of the ProviderOperations class. + /// + /// + /// Reference to the service client. + /// + internal ProviderOperations(ResourceManagementClient client) + { + this._client = client; + } + + private ResourceManagementClient _client; + + /// + /// Gets a reference to the + /// Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient. + /// + public ResourceManagementClient Client + { + get { return this._client; } + } + + /// + /// Gets a resource provider. + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Cancellation token. + /// + /// + /// Resource provider information. + /// + public async Task GetAsync(string resourceProviderNamespace, CancellationToken cancellationToken) + { + // Validate + if (resourceProviderNamespace == null) + { + throw new ArgumentNullException("resourceProviderNamespace"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + TracingAdapter.Enter(invocationId, this, "GetAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/providers/"; + url = url + Uri.EscapeDataString(resourceProviderNamespace); + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ProviderGetResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ProviderGetResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + Provider providerInstance = new Provider(); + result.Provider = providerInstance; + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + providerInstance.Id = idInstance; + } + + JToken namespaceValue = responseDoc["namespace"]; + if (namespaceValue != null && namespaceValue.Type != JTokenType.Null) + { + string namespaceInstance = ((string)namespaceValue); + providerInstance.Namespace = namespaceInstance; + } + + JToken registrationStateValue = responseDoc["registrationState"]; + if (registrationStateValue != null && registrationStateValue.Type != JTokenType.Null) + { + string registrationStateInstance = ((string)registrationStateValue); + providerInstance.RegistrationState = registrationStateInstance; + } + + JToken resourceTypesArray = responseDoc["resourceTypes"]; + if (resourceTypesArray != null && resourceTypesArray.Type != JTokenType.Null) + { + foreach (JToken resourceTypesValue in ((JArray)resourceTypesArray)) + { + ProviderResourceType providerResourceTypeInstance = new ProviderResourceType(); + providerInstance.ResourceTypes.Add(providerResourceTypeInstance); + + JToken resourceTypeValue = resourceTypesValue["resourceType"]; + if (resourceTypeValue != null && resourceTypeValue.Type != JTokenType.Null) + { + string resourceTypeInstance = ((string)resourceTypeValue); + providerResourceTypeInstance.Name = resourceTypeInstance; + } + + JToken locationsArray = resourceTypesValue["locations"]; + if (locationsArray != null && locationsArray.Type != JTokenType.Null) + { + foreach (JToken locationsValue in ((JArray)locationsArray)) + { + providerResourceTypeInstance.Locations.Add(((string)locationsValue)); + } + } + + JToken apiVersionsArray = resourceTypesValue["apiVersions"]; + if (apiVersionsArray != null && apiVersionsArray.Type != JTokenType.Null) + { + foreach (JToken apiVersionsValue in ((JArray)apiVersionsArray)) + { + providerResourceTypeInstance.ApiVersions.Add(((string)apiVersionsValue)); + } + } + + JToken propertiesSequenceElement = ((JToken)resourceTypesValue["properties"]); + if (propertiesSequenceElement != null && propertiesSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in propertiesSequenceElement) + { + string propertiesKey = ((string)property.Name); + string propertiesValue = ((string)property.Value); + providerResourceTypeInstance.Properties.Add(propertiesKey, propertiesValue); + } + } + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Gets a list of resource providers. + /// + /// + /// Optional. Query parameters. If null is passed returns all + /// deployments. + /// + /// + /// Cancellation token. + /// + /// + /// List of resource providers. + /// + public async Task ListAsync(ProviderListParameters parameters, CancellationToken cancellationToken) + { + // Validate + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "ListAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/providers"; + List queryParameters = new List(); + if (parameters != null && parameters.Top != null) + { + queryParameters.Add("$top=" + Uri.EscapeDataString(parameters.Top.Value.ToString())); + } + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ProviderListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ProviderListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + Provider providerInstance = new Provider(); + result.Providers.Add(providerInstance); + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + providerInstance.Id = idInstance; + } + + JToken namespaceValue = valueValue["namespace"]; + if (namespaceValue != null && namespaceValue.Type != JTokenType.Null) + { + string namespaceInstance = ((string)namespaceValue); + providerInstance.Namespace = namespaceInstance; + } + + JToken registrationStateValue = valueValue["registrationState"]; + if (registrationStateValue != null && registrationStateValue.Type != JTokenType.Null) + { + string registrationStateInstance = ((string)registrationStateValue); + providerInstance.RegistrationState = registrationStateInstance; + } + + JToken resourceTypesArray = valueValue["resourceTypes"]; + if (resourceTypesArray != null && resourceTypesArray.Type != JTokenType.Null) + { + foreach (JToken resourceTypesValue in ((JArray)resourceTypesArray)) + { + ProviderResourceType providerResourceTypeInstance = new ProviderResourceType(); + providerInstance.ResourceTypes.Add(providerResourceTypeInstance); + + JToken resourceTypeValue = resourceTypesValue["resourceType"]; + if (resourceTypeValue != null && resourceTypeValue.Type != JTokenType.Null) + { + string resourceTypeInstance = ((string)resourceTypeValue); + providerResourceTypeInstance.Name = resourceTypeInstance; + } + + JToken locationsArray = resourceTypesValue["locations"]; + if (locationsArray != null && locationsArray.Type != JTokenType.Null) + { + foreach (JToken locationsValue in ((JArray)locationsArray)) + { + providerResourceTypeInstance.Locations.Add(((string)locationsValue)); + } + } + + JToken apiVersionsArray = resourceTypesValue["apiVersions"]; + if (apiVersionsArray != null && apiVersionsArray.Type != JTokenType.Null) + { + foreach (JToken apiVersionsValue in ((JArray)apiVersionsArray)) + { + providerResourceTypeInstance.ApiVersions.Add(((string)apiVersionsValue)); + } + } + + JToken propertiesSequenceElement = ((JToken)resourceTypesValue["properties"]); + if (propertiesSequenceElement != null && propertiesSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in propertiesSequenceElement) + { + string propertiesKey = ((string)property.Name); + string propertiesValue = ((string)property.Value); + providerResourceTypeInstance.Properties.Add(propertiesKey, propertiesValue); + } + } + } + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Get a list of deployments. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of resource providers. + /// + public async Task ListNextAsync(string nextLink, CancellationToken cancellationToken) + { + // Validate + if (nextLink == null) + { + throw new ArgumentNullException("nextLink"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextLink", nextLink); + TracingAdapter.Enter(invocationId, this, "ListNextAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + nextLink; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ProviderListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ProviderListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + Provider providerInstance = new Provider(); + result.Providers.Add(providerInstance); + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + providerInstance.Id = idInstance; + } + + JToken namespaceValue = valueValue["namespace"]; + if (namespaceValue != null && namespaceValue.Type != JTokenType.Null) + { + string namespaceInstance = ((string)namespaceValue); + providerInstance.Namespace = namespaceInstance; + } + + JToken registrationStateValue = valueValue["registrationState"]; + if (registrationStateValue != null && registrationStateValue.Type != JTokenType.Null) + { + string registrationStateInstance = ((string)registrationStateValue); + providerInstance.RegistrationState = registrationStateInstance; + } + + JToken resourceTypesArray = valueValue["resourceTypes"]; + if (resourceTypesArray != null && resourceTypesArray.Type != JTokenType.Null) + { + foreach (JToken resourceTypesValue in ((JArray)resourceTypesArray)) + { + ProviderResourceType providerResourceTypeInstance = new ProviderResourceType(); + providerInstance.ResourceTypes.Add(providerResourceTypeInstance); + + JToken resourceTypeValue = resourceTypesValue["resourceType"]; + if (resourceTypeValue != null && resourceTypeValue.Type != JTokenType.Null) + { + string resourceTypeInstance = ((string)resourceTypeValue); + providerResourceTypeInstance.Name = resourceTypeInstance; + } + + JToken locationsArray = resourceTypesValue["locations"]; + if (locationsArray != null && locationsArray.Type != JTokenType.Null) + { + foreach (JToken locationsValue in ((JArray)locationsArray)) + { + providerResourceTypeInstance.Locations.Add(((string)locationsValue)); + } + } + + JToken apiVersionsArray = resourceTypesValue["apiVersions"]; + if (apiVersionsArray != null && apiVersionsArray.Type != JTokenType.Null) + { + foreach (JToken apiVersionsValue in ((JArray)apiVersionsArray)) + { + providerResourceTypeInstance.ApiVersions.Add(((string)apiVersionsValue)); + } + } + + JToken propertiesSequenceElement = ((JToken)resourceTypesValue["properties"]); + if (propertiesSequenceElement != null && propertiesSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in propertiesSequenceElement) + { + string propertiesKey = ((string)property.Name); + string propertiesValue = ((string)property.Value); + providerResourceTypeInstance.Properties.Add(propertiesKey, propertiesValue); + } + } + } + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Registers provider to be used with a subscription. + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Cancellation token. + /// + /// + /// Resource provider registration information. + /// + public async Task RegisterAsync(string resourceProviderNamespace, CancellationToken cancellationToken) + { + // Validate + if (resourceProviderNamespace == null) + { + throw new ArgumentNullException("resourceProviderNamespace"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + TracingAdapter.Enter(invocationId, this, "RegisterAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/providers/"; + url = url + Uri.EscapeDataString(resourceProviderNamespace); + url = url + "/register"; + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Post; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ProviderRegistionResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ProviderRegistionResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + Provider providerInstance = new Provider(); + result.Provider = providerInstance; + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + providerInstance.Id = idInstance; + } + + JToken namespaceValue = responseDoc["namespace"]; + if (namespaceValue != null && namespaceValue.Type != JTokenType.Null) + { + string namespaceInstance = ((string)namespaceValue); + providerInstance.Namespace = namespaceInstance; + } + + JToken registrationStateValue = responseDoc["registrationState"]; + if (registrationStateValue != null && registrationStateValue.Type != JTokenType.Null) + { + string registrationStateInstance = ((string)registrationStateValue); + providerInstance.RegistrationState = registrationStateInstance; + } + + JToken resourceTypesArray = responseDoc["resourceTypes"]; + if (resourceTypesArray != null && resourceTypesArray.Type != JTokenType.Null) + { + foreach (JToken resourceTypesValue in ((JArray)resourceTypesArray)) + { + ProviderResourceType providerResourceTypeInstance = new ProviderResourceType(); + providerInstance.ResourceTypes.Add(providerResourceTypeInstance); + + JToken resourceTypeValue = resourceTypesValue["resourceType"]; + if (resourceTypeValue != null && resourceTypeValue.Type != JTokenType.Null) + { + string resourceTypeInstance = ((string)resourceTypeValue); + providerResourceTypeInstance.Name = resourceTypeInstance; + } + + JToken locationsArray = resourceTypesValue["locations"]; + if (locationsArray != null && locationsArray.Type != JTokenType.Null) + { + foreach (JToken locationsValue in ((JArray)locationsArray)) + { + providerResourceTypeInstance.Locations.Add(((string)locationsValue)); + } + } + + JToken apiVersionsArray = resourceTypesValue["apiVersions"]; + if (apiVersionsArray != null && apiVersionsArray.Type != JTokenType.Null) + { + foreach (JToken apiVersionsValue in ((JArray)apiVersionsArray)) + { + providerResourceTypeInstance.ApiVersions.Add(((string)apiVersionsValue)); + } + } + + JToken propertiesSequenceElement = ((JToken)resourceTypesValue["properties"]); + if (propertiesSequenceElement != null && propertiesSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in propertiesSequenceElement) + { + string propertiesKey = ((string)property.Name); + string propertiesValue = ((string)property.Value); + providerResourceTypeInstance.Properties.Add(propertiesKey, propertiesValue); + } + } + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Unregisters provider from a subscription. + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Cancellation token. + /// + /// + /// Resource provider registration information. + /// + public async Task UnregisterAsync(string resourceProviderNamespace, CancellationToken cancellationToken) + { + // Validate + if (resourceProviderNamespace == null) + { + throw new ArgumentNullException("resourceProviderNamespace"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + TracingAdapter.Enter(invocationId, this, "UnregisterAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/providers/"; + url = url + Uri.EscapeDataString(resourceProviderNamespace); + url = url + "/unregister"; + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Post; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ProviderUnregistionResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ProviderUnregistionResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + Provider providerInstance = new Provider(); + result.Provider = providerInstance; + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + providerInstance.Id = idInstance; + } + + JToken namespaceValue = responseDoc["namespace"]; + if (namespaceValue != null && namespaceValue.Type != JTokenType.Null) + { + string namespaceInstance = ((string)namespaceValue); + providerInstance.Namespace = namespaceInstance; + } + + JToken registrationStateValue = responseDoc["registrationState"]; + if (registrationStateValue != null && registrationStateValue.Type != JTokenType.Null) + { + string registrationStateInstance = ((string)registrationStateValue); + providerInstance.RegistrationState = registrationStateInstance; + } + + JToken resourceTypesArray = responseDoc["resourceTypes"]; + if (resourceTypesArray != null && resourceTypesArray.Type != JTokenType.Null) + { + foreach (JToken resourceTypesValue in ((JArray)resourceTypesArray)) + { + ProviderResourceType providerResourceTypeInstance = new ProviderResourceType(); + providerInstance.ResourceTypes.Add(providerResourceTypeInstance); + + JToken resourceTypeValue = resourceTypesValue["resourceType"]; + if (resourceTypeValue != null && resourceTypeValue.Type != JTokenType.Null) + { + string resourceTypeInstance = ((string)resourceTypeValue); + providerResourceTypeInstance.Name = resourceTypeInstance; + } + + JToken locationsArray = resourceTypesValue["locations"]; + if (locationsArray != null && locationsArray.Type != JTokenType.Null) + { + foreach (JToken locationsValue in ((JArray)locationsArray)) + { + providerResourceTypeInstance.Locations.Add(((string)locationsValue)); + } + } + + JToken apiVersionsArray = resourceTypesValue["apiVersions"]; + if (apiVersionsArray != null && apiVersionsArray.Type != JTokenType.Null) + { + foreach (JToken apiVersionsValue in ((JArray)apiVersionsArray)) + { + providerResourceTypeInstance.ApiVersions.Add(((string)apiVersionsValue)); + } + } + + JToken propertiesSequenceElement = ((JToken)resourceTypesValue["properties"]); + if (propertiesSequenceElement != null && propertiesSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in propertiesSequenceElement) + { + string propertiesKey = ((string)property.Name); + string propertiesValue = ((string)property.Value); + providerResourceTypeInstance.Properties.Add(propertiesKey, propertiesValue); + } + } + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ProviderOperationsExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ProviderOperationsExtensions.cs new file mode 100644 index 000000000000..2852a1540c58 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ProviderOperationsExtensions.cs @@ -0,0 +1,234 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public static partial class ProviderOperationsExtensions + { + /// + /// Gets a resource provider. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IProviderOperations. + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Resource provider information. + /// + public static ProviderGetResult Get(this IProviderOperations operations, string resourceProviderNamespace) + { + return Task.Factory.StartNew((object s) => + { + return ((IProviderOperations)s).GetAsync(resourceProviderNamespace); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets a resource provider. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IProviderOperations. + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Resource provider information. + /// + public static Task GetAsync(this IProviderOperations operations, string resourceProviderNamespace) + { + return operations.GetAsync(resourceProviderNamespace, CancellationToken.None); + } + + /// + /// Gets a list of resource providers. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IProviderOperations. + /// + /// + /// Optional. Query parameters. If null is passed returns all + /// deployments. + /// + /// + /// List of resource providers. + /// + public static ProviderListResult List(this IProviderOperations operations, ProviderListParameters parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IProviderOperations)s).ListAsync(parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets a list of resource providers. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IProviderOperations. + /// + /// + /// Optional. Query parameters. If null is passed returns all + /// deployments. + /// + /// + /// List of resource providers. + /// + public static Task ListAsync(this IProviderOperations operations, ProviderListParameters parameters) + { + return operations.ListAsync(parameters, CancellationToken.None); + } + + /// + /// Get a list of deployments. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IProviderOperations. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of resource providers. + /// + public static ProviderListResult ListNext(this IProviderOperations operations, string nextLink) + { + return Task.Factory.StartNew((object s) => + { + return ((IProviderOperations)s).ListNextAsync(nextLink); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get a list of deployments. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IProviderOperations. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of resource providers. + /// + public static Task ListNextAsync(this IProviderOperations operations, string nextLink) + { + return operations.ListNextAsync(nextLink, CancellationToken.None); + } + + /// + /// Registers provider to be used with a subscription. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IProviderOperations. + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Resource provider registration information. + /// + public static ProviderRegistionResult Register(this IProviderOperations operations, string resourceProviderNamespace) + { + return Task.Factory.StartNew((object s) => + { + return ((IProviderOperations)s).RegisterAsync(resourceProviderNamespace); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Registers provider to be used with a subscription. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IProviderOperations. + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Resource provider registration information. + /// + public static Task RegisterAsync(this IProviderOperations operations, string resourceProviderNamespace) + { + return operations.RegisterAsync(resourceProviderNamespace, CancellationToken.None); + } + + /// + /// Unregisters provider from a subscription. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IProviderOperations. + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Resource provider registration information. + /// + public static ProviderUnregistionResult Unregister(this IProviderOperations operations, string resourceProviderNamespace) + { + return Task.Factory.StartNew((object s) => + { + return ((IProviderOperations)s).UnregisterAsync(resourceProviderNamespace); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Unregisters provider from a subscription. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IProviderOperations. + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Resource provider registration information. + /// + public static Task UnregisterAsync(this IProviderOperations operations, string resourceProviderNamespace) + { + return operations.UnregisterAsync(resourceProviderNamespace, CancellationToken.None); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ProviderOperationsMetadataOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ProviderOperationsMetadataOperations.cs new file mode 100644 index 000000000000..1813cc0b7e69 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ProviderOperationsMetadataOperations.cs @@ -0,0 +1,635 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Hyak.Common; +using Microsoft.Azure.Management.Internal.Resources.Models; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for getting provider operations metadata. + /// + internal partial class ProviderOperationsMetadataOperations : IServiceOperations, IProviderOperationsMetadataOperations + { + /// + /// Initializes a new instance of the + /// ProviderOperationsMetadataOperations class. + /// + /// + /// Reference to the service client. + /// + internal ProviderOperationsMetadataOperations(ResourceManagementClient client) + { + this._client = client; + } + + private ResourceManagementClient _client; + + /// + /// Gets a reference to the + /// Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient. + /// + public ResourceManagementClient Client + { + get { return this._client; } + } + + /// + /// Gets provider operations metadata + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Cancellation token. + /// + /// + /// Provider operations metadata + /// + public async Task GetAsync(string resourceProviderNamespace, CancellationToken cancellationToken) + { + // Validate + if (resourceProviderNamespace == null) + { + throw new ArgumentNullException("resourceProviderNamespace"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceProviderNamespace", resourceProviderNamespace); + TracingAdapter.Enter(invocationId, this, "GetAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/providers/Microsoft.Authorization/providerOperations/"; + url = url + Uri.EscapeDataString(resourceProviderNamespace); + List queryParameters = new List(); + queryParameters.Add("api-version=2015-07-01"); + queryParameters.Add("$expand=resourceTypes"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ProviderOperationsMetadataGetResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ProviderOperationsMetadataGetResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + ProviderOperationsMetadata providerInstance = new ProviderOperationsMetadata(); + result.Provider = providerInstance; + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + providerInstance.Id = idInstance; + } + + JToken nameValue = responseDoc["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + providerInstance.Name = nameInstance; + } + + JToken typeValue = responseDoc["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + providerInstance.Type = typeInstance; + } + + JToken displayNameValue = responseDoc["displayName"]; + if (displayNameValue != null && displayNameValue.Type != JTokenType.Null) + { + string displayNameInstance = ((string)displayNameValue); + providerInstance.DisplayName = displayNameInstance; + } + + JToken resourceTypesArray = responseDoc["resourceTypes"]; + if (resourceTypesArray != null && resourceTypesArray.Type != JTokenType.Null) + { + foreach (JToken resourceTypesValue in ((JArray)resourceTypesArray)) + { + ResourceType resourceTypeInstance = new ResourceType(); + providerInstance.ResourceTypes.Add(resourceTypeInstance); + + JToken nameValue2 = resourceTypesValue["name"]; + if (nameValue2 != null && nameValue2.Type != JTokenType.Null) + { + string nameInstance2 = ((string)nameValue2); + resourceTypeInstance.Name = nameInstance2; + } + + JToken displayNameValue2 = resourceTypesValue["displayName"]; + if (displayNameValue2 != null && displayNameValue2.Type != JTokenType.Null) + { + string displayNameInstance2 = ((string)displayNameValue2); + resourceTypeInstance.DisplayName = displayNameInstance2; + } + + JToken operationsArray = resourceTypesValue["operations"]; + if (operationsArray != null && operationsArray.Type != JTokenType.Null) + { + foreach (JToken operationsValue in ((JArray)operationsArray)) + { + Operation operationInstance = new Operation(); + resourceTypeInstance.Operations.Add(operationInstance); + + JToken nameValue3 = operationsValue["name"]; + if (nameValue3 != null && nameValue3.Type != JTokenType.Null) + { + string nameInstance3 = ((string)nameValue3); + operationInstance.Name = nameInstance3; + } + + JToken displayNameValue3 = operationsValue["displayName"]; + if (displayNameValue3 != null && displayNameValue3.Type != JTokenType.Null) + { + string displayNameInstance3 = ((string)displayNameValue3); + operationInstance.DisplayName = displayNameInstance3; + } + + JToken descriptionValue = operationsValue["description"]; + if (descriptionValue != null && descriptionValue.Type != JTokenType.Null) + { + string descriptionInstance = ((string)descriptionValue); + operationInstance.Description = descriptionInstance; + } + + JToken originValue = operationsValue["origin"]; + if (originValue != null && originValue.Type != JTokenType.Null) + { + string originInstance = ((string)originValue); + operationInstance.Origin = originInstance; + } + + JToken propertiesValue = operationsValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + object propertiesInstance = propertiesValue.ToString(Newtonsoft.Json.Formatting.Indented); + operationInstance.Properties = propertiesInstance; + } + } + } + } + } + + JToken operationsArray2 = responseDoc["operations"]; + if (operationsArray2 != null && operationsArray2.Type != JTokenType.Null) + { + foreach (JToken operationsValue2 in ((JArray)operationsArray2)) + { + Operation operationInstance2 = new Operation(); + providerInstance.Operations.Add(operationInstance2); + + JToken nameValue4 = operationsValue2["name"]; + if (nameValue4 != null && nameValue4.Type != JTokenType.Null) + { + string nameInstance4 = ((string)nameValue4); + operationInstance2.Name = nameInstance4; + } + + JToken displayNameValue4 = operationsValue2["displayName"]; + if (displayNameValue4 != null && displayNameValue4.Type != JTokenType.Null) + { + string displayNameInstance4 = ((string)displayNameValue4); + operationInstance2.DisplayName = displayNameInstance4; + } + + JToken descriptionValue2 = operationsValue2["description"]; + if (descriptionValue2 != null && descriptionValue2.Type != JTokenType.Null) + { + string descriptionInstance2 = ((string)descriptionValue2); + operationInstance2.Description = descriptionInstance2; + } + + JToken originValue2 = operationsValue2["origin"]; + if (originValue2 != null && originValue2.Type != JTokenType.Null) + { + string originInstance2 = ((string)originValue2); + operationInstance2.Origin = originInstance2; + } + + JToken propertiesValue2 = operationsValue2["properties"]; + if (propertiesValue2 != null && propertiesValue2.Type != JTokenType.Null) + { + object propertiesInstance2 = propertiesValue2.ToString(Newtonsoft.Json.Formatting.Indented); + operationInstance2.Properties = propertiesInstance2; + } + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Gets provider operations metadata list + /// + /// + /// Cancellation token. + /// + /// + /// Provider operations metadata list + /// + public async Task ListAsync(CancellationToken cancellationToken) + { + // Validate + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + TracingAdapter.Enter(invocationId, this, "ListAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/providers/Microsoft.Authorization/providerOperations"; + List queryParameters = new List(); + queryParameters.Add("api-version=2015-07-01"); + queryParameters.Add("$expand=resourceTypes"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ProviderOperationsMetadataListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ProviderOperationsMetadataListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + ProviderOperationsMetadata providerOperationsMetadataInstance = new ProviderOperationsMetadata(); + result.Providers.Add(providerOperationsMetadataInstance); + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + providerOperationsMetadataInstance.Id = idInstance; + } + + JToken nameValue = valueValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + providerOperationsMetadataInstance.Name = nameInstance; + } + + JToken typeValue = valueValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + providerOperationsMetadataInstance.Type = typeInstance; + } + + JToken displayNameValue = valueValue["displayName"]; + if (displayNameValue != null && displayNameValue.Type != JTokenType.Null) + { + string displayNameInstance = ((string)displayNameValue); + providerOperationsMetadataInstance.DisplayName = displayNameInstance; + } + + JToken resourceTypesArray = valueValue["resourceTypes"]; + if (resourceTypesArray != null && resourceTypesArray.Type != JTokenType.Null) + { + foreach (JToken resourceTypesValue in ((JArray)resourceTypesArray)) + { + ResourceType resourceTypeInstance = new ResourceType(); + providerOperationsMetadataInstance.ResourceTypes.Add(resourceTypeInstance); + + JToken nameValue2 = resourceTypesValue["name"]; + if (nameValue2 != null && nameValue2.Type != JTokenType.Null) + { + string nameInstance2 = ((string)nameValue2); + resourceTypeInstance.Name = nameInstance2; + } + + JToken displayNameValue2 = resourceTypesValue["displayName"]; + if (displayNameValue2 != null && displayNameValue2.Type != JTokenType.Null) + { + string displayNameInstance2 = ((string)displayNameValue2); + resourceTypeInstance.DisplayName = displayNameInstance2; + } + + JToken operationsArray = resourceTypesValue["operations"]; + if (operationsArray != null && operationsArray.Type != JTokenType.Null) + { + foreach (JToken operationsValue in ((JArray)operationsArray)) + { + Operation operationInstance = new Operation(); + resourceTypeInstance.Operations.Add(operationInstance); + + JToken nameValue3 = operationsValue["name"]; + if (nameValue3 != null && nameValue3.Type != JTokenType.Null) + { + string nameInstance3 = ((string)nameValue3); + operationInstance.Name = nameInstance3; + } + + JToken displayNameValue3 = operationsValue["displayName"]; + if (displayNameValue3 != null && displayNameValue3.Type != JTokenType.Null) + { + string displayNameInstance3 = ((string)displayNameValue3); + operationInstance.DisplayName = displayNameInstance3; + } + + JToken descriptionValue = operationsValue["description"]; + if (descriptionValue != null && descriptionValue.Type != JTokenType.Null) + { + string descriptionInstance = ((string)descriptionValue); + operationInstance.Description = descriptionInstance; + } + + JToken originValue = operationsValue["origin"]; + if (originValue != null && originValue.Type != JTokenType.Null) + { + string originInstance = ((string)originValue); + operationInstance.Origin = originInstance; + } + + JToken propertiesValue = operationsValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + object propertiesInstance = propertiesValue.ToString(Newtonsoft.Json.Formatting.Indented); + operationInstance.Properties = propertiesInstance; + } + } + } + } + } + + JToken operationsArray2 = valueValue["operations"]; + if (operationsArray2 != null && operationsArray2.Type != JTokenType.Null) + { + foreach (JToken operationsValue2 in ((JArray)operationsArray2)) + { + Operation operationInstance2 = new Operation(); + providerOperationsMetadataInstance.Operations.Add(operationInstance2); + + JToken nameValue4 = operationsValue2["name"]; + if (nameValue4 != null && nameValue4.Type != JTokenType.Null) + { + string nameInstance4 = ((string)nameValue4); + operationInstance2.Name = nameInstance4; + } + + JToken displayNameValue4 = operationsValue2["displayName"]; + if (displayNameValue4 != null && displayNameValue4.Type != JTokenType.Null) + { + string displayNameInstance4 = ((string)displayNameValue4); + operationInstance2.DisplayName = displayNameInstance4; + } + + JToken descriptionValue2 = operationsValue2["description"]; + if (descriptionValue2 != null && descriptionValue2.Type != JTokenType.Null) + { + string descriptionInstance2 = ((string)descriptionValue2); + operationInstance2.Description = descriptionInstance2; + } + + JToken originValue2 = operationsValue2["origin"]; + if (originValue2 != null && originValue2.Type != JTokenType.Null) + { + string originInstance2 = ((string)originValue2); + operationInstance2.Origin = originInstance2; + } + + JToken propertiesValue2 = operationsValue2["properties"]; + if (propertiesValue2 != null && propertiesValue2.Type != JTokenType.Null) + { + object propertiesInstance2 = propertiesValue2.ToString(Newtonsoft.Json.Formatting.Indented); + operationInstance2.Properties = propertiesInstance2; + } + } + } + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ProviderOperationsMetadataOperationsExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ProviderOperationsMetadataOperationsExtensions.cs new file mode 100644 index 000000000000..827ff4499ebf --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ProviderOperationsMetadataOperationsExtensions.cs @@ -0,0 +1,104 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public static partial class ProviderOperationsMetadataOperationsExtensions + { + /// + /// Gets provider operations metadata + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IProviderOperationsMetadataOperations. + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Provider operations metadata + /// + public static ProviderOperationsMetadataGetResult Get(this IProviderOperationsMetadataOperations operations, string resourceProviderNamespace) + { + return Task.Factory.StartNew((object s) => + { + return ((IProviderOperationsMetadataOperations)s).GetAsync(resourceProviderNamespace); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets provider operations metadata + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IProviderOperationsMetadataOperations. + /// + /// + /// Required. Namespace of the resource provider. + /// + /// + /// Provider operations metadata + /// + public static Task GetAsync(this IProviderOperationsMetadataOperations operations, string resourceProviderNamespace) + { + return operations.GetAsync(resourceProviderNamespace, CancellationToken.None); + } + + /// + /// Gets provider operations metadata list + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IProviderOperationsMetadataOperations. + /// + /// + /// Provider operations metadata list + /// + public static ProviderOperationsMetadataListResult List(this IProviderOperationsMetadataOperations operations) + { + return Task.Factory.StartNew((object s) => + { + return ((IProviderOperationsMetadataOperations)s).ListAsync(); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets provider operations metadata list + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IProviderOperationsMetadataOperations. + /// + /// + /// Provider operations metadata list + /// + public static Task ListAsync(this IProviderOperationsMetadataOperations operations) + { + return operations.ListAsync(CancellationToken.None); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceGroupOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceGroupOperations.cs new file mode 100644 index 000000000000..41d7670542ab --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceGroupOperations.cs @@ -0,0 +1,1615 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using Hyak.Common; +using Microsoft.Azure.Management.Internal.Resources.Models; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing resource groups. + /// + internal partial class ResourceGroupOperations : IServiceOperations, IResourceGroupOperations + { + /// + /// Initializes a new instance of the ResourceGroupOperations class. + /// + /// + /// Reference to the service client. + /// + internal ResourceGroupOperations(ResourceManagementClient client) + { + this._client = client; + } + + private ResourceManagementClient _client; + + /// + /// Gets a reference to the + /// Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient. + /// + public ResourceManagementClient Client + { + get { return this._client; } + } + + /// + /// Begin deleting resource group.To determine whether the operation + /// has finished processing the request, call + /// GetLongRunningOperationStatus. + /// + /// + /// Required. The name of the resource group to be deleted. The name is + /// case insensitive. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response for long running operations. + /// + public async Task BeginDeletingAsync(string resourceGroupName, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + TracingAdapter.Enter(invocationId, this, "BeginDeletingAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Delete; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.Accepted) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + LongRunningOperationResponse result = null; + // Deserialize Response + result = new LongRunningOperationResponse(); + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("Location")) + { + result.OperationStatusLink = httpResponse.Headers.GetValues("Location").FirstOrDefault(); + } + if (httpResponse.Headers.Contains("Retry-After")) + { + result.RetryAfter = int.Parse(httpResponse.Headers.GetValues("Retry-After").FirstOrDefault(), CultureInfo.InvariantCulture); + } + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (statusCode == HttpStatusCode.Conflict) + { + result.Status = OperationStatus.Failed; + } + if (statusCode == HttpStatusCode.OK) + { + result.Status = OperationStatus.Succeeded; + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Checks whether resource group exists. + /// + /// + /// Required. The name of the resource group to check. The name is case + /// insensitive. + /// + /// + /// Cancellation token. + /// + /// + /// Resource group information. + /// + public async Task CheckExistenceAsync(string resourceGroupName, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + TracingAdapter.Enter(invocationId, this, "CheckExistenceAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Head; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.NoContent && statusCode != HttpStatusCode.NotFound) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ResourceGroupExistsResult result = null; + // Deserialize Response + result = new ResourceGroupExistsResult(); + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (statusCode == HttpStatusCode.NoContent) + { + result.Exists = true; + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Create a resource group. + /// + /// + /// Required. The name of the resource group to be created or updated. + /// + /// + /// Required. Parameters supplied to the create or update resource + /// group service operation. + /// + /// + /// Cancellation token. + /// + /// + /// Resource group information. + /// + public async Task CreateOrUpdateAsync(string resourceGroupName, ResourceGroup parameters, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (parameters == null) + { + throw new ArgumentNullException("parameters"); + } + if (parameters.Location == null) + { + throw new ArgumentNullException("parameters.Location"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "CreateOrUpdateAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Put; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Serialize Request + string requestContent = null; + JToken requestDoc = null; + + JObject resourceGroupValue = new JObject(); + requestDoc = resourceGroupValue; + + resourceGroupValue["location"] = parameters.Location; + + if (parameters.Properties != null) + { + resourceGroupValue["properties"] = JObject.Parse(parameters.Properties); + } + + if (parameters.Tags != null) + { + if (parameters.Tags is ILazyCollection == false || ((ILazyCollection)parameters.Tags).IsInitialized) + { + JObject tagsDictionary = new JObject(); + foreach (KeyValuePair pair in parameters.Tags) + { + string tagsKey = pair.Key; + string tagsValue = pair.Value; + tagsDictionary[tagsKey] = tagsValue; + } + resourceGroupValue["tags"] = tagsDictionary; + } + } + + if (parameters.ProvisioningState != null) + { + resourceGroupValue["provisioningState"] = parameters.ProvisioningState; + } + + requestContent = requestDoc.ToString(Newtonsoft.Json.Formatting.Indented); + httpRequest.Content = new StringContent(requestContent, Encoding.UTF8); + httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.Created) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, requestContent, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ResourceGroupCreateOrUpdateResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.Created) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ResourceGroupCreateOrUpdateResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + ResourceGroupExtended resourceGroupInstance = new ResourceGroupExtended(); + result.ResourceGroup = resourceGroupInstance; + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + resourceGroupInstance.Id = idInstance; + } + + JToken nameValue = responseDoc["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + resourceGroupInstance.Name = nameInstance; + } + + JToken propertiesValue = responseDoc["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + JToken provisioningStateValue = propertiesValue["provisioningState"]; + if (provisioningStateValue != null && provisioningStateValue.Type != JTokenType.Null) + { + string provisioningStateInstance = ((string)provisioningStateValue); + resourceGroupInstance.ProvisioningState = provisioningStateInstance; + } + } + + JToken locationValue = responseDoc["location"]; + if (locationValue != null && locationValue.Type != JTokenType.Null) + { + string locationInstance = ((string)locationValue); + resourceGroupInstance.Location = locationInstance; + } + + JToken propertiesValue2 = responseDoc["properties"]; + if (propertiesValue2 != null && propertiesValue2.Type != JTokenType.Null) + { + string propertiesInstance = propertiesValue2.ToString(Newtonsoft.Json.Formatting.Indented); + resourceGroupInstance.Properties = propertiesInstance; + } + + JToken tagsSequenceElement = ((JToken)responseDoc["tags"]); + if (tagsSequenceElement != null && tagsSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in tagsSequenceElement) + { + string tagsKey2 = ((string)property.Name); + string tagsValue2 = ((string)property.Value); + resourceGroupInstance.Tags.Add(tagsKey2, tagsValue2); + } + } + + JToken provisioningStateValue2 = responseDoc["provisioningState"]; + if (provisioningStateValue2 != null && provisioningStateValue2.Type != JTokenType.Null) + { + string provisioningStateInstance2 = ((string)provisioningStateValue2); + resourceGroupInstance.ProvisioningState = provisioningStateInstance2; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Delete resource group and all of its resources. + /// + /// + /// Required. The name of the resource group to be deleted. The name is + /// case insensitive. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public async Task DeleteAsync(string resourceGroupName, CancellationToken cancellationToken) + { + ResourceManagementClient client = this.Client; + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + TracingAdapter.Enter(invocationId, this, "DeleteAsync", tracingParameters); + } + + cancellationToken.ThrowIfCancellationRequested(); + LongRunningOperationResponse response = await client.ResourceGroups.BeginDeletingAsync(resourceGroupName, cancellationToken).ConfigureAwait(false); + cancellationToken.ThrowIfCancellationRequested(); + LongRunningOperationResponse result = await client.GetLongRunningOperationStatusAsync(response.OperationStatusLink, cancellationToken).ConfigureAwait(false); + int delayInSeconds = response.RetryAfter; + if (delayInSeconds == 0) + { + delayInSeconds = 30; + } + if (client.LongRunningOperationInitialTimeout >= 0) + { + delayInSeconds = client.LongRunningOperationInitialTimeout; + } + while ((result.Status != Microsoft.Azure.OperationStatus.InProgress) == false) + { + cancellationToken.ThrowIfCancellationRequested(); + await TaskEx.Delay(delayInSeconds * 1000, cancellationToken).ConfigureAwait(false); + cancellationToken.ThrowIfCancellationRequested(); + result = await client.GetLongRunningOperationStatusAsync(response.OperationStatusLink, cancellationToken).ConfigureAwait(false); + delayInSeconds = result.RetryAfter; + if (delayInSeconds == 0) + { + delayInSeconds = 15; + } + if (client.LongRunningOperationRetryTimeout >= 0) + { + delayInSeconds = client.LongRunningOperationRetryTimeout; + } + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + + return result; + } + + /// + /// Get a resource group. + /// + /// + /// Required. The name of the resource group to get. The name is case + /// insensitive. + /// + /// + /// Cancellation token. + /// + /// + /// Resource group information. + /// + public async Task GetAsync(string resourceGroupName, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + TracingAdapter.Enter(invocationId, this, "GetAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ResourceGroupGetResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ResourceGroupGetResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + ResourceGroupExtended resourceGroupInstance = new ResourceGroupExtended(); + result.ResourceGroup = resourceGroupInstance; + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + resourceGroupInstance.Id = idInstance; + } + + JToken nameValue = responseDoc["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + resourceGroupInstance.Name = nameInstance; + } + + JToken propertiesValue = responseDoc["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + JToken provisioningStateValue = propertiesValue["provisioningState"]; + if (provisioningStateValue != null && provisioningStateValue.Type != JTokenType.Null) + { + string provisioningStateInstance = ((string)provisioningStateValue); + resourceGroupInstance.ProvisioningState = provisioningStateInstance; + } + } + + JToken locationValue = responseDoc["location"]; + if (locationValue != null && locationValue.Type != JTokenType.Null) + { + string locationInstance = ((string)locationValue); + resourceGroupInstance.Location = locationInstance; + } + + JToken propertiesValue2 = responseDoc["properties"]; + if (propertiesValue2 != null && propertiesValue2.Type != JTokenType.Null) + { + string propertiesInstance = propertiesValue2.ToString(Newtonsoft.Json.Formatting.Indented); + resourceGroupInstance.Properties = propertiesInstance; + } + + JToken tagsSequenceElement = ((JToken)responseDoc["tags"]); + if (tagsSequenceElement != null && tagsSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in tagsSequenceElement) + { + string tagsKey = ((string)property.Name); + string tagsValue = ((string)property.Value); + resourceGroupInstance.Tags.Add(tagsKey, tagsValue); + } + } + + JToken provisioningStateValue2 = responseDoc["provisioningState"]; + if (provisioningStateValue2 != null && provisioningStateValue2.Type != JTokenType.Null) + { + string provisioningStateInstance2 = ((string)provisioningStateValue2); + resourceGroupInstance.ProvisioningState = provisioningStateInstance2; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Gets a collection of resource groups. + /// + /// + /// Optional. Query parameters. If null is passed returns all resource + /// groups. + /// + /// + /// Cancellation token. + /// + /// + /// List of resource groups. + /// + public async Task ListAsync(ResourceGroupListParameters parameters, CancellationToken cancellationToken) + { + // Validate + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "ListAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups"; + List queryParameters = new List(); + List odataFilter = new List(); + if (parameters != null && parameters.TagName != null) + { + odataFilter.Add("tagname eq '" + Uri.EscapeDataString(parameters.TagName) + "'"); + } + if (parameters != null && parameters.TagValue != null) + { + odataFilter.Add("tagvalue eq '" + Uri.EscapeDataString(parameters.TagValue) + "'"); + } + if (odataFilter.Count > 0) + { + queryParameters.Add("$filter=" + string.Join(" and ", odataFilter)); + } + if (parameters != null && parameters.Top != null) + { + queryParameters.Add("$top=" + Uri.EscapeDataString(parameters.Top.Value.ToString())); + } + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ResourceGroupListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ResourceGroupListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + ResourceGroupExtended resourceGroupJsonFormatInstance = new ResourceGroupExtended(); + result.ResourceGroups.Add(resourceGroupJsonFormatInstance); + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + resourceGroupJsonFormatInstance.Id = idInstance; + } + + JToken nameValue = valueValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + resourceGroupJsonFormatInstance.Name = nameInstance; + } + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + JToken provisioningStateValue = propertiesValue["provisioningState"]; + if (provisioningStateValue != null && provisioningStateValue.Type != JTokenType.Null) + { + string provisioningStateInstance = ((string)provisioningStateValue); + resourceGroupJsonFormatInstance.ProvisioningState = provisioningStateInstance; + } + } + + JToken locationValue = valueValue["location"]; + if (locationValue != null && locationValue.Type != JTokenType.Null) + { + string locationInstance = ((string)locationValue); + resourceGroupJsonFormatInstance.Location = locationInstance; + } + + JToken propertiesValue2 = valueValue["properties"]; + if (propertiesValue2 != null && propertiesValue2.Type != JTokenType.Null) + { + string propertiesInstance = propertiesValue2.ToString(Newtonsoft.Json.Formatting.Indented); + resourceGroupJsonFormatInstance.Properties = propertiesInstance; + } + + JToken tagsSequenceElement = ((JToken)valueValue["tags"]); + if (tagsSequenceElement != null && tagsSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in tagsSequenceElement) + { + string tagsKey = ((string)property.Name); + string tagsValue = ((string)property.Value); + resourceGroupJsonFormatInstance.Tags.Add(tagsKey, tagsValue); + } + } + + JToken provisioningStateValue2 = valueValue["provisioningState"]; + if (provisioningStateValue2 != null && provisioningStateValue2.Type != JTokenType.Null) + { + string provisioningStateInstance2 = ((string)provisioningStateValue2); + resourceGroupJsonFormatInstance.ProvisioningState = provisioningStateInstance2; + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Get a list of deployments. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of resource groups. + /// + public async Task ListNextAsync(string nextLink, CancellationToken cancellationToken) + { + // Validate + if (nextLink == null) + { + throw new ArgumentNullException("nextLink"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextLink", nextLink); + TracingAdapter.Enter(invocationId, this, "ListNextAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + nextLink; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ResourceGroupListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ResourceGroupListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + ResourceGroupExtended resourceGroupJsonFormatInstance = new ResourceGroupExtended(); + result.ResourceGroups.Add(resourceGroupJsonFormatInstance); + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + resourceGroupJsonFormatInstance.Id = idInstance; + } + + JToken nameValue = valueValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + resourceGroupJsonFormatInstance.Name = nameInstance; + } + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + JToken provisioningStateValue = propertiesValue["provisioningState"]; + if (provisioningStateValue != null && provisioningStateValue.Type != JTokenType.Null) + { + string provisioningStateInstance = ((string)provisioningStateValue); + resourceGroupJsonFormatInstance.ProvisioningState = provisioningStateInstance; + } + } + + JToken locationValue = valueValue["location"]; + if (locationValue != null && locationValue.Type != JTokenType.Null) + { + string locationInstance = ((string)locationValue); + resourceGroupJsonFormatInstance.Location = locationInstance; + } + + JToken propertiesValue2 = valueValue["properties"]; + if (propertiesValue2 != null && propertiesValue2.Type != JTokenType.Null) + { + string propertiesInstance = propertiesValue2.ToString(Newtonsoft.Json.Formatting.Indented); + resourceGroupJsonFormatInstance.Properties = propertiesInstance; + } + + JToken tagsSequenceElement = ((JToken)valueValue["tags"]); + if (tagsSequenceElement != null && tagsSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in tagsSequenceElement) + { + string tagsKey = ((string)property.Name); + string tagsValue = ((string)property.Value); + resourceGroupJsonFormatInstance.Tags.Add(tagsKey, tagsValue); + } + } + + JToken provisioningStateValue2 = valueValue["provisioningState"]; + if (provisioningStateValue2 != null && provisioningStateValue2.Type != JTokenType.Null) + { + string provisioningStateInstance2 = ((string)provisioningStateValue2); + resourceGroupJsonFormatInstance.ProvisioningState = provisioningStateInstance2; + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Resource groups can be updated through a simple PATCH operation to + /// a group address. The format of the request is the same as that for + /// creating a resource groups, though if a field is unspecified + /// current value will be carried over. + /// + /// + /// Required. The name of the resource group to be created or updated. + /// The name is case insensitive. + /// + /// + /// Required. Parameters supplied to the update state resource group + /// service operation. + /// + /// + /// Cancellation token. + /// + /// + /// Resource group information. + /// + public async Task PatchAsync(string resourceGroupName, ResourceGroup parameters, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (parameters == null) + { + throw new ArgumentNullException("parameters"); + } + if (parameters.Location == null) + { + throw new ArgumentNullException("parameters.Location"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "PatchAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = new HttpMethod("PATCH"); + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Serialize Request + string requestContent = null; + JToken requestDoc = null; + + JObject resourceGroupValue = new JObject(); + requestDoc = resourceGroupValue; + + resourceGroupValue["location"] = parameters.Location; + + if (parameters.Properties != null) + { + resourceGroupValue["properties"] = JObject.Parse(parameters.Properties); + } + + if (parameters.Tags != null) + { + if (parameters.Tags is ILazyCollection == false || ((ILazyCollection)parameters.Tags).IsInitialized) + { + JObject tagsDictionary = new JObject(); + foreach (KeyValuePair pair in parameters.Tags) + { + string tagsKey = pair.Key; + string tagsValue = pair.Value; + tagsDictionary[tagsKey] = tagsValue; + } + resourceGroupValue["tags"] = tagsDictionary; + } + } + + if (parameters.ProvisioningState != null) + { + resourceGroupValue["provisioningState"] = parameters.ProvisioningState; + } + + requestContent = requestDoc.ToString(Newtonsoft.Json.Formatting.Indented); + httpRequest.Content = new StringContent(requestContent, Encoding.UTF8); + httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, requestContent, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ResourceGroupPatchResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ResourceGroupPatchResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + ResourceGroupExtended resourceGroupInstance = new ResourceGroupExtended(); + result.ResourceGroup = resourceGroupInstance; + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + resourceGroupInstance.Id = idInstance; + } + + JToken nameValue = responseDoc["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + resourceGroupInstance.Name = nameInstance; + } + + JToken propertiesValue = responseDoc["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + JToken provisioningStateValue = propertiesValue["provisioningState"]; + if (provisioningStateValue != null && provisioningStateValue.Type != JTokenType.Null) + { + string provisioningStateInstance = ((string)provisioningStateValue); + resourceGroupInstance.ProvisioningState = provisioningStateInstance; + } + } + + JToken locationValue = responseDoc["location"]; + if (locationValue != null && locationValue.Type != JTokenType.Null) + { + string locationInstance = ((string)locationValue); + resourceGroupInstance.Location = locationInstance; + } + + JToken propertiesValue2 = responseDoc["properties"]; + if (propertiesValue2 != null && propertiesValue2.Type != JTokenType.Null) + { + string propertiesInstance = propertiesValue2.ToString(Newtonsoft.Json.Formatting.Indented); + resourceGroupInstance.Properties = propertiesInstance; + } + + JToken tagsSequenceElement = ((JToken)responseDoc["tags"]); + if (tagsSequenceElement != null && tagsSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in tagsSequenceElement) + { + string tagsKey2 = ((string)property.Name); + string tagsValue2 = ((string)property.Value); + resourceGroupInstance.Tags.Add(tagsKey2, tagsValue2); + } + } + + JToken provisioningStateValue2 = responseDoc["provisioningState"]; + if (provisioningStateValue2 != null && provisioningStateValue2.Type != JTokenType.Null) + { + string provisioningStateInstance2 = ((string)provisioningStateValue2); + resourceGroupInstance.ProvisioningState = provisioningStateInstance2; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceGroupOperationsExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceGroupOperationsExtensions.cs new file mode 100644 index 000000000000..2d8d914d3512 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceGroupOperationsExtensions.cs @@ -0,0 +1,392 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public static partial class ResourceGroupOperationsExtensions + { + /// + /// Begin deleting resource group.To determine whether the operation + /// has finished processing the request, call + /// GetLongRunningOperationStatus. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceGroupOperations. + /// + /// + /// Required. The name of the resource group to be deleted. The name is + /// case insensitive. + /// + /// + /// A standard service response for long running operations. + /// + public static LongRunningOperationResponse BeginDeleting(this IResourceGroupOperations operations, string resourceGroupName) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceGroupOperations)s).BeginDeletingAsync(resourceGroupName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Begin deleting resource group.To determine whether the operation + /// has finished processing the request, call + /// GetLongRunningOperationStatus. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceGroupOperations. + /// + /// + /// Required. The name of the resource group to be deleted. The name is + /// case insensitive. + /// + /// + /// A standard service response for long running operations. + /// + public static Task BeginDeletingAsync(this IResourceGroupOperations operations, string resourceGroupName) + { + return operations.BeginDeletingAsync(resourceGroupName, CancellationToken.None); + } + + /// + /// Checks whether resource group exists. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceGroupOperations. + /// + /// + /// Required. The name of the resource group to check. The name is case + /// insensitive. + /// + /// + /// Resource group information. + /// + public static ResourceGroupExistsResult CheckExistence(this IResourceGroupOperations operations, string resourceGroupName) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceGroupOperations)s).CheckExistenceAsync(resourceGroupName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Checks whether resource group exists. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceGroupOperations. + /// + /// + /// Required. The name of the resource group to check. The name is case + /// insensitive. + /// + /// + /// Resource group information. + /// + public static Task CheckExistenceAsync(this IResourceGroupOperations operations, string resourceGroupName) + { + return operations.CheckExistenceAsync(resourceGroupName, CancellationToken.None); + } + + /// + /// Create a resource group. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceGroupOperations. + /// + /// + /// Required. The name of the resource group to be created or updated. + /// + /// + /// Required. Parameters supplied to the create or update resource + /// group service operation. + /// + /// + /// Resource group information. + /// + public static ResourceGroupCreateOrUpdateResult CreateOrUpdate(this IResourceGroupOperations operations, string resourceGroupName, ResourceGroup parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceGroupOperations)s).CreateOrUpdateAsync(resourceGroupName, parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Create a resource group. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceGroupOperations. + /// + /// + /// Required. The name of the resource group to be created or updated. + /// + /// + /// Required. Parameters supplied to the create or update resource + /// group service operation. + /// + /// + /// Resource group information. + /// + public static Task CreateOrUpdateAsync(this IResourceGroupOperations operations, string resourceGroupName, ResourceGroup parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, parameters, CancellationToken.None); + } + + /// + /// Delete resource group and all of its resources. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceGroupOperations. + /// + /// + /// Required. The name of the resource group to be deleted. The name is + /// case insensitive. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static AzureOperationResponse Delete(this IResourceGroupOperations operations, string resourceGroupName) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceGroupOperations)s).DeleteAsync(resourceGroupName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Delete resource group and all of its resources. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceGroupOperations. + /// + /// + /// Required. The name of the resource group to be deleted. The name is + /// case insensitive. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static Task DeleteAsync(this IResourceGroupOperations operations, string resourceGroupName) + { + return operations.DeleteAsync(resourceGroupName, CancellationToken.None); + } + + /// + /// Get a resource group. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceGroupOperations. + /// + /// + /// Required. The name of the resource group to get. The name is case + /// insensitive. + /// + /// + /// Resource group information. + /// + public static ResourceGroupGetResult Get(this IResourceGroupOperations operations, string resourceGroupName) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceGroupOperations)s).GetAsync(resourceGroupName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get a resource group. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceGroupOperations. + /// + /// + /// Required. The name of the resource group to get. The name is case + /// insensitive. + /// + /// + /// Resource group information. + /// + public static Task GetAsync(this IResourceGroupOperations operations, string resourceGroupName) + { + return operations.GetAsync(resourceGroupName, CancellationToken.None); + } + + /// + /// Gets a collection of resource groups. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceGroupOperations. + /// + /// + /// Optional. Query parameters. If null is passed returns all resource + /// groups. + /// + /// + /// List of resource groups. + /// + public static ResourceGroupListResult List(this IResourceGroupOperations operations, ResourceGroupListParameters parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceGroupOperations)s).ListAsync(parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets a collection of resource groups. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceGroupOperations. + /// + /// + /// Optional. Query parameters. If null is passed returns all resource + /// groups. + /// + /// + /// List of resource groups. + /// + public static Task ListAsync(this IResourceGroupOperations operations, ResourceGroupListParameters parameters) + { + return operations.ListAsync(parameters, CancellationToken.None); + } + + /// + /// Get a list of deployments. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceGroupOperations. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of resource groups. + /// + public static ResourceGroupListResult ListNext(this IResourceGroupOperations operations, string nextLink) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceGroupOperations)s).ListNextAsync(nextLink); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get a list of deployments. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceGroupOperations. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of resource groups. + /// + public static Task ListNextAsync(this IResourceGroupOperations operations, string nextLink) + { + return operations.ListNextAsync(nextLink, CancellationToken.None); + } + + /// + /// Resource groups can be updated through a simple PATCH operation to + /// a group address. The format of the request is the same as that for + /// creating a resource groups, though if a field is unspecified + /// current value will be carried over. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceGroupOperations. + /// + /// + /// Required. The name of the resource group to be created or updated. + /// The name is case insensitive. + /// + /// + /// Required. Parameters supplied to the update state resource group + /// service operation. + /// + /// + /// Resource group information. + /// + public static ResourceGroupPatchResult Patch(this IResourceGroupOperations operations, string resourceGroupName, ResourceGroup parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceGroupOperations)s).PatchAsync(resourceGroupName, parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Resource groups can be updated through a simple PATCH operation to + /// a group address. The format of the request is the same as that for + /// creating a resource groups, though if a field is unspecified + /// current value will be carried over. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceGroupOperations. + /// + /// + /// Required. The name of the resource group to be created or updated. + /// The name is case insensitive. + /// + /// + /// Required. Parameters supplied to the update state resource group + /// service operation. + /// + /// + /// Resource group information. + /// + public static Task PatchAsync(this IResourceGroupOperations operations, string resourceGroupName, ResourceGroup parameters) + { + return operations.PatchAsync(resourceGroupName, parameters, CancellationToken.None); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceManagementClient.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceManagementClient.cs new file mode 100644 index 000000000000..f6b99c34bec5 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceManagementClient.cs @@ -0,0 +1,469 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Hyak.Common; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public partial class ResourceManagementClient : ServiceClient, IResourceManagementClient + { + private string _apiVersion; + + /// + /// Gets the API version. + /// + public string ApiVersion + { + get { return this._apiVersion; } + } + + private Uri _baseUri; + + /// + /// Gets the URI used as the base for all cloud service requests. + /// + public Uri BaseUri + { + get { return this._baseUri; } + } + + private SubscriptionCloudCredentials _credentials; + + /// + /// Gets subscription credentials which uniquely identify Microsoft + /// Azure subscription. The subscription ID forms part of the URI for + /// every service call. + /// + public SubscriptionCloudCredentials Credentials + { + get { return this._credentials; } + } + + private int _longRunningOperationInitialTimeout; + + /// + /// Gets or sets the initial timeout for Long Running Operations. + /// + public int LongRunningOperationInitialTimeout + { + get { return this._longRunningOperationInitialTimeout; } + set { this._longRunningOperationInitialTimeout = value; } + } + + private int _longRunningOperationRetryTimeout; + + /// + /// Gets or sets the retry timeout for Long Running Operations. + /// + public int LongRunningOperationRetryTimeout + { + get { return this._longRunningOperationRetryTimeout; } + set { this._longRunningOperationRetryTimeout = value; } + } + + private IDeploymentOperationOperations _deploymentOperations; + + /// + /// Operations for managing deployment operations. + /// + public virtual IDeploymentOperationOperations DeploymentOperations + { + get { return this._deploymentOperations; } + } + + private IDeploymentOperations _deployments; + + /// + /// Operations for managing deployments. + /// + public virtual IDeploymentOperations Deployments + { + get { return this._deployments; } + } + + private IProviderOperations _providers; + + /// + /// Operations for managing providers. + /// + public virtual IProviderOperations Providers + { + get { return this._providers; } + } + + private IProviderOperationsMetadataOperations _providerOperationsMetadata; + + /// + /// Operations for getting provider operations metadata. + /// + public virtual IProviderOperationsMetadataOperations ProviderOperationsMetadata + { + get { return this._providerOperationsMetadata; } + } + + private IResourceGroupOperations _resourceGroups; + + /// + /// Operations for managing resource groups. + /// + public virtual IResourceGroupOperations ResourceGroups + { + get { return this._resourceGroups; } + } + + private IResourceOperations _resources; + + /// + /// Operations for managing resources. + /// + public virtual IResourceOperations Resources + { + get { return this._resources; } + } + + private IResourceProviderOperationDetailsOperations _resourceProviderOperationDetails; + + /// + /// Operations for managing Resource provider operations. + /// + public virtual IResourceProviderOperationDetailsOperations ResourceProviderOperationDetails + { + get { return this._resourceProviderOperationDetails; } + } + + private ITagOperations _tags; + + /// + /// Operations for managing tags. + /// + public virtual ITagOperations Tags + { + get { return this._tags; } + } + + /// + /// Initializes a new instance of the ResourceManagementClient class. + /// + public ResourceManagementClient() + : base() + { + this._deploymentOperations = new DeploymentOperationOperations(this); + this._deployments = new DeploymentOperations(this); + this._providers = new ProviderOperations(this); + this._providerOperationsMetadata = new ProviderOperationsMetadataOperations(this); + this._resourceGroups = new ResourceGroupOperations(this); + this._resources = new ResourceOperations(this); + this._resourceProviderOperationDetails = new ResourceProviderOperationDetailsOperations(this); + this._tags = new TagOperations(this); + this._apiVersion = "2014-04-01-preview"; + this._longRunningOperationInitialTimeout = -1; + this._longRunningOperationRetryTimeout = -1; + this.HttpClient.Timeout = TimeSpan.FromSeconds(300); + } + + /// + /// Initializes a new instance of the ResourceManagementClient class. + /// + /// + /// Required. Gets subscription credentials which uniquely identify + /// Microsoft Azure subscription. The subscription ID forms part of + /// the URI for every service call. + /// + /// + /// Optional. Gets the URI used as the base for all cloud service + /// requests. + /// + public ResourceManagementClient(SubscriptionCloudCredentials credentials, Uri baseUri) + : this() + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + this._credentials = credentials; + this._baseUri = baseUri; + + this.Credentials.InitializeServiceClient(this); + } + + /// + /// Initializes a new instance of the ResourceManagementClient class. + /// + /// + /// Required. Gets subscription credentials which uniquely identify + /// Microsoft Azure subscription. The subscription ID forms part of + /// the URI for every service call. + /// + public ResourceManagementClient(SubscriptionCloudCredentials credentials) + : this() + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this._credentials = credentials; + this._baseUri = new Uri("https://management.azure.com/"); + + this.Credentials.InitializeServiceClient(this); + } + + /// + /// Initializes a new instance of the ResourceManagementClient class. + /// + /// + /// The Http client + /// + public ResourceManagementClient(HttpClient httpClient) + : base(httpClient) + { + this._deploymentOperations = new DeploymentOperationOperations(this); + this._deployments = new DeploymentOperations(this); + this._providers = new ProviderOperations(this); + this._providerOperationsMetadata = new ProviderOperationsMetadataOperations(this); + this._resourceGroups = new ResourceGroupOperations(this); + this._resources = new ResourceOperations(this); + this._resourceProviderOperationDetails = new ResourceProviderOperationDetailsOperations(this); + this._tags = new TagOperations(this); + this._apiVersion = "2014-04-01-preview"; + this._longRunningOperationInitialTimeout = -1; + this._longRunningOperationRetryTimeout = -1; + this.HttpClient.Timeout = TimeSpan.FromSeconds(300); + } + + /// + /// Initializes a new instance of the ResourceManagementClient class. + /// + /// + /// Required. Gets subscription credentials which uniquely identify + /// Microsoft Azure subscription. The subscription ID forms part of + /// the URI for every service call. + /// + /// + /// Optional. Gets the URI used as the base for all cloud service + /// requests. + /// + /// + /// The Http client + /// + public ResourceManagementClient(SubscriptionCloudCredentials credentials, Uri baseUri, HttpClient httpClient) + : this(httpClient) + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + this._credentials = credentials; + this._baseUri = baseUri; + + this.Credentials.InitializeServiceClient(this); + } + + /// + /// Initializes a new instance of the ResourceManagementClient class. + /// + /// + /// Required. Gets subscription credentials which uniquely identify + /// Microsoft Azure subscription. The subscription ID forms part of + /// the URI for every service call. + /// + /// + /// The Http client + /// + public ResourceManagementClient(SubscriptionCloudCredentials credentials, HttpClient httpClient) + : this(httpClient) + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this._credentials = credentials; + this._baseUri = new Uri("https://management.azure.com/"); + + this.Credentials.InitializeServiceClient(this); + } + + /// + /// Clones properties from current instance to another + /// ResourceManagementClient instance + /// + /// + /// Instance of ResourceManagementClient to clone to + /// + protected override void Clone(ServiceClient client) + { + base.Clone(client); + + if (client is ResourceManagementClient) + { + ResourceManagementClient clonedClient = ((ResourceManagementClient)client); + + clonedClient._credentials = this._credentials; + clonedClient._baseUri = this._baseUri; + clonedClient._apiVersion = this._apiVersion; + clonedClient._longRunningOperationInitialTimeout = this._longRunningOperationInitialTimeout; + clonedClient._longRunningOperationRetryTimeout = this._longRunningOperationRetryTimeout; + + clonedClient.Credentials.InitializeServiceClient(clonedClient); + } + } + + /// + /// The Get Operation Status operation returns the status of the + /// specified operation. After calling an asynchronous operation, you + /// can call Get Operation Status to determine whether the operation + /// has succeeded, failed, or is still in progress. + /// + /// + /// Required. Location value returned by the Begin operation. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response for long running operations. + /// + public async Task GetLongRunningOperationStatusAsync(string operationStatusLink, CancellationToken cancellationToken) + { + // Validate + if (operationStatusLink == null) + { + throw new ArgumentNullException("operationStatusLink"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("operationStatusLink", operationStatusLink); + TracingAdapter.Enter(invocationId, this, "GetLongRunningOperationStatusAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + operationStatusLink; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + httpRequest.Headers.Add("x-ms-version", "2014-04-01-preview"); + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.Accepted && statusCode != HttpStatusCode.NoContent) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + LongRunningOperationResponse result = null; + // Deserialize Response + result = new LongRunningOperationResponse(); + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (statusCode == HttpStatusCode.Conflict) + { + result.Status = OperationStatus.Failed; + } + if (statusCode == HttpStatusCode.NoContent) + { + result.Status = OperationStatus.Succeeded; + } + if (statusCode == HttpStatusCode.OK) + { + result.Status = OperationStatus.Succeeded; + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceManagementClientExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceManagementClientExtensions.cs new file mode 100644 index 000000000000..641059005c00 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceManagementClientExtensions.cs @@ -0,0 +1,76 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public static partial class ResourceManagementClientExtensions + { + /// + /// The Get Operation Status operation returns the status of the + /// specified operation. After calling an asynchronous operation, you + /// can call Get Operation Status to determine whether the operation + /// has succeeded, failed, or is still in progress. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceManagementClient. + /// + /// + /// Required. Location value returned by the Begin operation. + /// + /// + /// A standard service response for long running operations. + /// + public static LongRunningOperationResponse GetLongRunningOperationStatus(this IResourceManagementClient operations, string operationStatusLink) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceManagementClient)s).GetLongRunningOperationStatusAsync(operationStatusLink); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// The Get Operation Status operation returns the status of the + /// specified operation. After calling an asynchronous operation, you + /// can call Get Operation Status to determine whether the operation + /// has succeeded, failed, or is still in progress. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceManagementClient. + /// + /// + /// Required. Location value returned by the Begin operation. + /// + /// + /// A standard service response for long running operations. + /// + public static Task GetLongRunningOperationStatusAsync(this IResourceManagementClient operations, string operationStatusLink) + { + return operations.GetLongRunningOperationStatusAsync(operationStatusLink, CancellationToken.None); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceOperations.cs new file mode 100644 index 000000000000..2b72af0e23e3 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceOperations.cs @@ -0,0 +1,1847 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using Hyak.Common; +using Microsoft.Azure.Management.Internal.Resources.Models; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing resources. + /// + internal partial class ResourceOperations : IServiceOperations, IResourceOperations + { + /// + /// Initializes a new instance of the ResourceOperations class. + /// + /// + /// Reference to the service client. + /// + internal ResourceOperations(ResourceManagementClient client) + { + this._client = client; + } + + private ResourceManagementClient _client; + + /// + /// Gets a reference to the + /// Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient. + /// + public ResourceManagementClient Client + { + get { return this._client; } + } + + /// + /// Begin moving resources.To determine whether the operation has + /// finished processing the request, call + /// GetLongRunningOperationStatus. + /// + /// + /// Required. Source resource group name. + /// + /// + /// Required. move resources' parameters. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response for long running operations. + /// + public async Task BeginMovingAsync(string sourceResourceGroupName, ResourcesMoveInfo parameters, CancellationToken cancellationToken) + { + // Validate + if (sourceResourceGroupName == null) + { + throw new ArgumentNullException("sourceResourceGroupName"); + } + if (sourceResourceGroupName != null && sourceResourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("sourceResourceGroupName"); + } + if (Regex.IsMatch(sourceResourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("sourceResourceGroupName"); + } + if (parameters == null) + { + throw new ArgumentNullException("parameters"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("sourceResourceGroupName", sourceResourceGroupName); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "BeginMovingAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourceGroups/"; + url = url + Uri.EscapeDataString(sourceResourceGroupName); + url = url + "/moveResources"; + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Post; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.Accepted && statusCode != HttpStatusCode.NoContent) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + LongRunningOperationResponse result = null; + // Deserialize Response + result = new LongRunningOperationResponse(); + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("Location")) + { + result.OperationStatusLink = httpResponse.Headers.GetValues("Location").FirstOrDefault(); + } + if (httpResponse.Headers.Contains("Retry-After")) + { + result.RetryAfter = int.Parse(httpResponse.Headers.GetValues("Retry-After").FirstOrDefault(), CultureInfo.InvariantCulture); + } + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (statusCode == HttpStatusCode.Conflict) + { + result.Status = OperationStatus.Failed; + } + if (statusCode == HttpStatusCode.Accepted) + { + result.Status = OperationStatus.InProgress; + } + if (statusCode == HttpStatusCode.NoContent) + { + result.Status = OperationStatus.Succeeded; + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Checks whether resource exists. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. Resource identity. + /// + /// + /// Cancellation token. + /// + /// + /// Resource group information. + /// + public async Task CheckExistenceAsync(string resourceGroupName, ResourceIdentity identity, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (identity == null) + { + throw new ArgumentNullException("identity"); + } + if (identity.ResourceName == null) + { + throw new ArgumentNullException("identity.ResourceName"); + } + if (identity.ResourceProviderApiVersion == null) + { + throw new ArgumentNullException("identity.ResourceProviderApiVersion"); + } + if (identity.ResourceProviderNamespace == null) + { + throw new ArgumentNullException("identity.ResourceProviderNamespace"); + } + if (identity.ResourceType == null) + { + throw new ArgumentNullException("identity.ResourceType"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("identity", identity); + TracingAdapter.Enter(invocationId, this, "CheckExistenceAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + url = url + "/providers/"; + url = url + Uri.EscapeDataString(identity.ResourceProviderNamespace); + url = url + "/"; + if (identity.ParentResourcePath != null) + { + url = url + identity.ParentResourcePath; + } + url = url + "/"; + url = url + identity.ResourceType; + url = url + "/"; + url = url + Uri.EscapeDataString(identity.ResourceName); + List queryParameters = new List(); + queryParameters.Add("api-version=" + Uri.EscapeDataString(identity.ResourceProviderApiVersion)); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.NotFound) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ResourceExistsResult result = null; + // Deserialize Response + result = new ResourceExistsResult(); + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (statusCode == HttpStatusCode.OK) + { + result.Exists = true; + } + else + { + result.Exists = false; + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Create a resource. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. Resource identity. + /// + /// + /// Required. Create or update resource parameters. + /// + /// + /// Cancellation token. + /// + /// + /// Resource information. + /// + public async Task CreateOrUpdateAsync(string resourceGroupName, ResourceIdentity identity, GenericResource parameters, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (identity == null) + { + throw new ArgumentNullException("identity"); + } + if (identity.ResourceName == null) + { + throw new ArgumentNullException("identity.ResourceName"); + } + if (identity.ResourceProviderApiVersion == null) + { + throw new ArgumentNullException("identity.ResourceProviderApiVersion"); + } + if (identity.ResourceProviderNamespace == null) + { + throw new ArgumentNullException("identity.ResourceProviderNamespace"); + } + if (identity.ResourceType == null) + { + throw new ArgumentNullException("identity.ResourceType"); + } + if (parameters == null) + { + throw new ArgumentNullException("parameters"); + } + if (parameters.Location == null) + { + throw new ArgumentNullException("parameters.Location"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("identity", identity); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "CreateOrUpdateAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + url = url + "/providers/"; + url = url + Uri.EscapeDataString(identity.ResourceProviderNamespace); + url = url + "/"; + if (identity.ParentResourcePath != null) + { + url = url + identity.ParentResourcePath; + } + url = url + "/"; + url = url + identity.ResourceType; + url = url + "/"; + url = url + Uri.EscapeDataString(identity.ResourceName); + List queryParameters = new List(); + queryParameters.Add("api-version=" + Uri.EscapeDataString(identity.ResourceProviderApiVersion)); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Put; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Serialize Request + string requestContent = null; + JToken requestDoc = null; + + JObject genericResourceValue = new JObject(); + requestDoc = genericResourceValue; + + if (parameters.Properties != null) + { + genericResourceValue["properties"] = JObject.Parse(parameters.Properties); + } + + if (parameters.ProvisioningState != null) + { + genericResourceValue["provisioningState"] = parameters.ProvisioningState; + } + + if (parameters.Plan != null) + { + JObject planValue = new JObject(); + genericResourceValue["plan"] = planValue; + + if (parameters.Plan.Name != null) + { + planValue["name"] = parameters.Plan.Name; + } + + if (parameters.Plan.Publisher != null) + { + planValue["publisher"] = parameters.Plan.Publisher; + } + + if (parameters.Plan.Product != null) + { + planValue["product"] = parameters.Plan.Product; + } + + if (parameters.Plan.PromotionCode != null) + { + planValue["promotionCode"] = parameters.Plan.PromotionCode; + } + } + + genericResourceValue["location"] = parameters.Location; + + if (parameters.Tags != null) + { + JObject tagsDictionary = new JObject(); + foreach (KeyValuePair pair in parameters.Tags) + { + string tagsKey = pair.Key; + string tagsValue = pair.Value; + tagsDictionary[tagsKey] = tagsValue; + } + genericResourceValue["tags"] = tagsDictionary; + } + + requestContent = requestDoc.ToString(Newtonsoft.Json.Formatting.Indented); + httpRequest.Content = new StringContent(requestContent, Encoding.UTF8); + httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.Created) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, requestContent, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ResourceCreateOrUpdateResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.Created) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ResourceCreateOrUpdateResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + GenericResourceExtended resourceInstance = new GenericResourceExtended(); + result.Resource = resourceInstance; + + JToken propertiesValue = responseDoc["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + JToken provisioningStateValue = propertiesValue["provisioningState"]; + if (provisioningStateValue != null && provisioningStateValue.Type != JTokenType.Null) + { + string provisioningStateInstance = ((string)provisioningStateValue); + resourceInstance.ProvisioningState = provisioningStateInstance; + } + } + + JToken propertiesValue2 = responseDoc["properties"]; + if (propertiesValue2 != null && propertiesValue2.Type != JTokenType.Null) + { + string propertiesInstance = propertiesValue2.ToString(Newtonsoft.Json.Formatting.Indented); + resourceInstance.Properties = propertiesInstance; + } + + JToken provisioningStateValue2 = responseDoc["provisioningState"]; + if (provisioningStateValue2 != null && provisioningStateValue2.Type != JTokenType.Null) + { + string provisioningStateInstance2 = ((string)provisioningStateValue2); + resourceInstance.ProvisioningState = provisioningStateInstance2; + } + + JToken planValue2 = responseDoc["plan"]; + if (planValue2 != null && planValue2.Type != JTokenType.Null) + { + Plan planInstance = new Plan(); + resourceInstance.Plan = planInstance; + + JToken nameValue = planValue2["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + planInstance.Name = nameInstance; + } + + JToken publisherValue = planValue2["publisher"]; + if (publisherValue != null && publisherValue.Type != JTokenType.Null) + { + string publisherInstance = ((string)publisherValue); + planInstance.Publisher = publisherInstance; + } + + JToken productValue = planValue2["product"]; + if (productValue != null && productValue.Type != JTokenType.Null) + { + string productInstance = ((string)productValue); + planInstance.Product = productInstance; + } + + JToken promotionCodeValue = planValue2["promotionCode"]; + if (promotionCodeValue != null && promotionCodeValue.Type != JTokenType.Null) + { + string promotionCodeInstance = ((string)promotionCodeValue); + planInstance.PromotionCode = promotionCodeInstance; + } + } + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + resourceInstance.Id = idInstance; + } + + JToken nameValue2 = responseDoc["name"]; + if (nameValue2 != null && nameValue2.Type != JTokenType.Null) + { + string nameInstance2 = ((string)nameValue2); + resourceInstance.Name = nameInstance2; + } + + JToken typeValue = responseDoc["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + resourceInstance.Type = typeInstance; + } + + JToken locationValue = responseDoc["location"]; + if (locationValue != null && locationValue.Type != JTokenType.Null) + { + string locationInstance = ((string)locationValue); + resourceInstance.Location = locationInstance; + } + + JToken tagsSequenceElement = ((JToken)responseDoc["tags"]); + if (tagsSequenceElement != null && tagsSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in tagsSequenceElement) + { + string tagsKey2 = ((string)property.Name); + string tagsValue2 = ((string)property.Value); + resourceInstance.Tags.Add(tagsKey2, tagsValue2); + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Delete resource and all of its resources. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. Resource identity. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public async Task DeleteAsync(string resourceGroupName, ResourceIdentity identity, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (identity == null) + { + throw new ArgumentNullException("identity"); + } + if (identity.ResourceName == null) + { + throw new ArgumentNullException("identity.ResourceName"); + } + if (identity.ResourceProviderApiVersion == null) + { + throw new ArgumentNullException("identity.ResourceProviderApiVersion"); + } + if (identity.ResourceProviderNamespace == null) + { + throw new ArgumentNullException("identity.ResourceProviderNamespace"); + } + if (identity.ResourceType == null) + { + throw new ArgumentNullException("identity.ResourceType"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("identity", identity); + TracingAdapter.Enter(invocationId, this, "DeleteAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + url = url + "/providers/"; + url = url + Uri.EscapeDataString(identity.ResourceProviderNamespace); + url = url + "/"; + if (identity.ParentResourcePath != null) + { + url = url + identity.ParentResourcePath; + } + url = url + "/"; + url = url + identity.ResourceType; + url = url + "/"; + url = url + Uri.EscapeDataString(identity.ResourceName); + List queryParameters = new List(); + queryParameters.Add("api-version=" + Uri.EscapeDataString(identity.ResourceProviderApiVersion)); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Delete; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.Accepted && statusCode != HttpStatusCode.NoContent) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + AzureOperationResponse result = null; + // Deserialize Response + result = new AzureOperationResponse(); + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Returns a resource belonging to a resource group. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. Resource identity. + /// + /// + /// Cancellation token. + /// + /// + /// Resource information. + /// + public async Task GetAsync(string resourceGroupName, ResourceIdentity identity, CancellationToken cancellationToken) + { + // Validate + if (resourceGroupName == null) + { + throw new ArgumentNullException("resourceGroupName"); + } + if (resourceGroupName != null && resourceGroupName.Length > 1000) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._]+$") == false) + { + throw new ArgumentOutOfRangeException("resourceGroupName"); + } + if (identity == null) + { + throw new ArgumentNullException("identity"); + } + if (identity.ResourceName == null) + { + throw new ArgumentNullException("identity.ResourceName"); + } + if (identity.ResourceProviderApiVersion == null) + { + throw new ArgumentNullException("identity.ResourceProviderApiVersion"); + } + if (identity.ResourceProviderNamespace == null) + { + throw new ArgumentNullException("identity.ResourceProviderNamespace"); + } + if (identity.ResourceType == null) + { + throw new ArgumentNullException("identity.ResourceType"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("identity", identity); + TracingAdapter.Enter(invocationId, this, "GetAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/resourcegroups/"; + url = url + Uri.EscapeDataString(resourceGroupName); + url = url + "/providers/"; + url = url + Uri.EscapeDataString(identity.ResourceProviderNamespace); + url = url + "/"; + if (identity.ParentResourcePath != null) + { + url = url + identity.ParentResourcePath; + } + url = url + "/"; + url = url + identity.ResourceType; + url = url + "/"; + url = url + Uri.EscapeDataString(identity.ResourceName); + List queryParameters = new List(); + queryParameters.Add("api-version=" + Uri.EscapeDataString(identity.ResourceProviderApiVersion)); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.NoContent) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ResourceGetResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.NoContent) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ResourceGetResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + GenericResourceExtended resourceInstance = new GenericResourceExtended(); + result.Resource = resourceInstance; + + JToken propertiesValue = responseDoc["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + JToken provisioningStateValue = propertiesValue["provisioningState"]; + if (provisioningStateValue != null && provisioningStateValue.Type != JTokenType.Null) + { + string provisioningStateInstance = ((string)provisioningStateValue); + resourceInstance.ProvisioningState = provisioningStateInstance; + } + } + + JToken propertiesValue2 = responseDoc["properties"]; + if (propertiesValue2 != null && propertiesValue2.Type != JTokenType.Null) + { + string propertiesInstance = propertiesValue2.ToString(Newtonsoft.Json.Formatting.Indented); + resourceInstance.Properties = propertiesInstance; + } + + JToken provisioningStateValue2 = responseDoc["provisioningState"]; + if (provisioningStateValue2 != null && provisioningStateValue2.Type != JTokenType.Null) + { + string provisioningStateInstance2 = ((string)provisioningStateValue2); + resourceInstance.ProvisioningState = provisioningStateInstance2; + } + + JToken planValue = responseDoc["plan"]; + if (planValue != null && planValue.Type != JTokenType.Null) + { + Plan planInstance = new Plan(); + resourceInstance.Plan = planInstance; + + JToken nameValue = planValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + planInstance.Name = nameInstance; + } + + JToken publisherValue = planValue["publisher"]; + if (publisherValue != null && publisherValue.Type != JTokenType.Null) + { + string publisherInstance = ((string)publisherValue); + planInstance.Publisher = publisherInstance; + } + + JToken productValue = planValue["product"]; + if (productValue != null && productValue.Type != JTokenType.Null) + { + string productInstance = ((string)productValue); + planInstance.Product = productInstance; + } + + JToken promotionCodeValue = planValue["promotionCode"]; + if (promotionCodeValue != null && promotionCodeValue.Type != JTokenType.Null) + { + string promotionCodeInstance = ((string)promotionCodeValue); + planInstance.PromotionCode = promotionCodeInstance; + } + } + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + resourceInstance.Id = idInstance; + } + + JToken nameValue2 = responseDoc["name"]; + if (nameValue2 != null && nameValue2.Type != JTokenType.Null) + { + string nameInstance2 = ((string)nameValue2); + resourceInstance.Name = nameInstance2; + } + + JToken typeValue = responseDoc["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + resourceInstance.Type = typeInstance; + } + + JToken locationValue = responseDoc["location"]; + if (locationValue != null && locationValue.Type != JTokenType.Null) + { + string locationInstance = ((string)locationValue); + resourceInstance.Location = locationInstance; + } + + JToken tagsSequenceElement = ((JToken)responseDoc["tags"]); + if (tagsSequenceElement != null && tagsSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in tagsSequenceElement) + { + string tagsKey = ((string)property.Name); + string tagsValue = ((string)property.Value); + resourceInstance.Tags.Add(tagsKey, tagsValue); + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Get all of the resources under a subscription. + /// + /// + /// Optional. Query parameters. If null is passed returns all resource + /// groups. + /// + /// + /// Cancellation token. + /// + /// + /// List of resource groups. + /// + public async Task ListAsync(ResourceListParameters parameters, CancellationToken cancellationToken) + { + // Validate + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "ListAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/"; + if (parameters != null && parameters.ResourceGroupName != null) + { + url = url + "resourceGroups/" + Uri.EscapeDataString(parameters.ResourceGroupName) + "/"; + } + url = url + "resources"; + List queryParameters = new List(); + List odataFilter = new List(); + if (parameters != null && parameters.ResourceType != null) + { + odataFilter.Add("resourceType eq '" + Uri.EscapeDataString(parameters.ResourceType) + "'"); + } + if (parameters != null && parameters.TagName != null) + { + odataFilter.Add("tagname eq '" + Uri.EscapeDataString(parameters.TagName) + "'"); + } + if (parameters != null && parameters.TagValue != null) + { + odataFilter.Add("tagvalue eq '" + Uri.EscapeDataString(parameters.TagValue) + "'"); + } + if (odataFilter.Count > 0) + { + queryParameters.Add("$filter=" + string.Join(" and ", odataFilter)); + } + if (parameters != null && parameters.Top != null) + { + queryParameters.Add("$top=" + Uri.EscapeDataString(parameters.Top.Value.ToString())); + } + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ResourceListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ResourceListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + GenericResourceExtended resourceJsonFormatInstance = new GenericResourceExtended(); + result.Resources.Add(resourceJsonFormatInstance); + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + JToken provisioningStateValue = propertiesValue["provisioningState"]; + if (provisioningStateValue != null && provisioningStateValue.Type != JTokenType.Null) + { + string provisioningStateInstance = ((string)provisioningStateValue); + resourceJsonFormatInstance.ProvisioningState = provisioningStateInstance; + } + } + + JToken propertiesValue2 = valueValue["properties"]; + if (propertiesValue2 != null && propertiesValue2.Type != JTokenType.Null) + { + string propertiesInstance = propertiesValue2.ToString(Newtonsoft.Json.Formatting.Indented); + resourceJsonFormatInstance.Properties = propertiesInstance; + } + + JToken provisioningStateValue2 = valueValue["provisioningState"]; + if (provisioningStateValue2 != null && provisioningStateValue2.Type != JTokenType.Null) + { + string provisioningStateInstance2 = ((string)provisioningStateValue2); + resourceJsonFormatInstance.ProvisioningState = provisioningStateInstance2; + } + + JToken planValue = valueValue["plan"]; + if (planValue != null && planValue.Type != JTokenType.Null) + { + Plan planInstance = new Plan(); + resourceJsonFormatInstance.Plan = planInstance; + + JToken nameValue = planValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + planInstance.Name = nameInstance; + } + + JToken publisherValue = planValue["publisher"]; + if (publisherValue != null && publisherValue.Type != JTokenType.Null) + { + string publisherInstance = ((string)publisherValue); + planInstance.Publisher = publisherInstance; + } + + JToken productValue = planValue["product"]; + if (productValue != null && productValue.Type != JTokenType.Null) + { + string productInstance = ((string)productValue); + planInstance.Product = productInstance; + } + + JToken promotionCodeValue = planValue["promotionCode"]; + if (promotionCodeValue != null && promotionCodeValue.Type != JTokenType.Null) + { + string promotionCodeInstance = ((string)promotionCodeValue); + planInstance.PromotionCode = promotionCodeInstance; + } + } + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + resourceJsonFormatInstance.Id = idInstance; + } + + JToken nameValue2 = valueValue["name"]; + if (nameValue2 != null && nameValue2.Type != JTokenType.Null) + { + string nameInstance2 = ((string)nameValue2); + resourceJsonFormatInstance.Name = nameInstance2; + } + + JToken typeValue = valueValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + resourceJsonFormatInstance.Type = typeInstance; + } + + JToken locationValue = valueValue["location"]; + if (locationValue != null && locationValue.Type != JTokenType.Null) + { + string locationInstance = ((string)locationValue); + resourceJsonFormatInstance.Location = locationInstance; + } + + JToken tagsSequenceElement = ((JToken)valueValue["tags"]); + if (tagsSequenceElement != null && tagsSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in tagsSequenceElement) + { + string tagsKey = ((string)property.Name); + string tagsValue = ((string)property.Value); + resourceJsonFormatInstance.Tags.Add(tagsKey, tagsValue); + } + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Get a list of deployments. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of resource groups. + /// + public async Task ListNextAsync(string nextLink, CancellationToken cancellationToken) + { + // Validate + if (nextLink == null) + { + throw new ArgumentNullException("nextLink"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextLink", nextLink); + TracingAdapter.Enter(invocationId, this, "ListNextAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + nextLink; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ResourceListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ResourceListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + GenericResourceExtended resourceJsonFormatInstance = new GenericResourceExtended(); + result.Resources.Add(resourceJsonFormatInstance); + + JToken propertiesValue = valueValue["properties"]; + if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) + { + JToken provisioningStateValue = propertiesValue["provisioningState"]; + if (provisioningStateValue != null && provisioningStateValue.Type != JTokenType.Null) + { + string provisioningStateInstance = ((string)provisioningStateValue); + resourceJsonFormatInstance.ProvisioningState = provisioningStateInstance; + } + } + + JToken propertiesValue2 = valueValue["properties"]; + if (propertiesValue2 != null && propertiesValue2.Type != JTokenType.Null) + { + string propertiesInstance = propertiesValue2.ToString(Newtonsoft.Json.Formatting.Indented); + resourceJsonFormatInstance.Properties = propertiesInstance; + } + + JToken provisioningStateValue2 = valueValue["provisioningState"]; + if (provisioningStateValue2 != null && provisioningStateValue2.Type != JTokenType.Null) + { + string provisioningStateInstance2 = ((string)provisioningStateValue2); + resourceJsonFormatInstance.ProvisioningState = provisioningStateInstance2; + } + + JToken planValue = valueValue["plan"]; + if (planValue != null && planValue.Type != JTokenType.Null) + { + Plan planInstance = new Plan(); + resourceJsonFormatInstance.Plan = planInstance; + + JToken nameValue = planValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + planInstance.Name = nameInstance; + } + + JToken publisherValue = planValue["publisher"]; + if (publisherValue != null && publisherValue.Type != JTokenType.Null) + { + string publisherInstance = ((string)publisherValue); + planInstance.Publisher = publisherInstance; + } + + JToken productValue = planValue["product"]; + if (productValue != null && productValue.Type != JTokenType.Null) + { + string productInstance = ((string)productValue); + planInstance.Product = productInstance; + } + + JToken promotionCodeValue = planValue["promotionCode"]; + if (promotionCodeValue != null && promotionCodeValue.Type != JTokenType.Null) + { + string promotionCodeInstance = ((string)promotionCodeValue); + planInstance.PromotionCode = promotionCodeInstance; + } + } + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + resourceJsonFormatInstance.Id = idInstance; + } + + JToken nameValue2 = valueValue["name"]; + if (nameValue2 != null && nameValue2.Type != JTokenType.Null) + { + string nameInstance2 = ((string)nameValue2); + resourceJsonFormatInstance.Name = nameInstance2; + } + + JToken typeValue = valueValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + resourceJsonFormatInstance.Type = typeInstance; + } + + JToken locationValue = valueValue["location"]; + if (locationValue != null && locationValue.Type != JTokenType.Null) + { + string locationInstance = ((string)locationValue); + resourceJsonFormatInstance.Location = locationInstance; + } + + JToken tagsSequenceElement = ((JToken)valueValue["tags"]); + if (tagsSequenceElement != null && tagsSequenceElement.Type != JTokenType.Null) + { + foreach (JProperty property in tagsSequenceElement) + { + string tagsKey = ((string)property.Name); + string tagsValue = ((string)property.Value); + resourceJsonFormatInstance.Tags.Add(tagsKey, tagsValue); + } + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Move resources within or across subscriptions. + /// + /// + /// Required. Source resource group name. + /// + /// + /// Required. move resources' parameters. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public async Task MoveResourcesAsync(string sourceResourceGroupName, ResourcesMoveInfo parameters, CancellationToken cancellationToken) + { + ResourceManagementClient client = this.Client; + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("sourceResourceGroupName", sourceResourceGroupName); + tracingParameters.Add("parameters", parameters); + TracingAdapter.Enter(invocationId, this, "MoveResourcesAsync", tracingParameters); + } + + cancellationToken.ThrowIfCancellationRequested(); + LongRunningOperationResponse response = await client.Resources.BeginMovingAsync(sourceResourceGroupName, parameters, cancellationToken).ConfigureAwait(false); + cancellationToken.ThrowIfCancellationRequested(); + LongRunningOperationResponse result = await client.GetLongRunningOperationStatusAsync(response.OperationStatusLink, cancellationToken).ConfigureAwait(false); + int delayInSeconds = response.RetryAfter; + if (delayInSeconds == 0) + { + delayInSeconds = 30; + } + if (client.LongRunningOperationInitialTimeout >= 0) + { + delayInSeconds = client.LongRunningOperationInitialTimeout; + } + while ((result.Status != Microsoft.Azure.OperationStatus.InProgress) == false) + { + cancellationToken.ThrowIfCancellationRequested(); + await TaskEx.Delay(delayInSeconds * 1000, cancellationToken).ConfigureAwait(false); + cancellationToken.ThrowIfCancellationRequested(); + result = await client.GetLongRunningOperationStatusAsync(response.OperationStatusLink, cancellationToken).ConfigureAwait(false); + delayInSeconds = result.RetryAfter; + if (delayInSeconds == 0) + { + delayInSeconds = 15; + } + if (client.LongRunningOperationRetryTimeout >= 0) + { + delayInSeconds = client.LongRunningOperationRetryTimeout; + } + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + + return result; + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceOperationsExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceOperationsExtensions.cs new file mode 100644 index 000000000000..f9dcf76962ba --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceOperationsExtensions.cs @@ -0,0 +1,412 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public static partial class ResourceOperationsExtensions + { + /// + /// Begin moving resources.To determine whether the operation has + /// finished processing the request, call + /// GetLongRunningOperationStatus. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceOperations. + /// + /// + /// Required. Source resource group name. + /// + /// + /// Required. move resources' parameters. + /// + /// + /// A standard service response for long running operations. + /// + public static LongRunningOperationResponse BeginMoving(this IResourceOperations operations, string sourceResourceGroupName, ResourcesMoveInfo parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceOperations)s).BeginMovingAsync(sourceResourceGroupName, parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Begin moving resources.To determine whether the operation has + /// finished processing the request, call + /// GetLongRunningOperationStatus. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceOperations. + /// + /// + /// Required. Source resource group name. + /// + /// + /// Required. move resources' parameters. + /// + /// + /// A standard service response for long running operations. + /// + public static Task BeginMovingAsync(this IResourceOperations operations, string sourceResourceGroupName, ResourcesMoveInfo parameters) + { + return operations.BeginMovingAsync(sourceResourceGroupName, parameters, CancellationToken.None); + } + + /// + /// Checks whether resource exists. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. Resource identity. + /// + /// + /// Resource group information. + /// + public static ResourceExistsResult CheckExistence(this IResourceOperations operations, string resourceGroupName, ResourceIdentity identity) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceOperations)s).CheckExistenceAsync(resourceGroupName, identity); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Checks whether resource exists. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. Resource identity. + /// + /// + /// Resource group information. + /// + public static Task CheckExistenceAsync(this IResourceOperations operations, string resourceGroupName, ResourceIdentity identity) + { + return operations.CheckExistenceAsync(resourceGroupName, identity, CancellationToken.None); + } + + /// + /// Create a resource. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. Resource identity. + /// + /// + /// Required. Create or update resource parameters. + /// + /// + /// Resource information. + /// + public static ResourceCreateOrUpdateResult CreateOrUpdate(this IResourceOperations operations, string resourceGroupName, ResourceIdentity identity, GenericResource parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceOperations)s).CreateOrUpdateAsync(resourceGroupName, identity, parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Create a resource. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. Resource identity. + /// + /// + /// Required. Create or update resource parameters. + /// + /// + /// Resource information. + /// + public static Task CreateOrUpdateAsync(this IResourceOperations operations, string resourceGroupName, ResourceIdentity identity, GenericResource parameters) + { + return operations.CreateOrUpdateAsync(resourceGroupName, identity, parameters, CancellationToken.None); + } + + /// + /// Delete resource and all of its resources. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. Resource identity. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static AzureOperationResponse Delete(this IResourceOperations operations, string resourceGroupName, ResourceIdentity identity) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceOperations)s).DeleteAsync(resourceGroupName, identity); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Delete resource and all of its resources. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. Resource identity. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static Task DeleteAsync(this IResourceOperations operations, string resourceGroupName, ResourceIdentity identity) + { + return operations.DeleteAsync(resourceGroupName, identity, CancellationToken.None); + } + + /// + /// Returns a resource belonging to a resource group. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. Resource identity. + /// + /// + /// Resource information. + /// + public static ResourceGetResult Get(this IResourceOperations operations, string resourceGroupName, ResourceIdentity identity) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceOperations)s).GetAsync(resourceGroupName, identity); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Returns a resource belonging to a resource group. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceOperations. + /// + /// + /// Required. The name of the resource group. The name is case + /// insensitive. + /// + /// + /// Required. Resource identity. + /// + /// + /// Resource information. + /// + public static Task GetAsync(this IResourceOperations operations, string resourceGroupName, ResourceIdentity identity) + { + return operations.GetAsync(resourceGroupName, identity, CancellationToken.None); + } + + /// + /// Get all of the resources under a subscription. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceOperations. + /// + /// + /// Optional. Query parameters. If null is passed returns all resource + /// groups. + /// + /// + /// List of resource groups. + /// + public static ResourceListResult List(this IResourceOperations operations, ResourceListParameters parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceOperations)s).ListAsync(parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get all of the resources under a subscription. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceOperations. + /// + /// + /// Optional. Query parameters. If null is passed returns all resource + /// groups. + /// + /// + /// List of resource groups. + /// + public static Task ListAsync(this IResourceOperations operations, ResourceListParameters parameters) + { + return operations.ListAsync(parameters, CancellationToken.None); + } + + /// + /// Get a list of deployments. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceOperations. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of resource groups. + /// + public static ResourceListResult ListNext(this IResourceOperations operations, string nextLink) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceOperations)s).ListNextAsync(nextLink); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get a list of deployments. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceOperations. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of resource groups. + /// + public static Task ListNextAsync(this IResourceOperations operations, string nextLink) + { + return operations.ListNextAsync(nextLink, CancellationToken.None); + } + + /// + /// Move resources within or across subscriptions. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceOperations. + /// + /// + /// Required. Source resource group name. + /// + /// + /// Required. move resources' parameters. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static AzureOperationResponse MoveResources(this IResourceOperations operations, string sourceResourceGroupName, ResourcesMoveInfo parameters) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceOperations)s).MoveResourcesAsync(sourceResourceGroupName, parameters); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Move resources within or across subscriptions. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceOperations. + /// + /// + /// Required. Source resource group name. + /// + /// + /// Required. move resources' parameters. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static Task MoveResourcesAsync(this IResourceOperations operations, string sourceResourceGroupName, ResourcesMoveInfo parameters) + { + return operations.MoveResourcesAsync(sourceResourceGroupName, parameters, CancellationToken.None); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceProviderOperationDetailsOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceProviderOperationDetailsOperations.cs new file mode 100644 index 000000000000..59af434c961a --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceProviderOperationDetailsOperations.cs @@ -0,0 +1,280 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Hyak.Common; +using Microsoft.Azure.Management.Internal.Resources.Models; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing Resource provider operations. + /// + internal partial class ResourceProviderOperationDetailsOperations : IServiceOperations, IResourceProviderOperationDetailsOperations + { + /// + /// Initializes a new instance of the + /// ResourceProviderOperationDetailsOperations class. + /// + /// + /// Reference to the service client. + /// + internal ResourceProviderOperationDetailsOperations(ResourceManagementClient client) + { + this._client = client; + } + + private ResourceManagementClient _client; + + /// + /// Gets a reference to the + /// Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient. + /// + public ResourceManagementClient Client + { + get { return this._client; } + } + + /// + /// Gets a list of resource providers. + /// + /// + /// Required. Resource identity. + /// + /// + /// Cancellation token. + /// + /// + /// List of resource provider operations. + /// + public async Task ListAsync(ResourceIdentity identity, CancellationToken cancellationToken) + { + // Validate + if (identity == null) + { + throw new ArgumentNullException("identity"); + } + if (identity.ResourceName == null) + { + throw new ArgumentNullException("identity."); + } + if (identity.ResourceProviderApiVersion == null) + { + throw new ArgumentNullException("identity."); + } + if (identity.ResourceProviderNamespace == null) + { + throw new ArgumentNullException("identity."); + } + if (identity.ResourceType == null) + { + throw new ArgumentNullException("identity."); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("identity", identity); + TracingAdapter.Enter(invocationId, this, "ListAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/providers/"; + url = url + Uri.EscapeDataString(identity.ResourceProviderNamespace); + url = url + "/operations"; + List queryParameters = new List(); + queryParameters.Add("api-version=" + Uri.EscapeDataString(identity.ResourceProviderApiVersion)); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.NoContent) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + ResourceProviderOperationDetailListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.NoContent) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new ResourceProviderOperationDetailListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + ResourceProviderOperationDefinition resourceProviderOperationDefinitionInstance = new ResourceProviderOperationDefinition(); + result.ResourceProviderOperationDetails.Add(resourceProviderOperationDefinitionInstance); + + JToken nameValue = valueValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + resourceProviderOperationDefinitionInstance.Name = nameInstance; + } + + JToken displayValue = valueValue["display"]; + if (displayValue != null && displayValue.Type != JTokenType.Null) + { + ResourceProviderOperationDisplayProperties displayInstance = new ResourceProviderOperationDisplayProperties(); + resourceProviderOperationDefinitionInstance.ResourceProviderOperationDisplayProperties = displayInstance; + + JToken publisherValue = displayValue["publisher"]; + if (publisherValue != null && publisherValue.Type != JTokenType.Null) + { + string publisherInstance = ((string)publisherValue); + displayInstance.Publisher = publisherInstance; + } + + JToken providerValue = displayValue["provider"]; + if (providerValue != null && providerValue.Type != JTokenType.Null) + { + string providerInstance = ((string)providerValue); + displayInstance.Provider = providerInstance; + } + + JToken resourceValue = displayValue["resource"]; + if (resourceValue != null && resourceValue.Type != JTokenType.Null) + { + string resourceInstance = ((string)resourceValue); + displayInstance.Resource = resourceInstance; + } + + JToken operationValue = displayValue["operation"]; + if (operationValue != null && operationValue.Type != JTokenType.Null) + { + string operationInstance = ((string)operationValue); + displayInstance.Operation = operationInstance; + } + + JToken descriptionValue = displayValue["description"]; + if (descriptionValue != null && descriptionValue.Type != JTokenType.Null) + { + string descriptionInstance = ((string)descriptionValue); + displayInstance.Description = descriptionInstance; + } + } + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceProviderOperationDetailsOperationsExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceProviderOperationDetailsOperationsExtensions.cs new file mode 100644 index 000000000000..c078c72ab7ca --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/ResourceProviderOperationDetailsOperationsExtensions.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public static partial class ResourceProviderOperationDetailsOperationsExtensions + { + /// + /// Gets a list of resource providers. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceProviderOperationDetailsOperations. + /// + /// + /// Required. Resource identity. + /// + /// + /// List of resource provider operations. + /// + public static ResourceProviderOperationDetailListResult List(this IResourceProviderOperationDetailsOperations operations, ResourceIdentity identity) + { + return Task.Factory.StartNew((object s) => + { + return ((IResourceProviderOperationDetailsOperations)s).ListAsync(identity); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets a list of resource providers. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.IResourceProviderOperationDetailsOperations. + /// + /// + /// Required. Resource identity. + /// + /// + /// List of resource provider operations. + /// + public static Task ListAsync(this IResourceProviderOperationDetailsOperations operations, ResourceIdentity identity) + { + return operations.ListAsync(identity, CancellationToken.None); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/SubscriptionClient.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/SubscriptionClient.cs new file mode 100644 index 000000000000..5ecadcf1758f --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/SubscriptionClient.cs @@ -0,0 +1,257 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Net.Http; +using Hyak.Common; + +namespace Microsoft.Azure.Internal.Subscriptions +{ + public partial class SubscriptionClient : ServiceClient, ISubscriptionClient + { + private string _apiVersion; + + /// + /// Gets the API version. + /// + public string ApiVersion + { + get { return this._apiVersion; } + } + + private Uri _baseUri; + + /// + /// Gets the URI used as the base for all cloud service requests. + /// + public Uri BaseUri + { + get { return this._baseUri; } + } + + private CloudCredentials _credentials; + + /// + /// Credentials used to authenticate requests. + /// + public CloudCredentials Credentials + { + get { return this._credentials; } + set { this._credentials = value; } + } + + private int _longRunningOperationInitialTimeout; + + /// + /// Gets or sets the initial timeout for Long Running Operations. + /// + public int LongRunningOperationInitialTimeout + { + get { return this._longRunningOperationInitialTimeout; } + set { this._longRunningOperationInitialTimeout = value; } + } + + private int _longRunningOperationRetryTimeout; + + /// + /// Gets or sets the retry timeout for Long Running Operations. + /// + public int LongRunningOperationRetryTimeout + { + get { return this._longRunningOperationRetryTimeout; } + set { this._longRunningOperationRetryTimeout = value; } + } + + private ISubscriptionOperations _subscriptions; + + /// + /// Operations for managing subscriptions. + /// + public virtual ISubscriptionOperations Subscriptions + { + get { return this._subscriptions; } + } + + private ITenantOperations _tenants; + + /// + /// Operations for managing tenants. + /// + public virtual ITenantOperations Tenants + { + get { return this._tenants; } + } + + /// + /// Initializes a new instance of the SubscriptionClient class. + /// + public SubscriptionClient() + : base() + { + this._subscriptions = new SubscriptionOperations(this); + this._tenants = new TenantOperations(this); + this._apiVersion = "2014-04-01-preview"; + this._longRunningOperationInitialTimeout = -1; + this._longRunningOperationRetryTimeout = -1; + this.HttpClient.Timeout = TimeSpan.FromSeconds(300); + } + + /// + /// Initializes a new instance of the SubscriptionClient class. + /// + /// + /// Required. Credentials used to authenticate requests. + /// + /// + /// Optional. Gets the URI used as the base for all cloud service + /// requests. + /// + public SubscriptionClient(CloudCredentials credentials, Uri baseUri) + : this() + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + this._credentials = credentials; + this._baseUri = baseUri; + + this.Credentials.InitializeServiceClient(this); + } + + /// + /// Initializes a new instance of the SubscriptionClient class. + /// + /// + /// Required. Credentials used to authenticate requests. + /// + public SubscriptionClient(CloudCredentials credentials) + : this() + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this._credentials = credentials; + this._baseUri = new Uri("https://management.azure.com/"); + + this.Credentials.InitializeServiceClient(this); + } + + /// + /// Initializes a new instance of the SubscriptionClient class. + /// + /// + /// The Http client + /// + public SubscriptionClient(HttpClient httpClient) + : base(httpClient) + { + this._subscriptions = new SubscriptionOperations(this); + this._tenants = new TenantOperations(this); + this._apiVersion = "2014-04-01-preview"; + this._longRunningOperationInitialTimeout = -1; + this._longRunningOperationRetryTimeout = -1; + this.HttpClient.Timeout = TimeSpan.FromSeconds(300); + } + + /// + /// Initializes a new instance of the SubscriptionClient class. + /// + /// + /// Required. Credentials used to authenticate requests. + /// + /// + /// Optional. Gets the URI used as the base for all cloud service + /// requests. + /// + /// + /// The Http client + /// + public SubscriptionClient(CloudCredentials credentials, Uri baseUri, HttpClient httpClient) + : this(httpClient) + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + this._credentials = credentials; + this._baseUri = baseUri; + + this.Credentials.InitializeServiceClient(this); + } + + /// + /// Initializes a new instance of the SubscriptionClient class. + /// + /// + /// Required. Credentials used to authenticate requests. + /// + /// + /// The Http client + /// + public SubscriptionClient(CloudCredentials credentials, HttpClient httpClient) + : this(httpClient) + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this._credentials = credentials; + this._baseUri = new Uri("https://management.azure.com/"); + + this.Credentials.InitializeServiceClient(this); + } + + /// + /// Clones properties from current instance to another + /// SubscriptionClient instance + /// + /// + /// Instance of SubscriptionClient to clone to + /// + protected override void Clone(ServiceClient client) + { + base.Clone(client); + + if (client is SubscriptionClient) + { + SubscriptionClient clonedClient = ((SubscriptionClient)client); + + clonedClient._credentials = this._credentials; + clonedClient._baseUri = this._baseUri; + clonedClient._apiVersion = this._apiVersion; + clonedClient._longRunningOperationInitialTimeout = this._longRunningOperationInitialTimeout; + clonedClient._longRunningOperationRetryTimeout = this._longRunningOperationRetryTimeout; + + clonedClient.Credentials.InitializeServiceClient(clonedClient); + } + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/SubscriptionClientExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/SubscriptionClientExtensions.cs new file mode 100644 index 000000000000..49753b6f25b7 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/SubscriptionClientExtensions.cs @@ -0,0 +1,28 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + + +namespace Microsoft.Azure.Internal.Subscriptions +{ + public static partial class SubscriptionClientExtensions + { + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/SubscriptionOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/SubscriptionOperations.cs new file mode 100644 index 000000000000..0f093caed22d --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/SubscriptionOperations.cs @@ -0,0 +1,598 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Hyak.Common; +using Microsoft.Azure.Internal.Subscriptions.Models; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Azure.Internal.Subscriptions +{ + /// + /// Operations for managing subscriptions. + /// + internal partial class SubscriptionOperations : IServiceOperations, ISubscriptionOperations + { + /// + /// Initializes a new instance of the SubscriptionOperations class. + /// + /// + /// Reference to the service client. + /// + internal SubscriptionOperations(SubscriptionClient client) + { + this._client = client; + } + + private SubscriptionClient _client; + + /// + /// Gets a reference to the + /// Microsoft.Azure.Internal.Subscriptions.SubscriptionClient. + /// + public SubscriptionClient Client + { + get { return this._client; } + } + + /// + /// Gets details about particular subscription. + /// + /// + /// Required. Id of the subscription. + /// + /// + /// Cancellation token. + /// + /// + /// Subscription detailed information. + /// + public async Task GetAsync(string subscriptionId, CancellationToken cancellationToken) + { + // Validate + if (subscriptionId == null) + { + throw new ArgumentNullException("subscriptionId"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("subscriptionId", subscriptionId); + TracingAdapter.Enter(invocationId, this, "GetAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + url = url + Uri.EscapeDataString(subscriptionId); + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + GetSubscriptionResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new GetSubscriptionResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + Subscription subscriptionInstance = new Subscription(); + result.Subscription = subscriptionInstance; + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + subscriptionInstance.Id = idInstance; + } + + JToken subscriptionIdValue = responseDoc["subscriptionId"]; + if (subscriptionIdValue != null && subscriptionIdValue.Type != JTokenType.Null) + { + string subscriptionIdInstance = ((string)subscriptionIdValue); + subscriptionInstance.SubscriptionId = subscriptionIdInstance; + } + + JToken displayNameValue = responseDoc["displayName"]; + if (displayNameValue != null && displayNameValue.Type != JTokenType.Null) + { + string displayNameInstance = ((string)displayNameValue); + subscriptionInstance.DisplayName = displayNameInstance; + } + + JToken stateValue = responseDoc["state"]; + if (stateValue != null && stateValue.Type != JTokenType.Null) + { + string stateInstance = ((string)stateValue); + subscriptionInstance.State = stateInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Gets a list of the subscriptionIds. + /// + /// + /// Cancellation token. + /// + /// + /// Subscription list operation response. + /// + public async Task ListAsync(CancellationToken cancellationToken) + { + // Validate + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + TracingAdapter.Enter(invocationId, this, "ListAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions"; + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + SubscriptionListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new SubscriptionListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + Subscription subscriptionInstance = new Subscription(); + result.Subscriptions.Add(subscriptionInstance); + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + subscriptionInstance.Id = idInstance; + } + + JToken subscriptionIdValue = valueValue["subscriptionId"]; + if (subscriptionIdValue != null && subscriptionIdValue.Type != JTokenType.Null) + { + string subscriptionIdInstance = ((string)subscriptionIdValue); + subscriptionInstance.SubscriptionId = subscriptionIdInstance; + } + + JToken displayNameValue = valueValue["displayName"]; + if (displayNameValue != null && displayNameValue.Type != JTokenType.Null) + { + string displayNameInstance = ((string)displayNameValue); + subscriptionInstance.DisplayName = displayNameInstance; + } + + JToken stateValue = valueValue["state"]; + if (stateValue != null && stateValue.Type != JTokenType.Null) + { + string stateInstance = ((string)stateValue); + subscriptionInstance.State = stateInstance; + } + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Gets a list of the subscription locations. + /// + /// + /// Required. Id of the subscription + /// + /// + /// Cancellation token. + /// + /// + /// Location list operation response. + /// + public async Task ListLocationsAsync(string subscriptionId, CancellationToken cancellationToken) + { + // Validate + if (subscriptionId == null) + { + throw new ArgumentNullException("subscriptionId"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("subscriptionId", subscriptionId); + TracingAdapter.Enter(invocationId, this, "ListLocationsAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + url = url + Uri.EscapeDataString(subscriptionId); + url = url + "/locations"; + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + LocationListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new LocationListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + Location locationInstance = new Location(); + result.Locations.Add(locationInstance); + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + locationInstance.Id = idInstance; + } + + JToken subscriptionIdValue = valueValue["subscriptionId"]; + if (subscriptionIdValue != null && subscriptionIdValue.Type != JTokenType.Null) + { + string subscriptionIdInstance = ((string)subscriptionIdValue); + locationInstance.SubscriptionId = subscriptionIdInstance; + } + + JToken nameValue = valueValue["name"]; + if (nameValue != null && nameValue.Type != JTokenType.Null) + { + string nameInstance = ((string)nameValue); + locationInstance.Name = nameInstance; + } + + JToken displayNameValue = valueValue["displayName"]; + if (displayNameValue != null && displayNameValue.Type != JTokenType.Null) + { + string displayNameInstance = ((string)displayNameValue); + locationInstance.DisplayName = displayNameInstance; + } + + JToken latitudeValue = valueValue["latitude"]; + if (latitudeValue != null && latitudeValue.Type != JTokenType.Null) + { + string latitudeInstance = ((string)latitudeValue); + locationInstance.Latitude = latitudeInstance; + } + + JToken longitudeValue = valueValue["longitude"]; + if (longitudeValue != null && longitudeValue.Type != JTokenType.Null) + { + string longitudeInstance = ((string)longitudeValue); + locationInstance.Longitude = longitudeInstance; + } + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/SubscriptionOperationsExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/SubscriptionOperationsExtensions.cs new file mode 100644 index 000000000000..a06a47a8e960 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/SubscriptionOperationsExtensions.cs @@ -0,0 +1,144 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Internal.Subscriptions.Models; + +namespace Microsoft.Azure.Internal.Subscriptions +{ + public static partial class SubscriptionOperationsExtensions + { + /// + /// Gets details about particular subscription. + /// + /// + /// Reference to the + /// Microsoft.Azure.Internal.Subscriptions.ISubscriptionOperations. + /// + /// + /// Required. Id of the subscription. + /// + /// + /// Subscription detailed information. + /// + public static GetSubscriptionResult Get(this ISubscriptionOperations operations, string subscriptionId) + { + return Task.Factory.StartNew((object s) => + { + return ((ISubscriptionOperations)s).GetAsync(subscriptionId); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets details about particular subscription. + /// + /// + /// Reference to the + /// Microsoft.Azure.Internal.Subscriptions.ISubscriptionOperations. + /// + /// + /// Required. Id of the subscription. + /// + /// + /// Subscription detailed information. + /// + public static Task GetAsync(this ISubscriptionOperations operations, string subscriptionId) + { + return operations.GetAsync(subscriptionId, CancellationToken.None); + } + + /// + /// Gets a list of the subscriptionIds. + /// + /// + /// Reference to the + /// Microsoft.Azure.Internal.Subscriptions.ISubscriptionOperations. + /// + /// + /// Subscription list operation response. + /// + public static SubscriptionListResult List(this ISubscriptionOperations operations) + { + return Task.Factory.StartNew((object s) => + { + return ((ISubscriptionOperations)s).ListAsync(); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets a list of the subscriptionIds. + /// + /// + /// Reference to the + /// Microsoft.Azure.Internal.Subscriptions.ISubscriptionOperations. + /// + /// + /// Subscription list operation response. + /// + public static Task ListAsync(this ISubscriptionOperations operations) + { + return operations.ListAsync(CancellationToken.None); + } + + /// + /// Gets a list of the subscription locations. + /// + /// + /// Reference to the + /// Microsoft.Azure.Internal.Subscriptions.ISubscriptionOperations. + /// + /// + /// Required. Id of the subscription + /// + /// + /// Location list operation response. + /// + public static LocationListResult ListLocations(this ISubscriptionOperations operations, string subscriptionId) + { + return Task.Factory.StartNew((object s) => + { + return ((ISubscriptionOperations)s).ListLocationsAsync(subscriptionId); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets a list of the subscription locations. + /// + /// + /// Reference to the + /// Microsoft.Azure.Internal.Subscriptions.ISubscriptionOperations. + /// + /// + /// Required. Id of the subscription + /// + /// + /// Location list operation response. + /// + public static Task ListLocationsAsync(this ISubscriptionOperations operations, string subscriptionId) + { + return operations.ListLocationsAsync(subscriptionId, CancellationToken.None); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/TagOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/TagOperations.cs new file mode 100644 index 000000000000..bca514599ccf --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/TagOperations.cs @@ -0,0 +1,1216 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Hyak.Common; +using Microsoft.Azure.Management.Internal.Resources.Models; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + /// + /// Operations for managing tags. + /// + internal partial class TagOperations : IServiceOperations, ITagOperations + { + /// + /// Initializes a new instance of the TagOperations class. + /// + /// + /// Reference to the service client. + /// + internal TagOperations(ResourceManagementClient client) + { + this._client = client; + } + + private ResourceManagementClient _client; + + /// + /// Gets a reference to the + /// Microsoft.Azure.Management.Internal.Resources.ResourceManagementClient. + /// + public ResourceManagementClient Client + { + get { return this._client; } + } + + /// + /// Create a subscription resource tag. + /// + /// + /// Required. The name of the tag. + /// + /// + /// Cancellation token. + /// + /// + /// Tag information. + /// + public async Task CreateOrUpdateAsync(string tagName, CancellationToken cancellationToken) + { + // Validate + if (tagName == null) + { + throw new ArgumentNullException("tagName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("tagName", tagName); + TracingAdapter.Enter(invocationId, this, "CreateOrUpdateAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/tagNames/"; + url = url + Uri.EscapeDataString(tagName); + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Put; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.Created) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + TagCreateResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.Created) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new TagCreateResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + TagDetails tagInstance = new TagDetails(); + result.Tag = tagInstance; + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + tagInstance.Id = idInstance; + } + + JToken tagNameValue = responseDoc["tagName"]; + if (tagNameValue != null && tagNameValue.Type != JTokenType.Null) + { + string tagNameInstance = ((string)tagNameValue); + tagInstance.Name = tagNameInstance; + } + + JToken countValue = responseDoc["count"]; + if (countValue != null && countValue.Type != JTokenType.Null) + { + TagCount countInstance = new TagCount(); + tagInstance.Count = countInstance; + + JToken typeValue = countValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + countInstance.Type = typeInstance; + } + + JToken valueValue = countValue["value"]; + if (valueValue != null && valueValue.Type != JTokenType.Null) + { + string valueInstance = ((string)valueValue); + countInstance.Value = valueInstance; + } + } + + JToken valuesArray = responseDoc["values"]; + if (valuesArray != null && valuesArray.Type != JTokenType.Null) + { + foreach (JToken valuesValue in ((JArray)valuesArray)) + { + TagValue tagValueInstance = new TagValue(); + tagInstance.Values.Add(tagValueInstance); + + JToken idValue2 = valuesValue["id"]; + if (idValue2 != null && idValue2.Type != JTokenType.Null) + { + string idInstance2 = ((string)idValue2); + tagValueInstance.Id = idInstance2; + } + + JToken tagValueValue = valuesValue["tagValue"]; + if (tagValueValue != null && tagValueValue.Type != JTokenType.Null) + { + string tagValueInstance2 = ((string)tagValueValue); + tagValueInstance.Value = tagValueInstance2; + } + + JToken countValue2 = valuesValue["count"]; + if (countValue2 != null && countValue2.Type != JTokenType.Null) + { + TagCount countInstance2 = new TagCount(); + tagValueInstance.Count = countInstance2; + + JToken typeValue2 = countValue2["type"]; + if (typeValue2 != null && typeValue2.Type != JTokenType.Null) + { + string typeInstance2 = ((string)typeValue2); + countInstance2.Type = typeInstance2; + } + + JToken valueValue2 = countValue2["value"]; + if (valueValue2 != null && valueValue2.Type != JTokenType.Null) + { + string valueInstance2 = ((string)valueValue2); + countInstance2.Value = valueInstance2; + } + } + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Create a subscription resource tag value. + /// + /// + /// Required. The name of the tag. + /// + /// + /// Required. The value of the tag. + /// + /// + /// Cancellation token. + /// + /// + /// Tag information. + /// + public async Task CreateOrUpdateValueAsync(string tagName, string tagValue, CancellationToken cancellationToken) + { + // Validate + if (tagName == null) + { + throw new ArgumentNullException("tagName"); + } + if (tagValue == null) + { + throw new ArgumentNullException("tagValue"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("tagName", tagName); + tracingParameters.Add("tagValue", tagValue); + TracingAdapter.Enter(invocationId, this, "CreateOrUpdateValueAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/tagNames/"; + url = url + Uri.EscapeDataString(tagName); + url = url + "/tagValues/"; + url = url + Uri.EscapeDataString(tagValue); + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Put; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.Created) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + TagCreateValueResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.Created) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new TagCreateValueResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + TagValue valueInstance = new TagValue(); + result.Value = valueInstance; + + JToken idValue = responseDoc["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + valueInstance.Id = idInstance; + } + + JToken tagValueValue = responseDoc["tagValue"]; + if (tagValueValue != null && tagValueValue.Type != JTokenType.Null) + { + string tagValueInstance = ((string)tagValueValue); + valueInstance.Value = tagValueInstance; + } + + JToken countValue = responseDoc["count"]; + if (countValue != null && countValue.Type != JTokenType.Null) + { + TagCount countInstance = new TagCount(); + valueInstance.Count = countInstance; + + JToken typeValue = countValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + countInstance.Type = typeInstance; + } + + JToken valueValue = countValue["value"]; + if (valueValue != null && valueValue.Type != JTokenType.Null) + { + string valueInstance2 = ((string)valueValue); + countInstance.Value = valueInstance2; + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Delete a subscription resource tag. + /// + /// + /// Required. The name of the tag. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public async Task DeleteAsync(string tagName, CancellationToken cancellationToken) + { + // Validate + if (tagName == null) + { + throw new ArgumentNullException("tagName"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("tagName", tagName); + TracingAdapter.Enter(invocationId, this, "DeleteAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/tagNames/"; + url = url + Uri.EscapeDataString(tagName); + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Delete; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.NoContent) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + AzureOperationResponse result = null; + // Deserialize Response + result = new AzureOperationResponse(); + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Delete a subscription resource tag value. + /// + /// + /// Required. The name of the tag. + /// + /// + /// Required. The value of the tag. + /// + /// + /// Cancellation token. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public async Task DeleteValueAsync(string tagName, string tagValue, CancellationToken cancellationToken) + { + // Validate + if (tagName == null) + { + throw new ArgumentNullException("tagName"); + } + if (tagValue == null) + { + throw new ArgumentNullException("tagValue"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("tagName", tagName); + tracingParameters.Add("tagValue", tagValue); + TracingAdapter.Enter(invocationId, this, "DeleteValueAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/tagNames/"; + url = url + Uri.EscapeDataString(tagName); + url = url + "/tagValues/"; + url = url + Uri.EscapeDataString(tagValue); + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Delete; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK && statusCode != HttpStatusCode.NoContent) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + AzureOperationResponse result = null; + // Deserialize Response + result = new AzureOperationResponse(); + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Get a list of subscription resource tags. + /// + /// + /// Cancellation token. + /// + /// + /// List of subscription tags. + /// + public async Task ListAsync(CancellationToken cancellationToken) + { + // Validate + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + TracingAdapter.Enter(invocationId, this, "ListAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/subscriptions/"; + if (this.Client.Credentials.SubscriptionId != null) + { + url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); + } + url = url + "/tagNames"; + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + TagsListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new TagsListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + TagDetails tagDetailsInstance = new TagDetails(); + result.Tags.Add(tagDetailsInstance); + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + tagDetailsInstance.Id = idInstance; + } + + JToken tagNameValue = valueValue["tagName"]; + if (tagNameValue != null && tagNameValue.Type != JTokenType.Null) + { + string tagNameInstance = ((string)tagNameValue); + tagDetailsInstance.Name = tagNameInstance; + } + + JToken countValue = valueValue["count"]; + if (countValue != null && countValue.Type != JTokenType.Null) + { + TagCount countInstance = new TagCount(); + tagDetailsInstance.Count = countInstance; + + JToken typeValue = countValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + countInstance.Type = typeInstance; + } + + JToken valueValue2 = countValue["value"]; + if (valueValue2 != null && valueValue2.Type != JTokenType.Null) + { + string valueInstance = ((string)valueValue2); + countInstance.Value = valueInstance; + } + } + + JToken valuesArray = valueValue["values"]; + if (valuesArray != null && valuesArray.Type != JTokenType.Null) + { + foreach (JToken valuesValue in ((JArray)valuesArray)) + { + TagValue tagValueInstance = new TagValue(); + tagDetailsInstance.Values.Add(tagValueInstance); + + JToken idValue2 = valuesValue["id"]; + if (idValue2 != null && idValue2.Type != JTokenType.Null) + { + string idInstance2 = ((string)idValue2); + tagValueInstance.Id = idInstance2; + } + + JToken tagValueValue = valuesValue["tagValue"]; + if (tagValueValue != null && tagValueValue.Type != JTokenType.Null) + { + string tagValueInstance2 = ((string)tagValueValue); + tagValueInstance.Value = tagValueInstance2; + } + + JToken countValue2 = valuesValue["count"]; + if (countValue2 != null && countValue2.Type != JTokenType.Null) + { + TagCount countInstance2 = new TagCount(); + tagValueInstance.Count = countInstance2; + + JToken typeValue2 = countValue2["type"]; + if (typeValue2 != null && typeValue2.Type != JTokenType.Null) + { + string typeInstance2 = ((string)typeValue2); + countInstance2.Type = typeInstance2; + } + + JToken valueValue3 = countValue2["value"]; + if (valueValue3 != null && valueValue3.Type != JTokenType.Null) + { + string valueInstance2 = ((string)valueValue3); + countInstance2.Value = valueInstance2; + } + } + } + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + + /// + /// Get a list of tags under a subscription. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// Cancellation token. + /// + /// + /// List of subscription tags. + /// + public async Task ListNextAsync(string nextLink, CancellationToken cancellationToken) + { + // Validate + if (nextLink == null) + { + throw new ArgumentNullException("nextLink"); + } + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("nextLink", nextLink); + TracingAdapter.Enter(invocationId, this, "ListNextAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + nextLink; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + TagsListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new TagsListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + TagDetails tagDetailsInstance = new TagDetails(); + result.Tags.Add(tagDetailsInstance); + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + tagDetailsInstance.Id = idInstance; + } + + JToken tagNameValue = valueValue["tagName"]; + if (tagNameValue != null && tagNameValue.Type != JTokenType.Null) + { + string tagNameInstance = ((string)tagNameValue); + tagDetailsInstance.Name = tagNameInstance; + } + + JToken countValue = valueValue["count"]; + if (countValue != null && countValue.Type != JTokenType.Null) + { + TagCount countInstance = new TagCount(); + tagDetailsInstance.Count = countInstance; + + JToken typeValue = countValue["type"]; + if (typeValue != null && typeValue.Type != JTokenType.Null) + { + string typeInstance = ((string)typeValue); + countInstance.Type = typeInstance; + } + + JToken valueValue2 = countValue["value"]; + if (valueValue2 != null && valueValue2.Type != JTokenType.Null) + { + string valueInstance = ((string)valueValue2); + countInstance.Value = valueInstance; + } + } + + JToken valuesArray = valueValue["values"]; + if (valuesArray != null && valuesArray.Type != JTokenType.Null) + { + foreach (JToken valuesValue in ((JArray)valuesArray)) + { + TagValue tagValueInstance = new TagValue(); + tagDetailsInstance.Values.Add(tagValueInstance); + + JToken idValue2 = valuesValue["id"]; + if (idValue2 != null && idValue2.Type != JTokenType.Null) + { + string idInstance2 = ((string)idValue2); + tagValueInstance.Id = idInstance2; + } + + JToken tagValueValue = valuesValue["tagValue"]; + if (tagValueValue != null && tagValueValue.Type != JTokenType.Null) + { + string tagValueInstance2 = ((string)tagValueValue); + tagValueInstance.Value = tagValueInstance2; + } + + JToken countValue2 = valuesValue["count"]; + if (countValue2 != null && countValue2.Type != JTokenType.Null) + { + TagCount countInstance2 = new TagCount(); + tagValueInstance.Count = countInstance2; + + JToken typeValue2 = countValue2["type"]; + if (typeValue2 != null && typeValue2.Type != JTokenType.Null) + { + string typeInstance2 = ((string)typeValue2); + countInstance2.Type = typeInstance2; + } + + JToken valueValue3 = countValue2["value"]; + if (valueValue3 != null && valueValue3.Type != JTokenType.Null) + { + string valueInstance2 = ((string)valueValue3); + countInstance2.Value = valueInstance2; + } + } + } + } + } + } + + JToken nextLinkValue = responseDoc["nextLink"]; + if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null) + { + string nextLinkInstance = ((string)nextLinkValue); + result.NextLink = nextLinkInstance; + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/TagOperationsExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/TagOperationsExtensions.cs new file mode 100644 index 000000000000..45798bf07941 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/TagOperationsExtensions.cs @@ -0,0 +1,282 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Management.Internal.Resources.Models; + +namespace Microsoft.Azure.Management.Internal.Resources +{ + public static partial class TagOperationsExtensions + { + /// + /// Create a subscription resource tag. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.ITagOperations. + /// + /// + /// Required. The name of the tag. + /// + /// + /// Tag information. + /// + public static TagCreateResult CreateOrUpdate(this ITagOperations operations, string tagName) + { + return Task.Factory.StartNew((object s) => + { + return ((ITagOperations)s).CreateOrUpdateAsync(tagName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Create a subscription resource tag. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.ITagOperations. + /// + /// + /// Required. The name of the tag. + /// + /// + /// Tag information. + /// + public static Task CreateOrUpdateAsync(this ITagOperations operations, string tagName) + { + return operations.CreateOrUpdateAsync(tagName, CancellationToken.None); + } + + /// + /// Create a subscription resource tag value. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.ITagOperations. + /// + /// + /// Required. The name of the tag. + /// + /// + /// Required. The value of the tag. + /// + /// + /// Tag information. + /// + public static TagCreateValueResult CreateOrUpdateValue(this ITagOperations operations, string tagName, string tagValue) + { + return Task.Factory.StartNew((object s) => + { + return ((ITagOperations)s).CreateOrUpdateValueAsync(tagName, tagValue); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Create a subscription resource tag value. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.ITagOperations. + /// + /// + /// Required. The name of the tag. + /// + /// + /// Required. The value of the tag. + /// + /// + /// Tag information. + /// + public static Task CreateOrUpdateValueAsync(this ITagOperations operations, string tagName, string tagValue) + { + return operations.CreateOrUpdateValueAsync(tagName, tagValue, CancellationToken.None); + } + + /// + /// Delete a subscription resource tag. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.ITagOperations. + /// + /// + /// Required. The name of the tag. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static AzureOperationResponse Delete(this ITagOperations operations, string tagName) + { + return Task.Factory.StartNew((object s) => + { + return ((ITagOperations)s).DeleteAsync(tagName); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Delete a subscription resource tag. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.ITagOperations. + /// + /// + /// Required. The name of the tag. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static Task DeleteAsync(this ITagOperations operations, string tagName) + { + return operations.DeleteAsync(tagName, CancellationToken.None); + } + + /// + /// Delete a subscription resource tag value. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.ITagOperations. + /// + /// + /// Required. The name of the tag. + /// + /// + /// Required. The value of the tag. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static AzureOperationResponse DeleteValue(this ITagOperations operations, string tagName, string tagValue) + { + return Task.Factory.StartNew((object s) => + { + return ((ITagOperations)s).DeleteValueAsync(tagName, tagValue); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Delete a subscription resource tag value. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.ITagOperations. + /// + /// + /// Required. The name of the tag. + /// + /// + /// Required. The value of the tag. + /// + /// + /// A standard service response including an HTTP status code and + /// request ID. + /// + public static Task DeleteValueAsync(this ITagOperations operations, string tagName, string tagValue) + { + return operations.DeleteValueAsync(tagName, tagValue, CancellationToken.None); + } + + /// + /// Get a list of subscription resource tags. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.ITagOperations. + /// + /// + /// List of subscription tags. + /// + public static TagsListResult List(this ITagOperations operations) + { + return Task.Factory.StartNew((object s) => + { + return ((ITagOperations)s).ListAsync(); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get a list of subscription resource tags. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.ITagOperations. + /// + /// + /// List of subscription tags. + /// + public static Task ListAsync(this ITagOperations operations) + { + return operations.ListAsync(CancellationToken.None); + } + + /// + /// Get a list of tags under a subscription. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.ITagOperations. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of subscription tags. + /// + public static TagsListResult ListNext(this ITagOperations operations, string nextLink) + { + return Task.Factory.StartNew((object s) => + { + return ((ITagOperations)s).ListNextAsync(nextLink); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Get a list of tags under a subscription. + /// + /// + /// Reference to the + /// Microsoft.Azure.Management.Internal.Resources.ITagOperations. + /// + /// + /// Required. NextLink from the previous successful call to List + /// operation. + /// + /// + /// List of subscription tags. + /// + public static Task ListNextAsync(this ITagOperations operations, string nextLink) + { + return operations.ListNextAsync(nextLink, CancellationToken.None); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/TenantOperations.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/TenantOperations.cs new file mode 100644 index 000000000000..e2b7192a6c9c --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/TenantOperations.cs @@ -0,0 +1,218 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Threading; +using System.Threading.Tasks; +using Hyak.Common; +using Microsoft.Azure.Internal.Subscriptions.Models; +using Newtonsoft.Json.Linq; + +namespace Microsoft.Azure.Internal.Subscriptions +{ + /// + /// Operations for managing tenants. + /// + internal partial class TenantOperations : IServiceOperations, ITenantOperations + { + /// + /// Initializes a new instance of the TenantOperations class. + /// + /// + /// Reference to the service client. + /// + internal TenantOperations(SubscriptionClient client) + { + this._client = client; + } + + private SubscriptionClient _client; + + /// + /// Gets a reference to the + /// Microsoft.Azure.Internal.Subscriptions.SubscriptionClient. + /// + public SubscriptionClient Client + { + get { return this._client; } + } + + /// + /// Gets a list of the tenantIds. + /// + /// + /// Cancellation token. + /// + /// + /// Tenant Ids information. + /// + public async Task ListAsync(CancellationToken cancellationToken) + { + // Validate + + // Tracing + bool shouldTrace = TracingAdapter.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = TracingAdapter.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + TracingAdapter.Enter(invocationId, this, "ListAsync", tracingParameters); + } + + // Construct URL + string url = ""; + url = url + "/tenants"; + List queryParameters = new List(); + queryParameters.Add("api-version=2014-04-01-preview"); + if (queryParameters.Count > 0) + { + url = url + "?" + string.Join("&", queryParameters); + } + string baseUrl = this.Client.BaseUri.AbsoluteUri; + // Trim '/' character from the end of baseUrl and beginning of url. + if (baseUrl[baseUrl.Length - 1] == '/') + { + baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); + } + if (url[0] == '/') + { + url = url.Substring(1); + } + url = baseUrl + "/" + url; + url = url.Replace(" ", "%20"); + + // Create HTTP transport objects + HttpRequestMessage httpRequest = null; + try + { + httpRequest = new HttpRequestMessage(); + httpRequest.Method = HttpMethod.Get; + httpRequest.RequestUri = new Uri(url); + + // Set Headers + + // Set Credentials + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + + // Send Request + HttpResponseMessage httpResponse = null; + try + { + if (shouldTrace) + { + TracingAdapter.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + TracingAdapter.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + if (statusCode != HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); + if (shouldTrace) + { + TracingAdapter.Error(invocationId, ex); + } + throw ex; + } + + // Create Result + TenantListResult result = null; + // Deserialize Response + if (statusCode == HttpStatusCode.OK) + { + cancellationToken.ThrowIfCancellationRequested(); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + result = new TenantListResult(); + JToken responseDoc = null; + if (string.IsNullOrEmpty(responseContent) == false) + { + responseDoc = JToken.Parse(responseContent); + } + + if (responseDoc != null && responseDoc.Type != JTokenType.Null) + { + JToken valueArray = responseDoc["value"]; + if (valueArray != null && valueArray.Type != JTokenType.Null) + { + foreach (JToken valueValue in ((JArray)valueArray)) + { + TenantIdDescription tenantIdDescriptionInstance = new TenantIdDescription(); + result.TenantIds.Add(tenantIdDescriptionInstance); + + JToken idValue = valueValue["id"]; + if (idValue != null && idValue.Type != JTokenType.Null) + { + string idInstance = ((string)idValue); + tenantIdDescriptionInstance.Id = idInstance; + } + + JToken tenantIdValue = valueValue["tenantId"]; + if (tenantIdValue != null && tenantIdValue.Type != JTokenType.Null) + { + string tenantIdInstance = ((string)tenantIdValue); + tenantIdDescriptionInstance.TenantId = tenantIdInstance; + } + } + } + } + + } + result.StatusCode = statusCode; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + + if (shouldTrace) + { + TracingAdapter.Exit(invocationId, result); + } + return result; + } + finally + { + if (httpResponse != null) + { + httpResponse.Dispose(); + } + } + } + finally + { + if (httpRequest != null) + { + httpRequest.Dispose(); + } + } + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/TenantOperationsExtensions.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/TenantOperationsExtensions.cs new file mode 100644 index 000000000000..fe158f891fc4 --- /dev/null +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Generated/TenantOperationsExtensions.cs @@ -0,0 +1,62 @@ +// +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// + +// Warning: This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if the +// code is regenerated. + +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Azure.Internal.Subscriptions.Models; + +namespace Microsoft.Azure.Internal.Subscriptions +{ + public static partial class TenantOperationsExtensions + { + /// + /// Gets a list of the tenantIds. + /// + /// + /// Reference to the Microsoft.Azure.Internal.Subscriptions.ITenantOperations. + /// + /// + /// Tenant Ids information. + /// + public static TenantListResult List(this ITenantOperations operations) + { + return Task.Factory.StartNew((object s) => + { + return ((ITenantOperations)s).ListAsync(); + } + , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Gets a list of the tenantIds. + /// + /// + /// Reference to the Microsoft.Azure.Internal.Subscriptions.ITenantOperations. + /// + /// + /// Tenant Ids information. + /// + public static Task ListAsync(this ITenantOperations operations) + { + return operations.ListAsync(CancellationToken.None); + } + } +} diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Properties/AssemblyInfo.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Properties/AssemblyInfo.cs index 36cdff4f9503..abfe416364fb 100644 --- a/src/ResourceManager/Common/Commands.ResourceManager.Common/Properties/AssemblyInfo.cs +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Properties/AssemblyInfo.cs @@ -14,7 +14,6 @@ using System; using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; [assembly: AssemblyTitle("Microsoft Azure PowerShell - Resource Manager Common Library")] @@ -26,9 +25,4 @@ [assembly: CLSCompliant(false)] [assembly: Guid("3819d8a7-c62c-4c47-8ddd-0332d9ce1252")] [assembly: AssemblyVersion("1.0.0")] -[assembly: AssemblyFileVersion("1.0.0")] -#if SIGN -[assembly: InternalsVisibleTo("Microsoft.Azure.Commands.Profile.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")] -#else -[assembly: InternalsVisibleTo("Microsoft.Azure.Commands.Profile.Test")] -#endif \ No newline at end of file +[assembly: AssemblyFileVersion("1.0.0")] \ No newline at end of file diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/Properties/Resources.Designer.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/Properties/Resources.Designer.cs index 201a60db30d6..3622d8e6e313 100644 --- a/src/ResourceManager/Common/Commands.ResourceManager.Common/Properties/Resources.Designer.cs +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/Properties/Resources.Designer.cs @@ -8,10 +8,10 @@ // //------------------------------------------------------------------------------ -namespace Microsoft.Azure.Commands.ResourceManager.Common.Properties { - using System; - - +namespace Microsoft.Azure.Commands.ResourceManager.Common.Properties +{ + + /// /// A strongly-typed resource class, for looking up localized strings, etc. /// diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/RPRegistrationDelegatingHandler.cs b/src/ResourceManager/Common/Commands.ResourceManager.Common/RPRegistrationDelegatingHandler.cs index 1e1f89834bef..4bc45f617e86 100644 --- a/src/ResourceManager/Common/Commands.ResourceManager.Common/RPRegistrationDelegatingHandler.cs +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/RPRegistrationDelegatingHandler.cs @@ -14,16 +14,12 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Net.Http; -using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Commands.ResourceManager.Common.Properties; -using Microsoft.Azure.Common.Authentication; -using Microsoft.Azure.Common.Authentication.Models; -using Microsoft.Azure.Management.Resources; -using Microsoft.Azure.Management.Resources.Models; +using Microsoft.Azure.Management.Internal.Resources; +using Microsoft.Azure.Management.Internal.Resources.Models; using Microsoft.WindowsAzure.Commands.Utilities.Common; namespace Microsoft.Azure.Common.Authentication.Models diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/packages.config b/src/ResourceManager/Common/Commands.ResourceManager.Common/packages.config index dbe00161708b..847378896b70 100644 --- a/src/ResourceManager/Common/Commands.ResourceManager.Common/packages.config +++ b/src/ResourceManager/Common/Commands.ResourceManager.Common/packages.config @@ -6,7 +6,6 @@ - diff --git a/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs b/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs index 358efd617afb..b1c0ffe39a01 100644 --- a/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs +++ b/src/ResourceManager/Profile/Commands.Profile.Test/RPRegistrationDelegatingHandlerTests.cs @@ -18,14 +18,16 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Common.Authentication.Models; -using Microsoft.Azure.Management.Resources; +using Microsoft.Azure.Management.Internal.Resources; using Microsoft.WindowsAzure.Commands.Common.Test.Mocks; using Moq; using Xunit; using System.Linq; using Microsoft.WindowsAzure.Commands.Test.Utilities.Common; using Microsoft.Azure.Commands.ResourceManager.Common; -using Microsoft.Azure.Management.Resources.Models; +using Microsoft.Azure.Management.Internal.Resources.Models; +using Microsoft.WindowsAzure.Commands.ScenarioTest; +using Hyak.Common; namespace Microsoft.Azure.Commands.Profile.Test { @@ -36,6 +38,7 @@ public class RPRegistrationDelegatingHandlerTests : RMTestBase private const string incompatibleUri = "https://management.core.windows.net/"; [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] public void InvokeRegistrationForUnregisteredResourceProviders() { // Setup @@ -84,6 +87,7 @@ public void InvokeRegistrationForUnregisteredResourceProviders() } [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] public void DoesNotInvokeRegistrationForRegisteredResourceProviders() { // Setup @@ -117,6 +121,7 @@ public void DoesNotInvokeRegistrationForRegisteredResourceProviders() } [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] public void DoesNotInvokeRegistrationForUnrelatedStatusCode() { // Setup @@ -150,6 +155,7 @@ public void DoesNotInvokeRegistrationForUnrelatedStatusCode() } [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] public void DoesNotInvokeRegistrationForIncompatibleUri() { // Setup @@ -183,6 +189,7 @@ public void DoesNotInvokeRegistrationForIncompatibleUri() } [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] public void DoesNotHangForLongRegistrationCalls() { // Setup @@ -230,6 +237,44 @@ public void DoesNotHangForLongRegistrationCalls() Assert.Equal(response.Content.ReadAsStringAsync().Result, "registered to use namespace"); mockProvidersOperations.Verify(f => f.RegisterAsync("microsoft.compute", It.IsAny()), Times.AtMost(4)); } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void DoesNotThrowForFailedRegistrationCall() + { + // Setup + Mock mockClient = new Mock(); + Mock mockProvidersOperations = new Mock(); + mockClient.Setup(f => f.Providers).Returns(mockProvidersOperations.Object); + mockProvidersOperations.Setup(f => f.GetAsync(It.IsAny(), It.IsAny())) + .Throws(new CloudException("PR reg failed")); + HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, compatibleUri); + Dictionary> mapping = new Dictionary> + { + { + request, new List + { + new HttpResponseMessage(HttpStatusCode.Conflict) { Content = new StringContent("registered to use namespace") }, + new HttpResponseMessage(HttpStatusCode.Conflict) { Content = new StringContent("registered to use namespace") } + } + } + }; + List msgs = new List(); + RPRegistrationDelegatingHandler rpHandler = new RPRegistrationDelegatingHandler(() => mockClient.Object, s => msgs.Add(s)) + { + InnerHandler = new MockResponseDelegatingHandler(mapping) + }; + HttpClient httpClient = new HttpClient(rpHandler); + + // Test + HttpResponseMessage response = httpClient.SendAsync(request).Result; + + // Assert + Assert.True(msgs.Any(s => s.Equals("Failed to register resource provider 'microsoft.compute'.Details: 'PR reg failed'"))); + Assert.Equal(response.StatusCode, HttpStatusCode.Conflict); + Assert.Equal(response.Content.ReadAsStringAsync().Result, "registered to use namespace"); + mockProvidersOperations.Verify(f => f.RegisterAsync("microsoft.compute", It.IsAny()), Times.AtMost(4)); + } } public class MockResponseDelegatingHandler : DelegatingHandler diff --git a/src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj b/src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj index e2efc03e6b61..c5c13e3546d8 100644 --- a/src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj +++ b/src/ResourceManager/Profile/Commands.Profile/Commands.Profile.csproj @@ -138,12 +138,14 @@ + + diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/ModelExtensions.cs b/src/ResourceManager/Profile/Commands.Profile/Models/ModelExtensions.cs similarity index 90% rename from src/ResourceManager/Common/Commands.ResourceManager.Common/ModelExtensions.cs rename to src/ResourceManager/Profile/Commands.Profile/Models/ModelExtensions.cs index 4fc3182aafbe..ed8cbc23fa5f 100644 --- a/src/ResourceManager/Common/Commands.ResourceManager.Common/ModelExtensions.cs +++ b/src/ResourceManager/Profile/Commands.Profile/Models/ModelExtensions.cs @@ -18,10 +18,9 @@ namespace Microsoft.Azure.Commands.ResourceManager.Common { - public static class ModelExtensions + internal static class ModelExtensions { - - public static AzureSubscription ToAzureSubscription(this Subscription other, AzureContext context) + internal static AzureSubscription ToAzureSubscription(this Subscription other, AzureContext context) { var subscription = new AzureSubscription(); subscription.Account = context.Account != null ? context.Account.Id : null; diff --git a/src/ResourceManager/Common/Commands.ResourceManager.Common/RMProfileClient.cs b/src/ResourceManager/Profile/Commands.Profile/Models/RMProfileClient.cs similarity index 100% rename from src/ResourceManager/Common/Commands.ResourceManager.Common/RMProfileClient.cs rename to src/ResourceManager/Profile/Commands.Profile/Models/RMProfileClient.cs From 198071019bbc02027f9d7fe14e44e6b18f28d962 Mon Sep 17 00:00:00 2001 From: ogail Date: Tue, 6 Oct 2015 11:50:16 -0700 Subject: [PATCH 6/6] Regenerate MSI --- setup/azurecmdfiles.wxi | 92 ++++++++++++++++++++++++++++++++++------ tools/BuildInstaller.ps1 | 3 ++ 2 files changed, 83 insertions(+), 12 deletions(-) diff --git a/setup/azurecmdfiles.wxi b/setup/azurecmdfiles.wxi index a80793ae1e1d..1057e8bca48b 100644 --- a/setup/azurecmdfiles.wxi +++ b/setup/azurecmdfiles.wxi @@ -489,6 +489,9 @@ + + + @@ -498,6 +501,9 @@ + + + @@ -546,6 +552,18 @@ + + + + + + + + + + + + @@ -1045,6 +1063,12 @@ + + + + + + @@ -1141,9 +1165,6 @@ - - - @@ -1158,12 +1179,18 @@ + + + + + + @@ -1182,6 +1209,21 @@ + + + + + + + + + + + + + + + @@ -1642,9 +1684,6 @@ - - - @@ -1707,6 +1746,12 @@ + + + + + + @@ -1856,6 +1901,12 @@ + + + + + + @@ -2026,6 +2077,9 @@ + + + @@ -2221,9 +2275,6 @@ - - - @@ -4532,9 +4583,11 @@ + + @@ -4551,6 +4604,10 @@ + + + + @@ -4714,6 +4771,8 @@ + + @@ -4746,19 +4805,25 @@ - + + + + + + + @@ -4909,7 +4974,6 @@ - @@ -4930,6 +4994,8 @@ + + @@ -4979,6 +5045,8 @@ + + @@ -5035,6 +5103,7 @@ + @@ -5098,7 +5167,6 @@ - diff --git a/tools/BuildInstaller.ps1 b/tools/BuildInstaller.ps1 index 7b391af94584..150fb3fddde4 100644 --- a/tools/BuildInstaller.ps1 +++ b/tools/BuildInstaller.ps1 @@ -50,6 +50,9 @@ if ($wixInstallRoot -eq $null){ #and we just register both 3.8 & 3.5 to simplify the script $env:path = $env:path + ";$wixInstallRoot" +# Regenerate the installer files +&"$env:AzurePSRoot\tools\Installer\generate.ps1" 'Debug' + # Build the cmdlets and installer in debug mode msbuild "$env:AzurePSRoot\build.proj" /t:Build