Exemple #1
0
 /// <summary>
 /// Gets the first page of data slice instances with the link to the
 /// next page.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.DataFactories.Core.IDataSliceOperations.
 /// </param>
 /// <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='parameters'>
 /// Required. Parameters specifying how to list data slices of the table.
 /// </param>
 /// <returns>
 /// The List data slices operation response.
 /// </returns>
 public static Task <DataSliceListResponse> ListAsync(
     this IDataSliceOperations operations,
     string resourceGroupName,
     string dataFactoryName,
     string tableName,
     DataSliceListParameters parameters)
 {
     return(operations.ListAsync(
                resourceGroupName,
                dataFactoryName,
                tableName,
                parameters,
                CancellationToken.None));
 }
 public async Task <DataSliceListResponse> ListAsync(
     string resourceGroupName,
     string dataFactoryName,
     string tableName,
     DataSliceListParameters parameters,
     CancellationToken cancellationToken)
 {
     return(await this.Client.InternalClient.DataSlices.ListAsync(
                resourceGroupName,
                dataFactoryName,
                tableName,
                parameters,
                cancellationToken));
 }
Exemple #3
0
 /// <summary>
 /// Gets the first page of data slice instances with the link to the
 /// next page.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.DataFactories.Core.IDataSliceOperations.
 /// </param>
 /// <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='parameters'>
 /// Required. Parameters specifying how to list data slices of the table.
 /// </param>
 /// <returns>
 /// The List data slices operation response.
 /// </returns>
 public static DataSliceListResponse List(
     this IDataSliceOperations operations,
     string resourceGroupName,
     string dataFactoryName,
     string tableName,
     DataSliceListParameters parameters)
 {
     return(Task.Factory.StartNew(
                s => ((IDataSliceOperations)s).ListAsync(
                    resourceGroupName,
                    dataFactoryName,
                    tableName,
                    parameters),
                operations,
                CancellationToken.None,
                TaskCreationOptions.None,
                TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
        /// <summary>
        /// Gets the first page of data slice 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='parameters'>
        /// Required. Parameters specifying how to list data slices of the
        /// table.
        /// </param>
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        /// <returns>
        /// The List data slices operation response.
        /// </returns>
        public async Task <DataSliceListResponse> ListAsync(string resourceGroupName, string dataFactoryName, string tableName, DataSliceListParameters parameters, 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 (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            if (parameters.DataSliceRangeEndTime == null)
            {
                throw new ArgumentNullException("parameters.DataSliceRangeEndTime");
            }
            if (parameters.DataSliceRangeStartTime == null)
            {
                throw new ArgumentNullException("parameters.DataSliceRangeStartTime");
            }

            // 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("parameters", parameters);
                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 + "/datasets/";
            url = url + Uri.EscapeDataString(tableName);
            url = url + "/slices";
            List <string> queryParameters = new List <string>();

            queryParameters.Add("start=" + Uri.EscapeDataString(parameters.DataSliceRangeStartTime));
            queryParameters.Add("end=" + Uri.EscapeDataString(parameters.DataSliceRangeEndTime));
            queryParameters.Add("api-version=2015-09-01");
            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
                    DataSliceListResponse result = null;
                    // Deserialize Response
                    if (statusCode == HttpStatusCode.OK)
                    {
                        cancellationToken.ThrowIfCancellationRequested();
                        string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

                        result = new DataSliceListResponse();
                        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))
                                {
                                    DataSlice dataSliceInstance = new DataSlice();
                                    result.DataSlices.Add(dataSliceInstance);

                                    JToken startValue = valueValue["start"];
                                    if (startValue != null && startValue.Type != JTokenType.Null)
                                    {
                                        DateTime startInstance = ((DateTime)startValue);
                                        dataSliceInstance.Start = startInstance;
                                    }

                                    JToken endValue = valueValue["end"];
                                    if (endValue != null && endValue.Type != JTokenType.Null)
                                    {
                                        DateTime endInstance = ((DateTime)endValue);
                                        dataSliceInstance.End = endInstance;
                                    }

                                    JToken stateValue = valueValue["state"];
                                    if (stateValue != null && stateValue.Type != JTokenType.Null)
                                    {
                                        string stateInstance = ((string)stateValue);
                                        dataSliceInstance.State = stateInstance;
                                    }

                                    JToken substateValue = valueValue["substate"];
                                    if (substateValue != null && substateValue.Type != JTokenType.Null)
                                    {
                                        string substateInstance = ((string)substateValue);
                                        dataSliceInstance.Substate = substateInstance;
                                    }

                                    JToken latencyStatusValue = valueValue["latencyStatus"];
                                    if (latencyStatusValue != null && latencyStatusValue.Type != JTokenType.Null)
                                    {
                                        string latencyStatusInstance = ((string)latencyStatusValue);
                                        dataSliceInstance.LatencyStatus = latencyStatusInstance;
                                    }

                                    JToken retryCountValue = valueValue["retryCount"];
                                    if (retryCountValue != null && retryCountValue.Type != JTokenType.Null)
                                    {
                                        int retryCountInstance = ((int)retryCountValue);
                                        dataSliceInstance.RetryCount = retryCountInstance;
                                    }

                                    JToken longRetryCountValue = valueValue["longRetryCount"];
                                    if (longRetryCountValue != null && longRetryCountValue.Type != JTokenType.Null)
                                    {
                                        int longRetryCountInstance = ((int)longRetryCountValue);
                                        dataSliceInstance.LongRetryCount = longRetryCountInstance;
                                    }
                                }
                            }

                            JToken nextLinkValue = responseDoc["nextLink"];
                            if (nextLinkValue != null && nextLinkValue.Type != JTokenType.Null)
                            {
                                string nextLinkInstance = ((string)nextLinkValue);
                                result.NextLink = nextLinkInstance;
                            }
                        }
                    }
                    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();
                }
            }
        }