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=, #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 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
79 80 81 82 83 84 |
# File 'lib/faastruby/workspace.rb', line 79 def delete_file(relative_path:) response = @api.delele_file(workspace_name: @name, relative_path: relative_path) @status_code = response.code @errors += response.errors if response.errors.any? self end |
#deploy(package_file_name, root_to: false, catch_all: false, context: false) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/faastruby/workspace.rb', line 38 def deploy(package_file_name, root_to: false, catch_all: false, context: false) response = @api.deploy(workspace_name: @name, package: package_file_name, root_to: root_to, catch_all: catch_all, context: context) @status_code = response.code @errors += response.errors if response.errors.any? self end |
#destroy ⇒ Object
32 33 34 35 36 |
# File 'lib/faastruby/workspace.rb', line 32 def destroy response = @api.destroy_workspace(@name) @status_code = response.code @errors += response.errors if response.errors.any? end |
#fetch ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/faastruby/workspace.rb', line 61 def fetch response = @api.get_workspace_info(@name) @status_code = response.code if response.errors.any? @errors += response.errors else parse_attributes(response.body) end self end |
#parse_attributes(attributes) ⇒ Object
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/faastruby/workspace.rb', line 94 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
45 46 47 48 49 50 51 |
# File 'lib/faastruby/workspace.rb', line 45 def refresh_credentials response = @api.refresh_credentials(@name) @status_code = response.code @credentials = response.body[@name] unless response.body.nil? @errors += response.errors if response.errors.any? self end |
#update_runners(value) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/faastruby/workspace.rb', line 53 def update_runners(value) response = @api.update_runners(workspace_name: @name, runners_max: value) @runners_max = response.body['runners_max'].to_i if response.body['runners_max'] rescue nil @status_code = response.code @errors += response.errors if response.errors.any? self end |
#upload_file(package_file_name, relative_path:) ⇒ Object
72 73 74 75 76 77 |
# File 'lib/faastruby/workspace.rb', line 72 def upload_file(package_file_name, relative_path:) response = @api.upload_file(workspace_name: @name, package: package_file_name, relative_path: relative_path) @status_code = response.code @errors += response.errors if response.errors.any? self end |