Class: Omaship::ApiClient
- Inherits:
-
Object
- Object
- Omaship::ApiClient
- Defined in:
- lib/omaship/api_client.rb
Defined Under Namespace
Classes: Error, NotFoundError, PermissionDeniedError, UnauthorizedError, UpgradeRequiredError
Instance Method Summary collapse
- #authenticate ⇒ Object
- #create_landingpage(name:, color_scheme: "mono-dark", purpose_profile: {}) ⇒ Object
- #create_ship(name:, harbor_id:, root_domain:, bring_own_domain:, identifier_suffix:, visibility: "private", starter_kind: "app") ⇒ Object
-
#initialize(host:, token:) ⇒ ApiClient
constructor
A new instance of ApiClient.
- #list_ships ⇒ Object
- #ship(ship_id:) ⇒ Object
- #voyage(voyage_id:) ⇒ Object
Constructor Details
#initialize(host:, token:) ⇒ ApiClient
Returns a new instance of ApiClient.
13 14 15 16 |
# File 'lib/omaship/api_client.rb', line 13 def initialize(host:, token:) @host = host.to_s @token = token.to_s end |
Instance Method Details
#authenticate ⇒ Object
18 19 20 |
# File 'lib/omaship/api_client.rb', line 18 def authenticate get_json("/api/v1/cli/auth") end |
#create_landingpage(name:, color_scheme: "mono-dark", purpose_profile: {}) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/omaship/api_client.rb', line 48 def create_landingpage(name:, color_scheme: "mono-dark", purpose_profile: {}) post_json("/api/v1/cli/ships", { ship: { name: name, landingpage: true, color_scheme: color_scheme }, purpose_profile: purpose_profile }) end |
#create_ship(name:, harbor_id:, root_domain:, bring_own_domain:, identifier_suffix:, visibility: "private", starter_kind: "app") ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/omaship/api_client.rb', line 26 def create_ship( name:, harbor_id:, root_domain:, bring_own_domain:, identifier_suffix:, visibility: "private", starter_kind: "app" ) post_json("/api/v1/cli/ships", { ship: { name: name, harbor_id: harbor_id, root_domain: root_domain, visibility: visibility, starter_kind: starter_kind, bring_own_domain: bring_own_domain, identifier_suffix: identifier_suffix } }) end |
#list_ships ⇒ Object
22 23 24 |
# File 'lib/omaship/api_client.rb', line 22 def list_ships get_json("/api/v1/cli/ships").fetch("ships") end |
#ship(ship_id:) ⇒ Object
55 56 57 |
# File 'lib/omaship/api_client.rb', line 55 def ship(ship_id:) get_json("/api/v1/cli/ships/#{ship_id}") end |
#voyage(voyage_id:) ⇒ Object
59 60 61 |
# File 'lib/omaship/api_client.rb', line 59 def voyage(voyage_id:) get_json("/api/v1/cli/voyages/#{voyage_id}") end |