Skip to content

Commit

Permalink
.NET SDK Resource Provider:'DevSpaces'
Browse files Browse the repository at this point in the history
REST Spec PR 'Azure/azure-rest-api-specs#5713'
REST Spec PR Author 'sanar-microsoft'
REST Spec PR Last commit
  • Loading branch information
adxsdknet committed Apr 19, 2019
1 parent 85309e7 commit d0d4565
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 48 deletions.
2 changes: 1 addition & 1 deletion src/SDKs/DevSpaces/AzSdk.RP.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--This file and it's contents are updated at build time moving or editing might result in build failure. Take due deligence while editing this file-->
<PropertyGroup>
<AzureApiTag>DevSpaces_2019-01-01-preview;</AzureApiTag>
<AzureApiTag>DevSpaces_2019-04-01;</AzureApiTag>
<PackageTags>$(PackageTags);$(CommonTags);$(AzureApiTag);</PackageTags>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ internal ContainerHostMappingsOperations(DevSpacesManagementClient client)
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="CloudException">
/// <exception cref="ErrorResponseException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="SerializationException">
Expand All @@ -84,7 +84,7 @@ internal ContainerHostMappingsOperations(DevSpacesManagementClient client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<AzureOperationResponse<object>> GetContainerHostMappingWithHttpMessagesAsync(string resourceGroupName, string location, string containerHostResourceId = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<AzureOperationResponse<ContainerHostMapping>> GetContainerHostMappingWithHttpMessagesAsync(string resourceGroupName, string location, string containerHostResourceId = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (Client.ApiVersion == null)
{
Expand Down Expand Up @@ -206,16 +206,15 @@ internal ContainerHostMappingsOperations(DevSpacesManagementClient client)
HttpStatusCode _statusCode = _httpResponse.StatusCode;
cancellationToken.ThrowIfCancellationRequested();
string _responseContent = null;
if ((int)_statusCode != 200)
if ((int)_statusCode != 200 && (int)_statusCode != 204)
{
var ex = new CloudException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
var ex = new ErrorResponseException(string.Format("Operation returned an invalid status code '{0}'", _statusCode));
try
{
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
CloudError _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<CloudError>(_responseContent, Client.DeserializationSettings);
ErrorResponse _errorBody = Rest.Serialization.SafeJsonConvert.DeserializeObject<ErrorResponse>(_responseContent, Client.DeserializationSettings);
if (_errorBody != null)
{
ex = new CloudException(_errorBody.Message);
ex.Body = _errorBody;
}
}
Expand All @@ -225,10 +224,6 @@ internal ContainerHostMappingsOperations(DevSpacesManagementClient client)
}
ex.Request = new HttpRequestMessageWrapper(_httpRequest, _requestContent);
ex.Response = new HttpResponseMessageWrapper(_httpResponse, _responseContent);
if (_httpResponse.Headers.Contains("x-ms-request-id"))
{
ex.RequestId = _httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault();
}
if (_shouldTrace)
{
ServiceClientTracing.Error(_invocationId, ex);
Expand All @@ -241,7 +236,7 @@ internal ContainerHostMappingsOperations(DevSpacesManagementClient client)
throw ex;
}
// Create Result
var _result = new AzureOperationResponse<object>();
var _result = new AzureOperationResponse<ContainerHostMapping>();
_result.Request = _httpRequest;
_result.Response = _httpResponse;
if (_httpResponse.Headers.Contains("x-ms-request-id"))
Expand All @@ -254,7 +249,7 @@ internal ContainerHostMappingsOperations(DevSpacesManagementClient client)
_responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
try
{
_result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<object>(_responseContent, Client.DeserializationSettings);
_result.Body = Rest.Serialization.SafeJsonConvert.DeserializeObject<ContainerHostMapping>(_responseContent, Client.DeserializationSettings);
}
catch (JsonException ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static partial class ContainerHostMappingsOperationsExtensions
/// <param name='containerHostResourceId'>
/// ARM ID of the Container Host resource
/// </param>
public static object GetContainerHostMapping(this IContainerHostMappingsOperations operations, string resourceGroupName, string location, string containerHostResourceId = default(string))
public static ContainerHostMapping GetContainerHostMapping(this IContainerHostMappingsOperations operations, string resourceGroupName, string location, string containerHostResourceId = default(string))
{
return operations.GetContainerHostMappingAsync(resourceGroupName, location, containerHostResourceId).GetAwaiter().GetResult();
}
Expand All @@ -61,7 +61,7 @@ public static partial class ContainerHostMappingsOperationsExtensions
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<object> GetContainerHostMappingAsync(this IContainerHostMappingsOperations operations, string resourceGroupName, string location, string containerHostResourceId = default(string), CancellationToken cancellationToken = default(CancellationToken))
public static async Task<ContainerHostMapping> GetContainerHostMappingAsync(this IContainerHostMappingsOperations operations, string resourceGroupName, string location, string containerHostResourceId = default(string), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.GetContainerHostMappingWithHttpMessagesAsync(resourceGroupName, location, containerHostResourceId, null, cancellationToken).ConfigureAwait(false))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,10 @@ internal ControllersOperations(DevSpacesManagementClient client)
/// <param name='name'>
/// Name of the resource.
/// </param>
/// <param name='targetContainerHostResourceId'>
/// Resource ID of the target container host mapped to the Azure Dev Spaces
/// Controller.
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
Expand All @@ -968,7 +972,7 @@ internal ControllersOperations(DevSpacesManagementClient client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<AzureOperationResponse<ControllerConnectionDetailsList>> ListConnectionDetailsWithHttpMessagesAsync(string resourceGroupName, string name, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<AzureOperationResponse<ControllerConnectionDetailsList>> ListConnectionDetailsWithHttpMessagesAsync(string resourceGroupName, string name, string targetContainerHostResourceId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (Client.ApiVersion == null)
{
Expand Down Expand Up @@ -1012,6 +1016,15 @@ internal ControllersOperations(DevSpacesManagementClient client)
throw new ValidationException(ValidationRules.Pattern, "name", "^[a-zA-Z0-9](-?[a-zA-Z0-9])*$");
}
}
if (targetContainerHostResourceId == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "targetContainerHostResourceId");
}
ListConnectionDetailsParameters listConnectionDetailsParameters = new ListConnectionDetailsParameters();
if (targetContainerHostResourceId != null)
{
listConnectionDetailsParameters.TargetContainerHostResourceId = targetContainerHostResourceId;
}
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
string _invocationId = null;
Expand All @@ -1021,6 +1034,7 @@ internal ControllersOperations(DevSpacesManagementClient client)
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
tracingParameters.Add("resourceGroupName", resourceGroupName);
tracingParameters.Add("name", name);
tracingParameters.Add("listConnectionDetailsParameters", listConnectionDetailsParameters);
tracingParameters.Add("cancellationToken", cancellationToken);
ServiceClientTracing.Enter(_invocationId, this, "ListConnectionDetails", tracingParameters);
}
Expand Down Expand Up @@ -1073,6 +1087,12 @@ internal ControllersOperations(DevSpacesManagementClient client)

// Serialize Request
string _requestContent = null;
if(listConnectionDetailsParameters != null)
{
_requestContent = Rest.Serialization.SafeJsonConvert.SerializeObject(listConnectionDetailsParameters, 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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,13 @@ public static IPage<Controller> List(this IControllersOperations operations)
/// <param name='name'>
/// Name of the resource.
/// </param>
public static ControllerConnectionDetailsList ListConnectionDetails(this IControllersOperations operations, string resourceGroupName, string name)
/// <param name='targetContainerHostResourceId'>
/// Resource ID of the target container host mapped to the Azure Dev Spaces
/// Controller.
/// </param>
public static ControllerConnectionDetailsList ListConnectionDetails(this IControllersOperations operations, string resourceGroupName, string name, string targetContainerHostResourceId)
{
return operations.ListConnectionDetailsAsync(resourceGroupName, name).GetAwaiter().GetResult();
return operations.ListConnectionDetailsAsync(resourceGroupName, name, targetContainerHostResourceId).GetAwaiter().GetResult();
}

/// <summary>
Expand All @@ -335,12 +339,16 @@ public static ControllerConnectionDetailsList ListConnectionDetails(this IContro
/// <param name='name'>
/// Name of the resource.
/// </param>
/// <param name='targetContainerHostResourceId'>
/// Resource ID of the target container host mapped to the Azure Dev Spaces
/// Controller.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<ControllerConnectionDetailsList> ListConnectionDetailsAsync(this IControllersOperations operations, string resourceGroupName, string name, CancellationToken cancellationToken = default(CancellationToken))
public static async Task<ControllerConnectionDetailsList> ListConnectionDetailsAsync(this IControllersOperations operations, string resourceGroupName, string name, string targetContainerHostResourceId, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.ListConnectionDetailsWithHttpMessagesAsync(resourceGroupName, name, null, cancellationToken).ConfigureAwait(false))
using (var _result = await operations.ListConnectionDetailsWithHttpMessagesAsync(resourceGroupName, name, targetContainerHostResourceId, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ private void Initialize()
Operations = new Operations(this);
Controllers = new ControllersOperations(this);
BaseUri = new System.Uri("https://management.azure.com");
ApiVersion = "2019-01-01-preview";
ApiVersion = "2019-04-01";
AcceptLanguage = "en-US";
LongRunningOperationRetryTimeout = 30;
GenerateClientRequestId = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public partial interface IContainerHostMappingsOperations
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <exception cref="Microsoft.Rest.Azure.CloudException">
/// <exception cref="ErrorResponseException">
/// Thrown when the operation returned an invalid status code
/// </exception>
/// <exception cref="Microsoft.Rest.SerializationException">
Expand All @@ -51,6 +51,6 @@ public partial interface IContainerHostMappingsOperations
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<AzureOperationResponse<object>> GetContainerHostMappingWithHttpMessagesAsync(string resourceGroupName, string location, string containerHostResourceId = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
Task<AzureOperationResponse<ContainerHostMapping>> GetContainerHostMappingWithHttpMessagesAsync(string resourceGroupName, string location, string containerHostResourceId = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ public partial interface IControllersOperations
/// <param name='name'>
/// Name of the resource.
/// </param>
/// <param name='targetContainerHostResourceId'>
/// Resource ID of the target container host mapped to the Azure Dev
/// Spaces Controller.
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
Expand All @@ -217,7 +221,7 @@ public partial interface IControllersOperations
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<AzureOperationResponse<ControllerConnectionDetailsList>> ListConnectionDetailsWithHttpMessagesAsync(string resourceGroupName, string name, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
Task<AzureOperationResponse<ControllerConnectionDetailsList>> ListConnectionDetailsWithHttpMessagesAsync(string resourceGroupName, string name, string targetContainerHostResourceId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Creates an Azure Dev Spaces Controller.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ public ControllerConnectionDetails()
/// Initializes a new instance of the ControllerConnectionDetails
/// class.
/// </summary>
/// <param name="authKey">Authentication key for communicating with
/// services.</param>
public ControllerConnectionDetails(string authKey = default(string), OrchestratorSpecificConnectionDetails orchestratorSpecificConnectionDetails = default(OrchestratorSpecificConnectionDetails))
public ControllerConnectionDetails(OrchestratorSpecificConnectionDetails orchestratorSpecificConnectionDetails = default(OrchestratorSpecificConnectionDetails))
{
AuthKey = authKey;
OrchestratorSpecificConnectionDetails = orchestratorSpecificConnectionDetails;
CustomInit();
}
Expand All @@ -42,12 +39,6 @@ public ControllerConnectionDetails()
/// </summary>
partial void CustomInit();

/// <summary>
/// Gets authentication key for communicating with services.
/// </summary>
[JsonProperty(PropertyName = "authKey")]
public string AuthKey { get; private set; }

/// <summary>
/// </summary>
[JsonProperty(PropertyName = "orchestratorSpecificConnectionDetails")]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// <auto-generated>
// 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.
// </auto-generated>

namespace Microsoft.Azure.Management.DevSpaces.Models
{
using Microsoft.Rest;
using Newtonsoft.Json;
using System.Linq;

/// <summary>
/// Parameters for listing connection details of an Azure Dev Spaces
/// Controller.
/// </summary>
public partial class ListConnectionDetailsParameters
{
/// <summary>
/// Initializes a new instance of the ListConnectionDetailsParameters
/// class.
/// </summary>
public ListConnectionDetailsParameters()
{
CustomInit();
}

/// <summary>
/// Initializes a new instance of the ListConnectionDetailsParameters
/// class.
/// </summary>
/// <param name="targetContainerHostResourceId">Resource ID of the
/// target container host mapped to the Azure Dev Spaces
/// Controller.</param>
public ListConnectionDetailsParameters(string targetContainerHostResourceId)
{
TargetContainerHostResourceId = targetContainerHostResourceId;
CustomInit();
}

/// <summary>
/// An initialization method that performs custom operations like setting defaults
/// </summary>
partial void CustomInit();

/// <summary>
/// Gets or sets resource ID of the target container host mapped to the
/// Azure Dev Spaces Controller.
/// </summary>
[JsonProperty(PropertyName = "targetContainerHostResourceId")]
public string TargetContainerHostResourceId { get; set; }

/// <summary>
/// Validate the object.
/// </summary>
/// <exception cref="ValidationException">
/// Thrown if validation fails
/// </exception>
public virtual void Validate()
{
if (TargetContainerHostResourceId == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "TargetContainerHostResourceId");
}
}
}
}
Loading

0 comments on commit d0d4565

Please sign in to comment.