Class: ThreeScaleToolbox::Entities::ProxyConfig
- Inherits:
-
Object
- Object
- ThreeScaleToolbox::Entities::ProxyConfig
- Defined in:
- lib/3scale_toolbox/entities/proxy_config.rb
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#remote ⇒ Object
readonly
Returns the value of attribute remote.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #attrs ⇒ Object
-
#initialize(environment:, service:, version:, attrs: nil) ⇒ ProxyConfig
constructor
A new instance of ProxyConfig.
- #promote(to:) ⇒ Object
Constructor Details
#initialize(environment:, service:, version:, attrs: nil) ⇒ ProxyConfig
Returns a new instance of ProxyConfig.
24 25 26 27 28 29 30 |
# File 'lib/3scale_toolbox/entities/proxy_config.rb', line 24 def initialize(environment:, service:, version:, attrs: nil) @remote = service.remote @service = service @environment = environment @version = version @attrs = attrs end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
22 23 24 |
# File 'lib/3scale_toolbox/entities/proxy_config.rb', line 22 def environment @environment end |
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
22 23 24 |
# File 'lib/3scale_toolbox/entities/proxy_config.rb', line 22 def remote @remote end |
#service ⇒ Object (readonly)
Returns the value of attribute service.
22 23 24 |
# File 'lib/3scale_toolbox/entities/proxy_config.rb', line 22 def service @service end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
22 23 24 |
# File 'lib/3scale_toolbox/entities/proxy_config.rb', line 22 def version @version end |
Class Method Details
.find(service:, environment:, version:) ⇒ Object
5 6 7 8 9 |
# File 'lib/3scale_toolbox/entities/proxy_config.rb', line 5 def find(service:, environment:, version:) new(service: service, environment: environment, version: version).tap(&:attrs) rescue ThreeScale::API::HttpClient::NotFoundError nil end |
.find_latest(service:, environment:) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/3scale_toolbox/entities/proxy_config.rb', line 11 def find_latest(service:, environment:) proxy_cfg = service.remote.proxy_config_latest(service.id, environment) if (errors = proxy_cfg['errors']) raise ThreeScaleToolbox::ThreeScaleApiError.new('ProxyConfig find_latest not read', errors) end new(service: service, environment: environment, version: proxy_cfg["version"], attrs: proxy_cfg) rescue ThreeScale::API::HttpClient::NotFoundError nil end |
Instance Method Details
#attrs ⇒ Object
32 33 34 |
# File 'lib/3scale_toolbox/entities/proxy_config.rb', line 32 def attrs @attrs ||= proxy_config_attrs end |
#promote(to:) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/3scale_toolbox/entities/proxy_config.rb', line 36 def promote(to:) res = remote.promote_proxy_config(service.id, environment, version, to) if (errors = res['errors']) raise ThreeScaleToolbox::ThreeScaleApiError.new('ProxyConfig not promoted', errors) end res end |