lib/td/command/common.rb in td-0.16.7 vs lib/td/command/common.rb in td-0.16.8
- old
+ new
@@ -45,11 +45,11 @@
apikey = Config.apikey
raise ConfigError, "Account is not configured." unless apikey
# optional, if not provided a default is used from the ruby client library
begin
- if Config.endpoint
+ if !opts[:endpoint] && Config.endpoint
opts[:endpoint] = Config.endpoint
end
rescue ConfigNotFoundError => e
# rescue the ConfigNotFoundError exception which originates when
# the config file is not found because the check on the apikey
@@ -63,9 +63,20 @@
pairs = h.split("\n")
opts[:headers] = Hash[pairs.map {|pair| pair.split('=', 2) }]
end
Client.new(apikey, opts)
+ end
+
+ DEFAULT_IMPORT_ENDPOINT = "https://" + TreasureData::API::DEFAULT_IMPORT_ENDPOINT
+
+ def get_import_client
+ import_endpoint = begin
+ Config.import_endpoint || DEFAULT_IMPORT_ENDPOINT
+ rescue TreasureData::ConfigNotFoundError
+ DEFAULT_IMPORT_ENDPOINT
+ end
+ get_client(endpoint: import_endpoint)
end
def get_ssl_client(opts={})
opts[:ssl] = true
get_client(opts)