Class: FaaStRuby::Workspace
- Inherits:
-
BaseObject
- Object
- BaseObject
- FaaStRuby::Workspace
- Defined in:
- lib/faastruby/workspace.rb
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Instance methods.
-
#credentials ⇒ Object
Instance methods.
-
#email ⇒ Object
Instance methods.
-
#errors ⇒ Object
Instance methods.
-
#functions ⇒ Object
Instance methods.
-
#name ⇒ Object
Instance methods.
-
#object ⇒ Object
Instance methods.
-
#provider ⇒ Object
Instance methods.
-
#runners_current ⇒ Object
Instance methods.
-
#runners_max ⇒ Object
Instance methods.
-
#static_metadata ⇒ Object
Instance methods.
-
#status_code ⇒ Object
Instance methods.
-
#updated_at ⇒ Object
Instance methods.
Class Method Summary collapse
-
.create(name:, email: nil, provider: nil) ⇒ Object
Class methods.
Instance Method Summary collapse
- #delete_file(relative_path:) ⇒ Object
- #deploy(package_file_name, root_to: false, catch_all: false, context: false) ⇒ Object
- #destroy ⇒ Object
- #fetch ⇒ Object
- #parse_attributes(attributes) ⇒ Object
- #refresh_credentials ⇒ Object
- #update_runners(value) ⇒ Object
- #upload_file(package_file_name, relative_path:) ⇒ Object
Methods inherited from BaseObject
#assign_attributes, #attributes=, #call_api, #initialize, #mass_assign
Constructor Details
This class inherits a constructor from FaaStRuby::BaseObject
Instance Attribute Details
#created_at ⇒ Object
Instance methods
30 31 32 |
# File 'lib/faastruby/workspace.rb', line 30 def created_at @created_at end |
#credentials ⇒ Object
Instance methods
30 31 32 |
# File 'lib/faastruby/workspace.rb', line 30 def credentials @credentials end |
#email ⇒ Object
Instance methods
30 31 32 |
# File 'lib/faastruby/workspace.rb', line 30 def email @email end |
#errors ⇒ Object
Instance methods
30 31 32 |
# File 'lib/faastruby/workspace.rb', line 30 def errors @errors end |
#functions ⇒ Object
Instance methods
30 31 32 |
# File 'lib/faastruby/workspace.rb', line 30 def functions @functions end |
#name ⇒ Object
Instance methods
30 31 32 |
# File 'lib/faastruby/workspace.rb', line 30 def name @name end |
#object ⇒ Object
Instance methods
30 31 32 |
# File 'lib/faastruby/workspace.rb', line 30 def object @object end |
#provider ⇒ Object
Instance methods
30 31 32 |
# File 'lib/faastruby/workspace.rb', line 30 def provider @provider end |
#runners_current ⇒ Object
Instance methods
30 31 32 |
# File 'lib/faastruby/workspace.rb', line 30 def runners_current @runners_current end |
#runners_max ⇒ Object
Instance methods
30 31 32 |
# File 'lib/faastruby/workspace.rb', line 30 def runners_max @runners_max end |
#static_metadata ⇒ Object
Instance methods
30 31 32 |
# File 'lib/faastruby/workspace.rb', line 30 def @static_metadata end |
#status_code ⇒ Object
Instance methods
30 31 32 |
# File 'lib/faastruby/workspace.rb', line 30 def status_code @status_code end |
#updated_at ⇒ Object
Instance methods
30 31 32 |
# File 'lib/faastruby/workspace.rb', line 30 def updated_at @updated_at end |
Class Method Details
.create(name:, email: nil, provider: nil) ⇒ Object
Class methods
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/faastruby/workspace.rb', line 7 def self.create(name:, email: nil, provider: nil) api = API.new workspace = Workspace.new(name: name, email: email, errors: [], provider: provider) response = api.create_workspace(workspace_name: name, email: email, provider: provider) workspace.status_code = response.code if response.errors.any? workspace.errors += response.errors return workspace end case response.code when 422 workspace.errors += ['(422) Unprocessable Entity', response.body] when 200, 201 workspace.credentials = response.body['credentials'] workspace.runners_max = response.body['runners_max'].to_i if response.body['runners_max'] else workspace.errors << "(#{response.code}) Error" end return workspace end |
Instance Method Details
#delete_file(relative_path:) ⇒ Object
69 70 71 72 73 |
# File 'lib/faastruby/workspace.rb', line 69 def delete_file(relative_path:) call_api { @api.delete_file(workspace_name: @name, relative_path: relative_path) } self end |
#deploy(package_file_name, root_to: false, catch_all: false, context: false) ⇒ Object
36 37 38 39 40 |
# File 'lib/faastruby/workspace.rb', line 36 def deploy(package_file_name, root_to: false, catch_all: false, context: false) call_api { @api.deploy(workspace_name: @name, package: package_file_name, root_to: root_to, catch_all: catch_all, context: context) } self end |
#destroy ⇒ Object
32 33 34 |
# File 'lib/faastruby/workspace.rb', line 32 def destroy call_api { @api.destroy_workspace(@name) } end |
#fetch ⇒ Object
56 57 58 59 60 61 |
# File 'lib/faastruby/workspace.rb', line 56 def fetch response = call_api { @api.get_workspace_info(@name) } parse_attributes(response.body) unless response.errors.any? self end |
#parse_attributes(attributes) ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/faastruby/workspace.rb', line 82 def parse_attributes(attributes) @functions = attributes['functions'] @email = attributes['email'] @object = attributes['object'] @updated_at = attributes['updated_at'] @created_at = attributes['created_at'] @provider = attributes['provider'] @runners_max = attributes['runners_max'].to_i if attributes['runners_max'] rescue nil @runners_current = attributes['runners_current'].to_i rescue nil end |
#refresh_credentials ⇒ Object
42 43 44 45 46 47 |
# File 'lib/faastruby/workspace.rb', line 42 def refresh_credentials response = call_api { @api.refresh_credentials(@name) } @credentials = response.body[@name] unless response.body.nil? self end |
#update_runners(value) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/faastruby/workspace.rb', line 49 def update_runners(value) response = call_api { @api.update_runners(workspace_name: @name, runners_max: value) } @runners_max = response.body['runners_max'].to_i if response.body['runners_max'] rescue nil self end |
#upload_file(package_file_name, relative_path:) ⇒ Object
63 64 65 66 67 |
# File 'lib/faastruby/workspace.rb', line 63 def upload_file(package_file_name, relative_path:) call_api { @api.upload_file(workspace_name: @name, package: package_file_name, relative_path: relative_path) } self end |