/// <summary> /// Your documentation here. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/XXXXX.aspx /// for more information) /// </summary> /// <param name='filter'> /// Optional. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// Your documentation here. /// </returns> public async Task <EventTypesListResult> ListAsync(string filter, CancellationToken cancellationToken) { // Validate // Tracing bool shouldTrace = TracingAdapter.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = TracingAdapter.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("filter", filter); TracingAdapter.Enter(invocationId, this, "ListAsync", tracingParameters); } // Construct URL string url = ""; url = url + "/subscriptions/"; if (this.Client.Credentials.SubscriptionId != null) { url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); } url = url + "/providers/Microsoft.Insights/eventtypes/management/values"; List <string> queryParameters = new List <string>(); if (filter != null) { queryParameters.Add(Uri.EscapeDataString(filter)); } queryParameters.Add("api-version=1.0"); if (queryParameters.Count > 0) { url = url + "?" + string.Join("&", queryParameters); } string baseUrl = this.Client.BaseUri.AbsoluteUri; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.Length - 1] == '/') { baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); } if (url[0] == '/') { url = url.Substring(1); } url = baseUrl + "/" + url; url = url.Replace(" ", "%20"); // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Get; httpRequest.RequestUri = new Uri(url); // Set Headers // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { TracingAdapter.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { TracingAdapter.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); if (shouldTrace) { TracingAdapter.Error(invocationId, ex); } throw ex; } // Create Result EventTypesListResult result = null; // Deserialize Response if (statusCode == HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); result = new EventTypesListResult(); JToken responseDoc = null; if (string.IsNullOrEmpty(responseContent) == false) { responseDoc = JToken.Parse(responseContent); } if (responseDoc != null && responseDoc.Type != JTokenType.Null) { JToken valueArray = responseDoc["value"]; if (valueArray != null && valueArray.Type != JTokenType.Null) { foreach (JToken valueValue in ((JArray)valueArray)) { EventData eventDataInstance = new EventData(); result.EventData.Add(eventDataInstance); JToken eventDataIdValue = valueValue["eventDataId"]; if (eventDataIdValue != null && eventDataIdValue.Type != JTokenType.Null) { string eventDataIdInstance = ((string)eventDataIdValue); eventDataInstance.EventDataId = eventDataIdInstance; } JToken correlationIdValue = valueValue["correlationId"]; if (correlationIdValue != null && correlationIdValue.Type != JTokenType.Null) { string correlationIdInstance = ((string)correlationIdValue); eventDataInstance.CorrelationId = correlationIdInstance; } JToken operationNameValue = valueValue["operationName"]; if (operationNameValue != null && operationNameValue.Type != JTokenType.Null) { LocalizableString operationNameInstance = new LocalizableString(); eventDataInstance.OperationName = operationNameInstance; JToken valueValue2 = operationNameValue["value"]; if (valueValue2 != null && valueValue2.Type != JTokenType.Null) { string valueInstance = ((string)valueValue2); operationNameInstance.Value = valueInstance; } JToken localizedValueValue = operationNameValue["localizedValue"]; if (localizedValueValue != null && localizedValueValue.Type != JTokenType.Null) { string localizedValueInstance = ((string)localizedValueValue); operationNameInstance.LocalizedValue = localizedValueInstance; } } JToken propertiesSequenceElement = ((JToken)valueValue["properties"]); if (propertiesSequenceElement != null && propertiesSequenceElement.Type != JTokenType.Null) { foreach (JProperty property in propertiesSequenceElement) { string propertiesKey = ((string)property.Name); string propertiesValue = ((string)property.Value); eventDataInstance.Properties.Add(propertiesKey, propertiesValue); } } JToken eventSourceValue = valueValue["eventSource"]; if (eventSourceValue != null && eventSourceValue.Type != JTokenType.Null) { LocalizableString eventSourceInstance = new LocalizableString(); eventDataInstance.EventSource = eventSourceInstance; JToken valueValue3 = eventSourceValue["value"]; if (valueValue3 != null && valueValue3.Type != JTokenType.Null) { string valueInstance2 = ((string)valueValue3); eventSourceInstance.Value = valueInstance2; } JToken localizedValueValue2 = eventSourceValue["localizedValue"]; if (localizedValueValue2 != null && localizedValueValue2.Type != JTokenType.Null) { string localizedValueInstance2 = ((string)localizedValueValue2); eventSourceInstance.LocalizedValue = localizedValueInstance2; } } JToken statusValue = valueValue["status"]; if (statusValue != null && statusValue.Type != JTokenType.Null) { LocalizableString statusInstance = new LocalizableString(); eventDataInstance.Status = statusInstance; JToken valueValue4 = statusValue["value"]; if (valueValue4 != null && valueValue4.Type != JTokenType.Null) { string valueInstance3 = ((string)valueValue4); statusInstance.Value = valueInstance3; } JToken localizedValueValue3 = statusValue["localizedValue"]; if (localizedValueValue3 != null && localizedValueValue3.Type != JTokenType.Null) { string localizedValueInstance3 = ((string)localizedValueValue3); statusInstance.LocalizedValue = localizedValueInstance3; } } JToken subStatusValue = valueValue["subStatus"]; if (subStatusValue != null && subStatusValue.Type != JTokenType.Null) { LocalizableString subStatusInstance = new LocalizableString(); eventDataInstance.SubStatus = subStatusInstance; JToken valueValue5 = subStatusValue["value"]; if (valueValue5 != null && valueValue5.Type != JTokenType.Null) { string valueInstance4 = ((string)valueValue5); subStatusInstance.Value = valueInstance4; } JToken localizedValueValue4 = subStatusValue["localizedValue"]; if (localizedValueValue4 != null && localizedValueValue4.Type != JTokenType.Null) { string localizedValueInstance4 = ((string)localizedValueValue4); subStatusInstance.LocalizedValue = localizedValueInstance4; } } JToken eventTimestampValue = valueValue["eventTimestamp"]; if (eventTimestampValue != null && eventTimestampValue.Type != JTokenType.Null) { DateTime eventTimestampInstance = ((DateTime)eventTimestampValue); eventDataInstance.EventTimestamp = eventTimestampInstance; } } } JToken odatanextLinkValue = responseDoc["@odata.nextLink"]; if (odatanextLinkValue != null && odatanextLinkValue.Type != JTokenType.Null) { string odatanextLinkInstance = ((string)odatanextLinkValue); result.NextLink = odatanextLinkInstance; } } } result.StatusCode = statusCode; if (shouldTrace) { TracingAdapter.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
/// <summary> /// Your documentation here. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/XXXXX.aspx /// for more information) /// </summary> /// <param name='nextLink'> /// Required. Your documentation here. (see /// http://msdn.microsoft.com/en-us/library/windowsazure/XXXXX.aspx /// for more information) /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// Your documentation here. /// </returns> public async Task <EventTypesListResult> ListNextAsync(string nextLink, CancellationToken cancellationToken) { // Validate if (nextLink == null) { throw new ArgumentNullException("nextLink"); } // Tracing bool shouldTrace = TracingAdapter.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = TracingAdapter.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("nextLink", nextLink); TracingAdapter.Enter(invocationId, this, "ListNextAsync", tracingParameters); } // Construct URL string url = ""; url = url + Uri.EscapeDataString(nextLink); url = url.Replace(" ", "%20"); // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Get; httpRequest.RequestUri = new Uri(url); // Set Headers // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { TracingAdapter.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { TracingAdapter.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); if (shouldTrace) { TracingAdapter.Error(invocationId, ex); } throw ex; } // Create Result EventTypesListResult result = null; // Deserialize Response if (statusCode == HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); result = new EventTypesListResult(); JToken responseDoc = null; if (string.IsNullOrEmpty(responseContent) == false) { responseDoc = JToken.Parse(responseContent); } if (responseDoc != null && responseDoc.Type != JTokenType.Null) { JToken valueArray = responseDoc["value"]; if (valueArray != null && valueArray.Type != JTokenType.Null) { foreach (JToken valueValue in ((JArray)valueArray)) { EventData eventDataInstance = new EventData(); result.EventData.Add(eventDataInstance); JToken eventDataIdValue = valueValue["eventDataId"]; if (eventDataIdValue != null && eventDataIdValue.Type != JTokenType.Null) { string eventDataIdInstance = ((string)eventDataIdValue); eventDataInstance.EventDataId = eventDataIdInstance; } JToken correlationIdValue = valueValue["correlationId"]; if (correlationIdValue != null && correlationIdValue.Type != JTokenType.Null) { string correlationIdInstance = ((string)correlationIdValue); eventDataInstance.CorrelationId = correlationIdInstance; } JToken operationNameValue = valueValue["operationName"]; if (operationNameValue != null && operationNameValue.Type != JTokenType.Null) { LocalizableString operationNameInstance = new LocalizableString(); eventDataInstance.OperationName = operationNameInstance; JToken valueValue2 = operationNameValue["value"]; if (valueValue2 != null && valueValue2.Type != JTokenType.Null) { string valueInstance = ((string)valueValue2); operationNameInstance.Value = valueInstance; } JToken localizedValueValue = operationNameValue["localizedValue"]; if (localizedValueValue != null && localizedValueValue.Type != JTokenType.Null) { string localizedValueInstance = ((string)localizedValueValue); operationNameInstance.LocalizedValue = localizedValueInstance; } } JToken propertiesSequenceElement = ((JToken)valueValue["properties"]); if (propertiesSequenceElement != null && propertiesSequenceElement.Type != JTokenType.Null) { foreach (JProperty property in propertiesSequenceElement) { string propertiesKey = ((string)property.Name); string propertiesValue = ((string)property.Value); eventDataInstance.Properties.Add(propertiesKey, propertiesValue); } } JToken eventSourceValue = valueValue["eventSource"]; if (eventSourceValue != null && eventSourceValue.Type != JTokenType.Null) { LocalizableString eventSourceInstance = new LocalizableString(); eventDataInstance.EventSource = eventSourceInstance; JToken valueValue3 = eventSourceValue["value"]; if (valueValue3 != null && valueValue3.Type != JTokenType.Null) { string valueInstance2 = ((string)valueValue3); eventSourceInstance.Value = valueInstance2; } JToken localizedValueValue2 = eventSourceValue["localizedValue"]; if (localizedValueValue2 != null && localizedValueValue2.Type != JTokenType.Null) { string localizedValueInstance2 = ((string)localizedValueValue2); eventSourceInstance.LocalizedValue = localizedValueInstance2; } } JToken statusValue = valueValue["status"]; if (statusValue != null && statusValue.Type != JTokenType.Null) { LocalizableString statusInstance = new LocalizableString(); eventDataInstance.Status = statusInstance; JToken valueValue4 = statusValue["value"]; if (valueValue4 != null && valueValue4.Type != JTokenType.Null) { string valueInstance3 = ((string)valueValue4); statusInstance.Value = valueInstance3; } JToken localizedValueValue3 = statusValue["localizedValue"]; if (localizedValueValue3 != null && localizedValueValue3.Type != JTokenType.Null) { string localizedValueInstance3 = ((string)localizedValueValue3); statusInstance.LocalizedValue = localizedValueInstance3; } } JToken subStatusValue = valueValue["subStatus"]; if (subStatusValue != null && subStatusValue.Type != JTokenType.Null) { LocalizableString subStatusInstance = new LocalizableString(); eventDataInstance.SubStatus = subStatusInstance; JToken valueValue5 = subStatusValue["value"]; if (valueValue5 != null && valueValue5.Type != JTokenType.Null) { string valueInstance4 = ((string)valueValue5); subStatusInstance.Value = valueInstance4; } JToken localizedValueValue4 = subStatusValue["localizedValue"]; if (localizedValueValue4 != null && localizedValueValue4.Type != JTokenType.Null) { string localizedValueInstance4 = ((string)localizedValueValue4); subStatusInstance.LocalizedValue = localizedValueInstance4; } } JToken eventTimestampValue = valueValue["eventTimestamp"]; if (eventTimestampValue != null && eventTimestampValue.Type != JTokenType.Null) { DateTime eventTimestampInstance = ((DateTime)eventTimestampValue); eventDataInstance.EventTimestamp = eventTimestampInstance; } } } JToken odatanextLinkValue = responseDoc["@odata.nextLink"]; if (odatanextLinkValue != null && odatanextLinkValue.Type != JTokenType.Null) { string odatanextLinkInstance = ((string)odatanextLinkValue); result.NextLink = odatanextLinkInstance; } } } result.StatusCode = statusCode; if (shouldTrace) { TracingAdapter.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }