3scale-api 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/3scale/api/client.rb +205 -17
- data/lib/3scale/api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35e0461eb588d4122409263fd94afe29e14b40cb0d34dca1d2a2c4f4ea91737f
|
4
|
+
data.tar.gz: ee61ee6359a8ff0c5cb9165dfb15bf8c8fe1d647bfc53056dc58838062d83255
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 328d7a9238eb7ab5efc71e2d71702b9c938af24e07a0cbd75d60ddd1ef637e87d45a1fd17f19dc1f917f629f2b4a39269d7e243d7bc6a01ef9b4f23837888e30
|
7
|
+
data.tar.gz: 8b6440a49570f16618f81e73ccc5089694dc91f8615412ec3e4ed379737824b975fe99eef5c67413afaa40955c0bf93c660576f6051f8be1511412adfe6b5eee
|
data/lib/3scale/api/client.rb
CHANGED
@@ -32,10 +32,11 @@ module ThreeScale
|
|
32
32
|
end
|
33
33
|
|
34
34
|
# @api public
|
35
|
-
# @return [Array<Hash>]
|
36
35
|
# @param [Fixnum] service_id Service ID
|
37
|
-
|
38
|
-
|
36
|
+
# @param [Fixnum] plan_id Application Plan ID
|
37
|
+
# @return [Array<Hash>]
|
38
|
+
def list_applications(service_id: nil, plan_id: nil)
|
39
|
+
params = { service_id: service_id, plan_id: plan_id }.compact
|
39
40
|
response = http_client.get('/admin/api/applications', params: params)
|
40
41
|
extract(collection: 'applications', entity: 'application', from: response)
|
41
42
|
end
|
@@ -73,6 +74,16 @@ module ThreeScale
|
|
73
74
|
extract(entity: 'application', from: response)
|
74
75
|
end
|
75
76
|
|
77
|
+
# @api public
|
78
|
+
# @param [Fixnum] account_id Account ID
|
79
|
+
# @param [Fixnum] id Application ID
|
80
|
+
# @param [Hash] attrs Application Attributes
|
81
|
+
# @return [Hash] an Application
|
82
|
+
def update_application(account_id, id, attrs)
|
83
|
+
response = http_client.put("/admin/api/accounts/#{account_id}/applications/#{id}", body: attrs)
|
84
|
+
extract(entity: 'application', from: response)
|
85
|
+
end
|
86
|
+
|
76
87
|
# @api public
|
77
88
|
# @return [Hash] a Plan
|
78
89
|
# @param [Fixnum] account_id Account ID
|
@@ -139,18 +150,40 @@ module ThreeScale
|
|
139
150
|
# @return [Hash]
|
140
151
|
# @param [Fixnum] service_id Service ID
|
141
152
|
# @param [String] environment. Must be 'sandbox' or 'production'
|
142
|
-
def proxy_config_list(service_id, environment='sandbox')
|
153
|
+
def proxy_config_list(service_id, environment = 'sandbox')
|
143
154
|
response = http_client.get("/admin/api/services/#{service_id}/proxy/configs/#{environment}")
|
144
|
-
extract(entity: '
|
155
|
+
extract(collection: 'proxy_configs', entity: 'proxy_config', from: response)
|
145
156
|
end
|
146
157
|
|
147
158
|
# @api public
|
148
159
|
# @return [Hash]
|
149
160
|
# @param [Fixnum] service_id Service ID
|
150
161
|
# @param [String] environment. Must be 'sandbox' or 'production'
|
151
|
-
def proxy_config_latest(service_id, environment='sandbox')
|
162
|
+
def proxy_config_latest(service_id, environment = 'sandbox')
|
152
163
|
response = http_client.get("/admin/api/services/#{service_id}/proxy/configs/#{environment}/latest")
|
153
|
-
extract(entity: '
|
164
|
+
extract(entity: 'proxy_config', from: response)
|
165
|
+
end
|
166
|
+
|
167
|
+
# @api public
|
168
|
+
# @return [Hash]
|
169
|
+
# @param [Fixnum] service_id Service ID
|
170
|
+
# @param [String] environment. Must be 'sandbox' or 'production'
|
171
|
+
# @param [Fixnum] proxy configuration version
|
172
|
+
def show_proxy_config(service_id, environment, version)
|
173
|
+
response = http_client.get("/admin/api/services/#{service_id}/proxy/configs/#{environment}/#{version}")
|
174
|
+
extract(entity: 'proxy_config', from: response)
|
175
|
+
end
|
176
|
+
|
177
|
+
# @api public
|
178
|
+
# @return [Hash]
|
179
|
+
# @param [Fixnum] service_id Service ID
|
180
|
+
# @param [String] environment. Must be 'sandbox' or 'production'
|
181
|
+
# @param [Fixnum] proxy configuration version to promote
|
182
|
+
# @param [Fixnum] proxy configuration to which the specified proxy configuration will be promoted to
|
183
|
+
def promote_proxy_config(service_id, environment, version, to)
|
184
|
+
response = http_client.post("/admin/api/services/#{service_id}/proxy/configs/#{environment}/#{version}/promote",
|
185
|
+
body: { to: to })
|
186
|
+
extract(entity: 'proxy_config', from: response)
|
154
187
|
end
|
155
188
|
|
156
189
|
# @api public
|
@@ -219,7 +252,7 @@ module ThreeScale
|
|
219
252
|
|
220
253
|
# @api public
|
221
254
|
# @param [Fixnum] service_id Service ID
|
222
|
-
# @param [Fixnum] id Metric ID
|
255
|
+
# @param [Fixnum] id Metric ID
|
223
256
|
# @return [Hash]
|
224
257
|
def show_metric(service_id, id)
|
225
258
|
response = http_client.get("/admin/api/services/#{service_id}/metrics/#{id}")
|
@@ -269,8 +302,8 @@ module ThreeScale
|
|
269
302
|
|
270
303
|
# @api public
|
271
304
|
# @param [Fixnum] service_id Service ID
|
272
|
-
# @param [Fixnum] id Parent metric ID
|
273
|
-
# @param [Fixnum] id Method ID
|
305
|
+
# @param [Fixnum] id Parent metric ID
|
306
|
+
# @param [Fixnum] id Method ID
|
274
307
|
# @return [Hash]
|
275
308
|
def show_method(service_id, parent_id, id)
|
276
309
|
response = http_client.get("/admin/api/services/#{service_id}/metrics/#{parent_id}/methods/#{id}")
|
@@ -280,7 +313,7 @@ module ThreeScale
|
|
280
313
|
# @api public
|
281
314
|
# @return [Hash]
|
282
315
|
# @param [Fixnum] service_id Service ID
|
283
|
-
# @param [Fixnum] parent_id Parent metric ID
|
316
|
+
# @param [Fixnum] parent_id Parent metric ID
|
284
317
|
# @param [Fixnum] id Method ID
|
285
318
|
# @param [Hash] attributes Method Attributes
|
286
319
|
def update_method(service_id, parent_id, id, attributes)
|
@@ -313,14 +346,13 @@ module ThreeScale
|
|
313
346
|
# @api public
|
314
347
|
# @return [Bool]
|
315
348
|
# @param [Fixnum] service_id Service ID
|
316
|
-
# @param [Fixnum] parent_id Parent metric ID
|
349
|
+
# @param [Fixnum] parent_id Parent metric ID
|
317
350
|
# @param [Fixnum] metric_id Metric ID
|
318
351
|
def delete_method(service_id, parent_id, id)
|
319
352
|
http_client.delete("/admin/api/services/#{service_id}/metrics/#{parent_id}/methods/#{id}")
|
320
353
|
true
|
321
354
|
end
|
322
355
|
|
323
|
-
|
324
356
|
# @api public
|
325
357
|
# @param [Fixnum] application_plan_id Application Plan ID
|
326
358
|
# @param [Fixnum] metric_id Metric ID
|
@@ -374,7 +406,7 @@ module ThreeScale
|
|
374
406
|
# @return [Bool]
|
375
407
|
# @param [Fixnum] service_id Service ID
|
376
408
|
# @param [Fixnum] application_plan_id Application Plan ID
|
377
|
-
def delete_application_plan(service_id,application_plan_id)
|
409
|
+
def delete_application_plan(service_id, application_plan_id)
|
378
410
|
http_client.delete("/admin/api/services/#{service_id}/application_plans/#{application_plan_id}")
|
379
411
|
true
|
380
412
|
end
|
@@ -416,7 +448,7 @@ module ThreeScale
|
|
416
448
|
# @param [Hash] attributes Limit Attributes
|
417
449
|
def update_application_plan_limit(application_plan_id, metric_id, limit_id, attributes)
|
418
450
|
response = http_client.put("/admin/api/application_plans/#{application_plan_id}/metrics/#{metric_id}/limits/#{limit_id}",
|
419
|
-
|
451
|
+
body: { usage_limit: attributes })
|
420
452
|
extract(entity: 'limit', from: response)
|
421
453
|
end
|
422
454
|
|
@@ -436,6 +468,14 @@ module ThreeScale
|
|
436
468
|
extract(entity: 'account', from: response)
|
437
469
|
end
|
438
470
|
|
471
|
+
# @api public
|
472
|
+
# @param [Fixnum] id Account Id
|
473
|
+
# @return [Hash]
|
474
|
+
def show_account(id)
|
475
|
+
response = http_client.get("/admin/api/accounts/#{id}")
|
476
|
+
extract(entity: 'account', from: response)
|
477
|
+
end
|
478
|
+
|
439
479
|
# @api public
|
440
480
|
# @return [Array]
|
441
481
|
# @param [Fixnum] id Service ID
|
@@ -532,7 +572,7 @@ module ThreeScale
|
|
532
572
|
true
|
533
573
|
end
|
534
574
|
|
535
|
-
|
575
|
+
# @api public
|
536
576
|
# @param [Fixnum] id Service ID
|
537
577
|
# @return [Array<Hash>]
|
538
578
|
def show_oidc(service_id)
|
@@ -590,7 +630,7 @@ module ThreeScale
|
|
590
630
|
# @return [Hash]
|
591
631
|
def create_service_feature(id, attributes)
|
592
632
|
response = http_client.post("/admin/api/services/#{id}/features",
|
593
|
-
body: { feature: attributes})
|
633
|
+
body: { feature: attributes })
|
594
634
|
extract(entity: 'feature', from: response)
|
595
635
|
end
|
596
636
|
|
@@ -623,6 +663,154 @@ module ThreeScale
|
|
623
663
|
true
|
624
664
|
end
|
625
665
|
|
666
|
+
# @api public
|
667
|
+
# @param [Fixnum] account_id Account ID
|
668
|
+
# @param [String] state State
|
669
|
+
# @param [String] role Role
|
670
|
+
# @return [Array<Hash>]
|
671
|
+
def list_users(account_id, state: nil, role: nil)
|
672
|
+
params = { state: state, role: role }.reject { |_, value| value.nil? }
|
673
|
+
response = http_client.get("/admin/api/accounts/#{account_id}/users", params: params)
|
674
|
+
extract(collection: 'users', entity: 'user', from: response)
|
675
|
+
end
|
676
|
+
|
677
|
+
# @api public
|
678
|
+
# @param [String] account_id Account ID
|
679
|
+
# @param [String] email User email
|
680
|
+
# @param [String] username User Username
|
681
|
+
# @param [String] password User password
|
682
|
+
# @param [Hash] attributes User Attributes
|
683
|
+
# @return [Hash]
|
684
|
+
def create_user(account_id:, email:, username:, password:, **rest)
|
685
|
+
body = { email: email, username: username, password: password }.merge(rest)
|
686
|
+
response = http_client.post("/admin/api/accounts/#{account_id}/users", body: body)
|
687
|
+
extract(entity: 'user', from: response)
|
688
|
+
end
|
689
|
+
|
690
|
+
# @api public
|
691
|
+
# @param [String] account_id Account ID
|
692
|
+
# @param [String] user_id User ID
|
693
|
+
# @return [Hash]
|
694
|
+
def activate_user(account_id, user_id)
|
695
|
+
response = http_client.put("/admin/api/accounts/#{account_id}/users/#{user_id}/activate")
|
696
|
+
extract(entity: 'user', from: response)
|
697
|
+
end
|
698
|
+
|
699
|
+
# @api public
|
700
|
+
# @param [String] account_id Account ID
|
701
|
+
# @return [Hash]
|
702
|
+
def approve_account(account_id)
|
703
|
+
response = http_client.put("/admin/api/accounts/#{account_id}/approve")
|
704
|
+
extract(entity: 'account', from: response)
|
705
|
+
end
|
706
|
+
|
707
|
+
# @api public
|
708
|
+
# @param [String] account_id Account ID
|
709
|
+
# @return [Array<Hash>]
|
710
|
+
def list_account_applications(account_id)
|
711
|
+
response = http_client.get("/admin/api/accounts/#{account_id}/applications")
|
712
|
+
extract(collection: 'applications', entity: 'application', from: response)
|
713
|
+
end
|
714
|
+
|
715
|
+
# @api public
|
716
|
+
# @return [Array<Hash]
|
717
|
+
def list_application_plans
|
718
|
+
response = http_client.get("/admin/api/application_plans")
|
719
|
+
extract(collection: 'plans', entity: 'application_plan', from: response)
|
720
|
+
end
|
721
|
+
|
722
|
+
# @api public
|
723
|
+
# @param [String] account_id Account ID
|
724
|
+
# @param [String] application_id Application ID
|
725
|
+
# @return [Array<Hash>]
|
726
|
+
def list_application_keys(account_id, application_id)
|
727
|
+
response = http_client.get("/admin/api/accounts/#{account_id}/applications/#{application_id}/keys")
|
728
|
+
extract(collection: 'keys', entity: 'key', from: response)
|
729
|
+
end
|
730
|
+
|
731
|
+
# @api public
|
732
|
+
# @param [String] account_id Account ID
|
733
|
+
# @param [String] application_id Application ID
|
734
|
+
# @param [String] key Key
|
735
|
+
# @return [Hash]
|
736
|
+
def create_application_key(account_id, application_id, key)
|
737
|
+
response = http_client.post("/admin/api/accounts/#{account_id}/applications/#{application_id}/keys", body: {key: key})
|
738
|
+
extract(entity: 'application', from: response)
|
739
|
+
end
|
740
|
+
|
741
|
+
# @api public
|
742
|
+
# @param [String] account_id Account ID
|
743
|
+
# @param [String] application_id Application ID
|
744
|
+
# @return [Hash] application Application
|
745
|
+
def accept_application(account_id, application_id)
|
746
|
+
response = http_client.put("/admin/api/accounts/#{account_id}/applications/#{application_id}/accept")
|
747
|
+
extract(entity: 'application', from: response)
|
748
|
+
end
|
749
|
+
|
750
|
+
# @api public
|
751
|
+
# @param [String] account_id Account ID
|
752
|
+
# @param [String] application_id Application ID
|
753
|
+
# @return [Hash] application Application
|
754
|
+
def suspend_application(account_id, application_id)
|
755
|
+
response = http_client.put("/admin/api/accounts/#{account_id}/applications/#{application_id}/suspend")
|
756
|
+
extract(entity: 'application', from: response)
|
757
|
+
end
|
758
|
+
|
759
|
+
# @api public
|
760
|
+
# @param [String] account_id Account ID
|
761
|
+
# @param [String] application_id Application ID
|
762
|
+
# @return [Hash] application Application
|
763
|
+
def resume_application(account_id, application_id)
|
764
|
+
response = http_client.put("/admin/api/accounts/#{account_id}/applications/#{application_id}/resume")
|
765
|
+
extract(entity: 'application', from: response)
|
766
|
+
end
|
767
|
+
|
768
|
+
# @api public
|
769
|
+
# @return [Array<Hash>]
|
770
|
+
def list_policy_registry
|
771
|
+
response = http_client.get('/admin/api/registry/policies')
|
772
|
+
extract(collection: 'policies', entity: 'policy', from: response)
|
773
|
+
end
|
774
|
+
|
775
|
+
# @api public
|
776
|
+
# @param [Hash] attributes Policy Registry Attributes
|
777
|
+
# @return [Hash]
|
778
|
+
def create_policy_registry(attributes)
|
779
|
+
response = http_client.post('/admin/api/registry/policies', body: attributes)
|
780
|
+
extract(entity: 'policy', from: response)
|
781
|
+
end
|
782
|
+
|
783
|
+
# @api public
|
784
|
+
# @return [Hash]
|
785
|
+
# @param [Fixnum] id Policy Registry Id
|
786
|
+
def show_policy_registry(id)
|
787
|
+
response = http_client.get("/admin/api/registry/policies/#{id}")
|
788
|
+
extract(entity: 'policy', from: response)
|
789
|
+
end
|
790
|
+
|
791
|
+
# @api public
|
792
|
+
# @return [Hash]
|
793
|
+
# @param [Fixnum] id Policy Registry Id
|
794
|
+
# @param [Hash] attributes Policy Registry Attributes
|
795
|
+
def update_policy_registry(id, attributes)
|
796
|
+
response = http_client.put("/admin/api/registry/policies/#{id}", body: attributes)
|
797
|
+
extract(entity: 'policy', from: response)
|
798
|
+
end
|
799
|
+
|
800
|
+
# @api public
|
801
|
+
# @param [Fixnum] id Policy Registry Id
|
802
|
+
def delete_policy_registry(id)
|
803
|
+
http_client.delete("/admin/api/registry/policies/#{id}")
|
804
|
+
true
|
805
|
+
end
|
806
|
+
|
807
|
+
# @api public
|
808
|
+
# @return [Hash]
|
809
|
+
def show_provider
|
810
|
+
response = http_client.get('/admin/api/provider')
|
811
|
+
extract(entity: 'account', from: response)
|
812
|
+
end
|
813
|
+
|
626
814
|
protected
|
627
815
|
|
628
816
|
def extract(collection: nil, entity:, from:)
|
data/lib/3scale/api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: 3scale-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michal Cichra
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-06-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|