Skip to content

Commit

Permalink
[Monitor] Adding multi-dim metrics API, improving error response for …
Browse files Browse the repository at this point in the history
…Action Groups API, and fixing some documentation typos (from Swagger) (Azure#3646)

* Adding ActivityLogAlerts and ActionGroups API calls, PATH operations, and the corresponding unit tests

* Generating code from the 'current' branch of the Swagger specs repo

* Adding scenario tests

* Improving scenario tests and re-recording them

* Making sure the scenario tests point to the more recent version of the Resource Manager dll. Enabling tests for netcoreapp1.1

* Introducing multidimensional metrics API and removing the previous one.

* Reverting netcoreapp1.1 test target since it fails to find the records.

* Returning generate.md to its Azure\psSdkJson6 state

* Re-enabling tests for netcoreapp1.1

* [Monitor] Adding multi-dim metrics API and making sure ActionGroupsOperations do not throw standard exceptions, but return ErrorResponses with more information (PR Azure#1614).

* [Monitor] Fixing documentation typos (from Swagger). Improving the error response for Action Groups API.
  • Loading branch information
gucalder authored and JasonYang-MSFT committed Nov 17, 2017
1 parent 85bec21 commit 340c338
Show file tree
Hide file tree
Showing 24 changed files with 868 additions and 264 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ internal ActionGroupsOperations(MonitorManagementClient 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 Down Expand Up @@ -198,14 +198,13 @@ internal ActionGroupsOperations(MonitorManagementClient client)
string _responseContent = null;
if ((int)_statusCode != 200 && (int)_statusCode != 201)
{
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 @@ -215,10 +214,6 @@ internal ActionGroupsOperations(MonitorManagementClient 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 Down Expand Up @@ -296,7 +291,7 @@ internal ActionGroupsOperations(MonitorManagementClient 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 Down Expand Up @@ -408,16 +403,15 @@ internal ActionGroupsOperations(MonitorManagementClient client)
HttpStatusCode _statusCode = _httpResponse.StatusCode;
cancellationToken.ThrowIfCancellationRequested();
string _responseContent = null;
if ((int)_statusCode != 200 && (int)_statusCode != 404)
if ((int)_statusCode != 200)
{
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 @@ -427,10 +421,6 @@ internal ActionGroupsOperations(MonitorManagementClient 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 Down Expand Up @@ -490,7 +480,7 @@ internal ActionGroupsOperations(MonitorManagementClient 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="ValidationException">
Expand Down Expand Up @@ -601,14 +591,13 @@ internal ActionGroupsOperations(MonitorManagementClient client)
string _responseContent = null;
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 @@ -618,10 +607,6 @@ internal ActionGroupsOperations(MonitorManagementClient 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 Down Expand Up @@ -657,7 +642,7 @@ internal ActionGroupsOperations(MonitorManagementClient 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 Down Expand Up @@ -759,14 +744,13 @@ internal ActionGroupsOperations(MonitorManagementClient client)
string _responseContent = null;
if ((int)_statusCode != 200)
{
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 @@ -776,10 +760,6 @@ internal ActionGroupsOperations(MonitorManagementClient 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 Down Expand Up @@ -836,7 +816,7 @@ internal ActionGroupsOperations(MonitorManagementClient 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 Down Expand Up @@ -944,14 +924,13 @@ internal ActionGroupsOperations(MonitorManagementClient client)
string _responseContent = null;
if ((int)_statusCode != 200)
{
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 @@ -961,10 +940,6 @@ internal ActionGroupsOperations(MonitorManagementClient 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 Down Expand Up @@ -1028,7 +1003,7 @@ internal ActionGroupsOperations(MonitorManagementClient 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="ValidationException">
Expand Down Expand Up @@ -1153,16 +1128,15 @@ internal ActionGroupsOperations(MonitorManagementClient client)
HttpStatusCode _statusCode = _httpResponse.StatusCode;
cancellationToken.ThrowIfCancellationRequested();
string _responseContent = null;
if ((int)_statusCode != 200 && (int)_statusCode != 409 && (int)_statusCode != 404)
if ((int)_statusCode != 200 && (int)_statusCode != 409)
{
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 @@ -1172,10 +1146,6 @@ internal ActionGroupsOperations(MonitorManagementClient 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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public partial interface IActionGroupsOperations
/// <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 @@ -67,7 +67,7 @@ public partial interface IActionGroupsOperations
/// <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 @@ -92,7 +92,7 @@ public partial interface IActionGroupsOperations
/// <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.ValidationException">
Expand All @@ -108,7 +108,7 @@ public partial interface IActionGroupsOperations
/// <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 @@ -130,7 +130,7 @@ public partial interface IActionGroupsOperations
/// <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 Down Expand Up @@ -159,7 +159,7 @@ public partial interface IActionGroupsOperations
/// <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.ValidationException">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ActionGroupResource()
/// This will be used in SMS messages.</param>
/// <param name="enabled">Indicates whether this action group is
/// enabled. If an action group is not enabled, then none of its
/// receviers will receive communications.</param>
/// receivers will receive communications.</param>
/// <param name="id">Azure resource Id</param>
/// <param name="name">Azure resource name</param>
/// <param name="type">Azure resource type</param>
Expand Down Expand Up @@ -77,7 +77,7 @@ public ActionGroupResource()

/// <summary>
/// Gets or sets indicates whether this action group is enabled. If an
/// action group is not enabled, then none of its receviers will
/// action group is not enabled, then none of its receivers will
/// receive communications.
/// </summary>
[JsonProperty(PropertyName = "properties.enabled")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ActivityLogAlertResource()
/// prefixes. The alert will only apply to activityLogs with
/// resourceIds that fall under one of these prefixes. This list must
/// include at least one item.</param>
/// <param name="condition">The conditon that will cause this alert to
/// <param name="condition">The condition that will cause this alert to
/// activate.</param>
/// <param name="actions">The actions that will activate when the
/// condition is met.</param>
Expand Down Expand Up @@ -88,7 +88,7 @@ public ActivityLogAlertResource()
public bool? Enabled { get; set; }

/// <summary>
/// Gets or sets the conditon that will cause this alert to activate.
/// Gets or sets the condition that will cause this alert to activate.
/// </summary>
[JsonProperty(PropertyName = "properties.condition")]
public ActivityLogAlertAllOfCondition Condition { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public EmailReceiver()
/// unique across all receivers within an action group.</param>
/// <param name="emailAddress">The email address of this
/// receiver.</param>
/// <param name="status">Possible values include: 'NotSpecified',
/// 'Enabled', 'Disabled'</param>
/// <param name="status">The receiver status of the e-mail. Possible
/// values include: 'NotSpecified', 'Enabled', 'Disabled'</param>
public EmailReceiver(string name, string emailAddress, ReceiverStatus? status = default(ReceiverStatus?))
{
Name = name;
Expand Down Expand Up @@ -65,7 +65,8 @@ public EmailReceiver()
public string EmailAddress { get; set; }

/// <summary>
/// Gets possible values include: 'NotSpecified', 'Enabled', 'Disabled'
/// Gets the receiver status of the e-mail. Possible values include:
/// 'NotSpecified', 'Enabled', 'Disabled'
/// </summary>
[JsonProperty(PropertyName = "status")]
public ReceiverStatus? Status { get; private set; }
Expand Down
Loading

0 comments on commit 340c338

Please sign in to comment.