Class: Lamma::Alias
- Inherits:
-
Object
- Object
- Lamma::Alias
- Defined in:
- lib/lamma/alias.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
writeonly
Sets the attribute description.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #create ⇒ Object
- #create_or_update ⇒ Object
-
#initialize(function, name, version = nil, description = nil) ⇒ Alias
constructor
A new instance of Alias.
- #name ⇒ Object
- #remote_exist? ⇒ Boolean
- #remote_version ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(function, name, version = nil, description = nil) ⇒ Alias
Returns a new instance of Alias.
5 6 7 8 9 10 |
# File 'lib/lamma/alias.rb', line 5 def initialize(function, name, version=nil, description=nil) @function = function @name = name @version = version @description = description end |
Instance Attribute Details
#description=(value) ⇒ Object
Sets the attribute description
3 4 5 |
# File 'lib/lamma/alias.rb', line 3 def description=(value) @description = value end |
#version ⇒ Object
Returns the value of attribute version.
3 4 5 |
# File 'lib/lamma/alias.rb', line 3 def version @version end |
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/lamma/alias.rb', line 12 def create lambda_client.create_alias({ function_name: @function.name, name: name, # 'name' indicates the self function_version: @version, description: description }) end |
#create_or_update ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/lamma/alias.rb', line 30 def create_or_update if remote_exist? update else create end end |
#name ⇒ Object
38 39 40 |
# File 'lib/lamma/alias.rb', line 38 def name @name.upcase end |
#remote_exist? ⇒ Boolean
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/lamma/alias.rb', line 42 def remote_exist? begin lambda_client.get_alias({ function_name: @function.name, name: name }) rescue Aws::Lambda::Errors::ResourceNotFoundException false end end |
#remote_version ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/lamma/alias.rb', line 53 def remote_version begin lambda_client.get_alias({ function_name: @function.name, name: name }).function_version rescue Aws::Lambda::Errors::ResourceNotFoundException nil end end |
#update ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/lamma/alias.rb', line 21 def update lambda_client.update_alias({ function_name: @function.name, name: name, # 'name' indicates the self function_version: @version, description: description }) end |