Class: ApigeePlatform::Objects::Key
- Inherits:
-
Base
- Object
- ActiveResource::Base
- Base
- ApigeePlatform::Objects::Key
show all
- Defined in:
- lib/apigee-platform/objects/key.rb
Overview
abstract class, describes behavior of api keys, nested in developer_app and company_app
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
collection_path, configure, #custom_attributes, element_path, #encode, #id, #initialize, instantiate_record, #load, prefix_options, set_prefix_options
included
Class Method Details
.element_name ⇒ Object
4
5
6
|
# File 'lib/apigee-platform/objects/key.rb', line 4
def self.element_name
'key'
end
|
Instance Method Details
#add_product(product_name) ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/apigee-platform/objects/key.rb', line 12
def add_product(product_name)
unless apiproducts[product_name]
connection.post element_path, {
:apiProducts => apiproducts.keys + [product_name]
}.to_json
apiproducts[product_name] = 'pending'
end
end
|
#apiproducts ⇒ Object
40
41
42
|
# File 'lib/apigee-platform/objects/key.rb', line 40
def apiproducts
self.attributes['apiProducts']
end
|
#approve ⇒ Object
8
9
10
|
# File 'lib/apigee-platform/objects/key.rb', line 8
def approve
connection.post element_path
end
|
#approve_product(product_name) ⇒ Object
21
22
23
24
25
|
# File 'lib/apigee-platform/objects/key.rb', line 21
def approve_product(product_name)
return false unless apiproducts[product_name]
connection.post "#{element_path}/apiproducts/#{product_name}?action=approve", '', {'Content-Type' => 'application/octet-stream'}
apiproducts[product_name] = 'approved'
end
|
#onload ⇒ Object
44
45
46
|
# File 'lib/apigee-platform/objects/key.rb', line 44
def onload
self.attributes['apiProducts'] = self.attributes['apiProducts'].inject({}){|res, el| res[el.apiproduct] = el.status; res }
end
|
#remove_product(product_name) ⇒ Object
33
34
35
36
37
38
|
# File 'lib/apigee-platform/objects/key.rb', line 33
def remove_product(product_name)
return false unless apiproducts[product_name]
connection.delete "#{element_path}/apiproducts/#{product_name}"
apiproducts.delete(product_name)
true
end
|
#revoke_product(product_name) ⇒ Object
27
28
29
30
31
|
# File 'lib/apigee-platform/objects/key.rb', line 27
def revoke_product(product_name)
return false unless apiproducts[product_name]
connection.post "#{element_path}/apiproducts/#{product_name}?action=revoke", '', {'Content-Type' => 'application/octet-stream'}
apiproducts[product_name] = 'revoked'
end
|