Class: Skylight::Api Private
- Includes:
- Util::Logging
- Defined in:
- lib/skylight/api.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: ConfigValidationResults, Conflict, CreateFailed, Error, Unauthorized
Instance Attribute Summary collapse
- #config ⇒ Object readonly private
Instance Method Summary collapse
- #create_app(name, token = nil) ⇒ Object private
- #fetch_mergeable_apps(token) ⇒ Object private
-
#initialize(config) ⇒ Api
constructor
private
A new instance of Api.
- #merge_apps!(token, app_guid:, component_guid:, environment:) ⇒ Object private
- #validate_config ⇒ Object private
Methods included from Util::Logging
#config_for_logging, #debug, #error, #fmt, #info, #log, #log_context, #raise_on_error?, #t, #trace, #trace?, #warn
Constructor Details
#initialize(config) ⇒ Api
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Api.
109 110 111 |
# File 'lib/skylight/api.rb', line 109 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 |
# File 'lib/skylight/api.rb', line 9 def config @config end |
Instance Method Details
#create_app(name, token = nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/skylight/api.rb', line 113 def create_app(name, token = nil) params = { app: { name: name } } params[:token] = token if token res = http_request(:app_create, :post, params) raise CreateFailed, res unless res.success? res end |
#fetch_mergeable_apps(token) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
124 125 126 127 128 129 |
# File 'lib/skylight/api.rb', line 124 def fetch_mergeable_apps(token) headers = { "x-skylight-merge-token" => token } http_request(:merges, :get, headers).tap do |res| raise error_for_status(res.status), "HTTP #{res.status}: #{res.body}" unless res.success? end end |
#merge_apps!(token, app_guid:, component_guid:, environment:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
131 132 133 134 135 136 137 |
# File 'lib/skylight/api.rb', line 131 def merge_apps!(token, app_guid:, component_guid:, environment:) headers = { "x-skylight-merge-token" => token } body = { environment: environment, app_guid: app_guid, component_guid: component_guid } http_request(:merges, :post, body, headers).tap do |res| raise error_for_status(res.status), "HTTP #{res.status}: #{res.body}" unless res.success? end end |
#validate_config ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
139 140 141 142 |
# File 'lib/skylight/api.rb', line 139 def validate_config res = http_request(:validation, :post, config) ConfigValidationResults.new(config, res) end |