Class: Atlas::BoxVersion
Overview
Representation and handling of Box Version objects.
Instance Attribute Summary collapse
-
#description ⇒ Object
Properties of the version.
-
#providers ⇒ Object
Properties of the version.
-
#status ⇒ Object
Properties of the version.
-
#version ⇒ Object
Properties of the version.
Attributes inherited from Resource
Class Method Summary collapse
-
.create(box_tag, attr = {}) ⇒ Version
Create a new version.
-
.find(tag) ⇒ Version
Find a version by it’s tag.
Instance Method Summary collapse
-
#delete ⇒ Hash
Delete the version.
-
#initialize(tag, hash = {}) ⇒ BoxVersion
constructor
Initialize a version from a versiontag and object hash.
-
#release ⇒ Hash
Release the version.
-
#revoke ⇒ Hash
Revoke the version.
-
#save ⇒ Hash
Save the version.
Methods inherited from Resource
#inspect, #to_hash, #update_with_response
Constructor Details
#initialize(tag, hash = {}) ⇒ BoxVersion
Initialize a version from a versiontag and object hash.
47 48 49 50 51 |
# File 'lib/atlas/box_version.rb', line 47 def initialize(tag, hash = {}) hash['description'] = hash['description_markdown'] super(tag, hash) end |
Instance Attribute Details
#description ⇒ Object
Properties of the version.
12 13 14 |
# File 'lib/atlas/box_version.rb', line 12 def description @description end |
#providers ⇒ Object
Properties of the version.
12 13 14 |
# File 'lib/atlas/box_version.rb', line 12 def providers @providers end |
#status ⇒ Object
Properties of the version.
12 13 14 |
# File 'lib/atlas/box_version.rb', line 12 def status @status end |
#version ⇒ Object
Properties of the version.
12 13 14 |
# File 'lib/atlas/box_version.rb', line 12 def version @version end |
Class Method Details
.create(box_tag, attr = {}) ⇒ Version
Create a new version.
34 35 36 37 38 39 |
# File 'lib/atlas/box_version.rb', line 34 def self.create(box_tag, attr = {}) tag = "#{box_tag}/#{attr[:version]}" version = new(tag, attr) version.save version end |
.find(tag) ⇒ Version
Find a version by it’s tag.
19 20 21 22 23 24 |
# File 'lib/atlas/box_version.rb', line 19 def self.find(tag) url_builder = UrlBuilder.new tag response = Atlas.client.get(url_builder.box_version_url) new(tag, JSON.parse(response.body)) end |
Instance Method Details
#delete ⇒ Hash
Delete the version.
108 109 110 111 112 |
# File 'lib/atlas/box_version.rb', line 108 def delete response = Atlas.client.delete(url_builder.box_version_url) JSON.parse(response.body) end |
#release ⇒ Hash
Release the version.
90 91 92 93 94 |
# File 'lib/atlas/box_version.rb', line 90 def release response = Atlas.client.put("#{url_builder.box_version_url}/release") update_with_response(response.body) end |
#revoke ⇒ Hash
Revoke the version.
99 100 101 102 103 |
# File 'lib/atlas/box_version.rb', line 99 def revoke response = Atlas.client.put("#{url_builder.box_version_url}/revoke") update_with_response(response.body) end |
#save ⇒ Hash
Save the version.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/atlas/box_version.rb', line 68 def save # rubocop:disable Metrics/MethodLength, Metrics/AbcSize body = { version: to_hash } # providers are saved seperately body[:version].delete(:providers) begin response = Atlas.client.put(url_builder.box_version_url, body: body) rescue Excon::Errors::NotFound response = Atlas.client.post("#{url_builder.box_url}/versions", body: body) end # trigger the same on the providers providers.each(&:save) if providers update_with_response(response.body, [:providers]) end |