// Method = "POST", UriTemplate = "{subscriptionId}/cloudservices/{cloudServiceName}/resources/hdinsight/~/containers/{containerName}/services/http"
        public async Task <IHttpResponseMessageAbstraction> EnableDisableUserChangeRequest(string dnsName, string location, UserChangeRequestUserType requestType, string payload)
        {
            var manager = ServiceLocator.Instance.Locate <IUserChangeRequestManager>();
            var handler = manager.LocateUserChangeRequestHandler(this.credentials.GetType(), requestType);

            // Creates an HTTP client
            if (handler.IsNull())
            {
                throw new NotSupportedException("Request to submit a UserChangeRequest that is not supported by this client");
            }
            using (IHttpClientAbstraction client = ServiceLocator.Instance.Locate <IHDInsightHttpClientAbstractionFactory>().Create(this.credentials, this.context, this.ignoreSslErrors))
            {
                var hadoopContext = new HDInsightSubscriptionAbstractionContext(this.credentials, this.context);
                client.RequestUri = handler.Item1(hadoopContext, dnsName, location);
                client.Method     = HttpMethod.Post;
                client.RequestHeaders.Add(HDInsightRestConstants.XMsVersion);
                client.RequestHeaders.Add(HDInsightRestConstants.SchemaVersion2);
                client.RequestHeaders.Add(HDInsightRestConstants.Accept);
                client.Content = new StringContent(payload);

                IHttpResponseMessageAbstraction httpResponse = await client.SendAsync();

                if (httpResponse.StatusCode != HttpStatusCode.Accepted)
                {
                    throw new HttpLayerException(httpResponse.StatusCode, httpResponse.Content)
                          {
                              HelpLink = HelpLinkForException
                          };
                }
                return(httpResponse);
            }
        }
        // Method = "GET", UriTemplate = "{subscriptionId}/cloudservices/{cloudServiceName}/resources/hdinsight/~/containers/{containerName}/jobs/{jobId}"
        public async Task <IHttpResponseMessageAbstraction> GetJobDetail(string containerName, string location, string jobId)
        {
            // Creates an HTTP client
            var resolver = ServiceLocator.Instance.Locate <ICloudServiceNameResolver>();

            using (
                IHttpClientAbstraction client = ServiceLocator.Instance.Locate <IHDInsightHttpClientAbstractionFactory>().Create(this.credentials, this.context, this.ignoreSslErrors))
            {
                string regionCloudServicename = resolver.GetCloudServiceName(
                    this.credentials.SubscriptionId, this.credentials.DeploymentNamespace, location);

                string relativeUri = string.Format(
                    "{0}/cloudservices/{1}/resources/{2}/~/containers/{3}/jobs/{4}",
                    this.credentials.SubscriptionId,
                    regionCloudServicename,
                    this.credentials.DeploymentNamespace,
                    containerName,
                    jobId);

                client.RequestUri = new Uri(this.credentials.Endpoint, new Uri(relativeUri, UriKind.Relative));
                client.Method     = HttpMethod.Get;
                client.RequestHeaders.Add(HDInsightRestConstants.XMsVersion);
                client.RequestHeaders.Add(HDInsightRestConstants.SchemaVersion2);
                client.RequestHeaders.Add(HDInsightRestConstants.Accept);

                IHttpResponseMessageAbstraction httpResponse = await client.SendAsync();

                if (httpResponse.StatusCode != HttpStatusCode.Accepted)
                {
                    throw new HttpLayerException(httpResponse.StatusCode, httpResponse.Content);
                }
                return(httpResponse);
            }
        }
 internal void AddHttpResponse(IHttpResponseMessageAbstraction responseMessage, int count = 1)
 {
     for (int i = 0; i < count; i++)
     {
         var response = new Response() { ResponseMessage = responseMessage };
         this.responses.Add(response);
     }
 }
示例#4
0
 internal void AddHttpResponse(IHttpResponseMessageAbstraction responseMessage, int count = 1)
 {
     for (int i = 0; i < count; i++)
     {
         var response = new Response()
         {
             ResponseMessage = responseMessage
         };
         this.responses.Add(response);
     }
 }