Class: Concourse::Client
- Inherits:
-
Object
- Object
- Concourse::Client
- Defined in:
- lib/concourse/client.rb
Constant Summary collapse
- API_BASE_PATH =
'/api/v1/teams/main/'
Instance Attribute Summary collapse
-
#base_uri ⇒ Object
readonly
Returns the value of attribute base_uri.
Instance Method Summary collapse
- #get(path) ⇒ Object
-
#initialize(concourse_uri, username: nil, password: nil, options: {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(concourse_uri, username: nil, password: nil, options: {}) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 |
# File 'lib/concourse/client.rb', line 13 def initialize(concourse_uri, username: nil, password: nil, options: {}) @concourse_uri = URI(concourse_uri) @username = username @password = password @options = @base_uri = @concourse_uri.merge(API_BASE_PATH) end |
Instance Attribute Details
#base_uri ⇒ Object (readonly)
Returns the value of attribute base_uri.
11 12 13 |
# File 'lib/concourse/client.rb', line 11 def base_uri @base_uri end |
Instance Method Details
#get(path) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/concourse/client.rb', line 21 def get(path) path = path[1..-1] if path.start_with?('/') begin = if authenticated? .merge('Cookie' => "ATC-Authorization=\"#{bearer_token}\"") else end open(base_uri.merge(path), ).read rescue OpenURI::HTTPError => e if e. == '401 Unauthorized' && @bearer_token @bearer_token = nil retry else raise end end end |