Class: Jets::Router::State
- Inherits:
-
Object
- Object
- Jets::Router::State
- Extended by:
- Memoist
- Includes:
- AwsServices
- Defined in:
- lib/jets/router/state.rb
Instance Method Summary collapse
- #load(filename) ⇒ Object
-
#s3_storage_path(filename) ⇒ Object
Examples:.
-
#save(filename, data) ⇒ Object
Save previously deployed APIGW routes state.
Methods included from AwsServices
#apigateway, #aws_lambda, #aws_options, #cfn, #dynamodb, #logs, #s3, #s3_resource, #sns, #sqs, #sts
Methods included from AwsServices::StackStatus
#lookup, #stack_exists?, #stack_in_progress?
Methods included from AwsServices::GlobalMemoist
Instance Method Details
#load(filename) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/jets/router/state.rb', line 6 def load(filename) resp = s3.get_object( bucket: Jets.aws.s3_bucket, key: s3_storage_path(filename), ) text = resp.body.read JSON.load(text) rescue end |
#s3_storage_path(filename) ⇒ Object
43 44 45 |
# File 'lib/jets/router/state.rb', line 43 def s3_storage_path(filename) "jets/state/apigw/#{filename}.json" end |
#save(filename, data) ⇒ Object
Save previously deployed APIGW routes state
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/jets/router/state.rb', line 18 def save(filename, data) # body = Jets::Router.routes.to_json # body = JSON.generate(Jets::Cfn::Builders::PageBuilder.pages) body = data.respond_to?(:to_json) ? data.to_json : JSON.generate(data) s3.put_object( body: body, bucket: Jets.aws.s3_bucket, key: s3_storage_path(filename), ) end |