Class: Bitmovin::Resource
- Inherits:
-
Object
- Object
- Bitmovin::Resource
- Includes:
- Helpers
- Defined in:
- lib/bitmovin/resource.rb
Direct Known Subclasses
ConfigurationResource, Encoding::Encodings::EncodingTask, Encoding::Encodings::InputStreams::Ingest, Encoding::Encodings::InputStreams::Trimming::TimeBased, Encoding::Encodings::Muxings::Drms::DrmMuxingResource, Encoding::Encodings::Muxings::MuxingResource, Encoding::Encodings::Sprite, Encoding::Encodings::Stream, Encoding::Encodings::Thumbnail, Encoding::Inputs::AsperaInput, Encoding::Inputs::AzureInput, Encoding::Inputs::FtpInput, Encoding::Inputs::GcsInput, Encoding::Inputs::GenericS3Input, Encoding::Inputs::HttpInput, Encoding::Inputs::HttpsInput, Encoding::Inputs::RtmpInput, Encoding::Inputs::SftpInput, Encoding::Manifests::AudioAdaptationSet, Encoding::Manifests::DashManifest, Encoding::Manifests::Fmp4Representation, Encoding::Manifests::HlsAudioMedia, Encoding::Manifests::HlsManifest, Encoding::Manifests::HlsVariantStream, Encoding::Manifests::HlsVariantStreamList, Encoding::Manifests::ManifestResource, Encoding::Manifests::Period, Encoding::Manifests::VideoAdaptationSet, Encoding::Outputs::GcsOutput, Encoding::Outputs::S3Output, InputResource, Webhooks::WebhookResource
Class Attribute Summary collapse
-
.resource_path ⇒ Object
readonly
Returns the value of attribute resource_path.
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#modified_at ⇒ Object
Returns the value of attribute modified_at.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #delete! ⇒ Object
- #init_instance(path) ⇒ Object
-
#initialize(hash = {}) ⇒ Resource
constructor
A new instance of Resource.
- #inspect ⇒ Object
- #persisted? ⇒ Boolean
- #save! {|response.body| ... } ⇒ Object
Methods included from Helpers
#camelize_hash, #hash_to_struct, result, #result, #underscore_hash
Constructor Details
#initialize(hash = {}) ⇒ Resource
Returns a new instance of Resource.
31 32 33 |
# File 'lib/bitmovin/resource.rb', line 31 def initialize(hash = {}) init_from_hash(hash) end |
Class Attribute Details
.resource_path ⇒ Object (readonly)
Returns the value of attribute resource_path.
9 10 11 |
# File 'lib/bitmovin/resource.rb', line 9 def resource_path @resource_path end |
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at.
28 29 30 |
# File 'lib/bitmovin/resource.rb', line 28 def created_at @created_at end |
#description ⇒ Object
Returns the value of attribute description.
28 29 30 |
# File 'lib/bitmovin/resource.rb', line 28 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
28 29 30 |
# File 'lib/bitmovin/resource.rb', line 28 def id @id end |
#modified_at ⇒ Object
Returns the value of attribute modified_at.
28 29 30 |
# File 'lib/bitmovin/resource.rb', line 28 def modified_at @modified_at end |
#name ⇒ Object
Returns the value of attribute name.
28 29 30 |
# File 'lib/bitmovin/resource.rb', line 28 def name @name end |
Class Method Details
.find(id) ⇒ Object
18 19 20 21 |
# File 'lib/bitmovin/resource.rb', line 18 def find(id) response = Bitmovin.client.get File.join(@resource_path, id) new(Bitmovin::Helpers.result(response)) end |
.init(path) ⇒ Object
6 7 8 |
# File 'lib/bitmovin/resource.rb', line 6 def init(path) @resource_path = path end |
Instance Method Details
#delete! ⇒ Object
53 54 55 |
# File 'lib/bitmovin/resource.rb', line 53 def delete! Bitmovin.client.delete File.join(resource_path, @id) end |
#init_instance(path) ⇒ Object
24 25 26 |
# File 'lib/bitmovin/resource.rb', line 24 def init_instance(path) @instance_resource_path = path end |
#inspect ⇒ Object
57 58 59 |
# File 'lib/bitmovin/resource.rb', line 57 def inspect "#{self.class.name}(id: #{@id}, name: #{@name})" end |
#persisted? ⇒ Boolean
49 50 51 |
# File 'lib/bitmovin/resource.rb', line 49 def persisted? !@id.nil? end |
#save! {|response.body| ... } ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/bitmovin/resource.rb', line 35 def save! if @id raise BitmovinError.new(self), "Cannot save already persisted resource" end response = Bitmovin.client.post do |post| post.url resource_path post.body = collect_attributes end yield(response.body) if block_given? init_from_hash(result(response)) self end |