lib/3scale/api/client.rb in 3scale-api-0.1.7 vs lib/3scale/api/client.rb in 3scale-api-0.1.8
- old
+ new
@@ -287,9 +287,89 @@
def delete_application_plan_limit(application_plan_id, metric_id, limit_id)
http_client.delete("/admin/api/application_plans/#{application_plan_id}/metrics/#{metric_id}/limits/#{limit_id}")
true
end
+ # @api public
+ # @param [Hash] account criteria
+ # @return [Hash]
+ def find_account(criteria)
+ response = http_client.get('/admin/api/accounts/find', params: criteria)
+ extract(entity: 'account', from: response)
+ end
+
+ # @api public
+ # @return [Array]
+ # @param [Fixnum] id Service ID
+ def show_policies(id)
+ response = http_client.get("/admin/api/services/#{id}/proxy/policies")
+ extract(entity: 'policies_config', from: response)
+ end
+
+ # @api public
+ # @return [Array]
+ # @param [Fixnum] id Service ID
+ def update_policies(id, policies_config)
+ response = http_client.put("/admin/api/services/#{id}/proxy/policies", body: policies_config)
+ extract(entity: 'policies_config', from: response)
+ end
+
+ # @api public
+ # @param [Fixnum] application_plan_id Application Plan ID
+ # @param [Fixnum] metric_id Metric ID
+ # @return [Array<Hash>]
+ def list_pricingrules_per_metric(application_plan_id, metric_id)
+ response = http_client.get("/admin/api/application_plans/#{application_plan_id}/metrics/#{metric_id}/pricing_rules")
+ extract(collection: 'pricing_rules', entity: 'pricing_rule', from: response)
+ end
+
+ # @api public
+ # @param [Fixnum] application_plan_id Application Plan ID
+ # @return [Array<Hash>]
+ def list_pricingrules_per_application_plan(application_plan_id)
+ response = http_client.get("/admin/api/application_plans/#{application_plan_id}/pricing_rules")
+ extract(collection: 'pricing_rules', entity: 'pricing_rule', from: response)
+ end
+
+ # @api public
+ # @param [Fixnum] application_plan_id Application Plan ID
+ # @return [Array<Hash>]
+ def create_pricingrule(application_plan_id, metric_id, attributes)
+ response = http_client.post("/admin/api/application_plans/#{application_plan_id}/metrics/#{metric_id}/pricing_rules", body: attributes)
+ extract(entity: 'pricing_rule', from: response)
+ end
+
+ # @api public
+ # @return [Array<Hash>]
+ def list_activedocs
+ response = http_client.get('/admin/api/active_docs')
+ extract(collection: 'api_docs', entity: 'api_doc', from: response)
+ end
+
+ # @api public
+ # @param [Hash] attributes ActiveDocs attributes
+ # @return [Hash]
+ def create_activedocs(attributes)
+ response = http_client.post('/admin/api/active_docs', body: attributes)
+ extract(entity: 'api_doc', from: response)
+ end
+
+ # @api public
+ # @param [Fixnum] id ActiveDocs ID
+ # @param [Hash] attributes ActiveDocs attributes
+ # @return [Hash]
+ def update_activedocs(id, attributes)
+ response = http_client.put("/admin/api/active_docs/#{id}", body: attributes)
+ extract(entity: 'api_doc', from: response)
+ end
+
+ # @api public
+ # @return [Hash]
+ def delete_activedocs(id)
+ http_client.delete("/admin/api/active_docs/#{id}")
+ true
+ end
+
protected
def extract(collection: nil, entity:, from:)
from = from.fetch(collection) if collection