Class: Rapis::Client

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

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



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

def initialize
  @api = Aws::APIGateway::Client.new
end

Instance Method Details

#create(name, desc) ⇒ Object



13
14
15
16
17
18
# File 'lib/rapis/client.rb', line 13

def create(name, desc)
  @api.create_rest_api({
    name: name,
    description: desc
  })
end

#deploy(args) ⇒ Object



54
55
56
# File 'lib/rapis/client.rb', line 54

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

#export_api(api_id, stage_name) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/rapis/client.rb', line 34

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



20
21
22
23
24
25
26
27
28
# File 'lib/rapis/client.rb', line 20

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, pos = nil) ⇒ Object



30
31
32
# File 'lib/rapis/client.rb', line 30

def get_stages(api_id, pos=nil)
  @api.get_stages({rest_api_id: api_id}).item
end

#put_api(api_id, data) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/rapis/client.rb', line 45

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