Class: Skylight::Api Private

Inherits:
Object show all
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

Instance Method Summary collapse

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

#configObject (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.

Raises:



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_configObject

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