Class: Seahorse::Model::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/seahorse/model/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definition = {}) ⇒ Api

Returns a new instance of Api.

Parameters:

  • definition (Hash) (defaults to: {})


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

#definitionHash (readonly)

Returns:

  • (Hash)


28
29
30
# File 'lib/seahorse/model/api.rb', line 28

def definition
  @definition
end

#documentationString? (readonly)

Returns:

  • (String, nil)


22
23
24
# File 'lib/seahorse/model/api.rb', line 22

def documentation
  @documentation
end

#operation_namesArray<Symbol> (readonly)

Returns:

  • (Array<Symbol>)


19
20
21
# File 'lib/seahorse/model/api.rb', line 19

def operation_names
  @operation_names
end

#shape_mapShapeMap (readonly)

Returns:



25
26
27
# File 'lib/seahorse/model/api.rb', line 25

def shape_map
  @shape_map
end

#versionString? (readonly)

Returns:

  • (String, nil)


16
17
18
# File 'lib/seahorse/model/api.rb', line 16

def version
  @version
end

Instance Method Details

#inspectString

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.

Returns:

  • (String)


61
62
63
# File 'lib/seahorse/model/api.rb', line 61

def inspect
  "#<#{self.class.name} version=#{version.inspect}>"
end

#metadata(key) ⇒ Object?

Parameters:

  • key (String)

Returns:

  • (Object, nil)


55
56
57
# File 'lib/seahorse/model/api.rb', line 55

def (key)
  @metadata[key]
end

#operation(name) ⇒ Operation

Parameters:

  • name (Symbol)

Returns:



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.

Parameters:

  • name (Symbol)

Returns:

  • (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

#operationsEnumerable

Returns:

  • (Enumerable)


49
50
51
# File 'lib/seahorse/model/api.rb', line 49

def operations
  enum_for(:each_operation) { |*args| operation_names.size }
end