Exemplo n.º 1
0
        /// <summary>
        /// Creates the Rest Client associated with the interface.
        /// </summary>
        /// <typeparam name="T">The REST interface.</typeparam>
        /// <param name="baseUri">The base URI.</param>
        /// <param name="configuration">The configuration.</param>
        /// <returns>An instance of the rest client.</returns>
        public static T CreateClient <T>(Uri baseUri, HttpRestClientConfiguration configuration)
        {
            Type runtimeType = CreateConreteProxyImplementation <T>();

            //Call the constructor RestProxy(Uri, X509Certificate2, IWebProxy, Timespan)
            return((T)Activator.CreateInstance(runtimeType, new object[] { baseUri, configuration }));
        }
Exemplo n.º 2
0
        public HttpRestClient(Uri baseUri, HttpRestClientConfiguration configuration)
        {
            Contract.Requires <ArgumentNullException>(baseUri != null);
            Contract.Requires <ArgumentNullException>(baseUri.IsAbsoluteUri);
            Contract.Requires <ArgumentException>(baseUri.Scheme.Equals(Uri.UriSchemeHttp) || baseUri.Scheme.Equals(Uri.UriSchemeHttps));

            this._baseServiceUri = baseUri;
            this._methodToRequestParametersMap = BuildInterfaceMethodToParametersDictionary();
            this._configuration = configuration;
        }
Exemplo n.º 3
0
 public RdfeClustersResourceRestClient(System.Uri baseUri, Microsoft.WindowsAzure.Management.HDInsight.Framework.Rest.HttpRestClientConfiguration configuration) :
     base(baseUri, configuration)
 {
 }
        public IRdfeIaasClustersRestClient Create(
            HttpMessageHandler defaultHttpClientHandler,
            IHDInsightSubscriptionCredentials credentials,
            IAbstractionContext context,
            bool ignoreSslErrors)
        {
            HttpRestClientRetryPolicy retryPolicy = null;
            var tokenCreds = credentials as IHDInsightAccessTokenCredential;

            var customHandlers = new List<DelegatingHandler>();

            if (context != null && context.Logger != null)
            {
                customHandlers.Add(new HttpLoggingHandler(context.Logger));
                retryPolicy = new HttpRestClientRetryPolicy(context.RetryPolicy);
            }
            else
            {
                retryPolicy = new HttpRestClientRetryPolicy(RetryPolicyFactory.CreateExponentialRetryPolicy());
                customHandlers.Add(new HttpLoggingHandler(new Logger()));
            }

            if (tokenCreds != null)
            {
                customHandlers.Add(new BearerTokenMessageHandler(tokenCreds.AccessToken));
            }

            var httpConfiguration = new HttpRestClientConfiguration(defaultHttpClientHandler, customHandlers, retryPolicy);
            var client = new RdfeIaasClustersRestClient(credentials.Endpoint, httpConfiguration);
            return client;
        }