diff --git a/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/IMonitorHistoricalStateChangeOperations.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/IMonitorHistoricalStateChangeOperations.cs new file mode 100644 index 000000000000..04921cf056da --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/IMonitorHistoricalStateChangeOperations.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.WorkloadMonitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MonitorHistoricalStateChangeOperations operations. + /// + public partial interface IMonitorHistoricalStateChangeOperations + { + /// + /// Get the status of a monitor at a specific timestamp in history. + /// + /// + /// The subscriptionId of the resource + /// + /// + /// The resourceGroupName of the resource + /// + /// + /// The resourceNamespace of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The monitorId of the resource (url encoded) + /// + /// + /// The timestamp of the state change (Unix format) + /// + /// + /// ex: $expand=evidence,configuration + /// + /// + /// 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 subscriptionId, string resourceGroupName, string resourceNamespace, string resourceType, string resourceName, string monitorId, string timestampUnix, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/IMonitorInfoOperations.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/IMonitorInfoOperations.cs new file mode 100644 index 000000000000..20ae2c3ff392 --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/IMonitorInfoOperations.cs @@ -0,0 +1,67 @@ +// +// 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.WorkloadMonitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MonitorInfoOperations operations. + /// + public partial interface IMonitorInfoOperations + { + /// + /// Get the current status of a monitor of a resource. + /// + /// + /// The subscriptionId of the resource + /// + /// + /// The resourceGroupName of the resource + /// + /// + /// The resourceNamespace of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The monitorId of the resource (url encoded) + /// + /// + /// ex: $expand=evidence,configuration + /// + /// + /// 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 subscriptionId, string resourceGroupName, string resourceNamespace, string resourceType, string resourceName, string monitorId, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/IMonitorStateChangesOperations.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/IMonitorStateChangesOperations.cs new file mode 100644 index 000000000000..965c5aa5fd4a --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/IMonitorStateChangesOperations.cs @@ -0,0 +1,100 @@ +// +// 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.WorkloadMonitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MonitorStateChangesOperations operations. + /// + public partial interface IMonitorStateChangesOperations + { + /// + /// Get history of a monitor of a resource (with optional filter). + /// + /// + /// The subscriptionId of the resource + /// + /// + /// The resourceGroupName of the resource + /// + /// + /// The resourceNamespace of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The monitorId of the resource (url encoded) + /// + /// + /// list example: $filter=monitorName eq + /// 'logical-disks|C:|disk-free-space-mb'; history example: + /// $filter=isHeartbeat eq false + /// + /// + /// ex: $expand=evidence,configuration + /// + /// + /// The start Timestamp for the desired history + /// + /// + /// The end Timestamp for the desired history + /// + /// + /// 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 subscriptionId, string resourceGroupName, string resourceNamespace, string resourceType, string resourceName, string monitorId, string filter = default(string), string expand = default(string), System.DateTime? startTimestampUtc = default(System.DateTime?), System.DateTime? endTimestampUtc = default(System.DateTime?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get history of a monitor of a resource (with optional filter). + /// + /// + /// 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/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/IMonitorsOperations.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/IMonitorsOperations.cs new file mode 100644 index 000000000000..395ee3c69780 --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/IMonitorsOperations.cs @@ -0,0 +1,91 @@ +// +// 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.WorkloadMonitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + + /// + /// MonitorsOperations operations. + /// + public partial interface IMonitorsOperations + { + /// + /// Get list of a monitors of a resource (with optional filter). + /// + /// + /// The subscriptionId of the resource + /// + /// + /// The resourceGroupName of the resource + /// + /// + /// The resourceNamespace of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// list example: $filter=monitorName eq + /// 'logical-disks|C:|disk-free-space-mb'; history example: + /// $filter=isHeartbeat eq false + /// + /// + /// ex: $expand=evidence,configuration + /// + /// + /// 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 subscriptionId, string resourceGroupName, string resourceNamespace, string resourceType, string resourceName, string filter = default(string), string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Get list of a monitors of a resource (with optional filter). + /// + /// + /// 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/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/IOperations.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/IOperations.cs new file mode 100644 index 000000000000..03fb361baa40 --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/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.WorkloadMonitor +{ + 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 + { + /// + /// Gets a list of possible 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)); + /// + /// Gets a list of possible 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/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/IWorkloadMonitorAPIClient.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/IWorkloadMonitorAPIClient.cs new file mode 100644 index 000000000000..da0b50449cb7 --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/IWorkloadMonitorAPIClient.cs @@ -0,0 +1,93 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.WorkloadMonitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using Newtonsoft.Json; + + /// + /// Workload Monitor API + /// + public partial interface IWorkloadMonitorAPIClient : 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; } + + /// + /// The API version to use for this operation. + /// + string ApiVersion { get; } + + /// + /// The preferred language for the response. + /// + string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default + /// value is 30. + /// + int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. When + /// set to true a unique x-ms-client-request-id value is generated and + /// included in each request. Default is true. + /// + bool? GenerateClientRequestId { get; set; } + + + /// + /// Gets the IOperations. + /// + IOperations Operations { get; } + + /// + /// Gets the IMonitorsOperations. + /// + IMonitorsOperations Monitors { get; } + + /// + /// Gets the IMonitorInfoOperations. + /// + IMonitorInfoOperations MonitorInfo { get; } + + /// + /// Gets the IMonitorStateChangesOperations. + /// + IMonitorStateChangesOperations MonitorStateChanges { get; } + + /// + /// Gets the IMonitorHistoricalStateChangeOperations. + /// + IMonitorHistoricalStateChangeOperations MonitorHistoricalStateChange { get; } + + } +} diff --git a/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/DefaultError.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/DefaultError.cs new file mode 100644 index 000000000000..84225aac48cc --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/DefaultError.cs @@ -0,0 +1,57 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.WorkloadMonitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// Default Error + /// + /// + /// Error body contract. + /// + public partial class DefaultError + { + /// + /// Initializes a new instance of the DefaultError class. + /// + public DefaultError() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DefaultError class. + /// + /// error details + public DefaultError(DefaultErrorError error = default(DefaultErrorError)) + { + Error = error; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets error details + /// + /// + /// Details about the error + /// + [JsonProperty(PropertyName = "error")] + public DefaultErrorError Error { get; set; } + + } +} diff --git a/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/DefaultErrorError.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/DefaultErrorError.cs new file mode 100644 index 000000000000..2a5288f8da60 --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/DefaultErrorError.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.WorkloadMonitor.Models +{ + using Newtonsoft.Json; + using System.Linq; + + /// + /// error details + /// + /// + /// Details about the error + /// + public partial class DefaultErrorError + { + /// + /// Initializes a new instance of the DefaultErrorError class. + /// + public DefaultErrorError() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the DefaultErrorError class. + /// + /// Service-defined error code. This code serves as + /// a sub-status for the HTTP error code specified in the + /// response. + /// Human-readable representation of the + /// error. + public DefaultErrorError(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 service-defined error code. This code serves as a + /// sub-status for the HTTP error code specified in the response. + /// + [JsonProperty(PropertyName = "code")] + public string Code { get; set; } + + /// + /// Gets or sets human-readable representation of the error. + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + } +} diff --git a/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/DefaultErrorException.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/DefaultErrorException.cs new file mode 100644 index 000000000000..a7baa62087bc --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/DefaultErrorException.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.WorkloadMonitor.Models +{ + using Microsoft.Rest; + + /// + /// Exception thrown for an invalid response with DefaultError information. + /// + public partial class DefaultErrorException : 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 DefaultError Body { get; set; } + + /// + /// Initializes a new instance of the DefaultErrorException class. + /// + public DefaultErrorException() + { + } + + /// + /// Initializes a new instance of the DefaultErrorException class. + /// + /// The exception message. + public DefaultErrorException(string message) + : this(message, null) + { + } + + /// + /// Initializes a new instance of the DefaultErrorException class. + /// + /// The exception message. + /// Inner exception. + public DefaultErrorException(string message, System.Exception innerException) + : base(message, innerException) + { + } + } +} diff --git a/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/HealthState.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/HealthState.cs new file mode 100644 index 000000000000..78bcd5748ce7 --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/HealthState.cs @@ -0,0 +1,24 @@ +// +// 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.WorkloadMonitor.Models +{ + + /// + /// Defines values for HealthState. + /// + public static class HealthState + { + public const string Healthy = "Healthy"; + public const string Critical = "Critical"; + public const string Warning = "Warning"; + public const string Unknown = "Unknown"; + } +} diff --git a/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/Monitor.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/Monitor.cs new file mode 100644 index 000000000000..7c93358ad3eb --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/Monitor.cs @@ -0,0 +1,228 @@ +// +// 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.WorkloadMonitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Monitor Status + /// + /// + /// Information about a monitor. + /// + [Rest.Serialization.JsonTransformation] + public partial class Monitor + { + /// + /// Initializes a new instance of the Monitor class. + /// + public Monitor() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the Monitor class. + /// + /// Arm ID + /// Url-encoded monitor name + /// Resource type + /// Monitor Name + /// Monitor Type + /// Monitored Object + /// Parent Monitor Name + /// Health State + /// Health State + /// Last Evaluated + /// Last State + /// Change + /// Last Reported + /// Evidence + /// Configuration + public Monitor(string id, string name, string type, string monitorName = default(string), string monitorType = default(string), string monitoredObject = default(string), string parentMonitorName = default(string), string previousMonitorState = default(string), string currentMonitorState = default(string), string evaluationTimestamp = default(string), string currentStateFirstObservedTimestamp = default(string), string lastReportedTimestamp = default(string), object evidence = default(object), object monitorConfiguration = default(object)) + { + Id = id; + Name = name; + Type = type; + MonitorName = monitorName; + MonitorType = monitorType; + MonitoredObject = monitoredObject; + ParentMonitorName = parentMonitorName; + PreviousMonitorState = previousMonitorState; + CurrentMonitorState = currentMonitorState; + EvaluationTimestamp = evaluationTimestamp; + CurrentStateFirstObservedTimestamp = currentStateFirstObservedTimestamp; + LastReportedTimestamp = lastReportedTimestamp; + Evidence = evidence; + MonitorConfiguration = monitorConfiguration; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets arm ID + /// + /// + /// Arm ID of this monitor. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets url-encoded monitor name + /// + /// + /// Url-encoded monitor name. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets resource type + /// + /// + /// Type of ARM resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets monitor Name + /// + /// + /// Human-readable name of this monitor. + /// + [JsonProperty(PropertyName = "properties.monitorName")] + public string MonitorName { get; set; } + + /// + /// Gets or sets monitor Type + /// + /// + /// Type of this monitor. + /// + [JsonProperty(PropertyName = "properties.monitorType")] + public string MonitorType { get; set; } + + /// + /// Gets or sets monitored Object + /// + /// + /// Dynamic monitored object of this monitor. + /// + [JsonProperty(PropertyName = "properties.monitoredObject")] + public string MonitoredObject { get; set; } + + /// + /// Gets or sets parent Monitor Name + /// + /// + /// Name of this monitor's parent. + /// + [JsonProperty(PropertyName = "properties.parentMonitorName")] + public string ParentMonitorName { get; set; } + + /// + /// Gets or sets health State + /// + /// + /// Current health state of this monitor. Possible values include: + /// 'Healthy', 'Critical', 'Warning', 'Unknown' + /// + [JsonProperty(PropertyName = "properties.previousMonitorState")] + public string PreviousMonitorState { get; set; } + + /// + /// Gets or sets health State + /// + /// + /// Current health state of this monitor. Possible values include: + /// 'Healthy', 'Critical', 'Warning', 'Unknown' + /// + [JsonProperty(PropertyName = "properties.currentMonitorState")] + public string CurrentMonitorState { get; set; } + + /// + /// Gets or sets last Evaluated + /// + /// + /// Timestamp that this monitor was last evaluated. + /// + [JsonProperty(PropertyName = "properties.evaluationTimestamp")] + public string EvaluationTimestamp { get; set; } + + /// + /// Gets or sets last State Change + /// + /// + /// Timestamp of this monitor's last state change. + /// + [JsonProperty(PropertyName = "properties.currentStateFirstObservedTimestamp")] + public string CurrentStateFirstObservedTimestamp { get; set; } + + /// + /// Gets or sets last Reported + /// + /// + /// Timestamp of this monitor's last reported state. + /// + [JsonProperty(PropertyName = "properties.lastReportedTimestamp")] + public string LastReportedTimestamp { get; set; } + + /// + /// Gets or sets evidence + /// + /// + /// Evidence of this monitor's last state change. + /// + [JsonProperty(PropertyName = "properties.evidence")] + public object Evidence { get; set; } + + /// + /// Gets or sets configuration + /// + /// + /// Configuration settings at the time of this monitor's last state + /// change. + /// + [JsonProperty(PropertyName = "properties.monitorConfiguration")] + public object MonitorConfiguration { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (Type == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Type"); + } + } + } +} diff --git a/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/MonitorStateChange.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/MonitorStateChange.cs new file mode 100644 index 000000000000..8c311c2ec090 --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/MonitorStateChange.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.WorkloadMonitor.Models +{ + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Monitor State Change + /// + /// + /// Information about a state transition of a monitor. + /// + [Rest.Serialization.JsonTransformation] + public partial class MonitorStateChange + { + /// + /// Initializes a new instance of the MonitorStateChange class. + /// + public MonitorStateChange() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the MonitorStateChange class. + /// + /// Arm ID + /// Name of resource + /// Resource type + /// Monitor Name + /// Monitor Type + /// Monitored Object + /// Timestamp + /// Timestamp + /// Previous Health State + /// New Health State + /// Evidence + /// Configuration + public MonitorStateChange(string id, string name, string type, string monitorName = default(string), string monitorType = default(string), string monitoredObject = default(string), string evaluationTimestamp = default(string), string currentStateFirstObservedTimestamp = default(string), string previousMonitorState = default(string), string currentMonitorState = default(string), object evidence = default(object), object monitorConfiguration = default(object)) + { + Id = id; + Name = name; + Type = type; + MonitorName = monitorName; + MonitorType = monitorType; + MonitoredObject = monitoredObject; + EvaluationTimestamp = evaluationTimestamp; + CurrentStateFirstObservedTimestamp = currentStateFirstObservedTimestamp; + PreviousMonitorState = previousMonitorState; + CurrentMonitorState = currentMonitorState; + Evidence = evidence; + MonitorConfiguration = monitorConfiguration; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets arm ID + /// + /// + /// Arm ID of this monitor. + /// + [JsonProperty(PropertyName = "id")] + public string Id { get; set; } + + /// + /// Gets or sets name of resource + /// + /// + /// Timestamp of state change (in unix). + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets resource type + /// + /// + /// Type of ARM resource. + /// + [JsonProperty(PropertyName = "type")] + public string Type { get; set; } + + /// + /// Gets or sets monitor Name + /// + /// + /// Human-readable name of this monitor. + /// + [JsonProperty(PropertyName = "properties.monitorName")] + public string MonitorName { get; set; } + + /// + /// Gets or sets monitor Type + /// + /// + /// Type of this monitor. + /// + [JsonProperty(PropertyName = "properties.monitorType")] + public string MonitorType { get; set; } + + /// + /// Gets or sets monitored Object + /// + /// + /// Dynamic monitored object of this monitor. + /// + [JsonProperty(PropertyName = "properties.monitoredObject")] + public string MonitoredObject { get; set; } + + /// + /// Gets or sets timestamp + /// + /// + /// Timestamp of that this event ocurred. + /// + [JsonProperty(PropertyName = "properties.evaluationTimestamp")] + public string EvaluationTimestamp { get; set; } + + /// + /// Gets or sets timestamp + /// + /// + /// Timestamp of that this health state first ocurred. + /// + [JsonProperty(PropertyName = "properties.currentStateFirstObservedTimestamp")] + public string CurrentStateFirstObservedTimestamp { get; set; } + + /// + /// Gets or sets previous Health State + /// + /// + /// Previous health state. Possible values include: 'Healthy', + /// 'Critical', 'Warning', 'Unknown' + /// + [JsonProperty(PropertyName = "properties.previousMonitorState")] + public string PreviousMonitorState { get; set; } + + /// + /// Gets or sets new Health State + /// + /// + /// New health state. Possible values include: 'Healthy', 'Critical', + /// 'Warning', 'Unknown' + /// + [JsonProperty(PropertyName = "properties.currentMonitorState")] + public string CurrentMonitorState { get; set; } + + /// + /// Gets or sets evidence + /// + /// + /// Evidence of this monitor's last state change. + /// + [JsonProperty(PropertyName = "properties.evidence")] + public object Evidence { get; set; } + + /// + /// Gets or sets configuration + /// + /// + /// Configuration settings at the time of this monitor's last state + /// change. + /// + [JsonProperty(PropertyName = "properties.monitorConfiguration")] + public object MonitorConfiguration { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Id == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Id"); + } + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (Type == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Type"); + } + } + } +} diff --git a/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/Operation.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/Operation.cs new file mode 100644 index 000000000000..3deba9cb5fb5 --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/Operation.cs @@ -0,0 +1,105 @@ +// +// 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.WorkloadMonitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Operation + /// + /// + /// Operation supported by the 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 + /// Display + /// Origin + public Operation(string name, OperationDisplay display, string origin) + { + Name = name; + Display = display; + Origin = origin; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets operation Name + /// + /// + /// Name of the operation. + /// + [JsonProperty(PropertyName = "name")] + public string Name { get; set; } + + /// + /// Gets or sets display + /// + /// + /// The properties of the resource operation. + /// + [JsonProperty(PropertyName = "display")] + public OperationDisplay Display { get; set; } + + /// + /// Gets or sets origin + /// + /// + /// The origin of the operation. + /// + [JsonProperty(PropertyName = "origin")] + public string Origin { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Name == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Name"); + } + if (Display == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Display"); + } + if (Origin == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Origin"); + } + if (Display != null) + { + Display.Validate(); + } + } + } +} diff --git a/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/OperationDisplay.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/OperationDisplay.cs new file mode 100644 index 000000000000..f203e3933307 --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/OperationDisplay.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.WorkloadMonitor.Models +{ + using Microsoft.Rest; + using Newtonsoft.Json; + using System.Linq; + + /// + /// Display + /// + /// + /// The properties of the resource operation. + /// + public partial class OperationDisplay + { + /// + /// Initializes a new instance of the OperationDisplay class. + /// + public OperationDisplay() + { + CustomInit(); + } + + /// + /// Initializes a new instance of the OperationDisplay class. + /// + /// Provider Name + /// Resource Name + /// Operation Name + /// Description + public OperationDisplay(string provider, string resource, string operation, string description) + { + Provider = provider; + Resource = resource; + Operation = operation; + Description = description; + CustomInit(); + } + + /// + /// An initialization method that performs custom operations like setting defaults + /// + partial void CustomInit(); + + /// + /// Gets or sets provider Name + /// + /// + /// Provider name of this operation. + /// + [JsonProperty(PropertyName = "provider")] + public string Provider { get; set; } + + /// + /// Gets or sets resource Name + /// + /// + /// Resource name of this operation. + /// + [JsonProperty(PropertyName = "resource")] + public string Resource { get; set; } + + /// + /// Gets or sets operation Name + /// + /// + /// Operation name of the operation. + /// + [JsonProperty(PropertyName = "operation")] + public string Operation { get; set; } + + /// + /// Gets or sets description + /// + /// + /// Description of the operation. + /// + [JsonProperty(PropertyName = "description")] + public string Description { get; set; } + + /// + /// Validate the object. + /// + /// + /// Thrown if validation fails + /// + public virtual void Validate() + { + if (Provider == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Provider"); + } + if (Resource == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Resource"); + } + if (Operation == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Operation"); + } + if (Description == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "Description"); + } + } + } +} diff --git a/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/Page.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Models/Page.cs new file mode 100644 index 000000000000..ade086223d7a --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/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.WorkloadMonitor.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/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorHistoricalStateChangeOperations.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorHistoricalStateChangeOperations.cs new file mode 100644 index 000000000000..149d5ed0dbb8 --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorHistoricalStateChangeOperations.cs @@ -0,0 +1,289 @@ +// +// 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.WorkloadMonitor +{ + 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; + + /// + /// MonitorHistoricalStateChangeOperations operations. + /// + internal partial class MonitorHistoricalStateChangeOperations : IServiceOperations, IMonitorHistoricalStateChangeOperations + { + /// + /// Initializes a new instance of the MonitorHistoricalStateChangeOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal MonitorHistoricalStateChangeOperations(WorkloadMonitorAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the WorkloadMonitorAPIClient + /// + public WorkloadMonitorAPIClient Client { get; private set; } + + /// + /// Get the status of a monitor at a specific timestamp in history. + /// + /// + /// The subscriptionId of the resource + /// + /// + /// The resourceGroupName of the resource + /// + /// + /// The resourceNamespace of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The monitorId of the resource (url encoded) + /// + /// + /// The timestamp of the state change (Unix format) + /// + /// + /// ex: $expand=evidence,configuration + /// + /// + /// 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 subscriptionId, string resourceGroupName, string resourceNamespace, string resourceType, string resourceName, string monitorId, string timestampUnix, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceNamespace"); + } + if (resourceType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceType"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + if (monitorId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorId"); + } + if (timestampUnix == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "timestampUnix"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("subscriptionId", subscriptionId); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceNamespace", resourceNamespace); + tracingParameters.Add("resourceType", resourceType); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("monitorId", monitorId); + tracingParameters.Add("timestampUnix", timestampUnix); + tracingParameters.Add("expand", expand); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.WorkloadMonitor/monitors/{monitorId}/history/{timestampUnix}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceNamespace}", System.Uri.EscapeDataString(resourceNamespace)); + _url = _url.Replace("{resourceType}", System.Uri.EscapeDataString(resourceType)); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _url = _url.Replace("{monitorId}", System.Uri.EscapeDataString(monitorId)); + _url = _url.Replace("{timestampUnix}", System.Uri.EscapeDataString(timestampUnix)); + 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 (_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 DefaultErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DefaultError _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/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorHistoricalStateChangeOperationsExtensions.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorHistoricalStateChangeOperationsExtensions.cs new file mode 100644 index 000000000000..65107ae7c94a --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorHistoricalStateChangeOperationsExtensions.cs @@ -0,0 +1,101 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.WorkloadMonitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for MonitorHistoricalStateChangeOperations. + /// + public static partial class MonitorHistoricalStateChangeOperationsExtensions + { + /// + /// Get the status of a monitor at a specific timestamp in history. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The subscriptionId of the resource + /// + /// + /// The resourceGroupName of the resource + /// + /// + /// The resourceNamespace of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The monitorId of the resource (url encoded) + /// + /// + /// The timestamp of the state change (Unix format) + /// + /// + /// ex: $expand=evidence,configuration + /// + public static MonitorStateChange Get(this IMonitorHistoricalStateChangeOperations operations, string subscriptionId, string resourceGroupName, string resourceNamespace, string resourceType, string resourceName, string monitorId, string timestampUnix, string expand = default(string)) + { + return operations.GetAsync(subscriptionId, resourceGroupName, resourceNamespace, resourceType, resourceName, monitorId, timestampUnix, expand).GetAwaiter().GetResult(); + } + + /// + /// Get the status of a monitor at a specific timestamp in history. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The subscriptionId of the resource + /// + /// + /// The resourceGroupName of the resource + /// + /// + /// The resourceNamespace of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The monitorId of the resource (url encoded) + /// + /// + /// The timestamp of the state change (Unix format) + /// + /// + /// ex: $expand=evidence,configuration + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IMonitorHistoricalStateChangeOperations operations, string subscriptionId, string resourceGroupName, string resourceNamespace, string resourceType, string resourceName, string monitorId, string timestampUnix, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(subscriptionId, resourceGroupName, resourceNamespace, resourceType, resourceName, monitorId, timestampUnix, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorInfoOperations.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorInfoOperations.cs new file mode 100644 index 000000000000..215884f444ee --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorInfoOperations.cs @@ -0,0 +1,280 @@ +// +// 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.WorkloadMonitor +{ + 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; + + /// + /// MonitorInfoOperations operations. + /// + internal partial class MonitorInfoOperations : IServiceOperations, IMonitorInfoOperations + { + /// + /// Initializes a new instance of the MonitorInfoOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal MonitorInfoOperations(WorkloadMonitorAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the WorkloadMonitorAPIClient + /// + public WorkloadMonitorAPIClient Client { get; private set; } + + /// + /// Get the current status of a monitor of a resource. + /// + /// + /// The subscriptionId of the resource + /// + /// + /// The resourceGroupName of the resource + /// + /// + /// The resourceNamespace of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The monitorId of the resource (url encoded) + /// + /// + /// ex: $expand=evidence,configuration + /// + /// + /// 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 subscriptionId, string resourceGroupName, string resourceNamespace, string resourceType, string resourceName, string monitorId, string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceNamespace"); + } + if (resourceType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceType"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + if (monitorId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("subscriptionId", subscriptionId); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceNamespace", resourceNamespace); + tracingParameters.Add("resourceType", resourceType); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("monitorId", monitorId); + tracingParameters.Add("expand", expand); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.WorkloadMonitor/monitors/{monitorId}").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceNamespace}", System.Uri.EscapeDataString(resourceNamespace)); + _url = _url.Replace("{resourceType}", System.Uri.EscapeDataString(resourceType)); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _url = _url.Replace("{monitorId}", System.Uri.EscapeDataString(monitorId)); + 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 (_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 DefaultErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DefaultError _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/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorInfoOperationsExtensions.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorInfoOperationsExtensions.cs new file mode 100644 index 000000000000..10768780ef60 --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorInfoOperationsExtensions.cs @@ -0,0 +1,95 @@ +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. +// + +namespace Microsoft.Azure.Management.WorkloadMonitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for MonitorInfoOperations. + /// + public static partial class MonitorInfoOperationsExtensions + { + /// + /// Get the current status of a monitor of a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The subscriptionId of the resource + /// + /// + /// The resourceGroupName of the resource + /// + /// + /// The resourceNamespace of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The monitorId of the resource (url encoded) + /// + /// + /// ex: $expand=evidence,configuration + /// + public static Monitor Get(this IMonitorInfoOperations operations, string subscriptionId, string resourceGroupName, string resourceNamespace, string resourceType, string resourceName, string monitorId, string expand = default(string)) + { + return operations.GetAsync(subscriptionId, resourceGroupName, resourceNamespace, resourceType, resourceName, monitorId, expand).GetAwaiter().GetResult(); + } + + /// + /// Get the current status of a monitor of a resource. + /// + /// + /// The operations group for this extension method. + /// + /// + /// The subscriptionId of the resource + /// + /// + /// The resourceGroupName of the resource + /// + /// + /// The resourceNamespace of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The monitorId of the resource (url encoded) + /// + /// + /// ex: $expand=evidence,configuration + /// + /// + /// The cancellation token. + /// + public static async Task GetAsync(this IMonitorInfoOperations operations, string subscriptionId, string resourceGroupName, string resourceNamespace, string resourceType, string resourceName, string monitorId, string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.GetWithHttpMessagesAsync(subscriptionId, resourceGroupName, resourceNamespace, resourceType, resourceName, monitorId, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorStateChangesOperations.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorStateChangesOperations.cs new file mode 100644 index 000000000000..493284e3845e --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorStateChangesOperations.cs @@ -0,0 +1,473 @@ +// +// 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.WorkloadMonitor +{ + 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; + + /// + /// MonitorStateChangesOperations operations. + /// + internal partial class MonitorStateChangesOperations : IServiceOperations, IMonitorStateChangesOperations + { + /// + /// Initializes a new instance of the MonitorStateChangesOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal MonitorStateChangesOperations(WorkloadMonitorAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the WorkloadMonitorAPIClient + /// + public WorkloadMonitorAPIClient Client { get; private set; } + + /// + /// Get history of a monitor of a resource (with optional filter). + /// + /// + /// The subscriptionId of the resource + /// + /// + /// The resourceGroupName of the resource + /// + /// + /// The resourceNamespace of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The monitorId of the resource (url encoded) + /// + /// + /// list example: $filter=monitorName eq 'logical-disks|C:|disk-free-space-mb'; + /// history example: $filter=isHeartbeat eq false + /// + /// + /// ex: $expand=evidence,configuration + /// + /// + /// The start Timestamp for the desired history + /// + /// + /// The end Timestamp for the desired history + /// + /// + /// 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 subscriptionId, string resourceGroupName, string resourceNamespace, string resourceType, string resourceName, string monitorId, string filter = default(string), string expand = default(string), System.DateTime? startTimestampUtc = default(System.DateTime?), System.DateTime? endTimestampUtc = default(System.DateTime?), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceNamespace"); + } + if (resourceType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceType"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + if (monitorId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "monitorId"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("subscriptionId", subscriptionId); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceNamespace", resourceNamespace); + tracingParameters.Add("resourceType", resourceType); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("monitorId", monitorId); + tracingParameters.Add("filter", filter); + tracingParameters.Add("expand", expand); + tracingParameters.Add("startTimestampUtc", startTimestampUtc); + tracingParameters.Add("endTimestampUtc", endTimestampUtc); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.WorkloadMonitor/monitors/{monitorId}/history").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceNamespace}", System.Uri.EscapeDataString(resourceNamespace)); + _url = _url.Replace("{resourceType}", System.Uri.EscapeDataString(resourceType)); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + _url = _url.Replace("{monitorId}", System.Uri.EscapeDataString(monitorId)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + if (startTimestampUtc != null) + { + _queryParameters.Add(string.Format("startTimestampUtc={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(startTimestampUtc, Client.SerializationSettings).Trim('"')))); + } + if (endTimestampUtc != null) + { + _queryParameters.Add(string.Format("endTimestampUtc={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(endTimestampUtc, 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 (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 DefaultErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DefaultError _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 history of a monitor of a resource (with optional filter). + /// + /// + /// 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 DefaultErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DefaultError _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/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorStateChangesOperationsExtensions.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorStateChangesOperationsExtensions.cs new file mode 100644 index 000000000000..4f6726fc0b6e --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorStateChangesOperationsExtensions.cs @@ -0,0 +1,149 @@ +// +// 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.WorkloadMonitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for MonitorStateChangesOperations. + /// + public static partial class MonitorStateChangesOperationsExtensions + { + /// + /// Get history of a monitor of a resource (with optional filter). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The subscriptionId of the resource + /// + /// + /// The resourceGroupName of the resource + /// + /// + /// The resourceNamespace of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The monitorId of the resource (url encoded) + /// + /// + /// list example: $filter=monitorName eq 'logical-disks|C:|disk-free-space-mb'; + /// history example: $filter=isHeartbeat eq false + /// + /// + /// ex: $expand=evidence,configuration + /// + /// + /// The start Timestamp for the desired history + /// + /// + /// The end Timestamp for the desired history + /// + public static IPage List(this IMonitorStateChangesOperations operations, string subscriptionId, string resourceGroupName, string resourceNamespace, string resourceType, string resourceName, string monitorId, string filter = default(string), string expand = default(string), System.DateTime? startTimestampUtc = default(System.DateTime?), System.DateTime? endTimestampUtc = default(System.DateTime?)) + { + return operations.ListAsync(subscriptionId, resourceGroupName, resourceNamespace, resourceType, resourceName, monitorId, filter, expand, startTimestampUtc, endTimestampUtc).GetAwaiter().GetResult(); + } + + /// + /// Get history of a monitor of a resource (with optional filter). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The subscriptionId of the resource + /// + /// + /// The resourceGroupName of the resource + /// + /// + /// The resourceNamespace of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The monitorId of the resource (url encoded) + /// + /// + /// list example: $filter=monitorName eq 'logical-disks|C:|disk-free-space-mb'; + /// history example: $filter=isHeartbeat eq false + /// + /// + /// ex: $expand=evidence,configuration + /// + /// + /// The start Timestamp for the desired history + /// + /// + /// The end Timestamp for the desired history + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IMonitorStateChangesOperations operations, string subscriptionId, string resourceGroupName, string resourceNamespace, string resourceType, string resourceName, string monitorId, string filter = default(string), string expand = default(string), System.DateTime? startTimestampUtc = default(System.DateTime?), System.DateTime? endTimestampUtc = default(System.DateTime?), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(subscriptionId, resourceGroupName, resourceNamespace, resourceType, resourceName, monitorId, filter, expand, startTimestampUtc, endTimestampUtc, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get history of a monitor of a resource (with optional filter). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IMonitorStateChangesOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get history of a monitor of a resource (with optional filter). + /// + /// + /// 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 IMonitorStateChangesOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorsOperations.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorsOperations.cs new file mode 100644 index 000000000000..dc47a866f2db --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorsOperations.cs @@ -0,0 +1,448 @@ +// +// 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.WorkloadMonitor +{ + 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; + + /// + /// MonitorsOperations operations. + /// + internal partial class MonitorsOperations : IServiceOperations, IMonitorsOperations + { + /// + /// Initializes a new instance of the MonitorsOperations class. + /// + /// + /// Reference to the service client. + /// + /// + /// Thrown when a required parameter is null + /// + internal MonitorsOperations(WorkloadMonitorAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the WorkloadMonitorAPIClient + /// + public WorkloadMonitorAPIClient Client { get; private set; } + + /// + /// Get list of a monitors of a resource (with optional filter). + /// + /// + /// The subscriptionId of the resource + /// + /// + /// The resourceGroupName of the resource + /// + /// + /// The resourceNamespace of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// list example: $filter=monitorName eq 'logical-disks|C:|disk-free-space-mb'; + /// history example: $filter=isHeartbeat eq false + /// + /// + /// ex: $expand=evidence,configuration + /// + /// + /// 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 subscriptionId, string resourceGroupName, string resourceNamespace, string resourceType, string resourceName, string filter = default(string), string expand = default(string), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + if (subscriptionId == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "subscriptionId"); + } + if (resourceGroupName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceGroupName"); + } + if (resourceNamespace == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceNamespace"); + } + if (resourceType == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceType"); + } + if (resourceName == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "resourceName"); + } + // Tracing + bool _shouldTrace = ServiceClientTracing.IsEnabled; + string _invocationId = null; + if (_shouldTrace) + { + _invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("subscriptionId", subscriptionId); + tracingParameters.Add("resourceGroupName", resourceGroupName); + tracingParameters.Add("resourceNamespace", resourceNamespace); + tracingParameters.Add("resourceType", resourceType); + tracingParameters.Add("resourceName", resourceName); + tracingParameters.Add("filter", filter); + tracingParameters.Add("expand", expand); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters); + } + // Construct URL + var _baseUrl = Client.BaseUri.AbsoluteUri; + var _url = new System.Uri(new System.Uri(_baseUrl + (_baseUrl.EndsWith("/") ? "" : "/")), "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.WorkloadMonitor/monitors").ToString(); + _url = _url.Replace("{subscriptionId}", System.Uri.EscapeDataString(subscriptionId)); + _url = _url.Replace("{resourceGroupName}", System.Uri.EscapeDataString(resourceGroupName)); + _url = _url.Replace("{resourceNamespace}", System.Uri.EscapeDataString(resourceNamespace)); + _url = _url.Replace("{resourceType}", System.Uri.EscapeDataString(resourceType)); + _url = _url.Replace("{resourceName}", System.Uri.EscapeDataString(resourceName)); + List _queryParameters = new List(); + if (Client.ApiVersion != null) + { + _queryParameters.Add(string.Format("api-version={0}", System.Uri.EscapeDataString(Client.ApiVersion))); + } + if (filter != null) + { + _queryParameters.Add(string.Format("$filter={0}", System.Uri.EscapeDataString(filter))); + } + if (expand != null) + { + _queryParameters.Add(string.Format("$expand={0}", System.Uri.EscapeDataString(expand))); + } + 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 DefaultErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DefaultError _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 list of a monitors of a resource (with optional filter). + /// + /// + /// 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 DefaultErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DefaultError _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/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorsOperationsExtensions.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorsOperationsExtensions.cs new file mode 100644 index 000000000000..11eaf66eb866 --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/MonitorsOperationsExtensions.cs @@ -0,0 +1,131 @@ +// +// 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.WorkloadMonitor +{ + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + using System.Threading; + using System.Threading.Tasks; + + /// + /// Extension methods for MonitorsOperations. + /// + public static partial class MonitorsOperationsExtensions + { + /// + /// Get list of a monitors of a resource (with optional filter). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The subscriptionId of the resource + /// + /// + /// The resourceGroupName of the resource + /// + /// + /// The resourceNamespace of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// list example: $filter=monitorName eq 'logical-disks|C:|disk-free-space-mb'; + /// history example: $filter=isHeartbeat eq false + /// + /// + /// ex: $expand=evidence,configuration + /// + public static IPage List(this IMonitorsOperations operations, string subscriptionId, string resourceGroupName, string resourceNamespace, string resourceType, string resourceName, string filter = default(string), string expand = default(string)) + { + return operations.ListAsync(subscriptionId, resourceGroupName, resourceNamespace, resourceType, resourceName, filter, expand).GetAwaiter().GetResult(); + } + + /// + /// Get list of a monitors of a resource (with optional filter). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The subscriptionId of the resource + /// + /// + /// The resourceGroupName of the resource + /// + /// + /// The resourceNamespace of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// The resourceType of the resource + /// + /// + /// list example: $filter=monitorName eq 'logical-disks|C:|disk-free-space-mb'; + /// history example: $filter=isHeartbeat eq false + /// + /// + /// ex: $expand=evidence,configuration + /// + /// + /// The cancellation token. + /// + public static async Task> ListAsync(this IMonitorsOperations operations, string subscriptionId, string resourceGroupName, string resourceNamespace, string resourceType, string resourceName, string filter = default(string), string expand = default(string), CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListWithHttpMessagesAsync(subscriptionId, resourceGroupName, resourceNamespace, resourceType, resourceName, filter, expand, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + /// + /// Get list of a monitors of a resource (with optional filter). + /// + /// + /// The operations group for this extension method. + /// + /// + /// The NextLink from the previous successful call to List operation. + /// + public static IPage ListNext(this IMonitorsOperations operations, string nextPageLink) + { + return operations.ListNextAsync(nextPageLink).GetAwaiter().GetResult(); + } + + /// + /// Get list of a monitors of a resource (with optional filter). + /// + /// + /// 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 IMonitorsOperations operations, string nextPageLink, CancellationToken cancellationToken = default(CancellationToken)) + { + using (var _result = await operations.ListNextWithHttpMessagesAsync(nextPageLink, null, cancellationToken).ConfigureAwait(false)) + { + return _result.Body; + } + } + + } +} diff --git a/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Operations.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Operations.cs new file mode 100644 index 000000000000..6e15ac329db6 --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/Operations.cs @@ -0,0 +1,380 @@ +// +// 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.WorkloadMonitor +{ + 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(WorkloadMonitorAPIClient client) + { + if (client == null) + { + throw new System.ArgumentNullException("client"); + } + Client = client; + } + + /// + /// Gets a reference to the WorkloadMonitorAPIClient + /// + public WorkloadMonitorAPIClient Client { get; private set; } + + /// + /// Gets a list of possible 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 + /// + /// + /// A response object containing the response body and response headers. + /// + public async Task>> ListWithHttpMessagesAsync(Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + // 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.WorkloadMonitor/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 DefaultErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DefaultError _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; + } + + /// + /// Gets a list of possible 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 DefaultErrorException(string.Format("Operation returned an invalid status code '{0}'", _statusCode)); + try + { + _responseContent = await _httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + DefaultError _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/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/OperationsExtensions.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/OperationsExtensions.cs new file mode 100644 index 000000000000..7cabad5f76a4 --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/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.WorkloadMonitor +{ + 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 + { + /// + /// Gets a list of possible operations + /// + /// + /// The operations group for this extension method. + /// + public static IPage List(this IOperations operations) + { + return operations.ListAsync().GetAwaiter().GetResult(); + } + + /// + /// Gets a list of possible 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; + } + } + + /// + /// Gets a list of possible 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(); + } + + /// + /// Gets a list of possible 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/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/SdkInfo_WorkloadMonitorAPI.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/SdkInfo_WorkloadMonitorAPI.cs new file mode 100644 index 000000000000..5cf3ac7e0c0c --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/SdkInfo_WorkloadMonitorAPI.cs @@ -0,0 +1,31 @@ + +// +// 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.WorkloadMonitor +{ + using System; + using System.Collections.Generic; + using System.Linq; + + internal static partial class SdkInfo + { + public static IEnumerable> ApiInfo_WorkloadMonitorAPI + { + get + { + return new Tuple[] + { + new Tuple("WorkloadMonitor", "MonitorHistoricalStateChange", "2020-01-13-preview"), + new Tuple("WorkloadMonitor", "MonitorInfo", "2020-01-13-preview"), + new Tuple("WorkloadMonitor", "MonitorStateChanges", "2020-01-13-preview"), + new Tuple("WorkloadMonitor", "Monitors", "2020-01-13-preview"), + new Tuple("WorkloadMonitor", "Operations", "2020-01-13-preview"), + }.AsEnumerable(); + } + } + } +} diff --git a/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/WorkloadMonitorAPIClient.cs b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/WorkloadMonitorAPIClient.cs new file mode 100644 index 000000000000..7b6b4aad56dc --- /dev/null +++ b/sdk/workloadmonitor/Microsoft.Azure.Management.WorkloadMonitor/src/Generated/WorkloadMonitorAPIClient.cs @@ -0,0 +1,379 @@ +// +// 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.WorkloadMonitor +{ + 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; + + /// + /// Workload Monitor API + /// + public partial class WorkloadMonitorAPIClient : ServiceClient, IWorkloadMonitorAPIClient, 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; } + + /// + /// The API version to use for this operation. + /// + public string ApiVersion { get; private set; } + + /// + /// The preferred language for the response. + /// + public string AcceptLanguage { get; set; } + + /// + /// The retry timeout in seconds for Long Running Operations. Default value is + /// 30. + /// + public int? LongRunningOperationRetryTimeout { get; set; } + + /// + /// Whether a unique x-ms-client-request-id should be generated. When set to + /// true a unique x-ms-client-request-id value is generated and included in + /// each request. Default is true. + /// + public bool? GenerateClientRequestId { get; set; } + + /// + /// Gets the IOperations. + /// + public virtual IOperations Operations { get; private set; } + + /// + /// Gets the IMonitorsOperations. + /// + public virtual IMonitorsOperations Monitors { get; private set; } + + /// + /// Gets the IMonitorInfoOperations. + /// + public virtual IMonitorInfoOperations MonitorInfo { get; private set; } + + /// + /// Gets the IMonitorStateChangesOperations. + /// + public virtual IMonitorStateChangesOperations MonitorStateChanges { get; private set; } + + /// + /// Gets the IMonitorHistoricalStateChangeOperations. + /// + public virtual IMonitorHistoricalStateChangeOperations MonitorHistoricalStateChange { get; private set; } + + /// + /// Initializes a new instance of the WorkloadMonitorAPIClient class. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling WorkloadMonitorAPIClient.Dispose(). False: will not dispose provided httpClient + protected WorkloadMonitorAPIClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) + { + Initialize(); + } + + /// + /// Initializes a new instance of the WorkloadMonitorAPIClient class. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected WorkloadMonitorAPIClient(params DelegatingHandler[] handlers) : base(handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the WorkloadMonitorAPIClient class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The delegating handlers to add to the http client pipeline. + /// + protected WorkloadMonitorAPIClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + Initialize(); + } + + /// + /// Initializes a new instance of the WorkloadMonitorAPIClient 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 WorkloadMonitorAPIClient(System.Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new System.ArgumentNullException("baseUri"); + } + BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the WorkloadMonitorAPIClient 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 WorkloadMonitorAPIClient(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 WorkloadMonitorAPIClient 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 WorkloadMonitorAPIClient(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 WorkloadMonitorAPIClient class. + /// + /// + /// Required. Credentials needed for the client to connect to Azure. + /// + /// + /// HttpClient to be used + /// + /// + /// True: will dispose the provided httpClient on calling WorkloadMonitorAPIClient.Dispose(). False: will not dispose provided httpClient + /// + /// Thrown when a required parameter is null + /// + public WorkloadMonitorAPIClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient) + { + if (credentials == null) + { + throw new System.ArgumentNullException("credentials"); + } + Credentials = credentials; + if (Credentials != null) + { + Credentials.InitializeServiceClient(this); + } + } + + /// + /// Initializes a new instance of the WorkloadMonitorAPIClient 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 WorkloadMonitorAPIClient(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 WorkloadMonitorAPIClient 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 WorkloadMonitorAPIClient(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 WorkloadMonitorAPIClient 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 WorkloadMonitorAPIClient(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() + { + Operations = new Operations(this); + Monitors = new MonitorsOperations(this); + MonitorInfo = new MonitorInfoOperations(this); + MonitorStateChanges = new MonitorStateChangesOperations(this); + MonitorHistoricalStateChange = new MonitorHistoricalStateChangeOperations(this); + BaseUri = new System.Uri("https://management.azure.com"); + ApiVersion = "2020-01-13-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()); + } + } +}