lib/3scale/api/client.rb in 3scale-api-0.3.0 vs lib/3scale/api/client.rb in 3scale-api-0.4.0
- old
+ new
@@ -216,10 +216,19 @@
body: { mapping_rule: attributes })
extract(entity: 'mapping_rule', from: response)
end
# @api public
+ # @param [Fixnum] service_id Service ID
+ # @param [Fixnum] id Metric ID
+ # @return [Hash]
+ def show_metric(service_id, id)
+ response = http_client.get("/admin/api/services/#{service_id}/metrics/#{id}")
+ extract(entity: 'metric', from: response)
+ end
+
+ # @api public
# @return [Array<Hash>]
# @param [Fixnum] service_id Service ID
def list_metrics(service_id)
response = http_client.get("/admin/api/services/#{service_id}/metrics")
extract(collection: 'metrics', entity: 'metric', from: response)
@@ -234,10 +243,55 @@
response = http_client.post("/admin/api/services/#{service_id}/metrics", body: { metric: attributes })
extract(entity: 'metric', from: response)
end
# @api public
+ # @return [Hash]
+ # @param [Fixnum] service_id Service ID
+ # @param [Fixnum] metric_id Metric ID
+ # @param [Hash] attributes Metric Attributes
+ # @option attributes [String] :friendly_name Metric Name
+ # @option attributes [String] :unit Metric unit
+ # @option attributes [String] :description Metric description
+ def update_metric(service_id, metric_id, attributes)
+ response = http_client.put("/admin/api/services/#{service_id}/metrics/#{metric_id}",
+ body: { metric: attributes })
+ extract(entity: 'metric', from: response)
+ end
+
+ # @api public
+ # @return [Bool]
+ # @param [Fixnum] service_id Service ID
+ # @param [Fixnum] metric_id Metric ID
+ def delete_metric(service_id, metric_id)
+ http_client.delete("/admin/api/services/#{service_id}/metrics/#{metric_id}")
+ true
+ end
+
+ # @api public
+ # @param [Fixnum] service_id Service ID
+ # @param [Fixnum] 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)
+ end
+
+ # @api public
+ # @return [Hash]
+ # @param [Fixnum] service_id Service ID
+ # @param [Fixnum] parent_id Parent metric ID
+ # @param [Fixnum] id Method ID
+ # @param [Hash] attributes Method Attributes
+ def update_method(service_id, parent_id, id, attributes)
+ response = http_client.put("/admin/api/services/#{service_id}/metrics/#{parent_id}/methods/#{id}",
+ body: { metric: attributes })
+ extract(entity: 'method', from: response)
+ end
+
+ # @api public
# @return [Array<Hash>]
# @param [Fixnum] service_id Service ID
# @param [Fixnum] metric_id Metric ID
def list_methods(service_id, metric_id)
response = http_client.get("/admin/api/services/#{service_id}/metrics/#{metric_id}/methods")
@@ -253,9 +307,20 @@
def create_method(service_id, metric_id, attributes)
response = http_client.post("/admin/api/services/#{service_id}/metrics/#{metric_id}/methods",
body: { metric: attributes })
extract(entity: 'method', from: response)
end
+
+ # @api public
+ # @return [Bool]
+ # @param [Fixnum] service_id Service ID
+ # @param [Fixnum] parent_id Parent metric ID
+ # @param [Fixnum] metric_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
+
# @api public
# @param [Fixnum] application_plan_id Application Plan ID
# @param [Fixnum] metric_id Metric ID
# @return [Hash]