diff --git a/src/SDKs/ManagementGroups/AzSdk.RP.props b/src/SDKs/ManagementGroups/AzSdk.RP.props
new file mode 100644
index 000000000000..e32d8b56589e
--- /dev/null
+++ b/src/SDKs/ManagementGroups/AzSdk.RP.props
@@ -0,0 +1,7 @@
+
+
+
+ Management_2017-11-01-preview;
+ $(PackageTags);$(CommonTags);$(AzureApiTag);
+
+
\ No newline at end of file
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/IManagementGroupSubscriptionsOperations.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/IManagementGroupSubscriptionsOperations.cs
new file mode 100644
index 000000000000..0673f0274691
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/IManagementGroupSubscriptionsOperations.cs
@@ -0,0 +1,79 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// ManagementGroupSubscriptionsOperations operations.
+ ///
+ public partial interface IManagementGroupSubscriptionsOperations
+ {
+ ///
+ /// Associates existing subscription with the management group.
+ ///
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Subscription ID.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task CreateWithHttpMessagesAsync(string groupId, string subscriptionId, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// De-associates subscription from the management group.
+ ///
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Subscription ID.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task DeleteWithHttpMessagesAsync(string groupId, string subscriptionId, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/IManagementGroupsAPIClient.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/IManagementGroupsAPIClient.cs
new file mode 100644
index 000000000000..63ca331df15b
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/IManagementGroupsAPIClient.cs
@@ -0,0 +1,87 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using Newtonsoft.Json;
+
+ ///
+ /// The Azure Management Groups API enables consolidation of multiple
+ /// subscriptions/resources into an organizational hierarchy and centrally
+ /// manage access control, policies, alerting and reporting for those
+ /// resources.
+ ///
+ ///
+ public partial interface IManagementGroupsAPIClient : System.IDisposable
+ {
+ ///
+ /// The base URI of the service.
+ ///
+ System.Uri BaseUri { get; set; }
+
+ ///
+ /// Gets or sets json serialization settings.
+ ///
+ JsonSerializerSettings SerializationSettings { get; }
+
+ ///
+ /// Gets or sets json deserialization settings.
+ ///
+ JsonSerializerSettings DeserializationSettings { get; }
+
+ ///
+ /// Credentials needed for the client to connect to Azure.
+ ///
+ ServiceClientCredentials Credentials { get; }
+
+ ///
+ /// Version of the API to be used with the client request. The current
+ /// version is 2017-11-01-preview.
+ ///
+ string ApiVersion { get; }
+
+ ///
+ /// Gets or sets the preferred language for the response.
+ ///
+ string AcceptLanguage { get; set; }
+
+ ///
+ /// Gets or sets the retry timeout in seconds for Long Running
+ /// Operations. Default value is 30.
+ ///
+ int? LongRunningOperationRetryTimeout { get; set; }
+
+ ///
+ /// When set to true a unique x-ms-client-request-id value is generated
+ /// and included in each request. Default is true.
+ ///
+ bool? GenerateClientRequestId { get; set; }
+
+
+ ///
+ /// Gets the IManagementGroupsOperations.
+ ///
+ IManagementGroupsOperations ManagementGroups { get; }
+
+ ///
+ /// Gets the IManagementGroupSubscriptionsOperations.
+ ///
+ IManagementGroupSubscriptionsOperations ManagementGroupSubscriptions { get; }
+
+ ///
+ /// Gets the IOperations.
+ ///
+ IOperations Operations { get; }
+
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/IManagementGroupsOperations.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/IManagementGroupsOperations.cs
new file mode 100644
index 000000000000..d10ec6d220d0
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/IManagementGroupsOperations.cs
@@ -0,0 +1,205 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// ManagementGroupsOperations operations.
+ ///
+ public partial interface IManagementGroupsOperations
+ {
+ ///
+ /// List management groups for the authenticated user.
+ ///
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// Page continuation token is only used if a previous operation
+ /// returned a partial result.
+ /// If a previous response contains a nextLink element, the value of
+ /// the nextLink element will include a token parameter that specifies
+ /// a starting point to use for subsequent calls.
+ ///
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task>> ListWithHttpMessagesAsync(string cacheControl = "no-cache", string skiptoken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Get the details of the management group.
+ ///
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// The $expand=children query string parameter allows clients to
+ /// request inclusion of children in the response payload. Possible
+ /// values include: 'children'
+ ///
+ ///
+ /// The $recurse=true query string parameter allows clients to request
+ /// inclusion of entire hierarchy in the response payload.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> GetWithHttpMessagesAsync(string groupId, string expand = default(string), bool? recurse = default(bool?), string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Create or update a management group.
+ /// If a management group is already created and a subsequent create
+ /// request is issued with different properties, the management group
+ /// properties will be updated.
+ ///
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Management group creation parameters.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> CreateOrUpdateWithHttpMessagesAsync(string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Update a management group.
+ ///
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Management group creation parameters.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task> UpdateWithHttpMessagesAsync(string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Delete management group.
+ /// If a management group contains child resources, the request will
+ /// fail.
+ ///
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task DeleteWithHttpMessagesAsync(string groupId, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// List management groups for the authenticated user.
+ ///
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task>> ListNextWithHttpMessagesAsync(string nextPageLink, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/IOperations.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/IOperations.cs
new file mode 100644
index 000000000000..eaeea1579ebf
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/IOperations.cs
@@ -0,0 +1,68 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Operations operations.
+ ///
+ public partial interface IOperations
+ {
+ ///
+ /// Lists all of the available Management REST API operations.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Lists all of the available Management REST API operations.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// The headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/ManagementGroupSubscriptionsOperations.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/ManagementGroupSubscriptionsOperations.cs
new file mode 100644
index 000000000000..0093af6a4878
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/ManagementGroupSubscriptionsOperations.cs
@@ -0,0 +1,410 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// ManagementGroupSubscriptionsOperations operations.
+ ///
+ internal partial class ManagementGroupSubscriptionsOperations : IServiceOperations, IManagementGroupSubscriptionsOperations
+ {
+ ///
+ /// Initializes a new instance of the ManagementGroupSubscriptionsOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal ManagementGroupSubscriptionsOperations(ManagementGroupsAPIClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the ManagementGroupsAPIClient
+ ///
+ public ManagementGroupsAPIClient Client { get; private set; }
+
+ ///
+ /// Associates existing subscription with the management group.
+ ///
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Subscription ID.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task CreateWithHttpMessagesAsync(string groupId, string subscriptionId, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (groupId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "groupId");
+ }
+ if (subscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("groupId", groupId);
+ tracingParameters.Add("subscriptionId", subscriptionId);
+ tracingParameters.Add("cacheControl", cacheControl);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Create", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}").ToString();
+ _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId));
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("PUT");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (cacheControl != null)
+ {
+ if (_httpRequest.Headers.Contains("Cache-Control"))
+ {
+ _httpRequest.Headers.Remove("Cache-Control");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl);
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 204)
+ {
+ var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// De-associates subscription from the management group.
+ ///
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Subscription ID.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task DeleteWithHttpMessagesAsync(string groupId, string subscriptionId, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (groupId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "groupId");
+ }
+ if (subscriptionId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("groupId", groupId);
+ tracingParameters.Add("subscriptionId", subscriptionId);
+ tracingParameters.Add("cacheControl", cacheControl);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}/subscriptions/{subscriptionId}").ToString();
+ _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId));
+ _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("DELETE");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (cacheControl != null)
+ {
+ if (_httpRequest.Headers.Contains("Cache-Control"))
+ {
+ _httpRequest.Headers.Remove("Cache-Control");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl);
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 204)
+ {
+ var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/ManagementGroupSubscriptionsOperationsExtensions.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/ManagementGroupSubscriptionsOperationsExtensions.cs
new file mode 100644
index 000000000000..f9ad8cc8fd71
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/ManagementGroupSubscriptionsOperationsExtensions.cs
@@ -0,0 +1,115 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for ManagementGroupSubscriptionsOperations.
+ ///
+ public static partial class ManagementGroupSubscriptionsOperationsExtensions
+ {
+ ///
+ /// Associates existing subscription with the management group.
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Subscription ID.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ public static void Create(this IManagementGroupSubscriptionsOperations operations, string groupId, string subscriptionId, string cacheControl = "no-cache")
+ {
+ operations.CreateAsync(groupId, subscriptionId, cacheControl).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Associates existing subscription with the management group.
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Subscription ID.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CreateAsync(this IManagementGroupSubscriptionsOperations operations, string groupId, string subscriptionId, string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.CreateWithHttpMessagesAsync(groupId, subscriptionId, cacheControl, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// De-associates subscription from the management group.
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Subscription ID.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ public static void Delete(this IManagementGroupSubscriptionsOperations operations, string groupId, string subscriptionId, string cacheControl = "no-cache")
+ {
+ operations.DeleteAsync(groupId, subscriptionId, cacheControl).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// De-associates subscription from the management group.
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Subscription ID.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task DeleteAsync(this IManagementGroupSubscriptionsOperations operations, string groupId, string subscriptionId, string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.DeleteWithHttpMessagesAsync(groupId, subscriptionId, cacheControl, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/ManagementGroupsAPIClient.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/ManagementGroupsAPIClient.cs
new file mode 100644
index 000000000000..040378769fc8
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/ManagementGroupsAPIClient.cs
@@ -0,0 +1,331 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Microsoft.Rest.Serialization;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+
+ ///
+ /// The Azure Management Groups API enables consolidation of multiple
+ /// subscriptions/resources into an organizational hierarchy and centrally
+ /// manage access control, policies, alerting and reporting for those
+ /// resources.
+ ///
+ ///
+ public partial class ManagementGroupsAPIClient : ServiceClient, IManagementGroupsAPIClient, IAzureClient
+ {
+ ///
+ /// The base URI of the service.
+ ///
+ public System.Uri BaseUri { get; set; }
+
+ ///
+ /// Gets or sets json serialization settings.
+ ///
+ public JsonSerializerSettings SerializationSettings { get; private set; }
+
+ ///
+ /// Gets or sets json deserialization settings.
+ ///
+ public JsonSerializerSettings DeserializationSettings { get; private set; }
+
+ ///
+ /// Credentials needed for the client to connect to Azure.
+ ///
+ public ServiceClientCredentials Credentials { get; private set; }
+
+ ///
+ /// Version of the API to be used with the client request. The current version
+ /// is 2017-11-01-preview.
+ ///
+ public string ApiVersion { get; private set; }
+
+ ///
+ /// Gets or sets the preferred language for the response.
+ ///
+ public string AcceptLanguage { get; set; }
+
+ ///
+ /// Gets or sets the retry timeout in seconds for Long Running Operations.
+ /// Default value is 30.
+ ///
+ public int? LongRunningOperationRetryTimeout { get; set; }
+
+ ///
+ /// When set to true a unique x-ms-client-request-id value is generated and
+ /// included in each request. Default is true.
+ ///
+ public bool? GenerateClientRequestId { get; set; }
+
+ ///
+ /// Gets the IManagementGroupsOperations.
+ ///
+ public virtual IManagementGroupsOperations ManagementGroups { get; private set; }
+
+ ///
+ /// Gets the IManagementGroupSubscriptionsOperations.
+ ///
+ public virtual IManagementGroupSubscriptionsOperations ManagementGroupSubscriptions { get; private set; }
+
+ ///
+ /// Gets the IOperations.
+ ///
+ public virtual IOperations Operations { get; private set; }
+
+ ///
+ /// Initializes a new instance of the ManagementGroupsAPIClient class.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ protected ManagementGroupsAPIClient(params DelegatingHandler[] handlers) : base(handlers)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the ManagementGroupsAPIClient class.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ protected ManagementGroupsAPIClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers)
+ {
+ Initialize();
+ }
+
+ ///
+ /// Initializes a new instance of the ManagementGroupsAPIClient class.
+ ///
+ ///
+ /// Optional. The base URI of the service.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ protected ManagementGroupsAPIClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers)
+ {
+ if (baseUri == null)
+ {
+ throw new System.ArgumentNullException("baseUri");
+ }
+ BaseUri = baseUri;
+ }
+
+ ///
+ /// Initializes a new instance of the ManagementGroupsAPIClient class.
+ ///
+ ///
+ /// Optional. The base URI of the service.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ protected ManagementGroupsAPIClient(System.Uri baseUri, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
+ {
+ if (baseUri == null)
+ {
+ throw new System.ArgumentNullException("baseUri");
+ }
+ BaseUri = baseUri;
+ }
+
+ ///
+ /// Initializes a new instance of the ManagementGroupsAPIClient class.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public ManagementGroupsAPIClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers)
+ {
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the ManagementGroupsAPIClient class.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public ManagementGroupsAPIClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
+ {
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the ManagementGroupsAPIClient class.
+ ///
+ ///
+ /// Optional. The base URI of the service.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public ManagementGroupsAPIClient(System.Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers)
+ {
+ if (baseUri == null)
+ {
+ throw new System.ArgumentNullException("baseUri");
+ }
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ BaseUri = baseUri;
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the ManagementGroupsAPIClient class.
+ ///
+ ///
+ /// Optional. The base URI of the service.
+ ///
+ ///
+ /// Required. Credentials needed for the client to connect to Azure.
+ ///
+ ///
+ /// Optional. The http client handler used to handle http transport.
+ ///
+ ///
+ /// Optional. The delegating handlers to add to the http client pipeline.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ public ManagementGroupsAPIClient(System.Uri baseUri, ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : this(rootHandler, handlers)
+ {
+ if (baseUri == null)
+ {
+ throw new System.ArgumentNullException("baseUri");
+ }
+ if (credentials == null)
+ {
+ throw new System.ArgumentNullException("credentials");
+ }
+ BaseUri = baseUri;
+ Credentials = credentials;
+ if (Credentials != null)
+ {
+ Credentials.InitializeServiceClient(this);
+ }
+ }
+
+ ///
+ /// An optional partial-method to perform custom initialization.
+ ///
+ partial void CustomInitialize();
+ ///
+ /// Initializes client properties.
+ ///
+ private void Initialize()
+ {
+ ManagementGroups = new ManagementGroupsOperations(this);
+ ManagementGroupSubscriptions = new ManagementGroupSubscriptionsOperations(this);
+ Operations = new Operations(this);
+ BaseUri = new System.Uri("https://management.azure.com");
+ ApiVersion = "2017-11-01-preview";
+ AcceptLanguage = "en-US";
+ LongRunningOperationRetryTimeout = 30;
+ GenerateClientRequestId = true;
+ SerializationSettings = new JsonSerializerSettings
+ {
+ Formatting = Newtonsoft.Json.Formatting.Indented,
+ DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
+ DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
+ NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
+ ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
+ ContractResolver = new ReadOnlyJsonContractResolver(),
+ Converters = new List
+ {
+ new Iso8601TimeSpanConverter()
+ }
+ };
+ SerializationSettings.Converters.Add(new TransformationJsonConverter());
+ DeserializationSettings = new JsonSerializerSettings
+ {
+ DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat,
+ DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc,
+ NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore,
+ ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
+ ContractResolver = new ReadOnlyJsonContractResolver(),
+ Converters = new List
+ {
+ new Iso8601TimeSpanConverter()
+ }
+ };
+ CustomInitialize();
+ DeserializationSettings.Converters.Add(new TransformationJsonConverter());
+ DeserializationSettings.Converters.Add(new CloudErrorJsonConverter());
+ }
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/ManagementGroupsOperations.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/ManagementGroupsOperations.cs
new file mode 100644
index 000000000000..90deff98fc0f
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/ManagementGroupsOperations.cs
@@ -0,0 +1,1219 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// ManagementGroupsOperations operations.
+ ///
+ internal partial class ManagementGroupsOperations : IServiceOperations, IManagementGroupsOperations
+ {
+ ///
+ /// Initializes a new instance of the ManagementGroupsOperations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal ManagementGroupsOperations(ManagementGroupsAPIClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the ManagementGroupsAPIClient
+ ///
+ public ManagementGroupsAPIClient Client { get; private set; }
+
+ ///
+ /// List management groups for the authenticated user.
+ ///
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// Page continuation token is only used if a previous operation returned a
+ /// partial result.
+ /// If a previous response contains a nextLink element, the value of the
+ /// nextLink element will include a token parameter that specifies a starting
+ /// point to use for subsequent calls.
+ ///
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task>> ListWithHttpMessagesAsync(string cacheControl = "no-cache", string skiptoken = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("cacheControl", cacheControl);
+ tracingParameters.Add("skiptoken", skiptoken);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups").ToString();
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (skiptoken != null)
+ {
+ _queryParameters.Add(string.Format("$skiptoken={0}", System.Uri.EscapeDataString(skiptoken)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (cacheControl != null)
+ {
+ if (_httpRequest.Headers.Contains("Cache-Control"))
+ {
+ _httpRequest.Headers.Remove("Cache-Control");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl);
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse>();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Get the details of the management group.
+ ///
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// The $expand=children query string parameter allows clients to request
+ /// inclusion of children in the response payload. Possible values include:
+ /// 'children'
+ ///
+ ///
+ /// The $recurse=true query string parameter allows clients to request
+ /// inclusion of entire hierarchy in the response payload.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> GetWithHttpMessagesAsync(string groupId, string expand = default(string), bool? recurse = default(bool?), string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (groupId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "groupId");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("groupId", groupId);
+ tracingParameters.Add("expand", expand);
+ tracingParameters.Add("recurse", recurse);
+ tracingParameters.Add("cacheControl", cacheControl);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}").ToString();
+ _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (expand != null)
+ {
+ _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand)));
+ }
+ if (recurse != null)
+ {
+ _queryParameters.Add(string.Format("$recurse={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(recurse, Client.SerializationSettings).Trim('"'))));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (cacheControl != null)
+ {
+ if (_httpRequest.Headers.Contains("Cache-Control"))
+ {
+ _httpRequest.Headers.Remove("Cache-Control");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl);
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Create or update a management group.
+ /// If a management group is already created and a subsequent create request is
+ /// issued with different properties, the management group properties will be
+ /// updated.
+ ///
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Management group creation parameters.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> CreateOrUpdateWithHttpMessagesAsync(string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (groupId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "groupId");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ if (createManagementGroupRequest == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "createManagementGroupRequest");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("groupId", groupId);
+ tracingParameters.Add("createManagementGroupRequest", createManagementGroupRequest);
+ tracingParameters.Add("cacheControl", cacheControl);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "CreateOrUpdate", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}").ToString();
+ _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("PUT");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (cacheControl != null)
+ {
+ if (_httpRequest.Headers.Contains("Cache-Control"))
+ {
+ _httpRequest.Headers.Remove("Cache-Control");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl);
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ if(createManagementGroupRequest != null)
+ {
+ _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createManagementGroupRequest, Client.SerializationSettings);
+ _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
+ _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
+ }
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Update a management group.
+ ///
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Management group creation parameters.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task> UpdateWithHttpMessagesAsync(string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (groupId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "groupId");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ if (createManagementGroupRequest == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "createManagementGroupRequest");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("groupId", groupId);
+ tracingParameters.Add("createManagementGroupRequest", createManagementGroupRequest);
+ tracingParameters.Add("cacheControl", cacheControl);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Update", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}").ToString();
+ _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("PATCH");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (cacheControl != null)
+ {
+ if (_httpRequest.Headers.Contains("Cache-Control"))
+ {
+ _httpRequest.Headers.Remove("Cache-Control");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl);
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ if(createManagementGroupRequest != null)
+ {
+ _requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(createManagementGroupRequest, Client.SerializationSettings);
+ _httpRequest.Content = new StringContent(_requestContent, System.Text.Encoding.UTF8);
+ _httpRequest.Content.Headers.ContentType =System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
+ }
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Delete management group.
+ /// If a management group contains child resources, the request will fail.
+ ///
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task DeleteWithHttpMessagesAsync(string groupId, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (groupId == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "groupId");
+ }
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("groupId", groupId);
+ tracingParameters.Add("cacheControl", cacheControl);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "Delete", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/managementGroups/{groupId}").ToString();
+ _url = _url.Replace("{groupId}", System.Uri.EscapeDataString(groupId));
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("DELETE");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (cacheControl != null)
+ {
+ if (_httpRequest.Headers.Contains("Cache-Control"))
+ {
+ _httpRequest.Headers.Remove("Cache-Control");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl);
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200 && (int)_statusCode != 204)
+ {
+ var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// List management groups for the authenticated user.
+ ///
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, string cacheControl = "no-cache", Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (nextPageLink == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("nextPageLink", nextPageLink);
+ tracingParameters.Add("cacheControl", cacheControl);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters);
+ }
+ // Construct URL
+ string _url = "{nextLink}";
+ _url = _url.Replace("{nextLink}", nextPageLink);
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (cacheControl != null)
+ {
+ if (_httpRequest.Headers.Contains("Cache-Control"))
+ {
+ _httpRequest.Headers.Remove("Cache-Control");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("Cache-Control", cacheControl);
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse>();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/ManagementGroupsOperationsExtensions.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/ManagementGroupsOperationsExtensions.cs
new file mode 100644
index 000000000000..de43b076160a
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/ManagementGroupsOperationsExtensions.cs
@@ -0,0 +1,322 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for ManagementGroupsOperations.
+ ///
+ public static partial class ManagementGroupsOperationsExtensions
+ {
+ ///
+ /// List management groups for the authenticated user.
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// Page continuation token is only used if a previous operation returned a
+ /// partial result.
+ /// If a previous response contains a nextLink element, the value of the
+ /// nextLink element will include a token parameter that specifies a starting
+ /// point to use for subsequent calls.
+ ///
+ ///
+ public static IPage List(this IManagementGroupsOperations operations, string cacheControl = "no-cache", string skiptoken = default(string))
+ {
+ return operations.ListAsync(cacheControl, skiptoken).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// List management groups for the authenticated user.
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// Page continuation token is only used if a previous operation returned a
+ /// partial result.
+ /// If a previous response contains a nextLink element, the value of the
+ /// nextLink element will include a token parameter that specifies a starting
+ /// point to use for subsequent calls.
+ ///
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> ListAsync(this IManagementGroupsOperations operations, string cacheControl = "no-cache", string skiptoken = default(string), CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListWithHttpMessagesAsync(cacheControl, skiptoken, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Get the details of the management group.
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// The $expand=children query string parameter allows clients to request
+ /// inclusion of children in the response payload. Possible values include:
+ /// 'children'
+ ///
+ ///
+ /// The $recurse=true query string parameter allows clients to request
+ /// inclusion of entire hierarchy in the response payload.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ public static ManagementGroup Get(this IManagementGroupsOperations operations, string groupId, string expand = default(string), bool? recurse = default(bool?), string cacheControl = "no-cache")
+ {
+ return operations.GetAsync(groupId, expand, recurse, cacheControl).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Get the details of the management group.
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// The $expand=children query string parameter allows clients to request
+ /// inclusion of children in the response payload. Possible values include:
+ /// 'children'
+ ///
+ ///
+ /// The $recurse=true query string parameter allows clients to request
+ /// inclusion of entire hierarchy in the response payload.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task GetAsync(this IManagementGroupsOperations operations, string groupId, string expand = default(string), bool? recurse = default(bool?), string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.GetWithHttpMessagesAsync(groupId, expand, recurse, cacheControl, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Create or update a management group.
+ /// If a management group is already created and a subsequent create request is
+ /// issued with different properties, the management group properties will be
+ /// updated.
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Management group creation parameters.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ public static ManagementGroup CreateOrUpdate(this IManagementGroupsOperations operations, string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = "no-cache")
+ {
+ return operations.CreateOrUpdateAsync(groupId, createManagementGroupRequest, cacheControl).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Create or update a management group.
+ /// If a management group is already created and a subsequent create request is
+ /// issued with different properties, the management group properties will be
+ /// updated.
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Management group creation parameters.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task CreateOrUpdateAsync(this IManagementGroupsOperations operations, string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(groupId, createManagementGroupRequest, cacheControl, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Update a management group.
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Management group creation parameters.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ public static ManagementGroup Update(this IManagementGroupsOperations operations, string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = "no-cache")
+ {
+ return operations.UpdateAsync(groupId, createManagementGroupRequest, cacheControl).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Update a management group.
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Management group creation parameters.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task UpdateAsync(this IManagementGroupsOperations operations, string groupId, CreateManagementGroupRequest createManagementGroupRequest, string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.UpdateWithHttpMessagesAsync(groupId, createManagementGroupRequest, cacheControl, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Delete management group.
+ /// If a management group contains child resources, the request will fail.
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ public static void Delete(this IManagementGroupsOperations operations, string groupId, string cacheControl = "no-cache")
+ {
+ operations.DeleteAsync(groupId, cacheControl).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Delete management group.
+ /// If a management group contains child resources, the request will fail.
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// Management Group ID.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task DeleteAsync(this IManagementGroupsOperations operations, string groupId, string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ (await operations.DeleteWithHttpMessagesAsync(groupId, cacheControl, null, cancellationToken).ConfigureAwait(false)).Dispose();
+ }
+
+ ///
+ /// List management groups for the authenticated user.
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ public static IPage ListNext(this IManagementGroupsOperations operations, string nextPageLink, string cacheControl = "no-cache")
+ {
+ return operations.ListNextAsync(nextPageLink, cacheControl).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// List management groups for the authenticated user.
+ ///
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// Indicates that the request shouldn't utilize any caches.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> ListNextAsync(this IManagementGroupsOperations operations, string nextPageLink, string cacheControl = "no-cache", CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, cacheControl, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/CreateManagementGroupRequest.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/CreateManagementGroupRequest.cs
new file mode 100644
index 000000000000..24b43d68c957
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/CreateManagementGroupRequest.cs
@@ -0,0 +1,66 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups.Models
+{
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// Management group creation parameters.
+ ///
+ public partial class CreateManagementGroupRequest
+ {
+ ///
+ /// Initializes a new instance of the CreateManagementGroupRequest
+ /// class.
+ ///
+ public CreateManagementGroupRequest()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the CreateManagementGroupRequest
+ /// class.
+ ///
+ /// The friendly name of the management
+ /// group.
+ /// (Optional) The fully qualified ID for the
+ /// parent management group. For example,
+ /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
+ public CreateManagementGroupRequest(string displayName = default(string), string parentId = default(string))
+ {
+ DisplayName = displayName;
+ ParentId = parentId;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets the friendly name of the management group.
+ ///
+ [JsonProperty(PropertyName = "displayName")]
+ public string DisplayName { get; set; }
+
+ ///
+ /// Gets or sets (Optional) The fully qualified ID for the parent
+ /// management group. For example,
+ /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
+ ///
+ [JsonProperty(PropertyName = "parentId")]
+ public string ParentId { get; set; }
+
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ErrorDetails.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ErrorDetails.cs
new file mode 100644
index 000000000000..aa89c6be6343
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ErrorDetails.cs
@@ -0,0 +1,61 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups.Models
+{
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// The details of the error.
+ ///
+ public partial class ErrorDetails
+ {
+ ///
+ /// Initializes a new instance of the ErrorDetails class.
+ ///
+ public ErrorDetails()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the ErrorDetails class.
+ ///
+ /// One of a server-defined set of error
+ /// codes.
+ /// A human-readable representation of the
+ /// error.
+ public ErrorDetails(string code = default(string), string message = default(string))
+ {
+ Code = code;
+ Message = message;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets one of a server-defined set of error codes.
+ ///
+ [JsonProperty(PropertyName = "code")]
+ public string Code { get; set; }
+
+ ///
+ /// Gets or sets a human-readable representation of the error.
+ ///
+ [JsonProperty(PropertyName = "message")]
+ public string Message { get; set; }
+
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ErrorResponse.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ErrorResponse.cs
new file mode 100644
index 000000000000..735ee8f44514
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ErrorResponse.cs
@@ -0,0 +1,51 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups.Models
+{
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// The error object.
+ ///
+ public partial class ErrorResponse
+ {
+ ///
+ /// Initializes a new instance of the ErrorResponse class.
+ ///
+ public ErrorResponse()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the ErrorResponse class.
+ ///
+ /// Error
+ public ErrorResponse(ErrorDetails error = default(ErrorDetails))
+ {
+ Error = error;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets error
+ ///
+ [JsonProperty(PropertyName = "error")]
+ public ErrorDetails Error { get; set; }
+
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ErrorResponseException.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ErrorResponseException.cs
new file mode 100644
index 000000000000..b843ee906177
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ErrorResponseException.cs
@@ -0,0 +1,62 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups.Models
+{
+ using Microsoft.Rest;
+
+ ///
+ /// Exception thrown for an invalid response with ErrorResponse
+ /// information.
+ ///
+ public partial class ErrorResponseException : RestException
+ {
+ ///
+ /// Gets information about the associated HTTP request.
+ ///
+ public HttpRequestMessageWrapper Request { get; set; }
+
+ ///
+ /// Gets information about the associated HTTP response.
+ ///
+ public HttpResponseMessageWrapper Response { get; set; }
+
+ ///
+ /// Gets or sets the body object.
+ ///
+ public ErrorResponse Body { get; set; }
+
+ ///
+ /// Initializes a new instance of the ErrorResponseException class.
+ ///
+ public ErrorResponseException()
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the ErrorResponseException class.
+ ///
+ /// The exception message.
+ public ErrorResponseException(string message)
+ : this(message, null)
+ {
+ }
+
+ ///
+ /// Initializes a new instance of the ErrorResponseException class.
+ ///
+ /// The exception message.
+ /// Inner exception.
+ public ErrorResponseException(string message, System.Exception innerException)
+ : base(message, innerException)
+ {
+ }
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ManagementGroup.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ManagementGroup.cs
new file mode 100644
index 000000000000..6929d51600a7
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ManagementGroup.cs
@@ -0,0 +1,116 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups.Models
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Microsoft.Rest.Serialization;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ ///
+ /// The management group details.
+ ///
+ [Rest.Serialization.JsonTransformation]
+ public partial class ManagementGroup : IResource
+ {
+ ///
+ /// Initializes a new instance of the ManagementGroup class.
+ ///
+ public ManagementGroup()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the ManagementGroup class.
+ ///
+ /// The fully qualified ID for the management group.
+ /// For example,
+ /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
+ /// The type of the resource. For example,
+ /// /providers/Microsoft.Management/managementGroups
+ /// The name of the management group. For example,
+ /// 00000000-0000-0000-0000-000000000000
+ /// The AAD Tenant ID associated with the
+ /// management group. For example,
+ /// 00000000-0000-0000-0000-000000000000
+ /// The friendly name of the management
+ /// group.
+ /// Details
+ /// The list of children.
+ public ManagementGroup(string id = default(string), string type = default(string), string name = default(string), string tenantId = default(string), string displayName = default(string), ManagementGroupDetails details = default(ManagementGroupDetails), IList children = default(IList))
+ {
+ Id = id;
+ Type = type;
+ Name = name;
+ TenantId = tenantId;
+ DisplayName = displayName;
+ Details = details;
+ Children = children;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets the fully qualified ID for the management group. For example,
+ /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
+ ///
+ [JsonProperty(PropertyName = "id")]
+ public string Id { get; private set; }
+
+ ///
+ /// Gets the type of the resource. For example,
+ /// /providers/Microsoft.Management/managementGroups
+ ///
+ [JsonProperty(PropertyName = "type")]
+ public string Type { get; private set; }
+
+ ///
+ /// Gets the name of the management group. For example,
+ /// 00000000-0000-0000-0000-000000000000
+ ///
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; private set; }
+
+ ///
+ /// Gets or sets the AAD Tenant ID associated with the management
+ /// group. For example, 00000000-0000-0000-0000-000000000000
+ ///
+ [JsonProperty(PropertyName = "properties.tenantId")]
+ public string TenantId { get; set; }
+
+ ///
+ /// Gets or sets the friendly name of the management group.
+ ///
+ [JsonProperty(PropertyName = "properties.displayName")]
+ public string DisplayName { get; set; }
+
+ ///
+ /// Gets or sets details
+ ///
+ [JsonProperty(PropertyName = "properties.details")]
+ public ManagementGroupDetails Details { get; set; }
+
+ ///
+ /// Gets or sets the list of children.
+ ///
+ [JsonProperty(PropertyName = "properties.children")]
+ public IList Children { get; set; }
+
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ManagementGroupChildInfo.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ManagementGroupChildInfo.cs
new file mode 100644
index 000000000000..45f3819245df
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ManagementGroupChildInfo.cs
@@ -0,0 +1,85 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups.Models
+{
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ ///
+ /// The child information of a management group.
+ ///
+ public partial class ManagementGroupChildInfo
+ {
+ ///
+ /// Initializes a new instance of the ManagementGroupChildInfo class.
+ ///
+ public ManagementGroupChildInfo()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the ManagementGroupChildInfo class.
+ ///
+ /// The type of child resource.
+ /// The fully qualified ID for the child resource
+ /// (management group or subscription). For example,
+ /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
+ /// The friendly name of the child
+ /// resource.
+ /// The list of children.
+ public ManagementGroupChildInfo(string childType = default(string), string childId = default(string), string displayName = default(string), IList children = default(IList))
+ {
+ ChildType = childType;
+ ChildId = childId;
+ DisplayName = displayName;
+ Children = children;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets the type of child resource.
+ ///
+ ///
+ /// Possible values include: 'ManagementGroup', 'Subscription'
+ ///
+ [JsonProperty(PropertyName = "childType")]
+ public string ChildType { get; set; }
+
+ ///
+ /// Gets or sets the fully qualified ID for the child resource
+ /// (management group or subscription). For example,
+ /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
+ ///
+ [JsonProperty(PropertyName = "childId")]
+ public string ChildId { get; set; }
+
+ ///
+ /// Gets or sets the friendly name of the child resource.
+ ///
+ [JsonProperty(PropertyName = "displayName")]
+ public string DisplayName { get; set; }
+
+ ///
+ /// Gets or sets the list of children.
+ ///
+ [JsonProperty(PropertyName = "children")]
+ public IList Children { get; set; }
+
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ManagementGroupDetails.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ManagementGroupDetails.cs
new file mode 100644
index 000000000000..5c92ff59b371
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ManagementGroupDetails.cs
@@ -0,0 +1,78 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups.Models
+{
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// The details of a management group.
+ ///
+ public partial class ManagementGroupDetails
+ {
+ ///
+ /// Initializes a new instance of the ManagementGroupDetails class.
+ ///
+ public ManagementGroupDetails()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the ManagementGroupDetails class.
+ ///
+ /// The version number of the object.
+ /// The date and time when this object was
+ /// last updated.
+ /// The identity of the principal or process
+ /// that updated the object.
+ /// Parent
+ public ManagementGroupDetails(double? version = default(double?), System.DateTime? updatedTime = default(System.DateTime?), string updatedBy = default(string), ParentGroupInfo parent = default(ParentGroupInfo))
+ {
+ Version = version;
+ UpdatedTime = updatedTime;
+ UpdatedBy = updatedBy;
+ Parent = parent;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets the version number of the object.
+ ///
+ [JsonProperty(PropertyName = "version")]
+ public double? Version { get; set; }
+
+ ///
+ /// Gets or sets the date and time when this object was last updated.
+ ///
+ [JsonProperty(PropertyName = "updatedTime")]
+ public System.DateTime? UpdatedTime { get; set; }
+
+ ///
+ /// Gets or sets the identity of the principal or process that updated
+ /// the object.
+ ///
+ [JsonProperty(PropertyName = "updatedBy")]
+ public string UpdatedBy { get; set; }
+
+ ///
+ /// Gets or sets parent
+ ///
+ [JsonProperty(PropertyName = "parent")]
+ public ParentGroupInfo Parent { get; set; }
+
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ManagementGroupInfo.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ManagementGroupInfo.cs
new file mode 100644
index 000000000000..42cb7d13f142
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ManagementGroupInfo.cs
@@ -0,0 +1,97 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups.Models
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Serialization;
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// The management group resource.
+ ///
+ [Rest.Serialization.JsonTransformation]
+ public partial class ManagementGroupInfo
+ {
+ ///
+ /// Initializes a new instance of the ManagementGroupInfo class.
+ ///
+ public ManagementGroupInfo()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the ManagementGroupInfo class.
+ ///
+ /// The fully qualified ID for the management group.
+ /// For example,
+ /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
+ /// The type of the resource. For example,
+ /// /providers/Microsoft.Management/managementGroups
+ /// The name of the management group. For example,
+ /// 00000000-0000-0000-0000-000000000000
+ /// The AAD Tenant ID associated with the
+ /// management group. For example,
+ /// 00000000-0000-0000-0000-000000000000
+ /// The friendly name of the management
+ /// group.
+ public ManagementGroupInfo(string id = default(string), string type = default(string), string name = default(string), string tenantId = default(string), string displayName = default(string))
+ {
+ Id = id;
+ Type = type;
+ Name = name;
+ TenantId = tenantId;
+ DisplayName = displayName;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets the fully qualified ID for the management group. For example,
+ /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
+ ///
+ [JsonProperty(PropertyName = "id")]
+ public string Id { get; private set; }
+
+ ///
+ /// Gets the type of the resource. For example,
+ /// /providers/Microsoft.Management/managementGroups
+ ///
+ [JsonProperty(PropertyName = "type")]
+ public string Type { get; private set; }
+
+ ///
+ /// Gets the name of the management group. For example,
+ /// 00000000-0000-0000-0000-000000000000
+ ///
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; private set; }
+
+ ///
+ /// Gets or sets the AAD Tenant ID associated with the management
+ /// group. For example, 00000000-0000-0000-0000-000000000000
+ ///
+ [JsonProperty(PropertyName = "properties.tenantId")]
+ public string TenantId { get; set; }
+
+ ///
+ /// Gets or sets the friendly name of the management group.
+ ///
+ [JsonProperty(PropertyName = "properties.displayName")]
+ public string DisplayName { get; set; }
+
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/Operation.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/Operation.cs
new file mode 100644
index 000000000000..e9ba40616622
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/Operation.cs
@@ -0,0 +1,61 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups.Models
+{
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// Operation supported by the Microsoft.Management resource provider.
+ ///
+ public partial class Operation
+ {
+ ///
+ /// Initializes a new instance of the Operation class.
+ ///
+ public Operation()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the Operation class.
+ ///
+ /// Operation name:
+ /// {provider}/{resource}/{operation}.
+ /// The object that represents the
+ /// operation.
+ public Operation(string name = default(string), OperationDisplay display = default(OperationDisplay))
+ {
+ Name = name;
+ Display = display;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets operation name: {provider}/{resource}/{operation}.
+ ///
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; private set; }
+
+ ///
+ /// Gets or sets the object that represents the operation.
+ ///
+ [JsonProperty(PropertyName = "display")]
+ public OperationDisplay Display { get; set; }
+
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/OperationDisplay.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/OperationDisplay.cs
new file mode 100644
index 000000000000..1a843252f94e
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/OperationDisplay.cs
@@ -0,0 +1,77 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups.Models
+{
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// The object that represents the operation.
+ ///
+ public partial class OperationDisplay
+ {
+ ///
+ /// Initializes a new instance of the OperationDisplay class.
+ ///
+ public OperationDisplay()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the OperationDisplay class.
+ ///
+ /// The name of the provider.
+ /// The resource on which the operation is
+ /// performed.
+ /// The operation that can be
+ /// performed.
+ /// Operation description.
+ public OperationDisplay(string provider = default(string), string resource = default(string), string operation = default(string), string description = default(string))
+ {
+ Provider = provider;
+ Resource = resource;
+ Operation = operation;
+ Description = description;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets the name of the provider.
+ ///
+ [JsonProperty(PropertyName = "provider")]
+ public string Provider { get; private set; }
+
+ ///
+ /// Gets the resource on which the operation is performed.
+ ///
+ [JsonProperty(PropertyName = "resource")]
+ public string Resource { get; private set; }
+
+ ///
+ /// Gets the operation that can be performed.
+ ///
+ [JsonProperty(PropertyName = "operation")]
+ public string Operation { get; private set; }
+
+ ///
+ /// Gets operation description.
+ ///
+ [JsonProperty(PropertyName = "description")]
+ public string Description { get; private set; }
+
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/Page.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/Page.cs
new file mode 100644
index 000000000000..b28de3dea8a0
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/Page.cs
@@ -0,0 +1,53 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups.Models
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+
+ ///
+ /// Defines a page in Azure responses.
+ ///
+ /// Type of the page content items
+ [JsonObject]
+ public class Page : IPage
+ {
+ ///
+ /// Gets the link to the next page.
+ ///
+ [JsonProperty("nextLink")]
+ public string NextPageLink { get; private set; }
+
+ [JsonProperty("value")]
+ private IList Items{ get; set; }
+
+ ///
+ /// Returns an enumerator that iterates through the collection.
+ ///
+ /// A an enumerator that can be used to iterate through the collection.
+ public IEnumerator GetEnumerator()
+ {
+ return Items == null ? System.Linq.Enumerable.Empty().GetEnumerator() : Items.GetEnumerator();
+ }
+
+ ///
+ /// Returns an enumerator that iterates through the collection.
+ ///
+ /// A an enumerator that can be used to iterate through the collection.
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ParentGroupInfo.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ParentGroupInfo.cs
new file mode 100644
index 000000000000..480fbedcd24d
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Models/ParentGroupInfo.cs
@@ -0,0 +1,64 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups.Models
+{
+ using Newtonsoft.Json;
+ using System.Linq;
+
+ ///
+ /// (Optional) The ID of the parent management group.
+ ///
+ public partial class ParentGroupInfo
+ {
+ ///
+ /// Initializes a new instance of the ParentGroupInfo class.
+ ///
+ public ParentGroupInfo()
+ {
+ CustomInit();
+ }
+
+ ///
+ /// Initializes a new instance of the ParentGroupInfo class.
+ ///
+ /// The fully qualified ID for the parent
+ /// management group. For example,
+ /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
+ /// The friendly name of the parent
+ /// management group.
+ public ParentGroupInfo(string parentId = default(string), string displayName = default(string))
+ {
+ ParentId = parentId;
+ DisplayName = displayName;
+ CustomInit();
+ }
+
+ ///
+ /// An initialization method that performs custom operations like setting defaults
+ ///
+ partial void CustomInit();
+
+ ///
+ /// Gets or sets the fully qualified ID for the parent management
+ /// group. For example,
+ /// /providers/Microsoft.Management/managementGroups/0000000-0000-0000-0000-000000000000
+ ///
+ [JsonProperty(PropertyName = "parentId")]
+ public string ParentId { get; set; }
+
+ ///
+ /// Gets or sets the friendly name of the parent management group.
+ ///
+ [JsonProperty(PropertyName = "displayName")]
+ public string DisplayName { get; set; }
+
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Operations.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Operations.cs
new file mode 100644
index 000000000000..4e832f1beca4
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/Operations.cs
@@ -0,0 +1,390 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using Newtonsoft.Json;
+ using System.Collections;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using System.Net.Http;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Operations operations.
+ ///
+ internal partial class Operations : IServiceOperations, IOperations
+ {
+ ///
+ /// Initializes a new instance of the Operations class.
+ ///
+ ///
+ /// Reference to the service client.
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ internal Operations(ManagementGroupsAPIClient client)
+ {
+ if (client == null)
+ {
+ throw new System.ArgumentNullException("client");
+ }
+ Client = client;
+ }
+
+ ///
+ /// Gets a reference to the ManagementGroupsAPIClient
+ ///
+ public ManagementGroupsAPIClient Client { get; private set; }
+
+ ///
+ /// Lists all of the available Management REST API operations.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (Client.ApiVersion == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
+ }
+ // Construct URL
+ var _baseUrl = Client.BaseUri.AbsoluteUri;
+ var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "providers/Microsoft.Management/operations").ToString();
+ List _queryParameters = new List();
+ if (Client.ApiVersion != null)
+ {
+ _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion)));
+ }
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse>();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ ///
+ /// Lists all of the available Management REST API operations.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// Headers that will be added to request.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ ///
+ /// Thrown when the operation returned an invalid status code
+ ///
+ ///
+ /// Thrown when unable to deserialize the response
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// Thrown when a required parameter is null
+ ///
+ ///
+ /// A response object containing the response body and response headers.
+ ///
+ public async Task>> ListNextWithHttpMessagesAsync(string nextPageLink, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (nextPageLink == null)
+ {
+ throw new ValidationException(ValidationRules.CannotBeNull, "nextPageLink");
+ }
+ // Tracing
+ bool _shouldTrace = ServiceClientTracing.IsEnabled;
+ string _invocationId = null;
+ if (_shouldTrace)
+ {
+ _invocationId = ServiceClientTracing.NextInvocationId.ToString();
+ Dictionary tracingParameters = new Dictionary();
+ tracingParameters.Add("nextPageLink", nextPageLink);
+ tracingParameters.Add("cancellationToken", cancellationToken);
+ ServiceClientTracing.Enter(_invocationId, this, "ListNext", tracingParameters);
+ }
+ // Construct URL
+ string _url = "{nextLink}";
+ _url = _url.Replace("{nextLink}", nextPageLink);
+ List _queryParameters = new List();
+ if (_queryParameters.Count > 0)
+ {
+ _url += (_url.Contains("?") ? "&" : "?") + string.Join("&", _queryParameters);
+ }
+ // Create HTTP transport objects
+ var _httpRequest = new HttpRequestMessage();
+ HttpResponseMessage _httpResponse = null;
+ _httpRequest.Method = new HttpMethod("GET");
+ _httpRequest.RequestUri = new System.Uri(_url);
+ // Set Headers
+ if (Client.GenerateClientRequestId != null && Client.GenerateClientRequestId.Value)
+ {
+ _httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", System.Guid.NewGuid().ToString());
+ }
+ if (Client.AcceptLanguage != null)
+ {
+ if (_httpRequest.Headers.Contains("accept-language"))
+ {
+ _httpRequest.Headers.Remove("accept-language");
+ }
+ _httpRequest.Headers.TryAddWithoutValidation("accept-language", Client.AcceptLanguage);
+ }
+
+
+ if (customHeaders != null)
+ {
+ foreach(var _header in customHeaders)
+ {
+ if (_httpRequest.Headers.Contains(_header.Key))
+ {
+ _httpRequest.Headers.Remove(_header.Key);
+ }
+ _httpRequest.Headers.TryAddWithoutValidation(_header.Key, _header.Value);
+ }
+ }
+
+ // Serialize Request
+ string _requestContent = null;
+ // Set Credentials
+ if (Client.Credentials != null)
+ {
+ cancellationToken.ThrowIfCancellationRequested();
+ await Client.Credentials.ProcessHttpRequestAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ }
+ // Send Request
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.SendRequest(_invocationId, _httpRequest);
+ }
+ cancellationToken.ThrowIfCancellationRequested();
+ _httpResponse = await Client.HttpClient.SendAsync(_httpRequest, cancellationToken).ConfigureAwait(false);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.ReceiveResponse(_invocationId, _httpResponse);
+ }
+ HttpStatusCode _statusCode = _httpResponse.StatusCode;
+ cancellationToken.ThrowIfCancellationRequested();
+ string _responseContent = null;
+ if ((int)_statusCode != 200)
+ {
+ var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
+ try
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject(_responseContent, Client.DeserializationSettings);
+ if (_errorBody != null)
+ {
+ ex.Body = _errorBody;
+ }
+ }
+ catch (JsonException)
+ {
+ // Ignore the exception
+ }
+ ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
+ ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Error(_invocationId, ex);
+ }
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw ex;
+ }
+ // Create Result
+ var _result = new AzureOperationResponse>();
+ _result.Request = _httpRequest;
+ _result.Response = _httpResponse;
+ if (_httpResponse.Headers.Contains("x-ms-request-id"))
+ {
+ _result.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
+ }
+ // Deserialize Response
+ if ((int)_statusCode == 200)
+ {
+ _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
+ try
+ {
+ _result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject>(_responseContent, Client.DeserializationSettings);
+ }
+ catch (JsonException ex)
+ {
+ _httpRequest.Dispose();
+ if (_httpResponse != null)
+ {
+ _httpResponse.Dispose();
+ }
+ throw new SerializationException("Unable to deserialize the response.", _responseContent, ex);
+ }
+ }
+ if (_shouldTrace)
+ {
+ ServiceClientTracing.Exit(_invocationId, _result);
+ }
+ return _result;
+ }
+
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/OperationsExtensions.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/OperationsExtensions.cs
new file mode 100644
index 000000000000..0a88d0d93627
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/OperationsExtensions.cs
@@ -0,0 +1,87 @@
+//
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for
+// license information.
+//
+// Code generated by Microsoft (R) AutoRest Code Generator.
+// Changes may cause incorrect behavior and will be lost if the code is
+// regenerated.
+//
+
+namespace Microsoft.Azure.Management.ManagementGroups
+{
+ using Microsoft.Rest;
+ using Microsoft.Rest.Azure;
+ using Models;
+ using System.Threading;
+ using System.Threading.Tasks;
+
+ ///
+ /// Extension methods for Operations.
+ ///
+ public static partial class OperationsExtensions
+ {
+ ///
+ /// Lists all of the available Management REST API operations.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ public static IPage List(this IOperations operations)
+ {
+ return operations.ListAsync().GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Lists all of the available Management REST API operations.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> ListAsync(this IOperations operations, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ ///
+ /// Lists all of the available Management REST API operations.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ public static IPage ListNext(this IOperations operations, string nextPageLink)
+ {
+ return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult();
+ }
+
+ ///
+ /// Lists all of the available Management REST API operations.
+ ///
+ ///
+ /// The operations group for this extension method.
+ ///
+ ///
+ /// The NextLink from the previous successful call to List operation.
+ ///
+ ///
+ /// The cancellation token.
+ ///
+ public static async Task> ListNextAsync(this IOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false))
+ {
+ return _result.Body;
+ }
+ }
+
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/SdkInfo_ManagementGroupsAPI.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/SdkInfo_ManagementGroupsAPI.cs
new file mode 100644
index 000000000000..7ce4875d2107
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Generated/SdkInfo_ManagementGroupsAPI.cs
@@ -0,0 +1,20 @@
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+internal static partial class SdkInfo
+{
+ public static IEnumerable> ApiInfo_ManagementGroupsAPI
+ {
+ get
+ {
+ return new Tuple[]
+ {
+ new Tuple("Management", "ManagementGroupSubscriptions", "2017-11-01-preview"),
+ new Tuple("Management", "ManagementGroups", "2017-11-01-preview"),
+ new Tuple("Management", "Operations", "2017-11-01-preview"),
+ }.AsEnumerable();
+ }
+ }
+}
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Management.ManagementGroups.csproj b/src/SDKs/ManagementGroups/Management.ManagementGroups/Management.ManagementGroups.csproj
new file mode 100644
index 000000000000..179bd6b752fd
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Management.ManagementGroups.csproj
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+ Microsoft Azure Management Groups Library
+ 1.0.0-preview
+ Microsoft.Azure.Management.ManagementGroups
+ Microsoft.Azure.Management.ManagementGroups
+ Microsoft Azure Management Groups;Management Groups;Groups;
+
+
+
+
+ net452;netstandard1.4
+
+
+
+
+
+
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/Properties/AssemblyInfo.cs b/src/SDKs/ManagementGroups/Management.ManagementGroups/Properties/AssemblyInfo.cs
new file mode 100644
index 000000000000..188151e35031
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/Properties/AssemblyInfo.cs
@@ -0,0 +1,21 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+
+[assembly: AssemblyTitle("Microsoft Azure Management Groups Library")]
+[assembly: AssemblyDescription("Provides functionality to handle management groups.")]
+
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("Microsoft Azure .NET SDK")]
+[assembly: AssemblyCopyright("Copyright (c) Microsoft Corporation")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: NeutralResourcesLanguage("en")]
\ No newline at end of file
diff --git a/src/SDKs/ManagementGroups/Management.ManagementGroups/generate.cmd b/src/SDKs/ManagementGroups/Management.ManagementGroups/generate.cmd
new file mode 100644
index 000000000000..c6c247573e4b
--- /dev/null
+++ b/src/SDKs/ManagementGroups/Management.ManagementGroups/generate.cmd
@@ -0,0 +1,7 @@
+::
+:: Microsoft Azure SDK for Net - Generate library code
+:: Copyright (C) Microsoft Corporation. All Rights Reserved.
+::
+
+@echo off
+call %~dp0..\..\..\..\tools\generate.cmd managementgroups/resource-manager %*
diff --git a/src/SDKs/ManagementGroups/ManagementGroups.Tests/Helpers/ManagementGroupsTestUtilities.cs b/src/SDKs/ManagementGroups/ManagementGroups.Tests/Helpers/ManagementGroupsTestUtilities.cs
new file mode 100644
index 000000000000..6b47a1610f91
--- /dev/null
+++ b/src/SDKs/ManagementGroups/ManagementGroups.Tests/Helpers/ManagementGroupsTestUtilities.cs
@@ -0,0 +1,25 @@
+using System.Net;
+using Microsoft.Azure.Management.ManagementGroups;
+using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
+using ResourceGroups.Tests;
+
+namespace Resource.Tests.Helpers
+{
+ public static class ManagementGroupsTestUtilities
+ {
+
+ public static ManagementGroupsAPIClient GetManagementGroupsApiClient(MockContext context,
+ RecordedDelegatingHandler handler = null)
+ {
+ if (handler != null)
+ {
+ handler.IsPassThrough = true;
+ }
+
+ var client = context.GetServiceClient(
+ handlers: handler ?? new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
+
+ return client;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/SDKs/ManagementGroups/ManagementGroups.Tests/Helpers/RecordedDelegatingHandler.cs b/src/SDKs/ManagementGroups/ManagementGroups.Tests/Helpers/RecordedDelegatingHandler.cs
new file mode 100644
index 000000000000..5d11f3a7f1ed
--- /dev/null
+++ b/src/SDKs/ManagementGroups/ManagementGroups.Tests/Helpers/RecordedDelegatingHandler.cs
@@ -0,0 +1,94 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License. See License.txt in the project root for license information.
+
+using System;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Threading.Tasks;
+
+namespace ResourceGroups.Tests
+{
+ public class RecordedDelegatingHandler : DelegatingHandler
+ {
+ private HttpResponseMessage _response;
+
+ public RecordedDelegatingHandler()
+ {
+ StatusCodeToReturn = HttpStatusCode.Created;
+ SubsequentStatusCodeToReturn = StatusCodeToReturn;
+ }
+
+ public RecordedDelegatingHandler(HttpResponseMessage response)
+ {
+ StatusCodeToReturn = HttpStatusCode.Created;
+ SubsequentStatusCodeToReturn = StatusCodeToReturn;
+ _response = response;
+ if (_response.Content == null)
+ {
+ _response.Content = new StringContent(string.Empty);
+ }
+ }
+
+ public HttpStatusCode StatusCodeToReturn { get; set; }
+
+ public HttpStatusCode SubsequentStatusCodeToReturn { get; set; }
+
+ public string Request { get; private set; }
+
+ public HttpRequestHeaders RequestHeaders { get; private set; }
+
+ public HttpContentHeaders ContentHeaders { get; private set; }
+
+ public HttpMethod Method { get; private set; }
+
+ public Uri Uri { get; private set; }
+
+ public bool IsPassThrough { get; set; }
+
+ private int counter;
+
+ protected override async Task SendAsync(HttpRequestMessage request, System.Threading.CancellationToken cancellationToken)
+ {
+ counter++;
+ // Save request
+ if (request.Content == null)
+ {
+ Request = string.Empty;
+ }
+ else
+ {
+ Request = await request.Content.ReadAsStringAsync();
+ }
+ RequestHeaders = request.Headers;
+ if (request.Content != null)
+ {
+ ContentHeaders = request.Content.Headers;
+ }
+ Method = request.Method;
+ Uri = request.RequestUri;
+
+ // Prepare response
+ if (IsPassThrough)
+ {
+ return await base.SendAsync(request, cancellationToken);
+ }
+ else
+ {
+ if (_response != null && counter == 1)
+ {
+ return _response;
+ }
+ else
+ {
+ var statusCode = StatusCodeToReturn;
+ if (counter > 1)
+ statusCode = SubsequentStatusCodeToReturn;
+ HttpResponseMessage response = new HttpResponseMessage(statusCode);
+ response.Content = new StringContent("");
+ return response;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/SDKs/ManagementGroups/ManagementGroups.Tests/InMemoryTests/ManagementGroups.InMemoryTests.cs b/src/SDKs/ManagementGroups/ManagementGroups.Tests/InMemoryTests/ManagementGroups.InMemoryTests.cs
new file mode 100644
index 000000000000..6f7db4972806
--- /dev/null
+++ b/src/SDKs/ManagementGroups/ManagementGroups.Tests/InMemoryTests/ManagementGroups.InMemoryTests.cs
@@ -0,0 +1,164 @@
+using System;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using Microsoft.Azure.Management.ManagementGroups;
+using Microsoft.Azure.Test.HttpRecorder;
+using Microsoft.Rest;
+using ResourceGroups.Tests;
+using Xunit;
+
+namespace Resource.Tests.InMemoryTests
+{
+ public class InMemoryManagementGroupsTests
+ {
+
+ public ManagementGroupsAPIClient GetManagementGroupsApiClient(RecordedDelegatingHandler handler)
+ {
+ var groupId = Guid.NewGuid().ToString();
+ var token = new TokenCredentials(groupId, "abc123");
+ handler.IsPassThrough = false;
+ var client = new ManagementGroupsAPIClient(token, handler);
+ HttpMockServer.Mode = HttpRecorderMode.Playback;
+ return client;
+ }
+
+ [Fact]
+ public void ListGroups()
+ {
+ var response = new HttpResponseMessage(HttpStatusCode.OK)
+ {
+ Content = new StringContent(@"{
+ 'value': [{
+ 'id': '/providers/Microsoft.Management/managementGroups/10000000-d002-0000-0000-000000000000',
+ 'type': '/providers/Microsoft.Management/managementGroups',
+ 'name': '10000000-d002-0000-0000-000000000000',
+ 'properties': {
+ 'tenantId': '10000000-0000-0000-0000-000000000000',
+ 'displayName': 'Department 2 under Enrollment 1'
+ }
+ },
+ {
+ 'id': '/providers/Microsoft.Management/managementGroups/10000000-a001-0000-0000-000000000000',
+ 'type': '/providers/Microsoft.Management/managementGroups',
+ 'name': '10000000-a001-0000-0000-000000000000',
+ 'properties': {
+ 'tenantId': '10000000-0000-0000-0000-000000000000',
+ 'displayName': 'Account 1, under Department 1'
+ }
+ }]
+ }")
+ };
+
+ response.Headers.Add("x-ms-request-id", "1");
+
+ var handler = new RecordedDelegatingHandler(response) { StatusCodeToReturn = HttpStatusCode.OK };
+
+ var client = GetManagementGroupsApiClient(handler);
+
+ var listManagementGroupsResult = client.ManagementGroups.List();
+
+ Assert.Equal("/providers/Microsoft.Management/managementGroups/10000000-d002-0000-0000-000000000000", listManagementGroupsResult.FirstOrDefault().Id);
+ Assert.Equal("/providers/Microsoft.Management/managementGroups", listManagementGroupsResult.FirstOrDefault().Type);
+ Assert.Equal("10000000-d002-0000-0000-000000000000", listManagementGroupsResult.FirstOrDefault().Name.ToString());
+ Assert.Equal("10000000-0000-0000-0000-000000000000", listManagementGroupsResult.FirstOrDefault().TenantId.ToString());
+ Assert.Equal("Department 2 under Enrollment 1", listManagementGroupsResult.FirstOrDefault().DisplayName);
+ }
+
+ [Fact]
+ public void GetGroup()
+ {
+ var response = new HttpResponseMessage(HttpStatusCode.OK)
+ {
+ Content = new StringContent(@"{
+ ""id"": ""/providers/Microsoft.Management/managementGroups/testGroup123"",
+ ""type"": ""/providers/Microsoft.Management/managementGroups"",
+ ""name"": ""testGroup123"",
+ ""properties"": {
+ ""tenantId"": ""20000000-0000-0000-0000-000000000000"",
+ ""displayName"": ""TestGroup123"",
+ ""details"": {
+ ""version"": 1,
+ ""updatedTime"": ""2018-01-30T08:32:23.6425327Z"",
+ ""updatedBy"": ""20000000-0000-0000-0000-000000000000"",
+ ""parent"": {
+ ""parentId"": ""/providers/Microsoft.Management/managementGroups/testGroup1234"",
+ ""displayName"": ""TestGroup1234""
+ }
+ }
+ }
+ }")
+ };
+ response.Headers.Add("x-ms-request-id", "1");
+
+ var handler = new RecordedDelegatingHandler(response) { StatusCodeToReturn = HttpStatusCode.OK };
+
+ var client = GetManagementGroupsApiClient(handler);
+
+ var groupId = "testGroup123Child1";
+
+ var getManagementGroupResult = client.ManagementGroups.Get(groupId);
+
+ Assert.Equal("/providers/Microsoft.Management/managementGroups/testGroup123", getManagementGroupResult.Id);
+ Assert.Equal("/providers/Microsoft.Management/managementGroups", getManagementGroupResult.Type);
+ Assert.Equal("testGroup123", getManagementGroupResult.Name.ToString());
+ Assert.Equal("20000000-0000-0000-0000-000000000000", getManagementGroupResult.TenantId.ToString());
+ Assert.Equal("TestGroup123", getManagementGroupResult.DisplayName);
+ Assert.Equal("/providers/Microsoft.Management/managementGroups/testGroup1234", getManagementGroupResult.Details.Parent.ParentId);
+ Assert.Equal("TestGroup1234", getManagementGroupResult.Details.Parent.DisplayName);
+ }
+
+
+ [Fact]
+ public void GetGroupWithExpand()
+ {
+ var response = new HttpResponseMessage(HttpStatusCode.OK)
+ {
+ Content = new StringContent(@"{
+ ""id"": ""/providers/Microsoft.Management/managementGroups/testGroup123"",
+ ""type"": ""/providers/Microsoft.Management/managementGroups"",
+ ""name"": ""testGroup123"",
+ ""properties"": {
+ ""tenantId"": ""20000000-0000-0000-0000-000000000000"",
+ ""displayName"": ""TestGroup123"",
+ ""details"": {
+ ""version"": 1,
+ ""updatedTime"": ""2018-01-30T08:32:23.6425327Z"",
+ ""updatedBy"": ""20000000-0000-0000-0000-000000000000"",
+ ""parent"": {
+ ""parentId"": ""/providers/Microsoft.Management/managementGroups/testGroup1234"",
+ ""displayName"": ""TestGroup1234""
+ }
+ },
+ ""children"": [
+ {
+ ""childType"": ""/managementGroup"",
+ ""childId"": ""/providers/Microsoft.Management/managementGroups/testGroup123Child1"",
+ ""displayName"": ""TestGroup123Child1""
+ }
+ ]
+ }
+ }")
+ };
+ response.Headers.Add("x-ms-request-id", "1");
+
+ var handler = new RecordedDelegatingHandler(response) { StatusCodeToReturn = HttpStatusCode.OK };
+
+ var client = GetManagementGroupsApiClient(handler);
+
+ var groupId = "testGroup123Child1";
+
+ var getManagementGroupResult = client.ManagementGroups.Get(groupId, "children");
+
+ Assert.Equal("/providers/Microsoft.Management/managementGroups/testGroup123", getManagementGroupResult.Id);
+ Assert.Equal("/providers/Microsoft.Management/managementGroups", getManagementGroupResult.Type);
+ Assert.Equal("testGroup123", getManagementGroupResult.Name.ToString());
+ Assert.Equal("20000000-0000-0000-0000-000000000000", getManagementGroupResult.TenantId.ToString());
+ Assert.Equal("TestGroup123", getManagementGroupResult.DisplayName);
+ Assert.Equal("/providers/Microsoft.Management/managementGroups/testGroup1234", getManagementGroupResult.Details.Parent.ParentId);
+ Assert.Equal("TestGroup1234", getManagementGroupResult.Details.Parent.DisplayName);
+ Assert.Equal("/providers/Microsoft.Management/managementGroups/testGroup123Child1", getManagementGroupResult.Children.FirstOrDefault().ChildId);
+ Assert.Equal("TestGroup123Child1", getManagementGroupResult.Children.FirstOrDefault().DisplayName);
+ }
+ }
+}
diff --git a/src/SDKs/ManagementGroups/ManagementGroups.Tests/ManagementGroups.Tests.csproj b/src/SDKs/ManagementGroups/ManagementGroups.Tests/ManagementGroups.Tests.csproj
new file mode 100644
index 000000000000..3c18e97c6147
--- /dev/null
+++ b/src/SDKs/ManagementGroups/ManagementGroups.Tests/ManagementGroups.Tests.csproj
@@ -0,0 +1,26 @@
+
+
+
+
+ ManagementGroups.Tests
+ ManagementGroups.Tests Class Library
+ Microsoft Corporation
+ ManagementGroups.Tests
+ 1.0.0-preview
+
+
+
+ netcoreapp1.1
+
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+
diff --git a/src/SDKs/ManagementGroups/ManagementGroups.Tests/ScenarioTests/ManagementGroups.ScenarioTests.cs b/src/SDKs/ManagementGroups/ManagementGroups.Tests/ScenarioTests/ManagementGroups.ScenarioTests.cs
new file mode 100644
index 000000000000..9e3161289570
--- /dev/null
+++ b/src/SDKs/ManagementGroups/ManagementGroups.Tests/ScenarioTests/ManagementGroups.ScenarioTests.cs
@@ -0,0 +1,164 @@
+using System.Linq;
+using System.Net;
+using Microsoft.Azure.Management.ManagementGroups;
+using Microsoft.Azure.Management.ManagementGroups.Models;
+using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
+using Resource.Tests.Helpers;
+using Xunit;
+
+namespace ResourceGroups.Tests
+{
+ public class LiveManagementGroupsTests : TestBase
+ {
+ [Fact]
+ public void ListGroups()
+ {
+ using (MockContext context = MockContext.Start(this.GetType().FullName))
+ {
+ var managementGroupsClient = ManagementGroupsTestUtilities.GetManagementGroupsApiClient(context,
+ new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
+
+ var managementGroups = managementGroupsClient.ManagementGroups.List();
+
+ Assert.NotNull(managementGroups);
+ Assert.NotEmpty(managementGroups);
+ Assert.NotNull(managementGroups.First().Id);
+ Assert.NotNull(managementGroups.First().Type);
+ Assert.NotNull(managementGroups.First().Name);
+
+ }
+
+ }
+
+ [Fact]
+ public void GetGroup()
+ {
+ using (MockContext context = MockContext.Start(this.GetType().FullName))
+ {
+ var managementGroupsClient = ManagementGroupsTestUtilities.GetManagementGroupsApiClient(context,
+ new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
+
+ var groupId = "testGroup123";
+
+ var managementGroup = managementGroupsClient.ManagementGroups.Get(groupId);
+
+ Assert.NotNull(managementGroup);
+ Assert.Equal("/providers/Microsoft.Management/managementGroups/testGroup123", managementGroup.Id);
+ Assert.Equal("testGroup123", managementGroup.Name);
+ Assert.Equal("/providers/Microsoft.Management/managementGroups", managementGroup.Type);
+
+ }
+
+ }
+
+ [Fact]
+ public void GetGroupExpand()
+ {
+ using (MockContext context = MockContext.Start(this.GetType().FullName))
+ {
+ var managementGroupsClient = ManagementGroupsTestUtilities.GetManagementGroupsApiClient(context,
+ new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
+
+ var groupId = "testGroup123";
+
+ var managementGroup = managementGroupsClient.ManagementGroups.Get(groupId, "children");
+
+ Assert.NotNull(managementGroup);
+ Assert.Equal("/providers/Microsoft.Management/managementGroups/testGroup123", managementGroup.Id);
+ Assert.Equal("testGroup123", managementGroup.Name);
+ Assert.Equal("/providers/Microsoft.Management/managementGroups", managementGroup.Type);
+
+ Assert.NotNull(managementGroup.Children);
+ Assert.Null(managementGroup.Children.First().Children);
+
+ }
+
+ }
+
+ [Fact]
+ public void GetGroupExpandRecurse()
+ {
+ using (MockContext context = MockContext.Start(this.GetType().FullName))
+ {
+ var managementGroupsClient = ManagementGroupsTestUtilities.GetManagementGroupsApiClient(context,
+ new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
+
+ var groupId = "testGroup123";
+
+ var managementGroup = managementGroupsClient.ManagementGroups.Get(groupId, "children", true);
+
+ Assert.NotNull(managementGroup);
+ Assert.Equal("/providers/Microsoft.Management/managementGroups/testGroup123", managementGroup.Id);
+ Assert.Equal("testGroup123", managementGroup.Name);
+ Assert.Equal("/providers/Microsoft.Management/managementGroups", managementGroup.Type);
+
+ Assert.NotNull(managementGroup.Children);
+ Assert.NotNull(managementGroup.Children.First().Children);
+ }
+ }
+
+ [Fact]
+ public void CreateGroup()
+ {
+ using (MockContext context = MockContext.Start(this.GetType().FullName))
+ {
+ var managementGroupsClient = ManagementGroupsTestUtilities.GetManagementGroupsApiClient(context,
+ new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
+
+ var groupId = "testGroup123Child2";
+
+ var managementGroup = managementGroupsClient.ManagementGroups.CreateOrUpdate(groupId, new CreateManagementGroupRequest("TestGroup123->Child2", "/providers/Microsoft.Management/managementGroups/testGroup123"), cacheControl: "no-cache");
+
+ Assert.NotNull(managementGroup);
+ Assert.Equal("/providers/Microsoft.Management/managementGroups/testGroup123Child2", managementGroup.Id);
+ Assert.Equal("testGroup123Child2", managementGroup.Name);
+ Assert.Equal("/providers/Microsoft.Management/managementGroups", managementGroup.Type);
+ }
+ }
+
+ [Fact]
+ public void CreateGroupSubscription()
+ {
+ using (MockContext context = MockContext.Start(this.GetType().FullName))
+ {
+ var managementGroupsClient = ManagementGroupsTestUtilities.GetManagementGroupsApiClient(context,
+ new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.NoContent });
+
+ var groupId = "testGroup123Child2";
+ var subscriptionId = "2a418b54-7643-4d8f-982c-d0802205d12c";
+
+ managementGroupsClient.ManagementGroupSubscriptions.Create(groupId, subscriptionId, cacheControl: "no-cache");
+ }
+ }
+
+ [Fact]
+ public void DeleteGroupSubscription()
+ {
+ using (MockContext context = MockContext.Start(this.GetType().FullName))
+ {
+ var managementGroupsClient = ManagementGroupsTestUtilities.GetManagementGroupsApiClient(context,
+ new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.NoContent });
+
+ var groupId = "testGroup123Child2";
+ var subscriptionId = "2a418b54-7643-4d8f-982c-d0802205d12c";
+
+ managementGroupsClient.ManagementGroupSubscriptions.Delete(groupId, subscriptionId, cacheControl: "no-cache");
+ }
+ }
+
+ [Fact]
+ public void DeleteGroup()
+ {
+ using (MockContext context = MockContext.Start(this.GetType().FullName))
+ {
+ var managementGroupsClient = ManagementGroupsTestUtilities.GetManagementGroupsApiClient(context,
+ new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK });
+
+ var groupId = "testGroup123Child2";
+
+ managementGroupsClient.ManagementGroups.Delete(groupId, cacheControl: "no-cache");
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/CreateGroup.json b/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/CreateGroup.json
new file mode 100644
index 000000000000..8678ec2ab9a0
--- /dev/null
+++ b/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/CreateGroup.json
@@ -0,0 +1,94 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/providers/Microsoft.Management/managementGroups/testGroup123Child2?api-version=2017-11-01-preview",
+ "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuTWFuYWdlbWVudC9tYW5hZ2VtZW50R3JvdXBzL3Rlc3RHcm91cDEyM0NoaWxkMj9hcGktdmVyc2lvbj0yMDE3LTExLTAxLXByZXZpZXc=",
+ "RequestMethod": "PUT",
+ "RequestBody": "{\r\n \"displayName\": \"TestGroup123->Child2\",\r\n \"parentId\": \"/providers/Microsoft.Management/managementGroups/testGroup123\"\r\n}",
+ "RequestHeaders": {
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Content-Length": [
+ "125"
+ ],
+ "x-ms-client-request-id": [
+ "2ddd0f9d-5b40-43ce-ba82-f786e59e59c9"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "accept-language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.25211.01",
+ "Microsoft.Azure.Management.ManagementGroups.ManagementGroupsAPIClient/0.0.0.0"
+ ]
+ },
+ "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/testGroup123Child2\",\r\n \"type\": \"/providers/Microsoft.Management/managementGroups\",\r\n \"name\": \"testGroup123Child2\",\r\n \"properties\": {\r\n \"tenantId\": \"6b2064b9-34bd-46e6-9092-52f2dd5f7fc0\",\r\n \"displayName\": \"TestGroup123->Child2\",\r\n \"details\": {\r\n \"version\": 14,\r\n \"updatedTime\": \"2018-02-12T18:33:35.7043452Z\",\r\n \"updatedBy\": \"8b8f2464-6ad0-4327-b9da-5cc8ac2c650d\",\r\n \"parent\": {\r\n \"parentId\": \"/providers/Microsoft.Management/managementGroups/testGroup123\",\r\n \"displayName\": \"New Display Name\"\r\n }\r\n }\r\n }\r\n}",
+ "ResponseHeaders": {
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Expires": [
+ "-1"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Date": [
+ "Mon, 12 Feb 2018 18:33:38 GMT"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Transfer-Encoding": [
+ "chunked"
+ ],
+ "Server": [
+ "Microsoft-IIS/8.5"
+ ],
+ "Vary": [
+ "Accept-Encoding",
+ "Accept-Encoding"
+ ],
+ "x-ms-ratelimit-remaining-tenant-writes": [
+ "1199"
+ ],
+ "x-ms-request-id": [
+ "westus:ea302bc2-e370-4740-b0ef-30817a6a8a43"
+ ],
+ "x-ba-restapi": [
+ "1.0.3.520"
+ ],
+ "request-id": [
+ "80e1eb66-2a85-4a10-ae4e-3b146163cc35"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-correlation-request-id": [
+ "56511fb8-30fb-4429-8469-a1eb537eda2e"
+ ],
+ "x-ms-routing-request-id": [
+ "CENTRALUS:20180212T183339Z:56511fb8-30fb-4429-8469-a1eb537eda2e"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "X-Content-Type-Options": [
+ "nosniff"
+ ]
+ },
+ "StatusCode": 200
+ }
+ ],
+ "Names": {},
+ "Variables": {
+ "SubscriptionId": "394ae65d-9e71-4462-930f-3332dedf845c"
+ }
+}
\ No newline at end of file
diff --git a/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/CreateGroupSubscription.json b/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/CreateGroupSubscription.json
new file mode 100644
index 000000000000..0a743e95af72
--- /dev/null
+++ b/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/CreateGroupSubscription.json
@@ -0,0 +1,78 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/providers/Microsoft.Management/managementGroups/testGroup123Child2/subscriptions/2a418b54-7643-4d8f-982c-d0802205d12c?api-version=2017-11-01-preview",
+ "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuTWFuYWdlbWVudC9tYW5hZ2VtZW50R3JvdXBzL3Rlc3RHcm91cDEyM0NoaWxkMi9zdWJzY3JpcHRpb25zLzJhNDE4YjU0LTc2NDMtNGQ4Zi05ODJjLWQwODAyMjA1ZDEyYz9hcGktdmVyc2lvbj0yMDE3LTExLTAxLXByZXZpZXc=",
+ "RequestMethod": "PUT",
+ "RequestBody": "",
+ "RequestHeaders": {
+ "x-ms-client-request-id": [
+ "a29edc4f-aaea-403b-b18f-f9ce78acd570"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "accept-language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.25211.01",
+ "Microsoft.Azure.Management.ManagementGroups.ManagementGroupsAPIClient/0.0.0.0"
+ ]
+ },
+ "ResponseBody": "",
+ "ResponseHeaders": {
+ "Expires": [
+ "-1"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Date": [
+ "Mon, 12 Feb 2018 18:33:50 GMT"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Server": [
+ "Microsoft-IIS/8.5"
+ ],
+ "x-ms-request-id": [
+ "westus:6dc1b9e1-db70-454b-8cba-b6d1068dcda2"
+ ],
+ "x-ba-restapi": [
+ "1.0.3.520"
+ ],
+ "request-id": [
+ "227f11d1-7021-4dcd-87de-8281b7a20a4f"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-ratelimit-remaining-tenant-writes": [
+ "1198"
+ ],
+ "x-ms-correlation-request-id": [
+ "22c6dc6b-d5e5-4828-af4c-732d2dd8019b"
+ ],
+ "x-ms-routing-request-id": [
+ "CENTRALUS:20180212T183350Z:22c6dc6b-d5e5-4828-af4c-732d2dd8019b"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "X-Content-Type-Options": [
+ "nosniff"
+ ]
+ },
+ "StatusCode": 204
+ }
+ ],
+ "Names": {},
+ "Variables": {
+ "SubscriptionId": "394ae65d-9e71-4462-930f-3332dedf845c"
+ }
+}
\ No newline at end of file
diff --git a/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/DeleteGroup.json b/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/DeleteGroup.json
new file mode 100644
index 000000000000..797383b781ee
--- /dev/null
+++ b/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/DeleteGroup.json
@@ -0,0 +1,81 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/providers/Microsoft.Management/managementGroups/testGroup123Child2?api-version=2017-11-01-preview",
+ "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuTWFuYWdlbWVudC9tYW5hZ2VtZW50R3JvdXBzL3Rlc3RHcm91cDEyM0NoaWxkMj9hcGktdmVyc2lvbj0yMDE3LTExLTAxLXByZXZpZXc=",
+ "RequestMethod": "DELETE",
+ "RequestBody": "",
+ "RequestHeaders": {
+ "x-ms-client-request-id": [
+ "c0ce68b3-7807-4b29-928d-beaf10bf3b55"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "accept-language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.25211.01",
+ "Microsoft.Azure.Management.ManagementGroups.ManagementGroupsAPIClient/0.0.0.0"
+ ]
+ },
+ "ResponseBody": "",
+ "ResponseHeaders": {
+ "Content-Length": [
+ "0"
+ ],
+ "Expires": [
+ "-1"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Date": [
+ "Mon, 12 Feb 2018 18:34:12 GMT"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Server": [
+ "Microsoft-IIS/8.5"
+ ],
+ "x-ms-request-id": [
+ "westus:5fecb884-e64e-4e3f-a59b-92ca99f465d4"
+ ],
+ "x-ba-restapi": [
+ "1.0.3.520"
+ ],
+ "request-id": [
+ "9198b384-e858-4add-bcd0-6ea8c24a6b24"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-ratelimit-remaining-tenant-writes": [
+ "1196"
+ ],
+ "x-ms-correlation-request-id": [
+ "a5b83a72-48d0-4f3f-a932-61518718745b"
+ ],
+ "x-ms-routing-request-id": [
+ "CENTRALUS:20180212T183413Z:a5b83a72-48d0-4f3f-a932-61518718745b"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "X-Content-Type-Options": [
+ "nosniff"
+ ]
+ },
+ "StatusCode": 200
+ }
+ ],
+ "Names": {},
+ "Variables": {
+ "SubscriptionId": "394ae65d-9e71-4462-930f-3332dedf845c"
+ }
+}
\ No newline at end of file
diff --git a/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/DeleteGroupSubscription.json b/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/DeleteGroupSubscription.json
new file mode 100644
index 000000000000..66300c0b4d7c
--- /dev/null
+++ b/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/DeleteGroupSubscription.json
@@ -0,0 +1,78 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/providers/Microsoft.Management/managementGroups/testGroup123Child2/subscriptions/2a418b54-7643-4d8f-982c-d0802205d12c?api-version=2017-11-01-preview",
+ "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuTWFuYWdlbWVudC9tYW5hZ2VtZW50R3JvdXBzL3Rlc3RHcm91cDEyM0NoaWxkMi9zdWJzY3JpcHRpb25zLzJhNDE4YjU0LTc2NDMtNGQ4Zi05ODJjLWQwODAyMjA1ZDEyYz9hcGktdmVyc2lvbj0yMDE3LTExLTAxLXByZXZpZXc=",
+ "RequestMethod": "DELETE",
+ "RequestBody": "",
+ "RequestHeaders": {
+ "x-ms-client-request-id": [
+ "5a77467c-2d9e-4a92-96f4-f62eb9e4a955"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "accept-language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.25211.01",
+ "Microsoft.Azure.Management.ManagementGroups.ManagementGroupsAPIClient/0.0.0.0"
+ ]
+ },
+ "ResponseBody": "",
+ "ResponseHeaders": {
+ "Expires": [
+ "-1"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Date": [
+ "Mon, 12 Feb 2018 18:34:00 GMT"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Server": [
+ "Microsoft-IIS/8.5"
+ ],
+ "x-ms-request-id": [
+ "westus:be0afb3c-f08a-4eca-afd6-2998587e6c77"
+ ],
+ "x-ba-restapi": [
+ "1.0.3.520"
+ ],
+ "request-id": [
+ "68619187-7edf-45e0-9296-1b119bf4e751"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-ratelimit-remaining-tenant-writes": [
+ "1197"
+ ],
+ "x-ms-correlation-request-id": [
+ "0029df17-3bb2-4e15-b129-599d1f55740a"
+ ],
+ "x-ms-routing-request-id": [
+ "CENTRALUS:20180212T183401Z:0029df17-3bb2-4e15-b129-599d1f55740a"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "X-Content-Type-Options": [
+ "nosniff"
+ ]
+ },
+ "StatusCode": 204
+ }
+ ],
+ "Names": {},
+ "Variables": {
+ "SubscriptionId": "394ae65d-9e71-4462-930f-3332dedf845c"
+ }
+}
\ No newline at end of file
diff --git a/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/GetGroup.json b/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/GetGroup.json
new file mode 100644
index 000000000000..8049362a189a
--- /dev/null
+++ b/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/GetGroup.json
@@ -0,0 +1,88 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/providers/Microsoft.Management/managementGroups/testGroup123?api-version=2017-11-01-preview",
+ "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuTWFuYWdlbWVudC9tYW5hZ2VtZW50R3JvdXBzL3Rlc3RHcm91cDEyMz9hcGktdmVyc2lvbj0yMDE3LTExLTAxLXByZXZpZXc=",
+ "RequestMethod": "GET",
+ "RequestBody": "",
+ "RequestHeaders": {
+ "x-ms-client-request-id": [
+ "cc8b1f71-07c1-4639-8c85-bf98f790980a"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "accept-language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.25211.01",
+ "Microsoft.Azure.Management.ManagementGroups.ManagementGroupsAPIClient/0.0.0.0"
+ ]
+ },
+ "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/testGroup123\",\r\n \"type\": \"/providers/Microsoft.Management/managementGroups\",\r\n \"name\": \"testGroup123\",\r\n \"properties\": {\r\n \"tenantId\": \"6b2064b9-34bd-46e6-9092-52f2dd5f7fc0\",\r\n \"displayName\": \"New Display Name\",\r\n \"details\": {\r\n \"version\": 2,\r\n \"updatedTime\": \"2018-02-01T12:04:10.8271442Z\",\r\n \"updatedBy\": \"64360beb-ffb4-43a8-9314-01aa34db95a9\",\r\n \"parent\": {\r\n \"parentId\": \"/providers/Microsoft.Management/managementGroups/6b2064b9-34bd-46e6-9092-52f2dd5f7fc0\",\r\n \"displayName\": \"6b2064b9-34bd-46e6-9092-52f2dd5f7fc0\"\r\n }\r\n }\r\n }\r\n}",
+ "ResponseHeaders": {
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Expires": [
+ "-1"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Date": [
+ "Mon, 12 Feb 2018 18:32:54 GMT"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Transfer-Encoding": [
+ "chunked"
+ ],
+ "Server": [
+ "Microsoft-IIS/8.5"
+ ],
+ "Vary": [
+ "Accept-Encoding",
+ "Accept-Encoding"
+ ],
+ "x-ms-ratelimit-remaining-tenant-reads": [
+ "14996"
+ ],
+ "x-ms-request-id": [
+ "westus:d7a04ac6-817d-4da0-9f9d-a37f1ab03f7f"
+ ],
+ "x-ba-restapi": [
+ "1.0.3.520"
+ ],
+ "request-id": [
+ "e0bb3318-1912-44a1-b9dc-5236da7c29eb"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-correlation-request-id": [
+ "91f3cf28-88df-4d24-8581-d981b53291a6"
+ ],
+ "x-ms-routing-request-id": [
+ "CENTRALUS:20180212T183255Z:91f3cf28-88df-4d24-8581-d981b53291a6"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "X-Content-Type-Options": [
+ "nosniff"
+ ]
+ },
+ "StatusCode": 200
+ }
+ ],
+ "Names": {},
+ "Variables": {
+ "SubscriptionId": "394ae65d-9e71-4462-930f-3332dedf845c"
+ }
+}
\ No newline at end of file
diff --git a/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/GetGroupExpand.json b/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/GetGroupExpand.json
new file mode 100644
index 000000000000..d7045ef80de8
--- /dev/null
+++ b/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/GetGroupExpand.json
@@ -0,0 +1,88 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/providers/Microsoft.Management/managementGroups/testGroup123?api-version=2017-11-01-preview&$expand=children",
+ "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuTWFuYWdlbWVudC9tYW5hZ2VtZW50R3JvdXBzL3Rlc3RHcm91cDEyMz9hcGktdmVyc2lvbj0yMDE3LTExLTAxLXByZXZpZXcmJGV4cGFuZD1jaGlsZHJlbg==",
+ "RequestMethod": "GET",
+ "RequestBody": "",
+ "RequestHeaders": {
+ "x-ms-client-request-id": [
+ "2f975448-0317-413c-bf08-8237bef31655"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "accept-language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.25211.01",
+ "Microsoft.Azure.Management.ManagementGroups.ManagementGroupsAPIClient/0.0.0.0"
+ ]
+ },
+ "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/testGroup123\",\r\n \"type\": \"/providers/Microsoft.Management/managementGroups\",\r\n \"name\": \"testGroup123\",\r\n \"properties\": {\r\n \"tenantId\": \"6b2064b9-34bd-46e6-9092-52f2dd5f7fc0\",\r\n \"displayName\": \"New Display Name\",\r\n \"details\": {\r\n \"version\": 2,\r\n \"updatedTime\": \"2018-02-01T12:04:10.8271442Z\",\r\n \"updatedBy\": \"64360beb-ffb4-43a8-9314-01aa34db95a9\",\r\n \"parent\": {\r\n \"parentId\": \"/providers/Microsoft.Management/managementGroups/6b2064b9-34bd-46e6-9092-52f2dd5f7fc0\",\r\n \"displayName\": \"6b2064b9-34bd-46e6-9092-52f2dd5f7fc0\"\r\n }\r\n },\r\n \"children\": [\r\n {\r\n \"childType\": \"/managementGroup\",\r\n \"childId\": \"/providers/Microsoft.Management/managementGroups/testGroup123Child1\",\r\n \"displayName\": \"TestGroup123->Child1\"\r\n },\r\n {\r\n \"childType\": \"/subscription\",\r\n \"childId\": \"/subscriptions/394ae65d-9e71-4462-930f-3332dedf845c\",\r\n \"displayName\": \"Pay-As-You-Go\"\r\n }\r\n ]\r\n }\r\n}",
+ "ResponseHeaders": {
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Expires": [
+ "-1"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Date": [
+ "Mon, 12 Feb 2018 18:33:05 GMT"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Transfer-Encoding": [
+ "chunked"
+ ],
+ "Server": [
+ "Microsoft-IIS/8.5"
+ ],
+ "Vary": [
+ "Accept-Encoding",
+ "Accept-Encoding"
+ ],
+ "x-ms-ratelimit-remaining-tenant-reads": [
+ "14999"
+ ],
+ "x-ms-request-id": [
+ "westus:ee6e817f-b1bc-4e9d-9778-f08ecb299c45"
+ ],
+ "x-ba-restapi": [
+ "1.0.3.520"
+ ],
+ "request-id": [
+ "8e124438-4a80-4972-ba5a-b82ab5554c4d"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-correlation-request-id": [
+ "9243655a-2d72-4a20-88de-a349d17dbaef"
+ ],
+ "x-ms-routing-request-id": [
+ "CENTRALUS:20180212T183306Z:9243655a-2d72-4a20-88de-a349d17dbaef"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "X-Content-Type-Options": [
+ "nosniff"
+ ]
+ },
+ "StatusCode": 200
+ }
+ ],
+ "Names": {},
+ "Variables": {
+ "SubscriptionId": "394ae65d-9e71-4462-930f-3332dedf845c"
+ }
+}
\ No newline at end of file
diff --git a/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/GetGroupExpandRecurse.json b/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/GetGroupExpandRecurse.json
new file mode 100644
index 000000000000..4a6b4a55323f
--- /dev/null
+++ b/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/GetGroupExpandRecurse.json
@@ -0,0 +1,88 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/providers/Microsoft.Management/managementGroups/testGroup123?api-version=2017-11-01-preview&$expand=children&$recurse=true",
+ "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuTWFuYWdlbWVudC9tYW5hZ2VtZW50R3JvdXBzL3Rlc3RHcm91cDEyMz9hcGktdmVyc2lvbj0yMDE3LTExLTAxLXByZXZpZXcmJGV4cGFuZD1jaGlsZHJlbiYkcmVjdXJzZT10cnVl",
+ "RequestMethod": "GET",
+ "RequestBody": "",
+ "RequestHeaders": {
+ "x-ms-client-request-id": [
+ "561fc523-16d8-439d-8fa9-9a0bebf03e87"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "accept-language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.25211.01",
+ "Microsoft.Azure.Management.ManagementGroups.ManagementGroupsAPIClient/0.0.0.0"
+ ]
+ },
+ "ResponseBody": "{\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/testGroup123\",\r\n \"type\": \"/providers/Microsoft.Management/managementGroups\",\r\n \"name\": \"testGroup123\",\r\n \"properties\": {\r\n \"tenantId\": \"6b2064b9-34bd-46e6-9092-52f2dd5f7fc0\",\r\n \"displayName\": \"New Display Name\",\r\n \"details\": {\r\n \"version\": 2,\r\n \"updatedTime\": \"2018-02-01T12:04:10.8271442Z\",\r\n \"updatedBy\": \"64360beb-ffb4-43a8-9314-01aa34db95a9\",\r\n \"parent\": {\r\n \"parentId\": \"/providers/Microsoft.Management/managementGroups/6b2064b9-34bd-46e6-9092-52f2dd5f7fc0\",\r\n \"displayName\": \"6b2064b9-34bd-46e6-9092-52f2dd5f7fc0\"\r\n }\r\n },\r\n \"children\": [\r\n {\r\n \"childType\": \"/managementGroup\",\r\n \"childId\": \"/providers/Microsoft.Management/managementGroups/testGroup123Child1\",\r\n \"displayName\": \"TestGroup123->Child1\",\r\n \"children\": [\r\n {\r\n \"childType\": \"/managementGroup\",\r\n \"childId\": \"/providers/Microsoft.Management/managementGroups/testGroup123Child1Child1\",\r\n \"displayName\": \"TestGroup123->Child1->Child1\"\r\n },\r\n {\r\n \"childType\": \"/subscription\",\r\n \"childId\": \"/subscriptions/8158c3e6-0c47-4d68-af4c-d521343aa3f8\",\r\n \"displayName\": \"Pay-As-You-Go\"\r\n }\r\n ]\r\n },\r\n {\r\n \"childType\": \"/subscription\",\r\n \"childId\": \"/subscriptions/394ae65d-9e71-4462-930f-3332dedf845c\",\r\n \"displayName\": \"Pay-As-You-Go\"\r\n }\r\n ]\r\n }\r\n}",
+ "ResponseHeaders": {
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Expires": [
+ "-1"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Date": [
+ "Mon, 12 Feb 2018 18:33:24 GMT"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Transfer-Encoding": [
+ "chunked"
+ ],
+ "Server": [
+ "Microsoft-IIS/8.5"
+ ],
+ "Vary": [
+ "Accept-Encoding",
+ "Accept-Encoding"
+ ],
+ "x-ms-ratelimit-remaining-tenant-reads": [
+ "14997"
+ ],
+ "x-ms-request-id": [
+ "westus:c25240db-5499-42cd-8109-accaa9778089"
+ ],
+ "x-ba-restapi": [
+ "1.0.3.520"
+ ],
+ "request-id": [
+ "4bfd241f-0459-4a2e-ac69-299918ebd47b"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-correlation-request-id": [
+ "eb914bbc-67d8-437d-9931-0a02b6f651d0"
+ ],
+ "x-ms-routing-request-id": [
+ "CENTRALUS:20180212T183324Z:eb914bbc-67d8-437d-9931-0a02b6f651d0"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "X-Content-Type-Options": [
+ "nosniff"
+ ]
+ },
+ "StatusCode": 200
+ }
+ ],
+ "Names": {},
+ "Variables": {
+ "SubscriptionId": "394ae65d-9e71-4462-930f-3332dedf845c"
+ }
+}
\ No newline at end of file
diff --git a/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/ListGroups.json b/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/ListGroups.json
new file mode 100644
index 000000000000..f123801fa796
--- /dev/null
+++ b/src/SDKs/ManagementGroups/ManagementGroups.Tests/SessionRecords/ResourceGroups.Tests.LiveManagementGroupsTests/ListGroups.json
@@ -0,0 +1,88 @@
+{
+ "Entries": [
+ {
+ "RequestUri": "/providers/Microsoft.Management/managementGroups?api-version=2017-11-01-preview",
+ "EncodedRequestUri": "L3Byb3ZpZGVycy9NaWNyb3NvZnQuTWFuYWdlbWVudC9tYW5hZ2VtZW50R3JvdXBzP2FwaS12ZXJzaW9uPTIwMTctMTEtMDEtcHJldmlldw==",
+ "RequestMethod": "GET",
+ "RequestBody": "",
+ "RequestHeaders": {
+ "x-ms-client-request-id": [
+ "83d1b5fe-cc38-443c-b9c6-3dbff5614ba7"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "accept-language": [
+ "en-US"
+ ],
+ "User-Agent": [
+ "FxVersion/4.6.25211.01",
+ "Microsoft.Azure.Management.ManagementGroups.ManagementGroupsAPIClient/0.0.0.0"
+ ]
+ },
+ "ResponseBody": "{\r\n \"value\": [\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/testGroup123\",\r\n \"type\": \"/providers/Microsoft.Management/managementGroups\",\r\n \"name\": \"testGroup123\",\r\n \"properties\": {\r\n \"tenantId\": \"6b2064b9-34bd-46e6-9092-52f2dd5f7fc0\",\r\n \"displayName\": \"New Display Name\"\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/testGroup123Child1\",\r\n \"type\": \"/providers/Microsoft.Management/managementGroups\",\r\n \"name\": \"testGroup123Child1\",\r\n \"properties\": {\r\n \"tenantId\": \"6b2064b9-34bd-46e6-9092-52f2dd5f7fc0\",\r\n \"displayName\": \"TestGroup123->Child1\"\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/testGroup123Child1Child1\",\r\n \"type\": \"/providers/Microsoft.Management/managementGroups\",\r\n \"name\": \"testGroup123Child1Child1\",\r\n \"properties\": {\r\n \"tenantId\": \"6b2064b9-34bd-46e6-9092-52f2dd5f7fc0\",\r\n \"displayName\": \"TestGroup123->Child1->Child1\"\r\n }\r\n },\r\n {\r\n \"id\": \"/providers/Microsoft.Management/managementGroups/6b2064b9-34bd-46e6-9092-52f2dd5f7fc0\",\r\n \"type\": \"/providers/Microsoft.Management/managementGroups\",\r\n \"name\": \"6b2064b9-34bd-46e6-9092-52f2dd5f7fc0\",\r\n \"properties\": {\r\n \"tenantId\": \"6b2064b9-34bd-46e6-9092-52f2dd5f7fc0\",\r\n \"displayName\": \"6b2064b9-34bd-46e6-9092-52f2dd5f7fc0\"\r\n }\r\n }\r\n ],\r\n \"@nextLink\": null\r\n}",
+ "ResponseHeaders": {
+ "Content-Type": [
+ "application/json; charset=utf-8"
+ ],
+ "Expires": [
+ "-1"
+ ],
+ "Cache-Control": [
+ "no-cache"
+ ],
+ "Date": [
+ "Mon, 12 Feb 2018 18:32:44 GMT"
+ ],
+ "Pragma": [
+ "no-cache"
+ ],
+ "Transfer-Encoding": [
+ "chunked"
+ ],
+ "Server": [
+ "Microsoft-IIS/8.5"
+ ],
+ "Vary": [
+ "Accept-Encoding",
+ "Accept-Encoding"
+ ],
+ "x-ms-ratelimit-remaining-tenant-reads": [
+ "14997"
+ ],
+ "x-ms-request-id": [
+ "westus:1496e893-66c3-4f0d-acdc-2136709c2587"
+ ],
+ "x-ba-restapi": [
+ "1.0.3.520"
+ ],
+ "request-id": [
+ "2f4ef7ee-c4af-42e9-bcc3-60e290089ec0"
+ ],
+ "X-AspNet-Version": [
+ "4.0.30319"
+ ],
+ "X-Powered-By": [
+ "ASP.NET"
+ ],
+ "x-ms-correlation-request-id": [
+ "b3e94a4e-6d86-45f6-9350-0476ef3323ca"
+ ],
+ "x-ms-routing-request-id": [
+ "CENTRALUS:20180212T183244Z:b3e94a4e-6d86-45f6-9350-0476ef3323ca"
+ ],
+ "Strict-Transport-Security": [
+ "max-age=31536000; includeSubDomains"
+ ],
+ "X-Content-Type-Options": [
+ "nosniff"
+ ]
+ },
+ "StatusCode": 200
+ }
+ ],
+ "Names": {},
+ "Variables": {
+ "SubscriptionId": "394ae65d-9e71-4462-930f-3332dedf845c"
+ }
+}
\ No newline at end of file
diff --git a/src/SDKs/ManagementGroups/ManagementGroups.sln b/src/SDKs/ManagementGroups/ManagementGroups.sln
new file mode 100644
index 000000000000..8d23f3ef713e
--- /dev/null
+++ b/src/SDKs/ManagementGroups/ManagementGroups.sln
@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.27004.2008
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Management.ManagementGroups", "Management.ManagementGroups\Management.ManagementGroups.csproj", "{A8928771-00A2-4412-A921-19712279D15D}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ManagementGroups.Tests", "ManagementGroups.Tests\ManagementGroups.Tests.csproj", "{34013B7A-E0FC-4346-B484-F47AA5AD1BCF}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A8928771-00A2-4412-A921-19712279D15D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A8928771-00A2-4412-A921-19712279D15D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A8928771-00A2-4412-A921-19712279D15D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A8928771-00A2-4412-A921-19712279D15D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {34013B7A-E0FC-4346-B484-F47AA5AD1BCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {34013B7A-E0FC-4346-B484-F47AA5AD1BCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {34013B7A-E0FC-4346-B484-F47AA5AD1BCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {34013B7A-E0FC-4346-B484-F47AA5AD1BCF}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {F3556ACE-D28F-4D41-B41B-A6B26D69A6C1}
+ EndGlobalSection
+EndGlobal
diff --git a/src/SDKs/_metadata/managementgroups_resource-manager.txt b/src/SDKs/_metadata/managementgroups_resource-manager.txt
new file mode 100644
index 000000000000..300b620ba326
--- /dev/null
+++ b/src/SDKs/_metadata/managementgroups_resource-manager.txt
@@ -0,0 +1,11 @@
+2018-02-13 17:26:26 UTC
+
+1) azure-rest-api-specs repository information
+GitHub user: Azure
+Branch: master
+Commit: 4dec5ea20ff45c44ecd023f1fb1c49797b4875f9
+
+2) AutoRest information
+Requested version: latest
+Bootstrapper version: C:\Users\shahraj\AppData\Roaming\npm `-- autorest@2.0.4245
+Latest installed version: