public PSDataSliceRun(DataSliceRun dataSliceRun) { if (dataSliceRun == null) { throw new ArgumentNullException("dataSliceRun"); } this.dataSliceRun = dataSliceRun; }
/// <summary> /// Gets the next page of run instances with the link to the next page. /// </summary> /// <param name='nextLink'> /// Required. The url to the next data slice runs page. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// The List data slice runs operation response. /// </returns> public async Task <DataSliceRunListResponse> ListNextAsync(string nextLink, CancellationToken cancellationToken) { // Validate if (nextLink == null) { throw new ArgumentNullException("nextLink"); } // Tracing bool shouldTrace = CloudContext.Configuration.Tracing.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = Tracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("nextLink", nextLink); Tracing.Enter(invocationId, this, "ListNextAsync", tracingParameters); } // Construct URL string url = nextLink.Trim(); // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Get; httpRequest.RequestUri = new Uri(url); // Set Headers httpRequest.Headers.Add("x-ms-client-request-id", Guid.NewGuid().ToString()); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { Tracing.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { Tracing.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) { Tracing.Error(invocationId, ex); } throw ex; } // Create Result DataSliceRunListResponse result = null; // Deserialize Response cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); result = new DataSliceRunListResponse(); 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)) { DataSliceRun dataSliceRunInstance = new DataSliceRun(); result.DataSliceRuns.Add(dataSliceRunInstance); JToken idValue = valueValue["id"]; if (idValue != null && idValue.Type != JTokenType.Null) { string idInstance = ((string)idValue); dataSliceRunInstance.Id = idInstance; } JToken tableNameValue = valueValue["tableName"]; if (tableNameValue != null && tableNameValue.Type != JTokenType.Null) { string tableNameInstance = ((string)tableNameValue); dataSliceRunInstance.TableName = tableNameInstance; } JToken pipelineNameValue = valueValue["pipelineName"]; if (pipelineNameValue != null && pipelineNameValue.Type != JTokenType.Null) { string pipelineNameInstance = ((string)pipelineNameValue); dataSliceRunInstance.PipelineName = pipelineNameInstance; } JToken activityNameValue = valueValue["activityName"]; if (activityNameValue != null && activityNameValue.Type != JTokenType.Null) { string activityNameInstance = ((string)activityNameValue); dataSliceRunInstance.ActivityName = activityNameInstance; } JToken computeClusterNameValue = valueValue["computeClusterName"]; if (computeClusterNameValue != null && computeClusterNameValue.Type != JTokenType.Null) { string computeClusterNameInstance = ((string)computeClusterNameValue); dataSliceRunInstance.ComputeClusterName = computeClusterNameInstance; } JToken statusValue = valueValue["status"]; if (statusValue != null && statusValue.Type != JTokenType.Null) { string statusInstance = ((string)statusValue); dataSliceRunInstance.Status = statusInstance; } JToken processingStartTimeValue = valueValue["processingStartTime"]; if (processingStartTimeValue != null && processingStartTimeValue.Type != JTokenType.Null) { DateTime processingStartTimeInstance = ((DateTime)processingStartTimeValue); dataSliceRunInstance.ProcessingStartTime = processingStartTimeInstance; } JToken processingEndTimeValue = valueValue["processingEndTime"]; if (processingEndTimeValue != null && processingEndTimeValue.Type != JTokenType.Null) { DateTime processingEndTimeInstance = ((DateTime)processingEndTimeValue); dataSliceRunInstance.ProcessingEndTime = processingEndTimeInstance; } JToken batchTimeValue = valueValue["batchTime"]; if (batchTimeValue != null && batchTimeValue.Type != JTokenType.Null) { DateTime batchTimeInstance = ((DateTime)batchTimeValue); dataSliceRunInstance.BatchTime = batchTimeInstance; } JToken percentCompleteValue = valueValue["percentComplete"]; if (percentCompleteValue != null && percentCompleteValue.Type != JTokenType.Null) { int percentCompleteInstance = ((int)percentCompleteValue); dataSliceRunInstance.PercentComplete = percentCompleteInstance; } JToken dataSliceStartValue = valueValue["dataSliceStart"]; if (dataSliceStartValue != null && dataSliceStartValue.Type != JTokenType.Null) { DateTime dataSliceStartInstance = ((DateTime)dataSliceStartValue); dataSliceRunInstance.DataSliceStart = dataSliceStartInstance; } JToken dataSliceEndValue = valueValue["dataSliceEnd"]; if (dataSliceEndValue != null && dataSliceEndValue.Type != JTokenType.Null) { DateTime dataSliceEndInstance = ((DateTime)dataSliceEndValue); dataSliceRunInstance.DataSliceEnd = dataSliceEndInstance; } JToken timestampValue = valueValue["timestamp"]; if (timestampValue != null && timestampValue.Type != JTokenType.Null) { DateTime timestampInstance = ((DateTime)timestampValue); dataSliceRunInstance.Timestamp = timestampInstance; } JToken retryAttemptValue = valueValue["retryAttempt"]; if (retryAttemptValue != null && retryAttemptValue.Type != JTokenType.Null) { int retryAttemptInstance = ((int)retryAttemptValue); dataSliceRunInstance.RetryAttempt = retryAttemptInstance; } JToken hasLogsValue = valueValue["hasLogs"]; if (hasLogsValue != null && hasLogsValue.Type != JTokenType.Null) { bool hasLogsInstance = ((bool)hasLogsValue); dataSliceRunInstance.HasLogs = hasLogsInstance; } JToken typeValue = valueValue["type"]; if (typeValue != null && typeValue.Type != JTokenType.Null) { string typeInstance = ((string)typeValue); dataSliceRunInstance.Type = typeInstance; } 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); dataSliceRunInstance.Properties.Add(propertiesKey, propertiesValue); } } JToken errorMessageValue = valueValue["errorMessage"]; if (errorMessageValue != null && errorMessageValue.Type != JTokenType.Null) { string errorMessageInstance = ((string)errorMessageValue); dataSliceRunInstance.ErrorMessage = errorMessageInstance; } } } JToken odatanextLinkValue = responseDoc["@odata.nextLink"]; if (odatanextLinkValue != null && odatanextLinkValue.Type != JTokenType.Null) { string odatanextLinkInstance = ((string)odatanextLinkValue); result.NextLink = odatanextLinkInstance; } } result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { Tracing.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
/// <summary> /// Gets the first page of data slice run instances with the link to /// the next page. /// </summary> /// <param name='resourceGroupName'> /// Required. The resource group name of the data factory. /// </param> /// <param name='dataFactoryName'> /// Required. A unique data factory instance name. /// </param> /// <param name='tableName'> /// Required. A unique table instance name. /// </param> /// <param name='dataSliceStartTime'> /// Required. The start time of the data slice queried in round-trip /// ISO 8601 format. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// The List data slice runs operation response. /// </returns> public async Task <DataSliceRunListResponse> ListAsync(string resourceGroupName, string dataFactoryName, string tableName, string dataSliceStartTime, CancellationToken cancellationToken) { // Validate if (resourceGroupName == null) { throw new ArgumentNullException("resourceGroupName"); } if (resourceGroupName != null && resourceGroupName.Length > 1000) { throw new ArgumentOutOfRangeException("resourceGroupName"); } if (Regex.IsMatch(resourceGroupName, "^[-\\w\\._\\(\\)]+$") == false) { throw new ArgumentOutOfRangeException("resourceGroupName"); } if (dataFactoryName == null) { throw new ArgumentNullException("dataFactoryName"); } if (dataFactoryName != null && dataFactoryName.Length > 63) { throw new ArgumentOutOfRangeException("dataFactoryName"); } if (Regex.IsMatch(dataFactoryName, "^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$") == false) { throw new ArgumentOutOfRangeException("dataFactoryName"); } if (tableName == null) { throw new ArgumentNullException("tableName"); } if (tableName != null && tableName.Length > 260) { throw new ArgumentOutOfRangeException("tableName"); } if (Regex.IsMatch(tableName, "^[A-Za-z0-9_][^<>*#.%&:\\\\+?/]*$") == false) { throw new ArgumentOutOfRangeException("tableName"); } if (dataSliceStartTime == null) { throw new ArgumentNullException("dataSliceStartTime"); } // Tracing bool shouldTrace = TracingAdapter.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = TracingAdapter.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("resourceGroupName", resourceGroupName); tracingParameters.Add("dataFactoryName", dataFactoryName); tracingParameters.Add("tableName", tableName); tracingParameters.Add("dataSliceStartTime", dataSliceStartTime); 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 + "/resourcegroups/"; url = url + Uri.EscapeDataString(resourceGroupName); url = url + "/providers/Microsoft.DataFactory/datafactories/"; url = url + Uri.EscapeDataString(dataFactoryName); url = url + "/tables/"; url = url + Uri.EscapeDataString(tableName); url = url + "/sliceruns"; List <string> queryParameters = new List <string>(); queryParameters.Add("startTime=" + Uri.EscapeDataString(dataSliceStartTime)); queryParameters.Add("api-version=2015-01-01-preview"); 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 httpRequest.Headers.Add("x-ms-client-request-id", Guid.NewGuid().ToString()); // 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 DataSliceRunListResponse result = null; // Deserialize Response if (statusCode == HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); result = new DataSliceRunListResponse(); 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)) { DataSliceRun dataSliceRunInstance = new DataSliceRun(); result.DataSliceRuns.Add(dataSliceRunInstance); JToken idValue = valueValue["id"]; if (idValue != null && idValue.Type != JTokenType.Null) { string idInstance = ((string)idValue); dataSliceRunInstance.Id = idInstance; } JToken tableNameValue = valueValue["tableName"]; if (tableNameValue != null && tableNameValue.Type != JTokenType.Null) { string tableNameInstance = ((string)tableNameValue); dataSliceRunInstance.TableName = tableNameInstance; } JToken pipelineNameValue = valueValue["pipelineName"]; if (pipelineNameValue != null && pipelineNameValue.Type != JTokenType.Null) { string pipelineNameInstance = ((string)pipelineNameValue); dataSliceRunInstance.PipelineName = pipelineNameInstance; } JToken activityNameValue = valueValue["activityName"]; if (activityNameValue != null && activityNameValue.Type != JTokenType.Null) { string activityNameInstance = ((string)activityNameValue); dataSliceRunInstance.ActivityName = activityNameInstance; } JToken computeClusterNameValue = valueValue["computeClusterName"]; if (computeClusterNameValue != null && computeClusterNameValue.Type != JTokenType.Null) { string computeClusterNameInstance = ((string)computeClusterNameValue); dataSliceRunInstance.ComputeClusterName = computeClusterNameInstance; } JToken statusValue = valueValue["status"]; if (statusValue != null && statusValue.Type != JTokenType.Null) { string statusInstance = ((string)statusValue); dataSliceRunInstance.Status = statusInstance; } JToken processingStartTimeValue = valueValue["processingStartTime"]; if (processingStartTimeValue != null && processingStartTimeValue.Type != JTokenType.Null) { DateTime processingStartTimeInstance = ((DateTime)processingStartTimeValue); dataSliceRunInstance.ProcessingStartTime = processingStartTimeInstance; } JToken processingEndTimeValue = valueValue["processingEndTime"]; if (processingEndTimeValue != null && processingEndTimeValue.Type != JTokenType.Null) { DateTime processingEndTimeInstance = ((DateTime)processingEndTimeValue); dataSliceRunInstance.ProcessingEndTime = processingEndTimeInstance; } JToken batchTimeValue = valueValue["batchTime"]; if (batchTimeValue != null && batchTimeValue.Type != JTokenType.Null) { DateTime batchTimeInstance = ((DateTime)batchTimeValue); dataSliceRunInstance.BatchTime = batchTimeInstance; } JToken percentCompleteValue = valueValue["percentComplete"]; if (percentCompleteValue != null && percentCompleteValue.Type != JTokenType.Null) { int percentCompleteInstance = ((int)percentCompleteValue); dataSliceRunInstance.PercentComplete = percentCompleteInstance; } JToken dataSliceStartValue = valueValue["dataSliceStart"]; if (dataSliceStartValue != null && dataSliceStartValue.Type != JTokenType.Null) { DateTime dataSliceStartInstance = ((DateTime)dataSliceStartValue); dataSliceRunInstance.DataSliceStart = dataSliceStartInstance; } JToken dataSliceEndValue = valueValue["dataSliceEnd"]; if (dataSliceEndValue != null && dataSliceEndValue.Type != JTokenType.Null) { DateTime dataSliceEndInstance = ((DateTime)dataSliceEndValue); dataSliceRunInstance.DataSliceEnd = dataSliceEndInstance; } JToken timestampValue = valueValue["timestamp"]; if (timestampValue != null && timestampValue.Type != JTokenType.Null) { DateTime timestampInstance = ((DateTime)timestampValue); dataSliceRunInstance.Timestamp = timestampInstance; } JToken retryAttemptValue = valueValue["retryAttempt"]; if (retryAttemptValue != null && retryAttemptValue.Type != JTokenType.Null) { int retryAttemptInstance = ((int)retryAttemptValue); dataSliceRunInstance.RetryAttempt = retryAttemptInstance; } JToken hasLogsValue = valueValue["hasLogs"]; if (hasLogsValue != null && hasLogsValue.Type != JTokenType.Null) { bool hasLogsInstance = ((bool)hasLogsValue); dataSliceRunInstance.HasLogs = hasLogsInstance; } JToken typeValue = valueValue["type"]; if (typeValue != null && typeValue.Type != JTokenType.Null) { string typeInstance = ((string)typeValue); dataSliceRunInstance.Type = typeInstance; } 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); dataSliceRunInstance.Properties.Add(propertiesKey, propertiesValue); } } JToken errorMessageValue = valueValue["errorMessage"]; if (errorMessageValue != null && errorMessageValue.Type != JTokenType.Null) { string errorMessageInstance = ((string)errorMessageValue); dataSliceRunInstance.ErrorMessage = errorMessageInstance; } } } JToken odatanextLinkValue = responseDoc["@odata.nextLink"]; if (odatanextLinkValue != null && odatanextLinkValue.Type != JTokenType.Null) { string odatanextLinkInstance = ((string)odatanextLinkValue); result.NextLink = odatanextLinkInstance; } } } result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { TracingAdapter.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
public PSDataSliceRun() { dataSliceRun = new DataSliceRun(); }