Class: K8y::Client::API

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/k8y/client/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(group_version:) ⇒ API

Returns a new instance of API.



14
15
16
17
18
# File 'lib/k8y/client/api.rb', line 14

def initialize(group_version:)
  @group_version = group_version
  @discovered = false
  @api_methods = {}
end

Instance Attribute Details

#group_versionObject (readonly)

Returns the value of attribute group_version.



10
11
12
# File 'lib/k8y/client/api.rb', line 10

def group_version
  @group_version
end

Instance Method Details

#discovered?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/k8y/client/api.rb', line 20

def discovered?
  discovered
end

#has_api_method?(method) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/k8y/client/api.rb', line 24

def has_api_method?(method)
  api_methods.dig(method)
end

#pathObject

Core/v1 resources are in ‘/api/#version`. In general, all other resources are found in `/apis/GROUP/VERSION`



29
30
31
32
33
34
35
# File 'lib/k8y/client/api.rb', line 29

def path
  @path ||= if group == "core"
    "/api/#{version}"
  else
    "/apis/#{group}/#{version}"
  end
end