lib/3scale/api/client.rb in 3scale-api-0.6.0 vs lib/3scale/api/client.rb in 3scale-api-1.0.0

- old
+ new

@@ -171,22 +171,22 @@ # @api public # @return [Hash] # @param [Fixnum] service_id Service ID # @param [String] environment. Must be 'sandbox' or 'production' - # @param [Fixnum] proxy configuration version + # @param [Fixnum] version Proxy configuration version def show_proxy_config(service_id, environment, version) response = http_client.get("/admin/api/services/#{service_id}/proxy/configs/#{environment}/#{version}") extract(entity: 'proxy_config', from: response) end # @api public # @return [Hash] # @param [Fixnum] service_id Service ID - # @param [String] environment. Must be 'sandbox' or 'production' - # @param [Fixnum] proxy configuration version to promote - # @param [Fixnum] proxy configuration to which the specified proxy configuration will be promoted to + # @param [String] environment Must be 'sandbox' or 'production' + # @param [Fixnum] version Version to promote + # @param [Fixnum] to To which the specified proxy configuration will be promoted to def promote_proxy_config(service_id, environment, version, to) response = http_client.post("/admin/api/services/#{service_id}/proxy/configs/#{environment}/#{version}/promote", body: { to: to }) extract(entity: 'proxy_config', from: response) end @@ -305,11 +305,11 @@ true end # @api public # @param [Fixnum] service_id Service ID - # @param [Fixnum] id Parent metric ID + # @param [Fixnum] parent_id Parent metric ID # @param [Fixnum] id Method ID # @return [Hash] def show_method(service_id, parent_id, id) response = http_client.get("/admin/api/services/#{service_id}/metrics/#{parent_id}/methods/#{id}") extract(entity: 'method', from: response) @@ -350,11 +350,11 @@ # @api public # @return [Bool] # @param [Fixnum] service_id Service ID # @param [Fixnum] parent_id Parent metric ID - # @param [Fixnum] metric_id Metric ID + # @param [Fixnum] id Metric ID def delete_method(service_id, parent_id, id) http_client.delete("/admin/api/services/#{service_id}/metrics/#{parent_id}/methods/#{id}") true end @@ -386,11 +386,11 @@ body: { application_plan: attributes }) extract(entity: 'application_plan', from: response) end # @api public - # @param [Fixnum] id Service ID + # @param [Fixnum] service_id Service ID # @param [Fixnum] id Application Plan ID # @return [Hash] def show_application_plan(service_id, id) response = http_client.get("/admin/api/services/#{service_id}/application_plans/#{id}") extract(entity: 'application_plan', from: response) @@ -464,11 +464,11 @@ http_client.delete("/admin/api/application_plans/#{application_plan_id}/metrics/#{metric_id}/limits/#{limit_id}") true end # @api public - # @param [Hash] account criteria + # @param [Hash] criteria Search parameters # @return [Hash] def find_account(criteria) response = http_client.get('/admin/api/accounts/find', params: criteria) extract(entity: 'account', from: response) end @@ -559,36 +559,36 @@ response = http_client.get('/admin/api/accounts') extract(collection: 'accounts', entity: 'account', from: response) end # @api public - # @param [Fixnum] account_id Account ID + # @param [Fixnum] id Account ID # @return [Bool] def delete_account(id) http_client.delete("/admin/api/accounts/#{id}") true end # @api public # @param [Fixnum] account_id Account ID - # @param [Fixnum] application_id Application ID + # @param [Fixnum] id Application ID # @return [Bool] def delete_application(account_id, id) http_client.delete("/admin/api/accounts/#{account_id}/applications/#{id}") true end # @api public - # @param [Fixnum] id Service ID + # @param [Fixnum] service_id Service ID # @return [Array<Hash>] def show_oidc(service_id) response = http_client.get("/admin/api/services/#{service_id}/proxy/oidc_configuration") extract(entity: 'oidc_configuration', from: response) end # @api public - # @param [Fixnum] id Service ID + # @param [Fixnum] service_id Service ID # @return [Hash] def update_oidc(service_id, attributes) response = http_client.patch("/admin/api/services/#{service_id}/proxy/oidc_configuration", body: { oidc_configuration: attributes }) extract(entity: 'oidc_configuration', from: response) @@ -715,11 +715,11 @@ def list_account_applications(account_id) response = http_client.get("/admin/api/accounts/#{account_id}/applications") extract(collection: 'applications', entity: 'application', from: response) end - # @api public + # @api public # @return [Array<Hash] def list_application_plans response = http_client.get("/admin/api/application_plans") extract(collection: 'plans', entity: 'application_plan', from: response) end @@ -758,11 +758,11 @@ # @return [Hash] application Application def suspend_application(account_id, application_id) response = http_client.put("/admin/api/accounts/#{account_id}/applications/#{application_id}/suspend") extract(entity: 'application', from: response) end - + # @api public # @param [String] account_id Account ID # @param [String] application_id Application ID # @return [Hash] application Application def resume_application(account_id, application_id) @@ -812,9 +812,235 @@ # @api public # @return [Hash] def show_provider response = http_client.get('/admin/api/provider') extract(entity: 'account', from: response) + end + + # @api public + # @return [List] + def list_backends + response = http_client.get('/admin/api/backend_apis') + extract(collection: 'backend_apis', entity: 'backend_api', from: response) + end + + # @api public + # @param [Hash] attributes Backend attributes + # @return [Hash] + def create_backend(attributes) + response = http_client.post('/admin/api/backend_apis', body: attributes) + extract(entity: 'backend_api', from: response) + end + + # @api public + # @param [Fixnum] id Backend ID + def delete_backend(id) + http_client.delete("/admin/api/backend_apis/#{id}") + true + end + + # @api public + # @param [Fixnum] id Backend ID + # @return [Hash] + def backend(id) + response = http_client.get("/admin/api/backend_apis/#{id}") + extract(entity: 'backend_api', from: response) + end + + # @api public + # @param [Fixnum] id Backend ID + # @param [Hash] attributes Backend attributes + # @return [Hash] + def update_backend(id, attributes) + response = http_client.put("/admin/api/backend_apis/#{id}", body: attributes) + extract(entity: 'backend_api', from: response) + end + + # @api public + # @param [Fixnum] id Backend ID + # @return [List] + def list_backend_metrics(id) + response = http_client.get("/admin/api/backend_apis/#{id}/metrics") + extract(collection: 'metrics', entity: 'metric', from: response) + end + + # @api public + # @param [Fixnum] id Backend ID + # @param [Hash] attributes Metric attributes + # @return [Hash] + def create_backend_metric(id, attrs) + response = http_client.post("/admin/api/backend_apis/#{id}/metrics", body: attrs) + extract(entity: 'metric', from: response) + end + + # @api public + # @param [Fixnum] backend_id Backend ID + # @param [Fixnum] metric_id Backend Metric ID + def delete_backend_metric(backend_id, metric_id) + http_client.delete("/admin/api/backend_apis/#{backend_id}/metrics/#{metric_id}") + true + end + + # @api public + # @param [Fixnum] backend_id Backend ID + # @param [Fixnum] metric_id Backend Metric ID + # @return [Hash] + def backend_metric(backend_id, metric_id) + response = http_client.get("/admin/api/backend_apis/#{backend_id}/metrics/#{metric_id}") + extract(entity: 'metric', from: response) + end + + # @api public + # @param [Fixnum] backend_id Backend ID + # @param [Fixnum] metric_id Backend Metric ID + # @param [Hash] attributes Backend attributes + # @return [Hash] + def update_backend_metric(backend_id, metric_id, attributes) + response = http_client.put("/admin/api/backend_apis/#{backend_id}/metrics/#{metric_id}", body: attributes) + extract(entity: 'metric', from: response) + end + + # @api public + # @param [Fixnum] backend_id Backend ID + # @param [Fixnum] metric_id Backend Metric ID + # @return [List] + def list_backend_methods(backend_id, metric_id) + response = http_client.get("/admin/api/backend_apis/#{backend_id}/metrics/#{metric_id}/methods") + extract(collection: 'methods', entity: 'method', from: response) + end + + # @api public + # @param [Fixnum] backend_id Backend ID + # @param [Fixnum] metric_id Backend Metric ID + # @param [Hash] attributes Metric attributes + # @return [Hash] + def create_backend_method(backend_id, metric_id, attrs) + response = http_client.post("/admin/api/backend_apis/#{backend_id}/metrics/#{metric_id}/methods", + body: attrs) + extract(entity: 'method', from: response) + end + + # @api public + # @param [Fixnum] backend_id Backend ID + # @param [Fixnum] metric_id Backend Metric ID + # @param [Fixnum] method_id Backend Method ID + def delete_backend_method(backend_id, metric_id, method_id) + http_client.delete("/admin/api/backend_apis/#{backend_id}/metrics/#{metric_id}/methods/#{method_id}") + true + end + + # @api public + # @param [Fixnum] backend_id Backend ID + # @param [Fixnum] metric_id Backend Metric ID + # @param [Fixnum] method_id Backend Method ID + # @return [Hash] + def backend_method(backend_id, metric_id, method_id) + response = http_client.get("/admin/api/backend_apis/#{backend_id}/metrics/#{metric_id}/methods/#{method_id}") + extract(entity: 'method', from: response) + end + + # @api public + # @param [Fixnum] backend_id Backend ID + # @param [Fixnum] metric_id Backend Metric ID + # @param [Fixnum] method_id Backend Method ID + # @param [Hash] attributes Backend attributes + # @return [Hash] + def update_backend_method(backend_id, metric_id, method_id, attributes) + response = http_client.put("/admin/api/backend_apis/#{backend_id}/metrics/#{metric_id}/methods/#{method_id}", + body: attributes) + extract(entity: 'method', from: response) + end + + # @api public + # @param [Fixnum] backend_id Backend ID + # @return [List] + def list_backend_mapping_rules(backend_id) + response = http_client.get("/admin/api/backend_apis/#{backend_id}/mapping_rules") + extract(collection: 'mapping_rules', entity: 'mapping_rule', from: response) + end + + # @api public + # @param [Fixnum] backend_id Backend ID + # @param [Hash] attrs Metric attributes + # @return [Hash] + def create_backend_mapping_rule(backend_id, attrs) + response = http_client.post("/admin/api/backend_apis/#{backend_id}/mapping_rules", + body: attrs) + extract(entity: 'mapping_rule', from: response) + end + + # @api public + # @param [Fixnum] backend_id Backend ID + # @param [Fixnum] mapping_rule_id MappingRule ID + def delete_backend_mapping_rule(backend_id, mapping_rule_id) + http_client.delete("/admin/api/backend_apis/#{backend_id}/mapping_rules/#{mapping_rule_id}") + true + end + + # @api public + # @param [Fixnum] backend_id Backend ID + # @param [Fixnum] mapping_rule_id MappingRule ID + # @return [Hash] + def backend_mapping_rule(backend_id, mapping_rule_id) + response = http_client.get("/admin/api/backend_apis/#{backend_id}/mapping_rules/#{mapping_rule_id}") + extract(entity: 'mapping_rule', from: response) + end + + # @api public + # @param [Fixnum] backend_id Backend ID + # @param [Fixnum] mapping_rule_id MappingRule ID + # @param [Hash] attributes Backend attributes + # @return [Hash] + def update_backend_mapping_rule(backend_id, mapping_rule_id, attributes) + response = http_client.put("/admin/api/backend_apis/#{backend_id}/mapping_rules/#{mapping_rule_id}", + body: attributes) + extract(entity: 'mapping_rule', from: response) + end + + # @api public + # @param [Fixnum] product_id Product ID + # @return [List] + def list_backend_usages(product_id) + response = http_client.get("/admin/api/services/#{product_id}/backend_usages") + extract(entity: 'backend_usage', from: response) + end + + # @api public + # @param [Fixnum] product_id Product ID + # @param [Hash] attrs Backend Usage attributes + # @return [Hash] + def create_backend_usage(product_id, attrs) + response = http_client.post("/admin/api/services/#{product_id}/backend_usages", + body: attrs) + extract(entity: 'backend_usage', from: response) + end + + # @api public + # @param [Fixnum] product_id Product ID + # @param [Fixnum] id Backend Usage ID + def delete_backend_usage(product_id, id) + http_client.delete("/admin/api/services/#{product_id}/backend_usages/#{id}") + true + end + + # @api public + # @param [Fixnum] product_id Product ID + # @param [Fixnum] id Backend Usage ID + # @return [Hash] + def backend_usage(product_id, id) + response = http_client.get("/admin/api/services/#{product_id}/backend_usages/#{id}") + extract(entity: 'backend_usage', from: response) + end + + # @api public + # @param [Fixnum] product_id Product ID + # @param [Fixnum] id Backend Usage ID + # @param [Hash] attrs Backend Usage attributes + # @return [Hash] + def update_backend_usage(product_id, id, attrs) + response = http_client.put("/admin/api/services/#{product_id}/backend_usages/#{id}", + body: attrs) + extract(entity: 'backend_usage', from: response) end protected def extract(collection: nil, entity:, from:)