Class: Rapis::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/rapis/client.rb

Instance Method Summary collapse

Instance Method Details

#apiObject



3
4
5
# File 'lib/rapis/client.rb', line 3

def api
  Aws::APIGateway::Client.new
end

#create(name, desc) ⇒ Object



7
8
9
10
11
12
# File 'lib/rapis/client.rb', line 7

def create(name, desc)
  opt = {}
  opt[:name] = name
  opt[:description] = desc unless desc.nil?
  api.create_rest_api(opt)
end

#deploy(args) ⇒ Object



48
49
50
# File 'lib/rapis/client.rb', line 48

def deploy(args)
  api.create_deployment(args)
end

#export_api(api_id, stage_name) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/rapis/client.rb', line 28

def export_api(api_id, stage_name)
  ret = api.get_export(
    rest_api_id: api_id,
    stage_name: stage_name,
    export_type: 'swagger',
    parameters: { extensions: 'integrations' }
  )

  JSON.load(ret.body.read)
end

#get_apis(pos = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/rapis/client.rb', line 14

def get_apis(pos = nil)
  opt = {}
  opt[:limit] = 500
  opt[:position] = pos unless pos.nil?

  ret = api.get_rest_apis(opt)
  ret.items.concat(get_apis(ret.posision)) unless ret.position.nil?
  ret.items
end

#get_stages(api_id) ⇒ Object



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

def get_stages(api_id)
  api.get_stages(rest_api_id: api_id).item
end

#put_api(api_id, data) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/rapis/client.rb', line 39

def put_api(api_id, data)
  api.put_rest_api(
    rest_api_id: api_id,
    mode: 'overwrite',
    parameters: { extensions: 'integrations' },
    body: JSON.dump(data)
  )
end