Class: Seahorse::Model::Api
- Inherits:
-
Object
- Object
- Seahorse::Model::Api
- Defined in:
- lib/seahorse/model/api.rb
Instance Attribute Summary collapse
- #definition ⇒ Hash readonly
- #documentation ⇒ String? readonly
- #operation_names ⇒ Array<Symbol> readonly
- #shape_map ⇒ ShapeMap readonly
- #version ⇒ String? readonly
Instance Method Summary collapse
-
#initialize(definition = {}) ⇒ Api
constructor
A new instance of Api.
- #inspect ⇒ String private
- #metadata(key) ⇒ Object?
- #operation(name) ⇒ Operation
-
#operation?(name) ⇒ Boolean
Returns ‘true` if this API provides an operation with the given name.
- #operations ⇒ Enumerable
Constructor Details
#initialize(definition = {}) ⇒ Api
Returns a new instance of Api.
6 7 8 9 10 11 12 13 |
# File 'lib/seahorse/model/api.rb', line 6 def initialize(definition = {}) @metadata = definition['metadata'] || {} @version = ('apiVersion') @documentation = definition['documentation'] @definition = definition @shape_map = ShapeMap.new(definition['shapes'] || {}) compute_operations end |
Instance Attribute Details
#definition ⇒ Hash (readonly)
28 29 30 |
# File 'lib/seahorse/model/api.rb', line 28 def definition @definition end |
#documentation ⇒ String? (readonly)
22 23 24 |
# File 'lib/seahorse/model/api.rb', line 22 def documentation @documentation end |
#operation_names ⇒ Array<Symbol> (readonly)
19 20 21 |
# File 'lib/seahorse/model/api.rb', line 19 def operation_names @operation_names end |
#shape_map ⇒ ShapeMap (readonly)
25 26 27 |
# File 'lib/seahorse/model/api.rb', line 25 def shape_map @shape_map end |
#version ⇒ String? (readonly)
16 17 18 |
# File 'lib/seahorse/model/api.rb', line 16 def version @version end |
Instance Method Details
#inspect ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 |
# File 'lib/seahorse/model/api.rb', line 61 def inspect "#<#{self.class.name} version=#{version.inspect}>" end |
#metadata(key) ⇒ Object?
55 56 57 |
# File 'lib/seahorse/model/api.rb', line 55 def (key) @metadata[key] end |
#operation(name) ⇒ Operation
39 40 41 42 43 44 45 46 |
# File 'lib/seahorse/model/api.rb', line 39 def operation(name) name = name.to_sym if definition = @operation_defs[name] @operations[name] ||= Operation.new(definition, shape_map: @shape_map) else raise ArgumentError, "unknown operation :#{name}" end end |
#operation?(name) ⇒ Boolean
Returns ‘true` if this API provides an operation with the given name.
33 34 35 |
# File 'lib/seahorse/model/api.rb', line 33 def operation?(name) @operation_defs.key?(name.to_sym) end |
#operations ⇒ Enumerable
49 50 51 |
# File 'lib/seahorse/model/api.rb', line 49 def operations enum_for(:each_operation) { |*args| operation_names.size } end |