public ListIsoPermissions(string apiKey, string secret, string baseUri, IComputeCommandAuthenticator authenticator, IComputeRequestBuilder builder)
 {
     _apiKey = apiKey;
     _secret = secret;
     _baseUri = baseUri;
     _authenticator = authenticator;
     _builder = builder;
 }
Exemplo n.º 2
0
 public ListAsyncJobs(string apiKey, string secret, string baseUri, IComputeCommandAuthenticator authenticator, IComputeRequestBuilder builder)
 {
     _apiKey        = apiKey;
     _secret        = secret;
     _baseUri       = baseUri;
     _authenticator = authenticator;
     _builder       = builder;
 }
Exemplo n.º 3
0
 public ComputeClient(string apiKey, string base64Secret, string computeServiceUriRoot)
 {
     _builder = new ComputeCommandBuilder();
     _authenticator = new ComputeCommandAuthenticator();
     _apiKey = apiKey;
     _secret = base64Secret;
     _baseUri = computeServiceUriRoot;
 }
Exemplo n.º 4
0
 public ComputeClient(string apiKey, string base64Secret, string computeServiceUriRoot)
 {
     _builder       = new ComputeCommandBuilder();
     _authenticator = new ComputeCommandAuthenticator();
     _apiKey        = apiKey;
     _secret        = base64Secret;
     _baseUri       = computeServiceUriRoot;
 }
Exemplo n.º 5
0
        public WebRequest GenerateRequest(IComputeCommandRequest request, IComputeCommandAuthenticator authenticator, string baseUri, string apiKey, string secret)
        {
            Validator.ValidateObject(request, new ValidationContext(request, null, null), true);

            var requestType = request.GetType();

            var queryStringParameters = requestType.GetProperties(PropertyFilters)
                                        .Where(p => (p.GetValue(request, null) != null) &&
                                               (!string.IsNullOrWhiteSpace(p.GetValue(request, null).ToString())) &&
                                               (!p.Name.Equals("command", StringComparison.InvariantCultureIgnoreCase)))
                                        .Select(p =>
                                                new KeyValuePair <string, string>((char.ToLower(p.Name[0]) + p.Name.Remove(0, 1)), p.GetValue(request, null).ToString()))
                                        .ToList()
                                        .OrderBy(pair => pair.Key)
                                        .Aggregate(string.Empty, (query, arg) => string.Format("{0}&{1}={2}", query, arg.Key, arg.Value));

            var queryString = string.Format("apiKey={0}&command={1}{2}", apiKey, request.Command, queryStringParameters);
            var signature   = authenticator.AuthenticateRequest(queryString, secret);

            queryString = string.Format("?{0}&signature={1}", queryString, signature);

            return(WebRequest.Create(new Uri(new Uri(baseUri), queryString)));
        }