contentful-management 2.5.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +50 -1
- data/lib/contentful/management/api_usage.rb +67 -0
- data/lib/contentful/management/client.rb +20 -0
- data/lib/contentful/management/client_api_usage_methods_factory.rb +44 -0
- data/lib/contentful/management/client_usage_period_methods_factory.rb +38 -0
- data/lib/contentful/management/organization.rb +16 -0
- data/lib/contentful/management/resource_builder.rb +4 -0
- data/lib/contentful/management/resource_requester.rb +6 -4
- data/lib/contentful/management/usage_period.rb +59 -0
- data/lib/contentful/management/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/api_usage/all.yml +155 -0
- data/spec/fixtures/vcr_cassettes/usage_period/all.yml +114 -0
- data/spec/lib/contentful/management/api_usage_spec.rb +28 -0
- data/spec/lib/contentful/management/usage_period_spec.rb +27 -0
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3cfd74c3a04e3793e905a34376d42fb480b87db5c90e54d139139f4487502dd3
|
4
|
+
data.tar.gz: 59e6df1fcb94c5f2d0bc5332ed47432c28fd0430df70a2a72b0bb14f484a20c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef4905fce5b2beedf604320370e9f90bdc1f784e8cf02f36bd831a11e73db29d55a9f67865481da39c38974bfa43f828266b7f031bfcde4da7cb9ff957aa59ec
|
7
|
+
data.tar.gz: bfb19ea973172df0fd8578eb780efd94a3ac931526b9e0646c9d9cac03e4bbeea0ad5a7faa5d5bc2154c8fc77b4cce85cdbc15bfce01b9a7dfabdc7a9b52f69e
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -8,6 +8,7 @@ Ruby client for the Contentful Content Management API.
|
|
8
8
|
## Setup
|
9
9
|
|
10
10
|
Add this line to your application's Gemfile:
|
11
|
+
|
11
12
|
```ruby
|
12
13
|
gem 'contentful-management'
|
13
14
|
```
|
@@ -15,7 +16,7 @@ gem 'contentful-management'
|
|
15
16
|
## Usage
|
16
17
|
|
17
18
|
### Examples
|
18
|
-
Some examples can be found in the
|
19
|
+
Some examples can be found in the `examples/` directory or you take a look at this [extended example script](https://github.com/contentful/cma_import_script).
|
19
20
|
|
20
21
|
### Client
|
21
22
|
|
@@ -597,12 +598,24 @@ Creating a locale:
|
|
597
598
|
environment.locales.create(name: 'German', code: 'de-DE')
|
598
599
|
```
|
599
600
|
|
601
|
+
Creating a locale with fallback:
|
602
|
+
|
603
|
+
```ruby
|
604
|
+
environment.locales.create(name: 'German', code: 'de-DE', fallback_code: 'en-US')
|
605
|
+
```
|
606
|
+
|
600
607
|
Updating a locale:
|
601
608
|
|
602
609
|
```ruby
|
603
610
|
blog_post_locale.update(name: 'German', code: 'de-DE')
|
604
611
|
```
|
605
612
|
|
613
|
+
Updating a locale with fallback:
|
614
|
+
|
615
|
+
```ruby
|
616
|
+
blog_post_locale.update(name: 'German', code: 'de-DE', fallback_code: 'en-US')
|
617
|
+
```
|
618
|
+
|
606
619
|
Destroying a locale:
|
607
620
|
|
608
621
|
```ruby
|
@@ -796,6 +809,42 @@ Retrieving all organization details:
|
|
796
809
|
organizations = client.organizations.all
|
797
810
|
```
|
798
811
|
|
812
|
+
### Usage Periods (ALPHA)
|
813
|
+
|
814
|
+
*Note*: This feature is available only to Commited v2 customers.
|
815
|
+
|
816
|
+
Retrieving all Usage Periods for an Organizations you belong to:
|
817
|
+
|
818
|
+
```ruby
|
819
|
+
usage_periods = client.usage_periods('organization_id').all
|
820
|
+
```
|
821
|
+
|
822
|
+
Alternatively, if you have an already fetched organization:
|
823
|
+
|
824
|
+
```ruby
|
825
|
+
usage_periods = organization.usage_periods().all()
|
826
|
+
```
|
827
|
+
|
828
|
+
### API Usage (ALPHA)
|
829
|
+
|
830
|
+
*Note*: This feature is available only to Commited v2 customers.
|
831
|
+
|
832
|
+
Retrieving all API Usage statistics for an Organizations during a given usage period, broken down by organization for all APIs:
|
833
|
+
|
834
|
+
```ruby
|
835
|
+
# Valid usage types are by 'organization' and by 'space'.
|
836
|
+
# Usage period IDs are numerical and can be fetched from the Usage Periods API.
|
837
|
+
# Valid API breakdowns are: 'cda', 'cpa', 'cma' or 'all_apis'.
|
838
|
+
usage = client.api_usage('organization_id').all('organization', usage_period_id, 'all_apis')
|
839
|
+
```
|
840
|
+
|
841
|
+
Alternatively, if you have an already fetched organization:
|
842
|
+
|
843
|
+
```ruby
|
844
|
+
# Breaking down CMA usage by space, for a given period.
|
845
|
+
usage = organization.api_usage().all('space', usage_period_id, 'cma')
|
846
|
+
```
|
847
|
+
|
799
848
|
### Users
|
800
849
|
|
801
850
|
Retrieving current user details:
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require_relative 'resource'
|
2
|
+
|
3
|
+
module Contentful
|
4
|
+
module Management
|
5
|
+
# Resource class for ApiUsage.
|
6
|
+
# @see _ https://www.contentful.com/developers/docs/references/content-management-api/#/reference/api-usages
|
7
|
+
class ApiUsage
|
8
|
+
include Contentful::Management::Resource
|
9
|
+
include Contentful::Management::Resource::Refresher
|
10
|
+
include Contentful::Management::Resource::SystemProperties
|
11
|
+
|
12
|
+
property :unitOfMeasure
|
13
|
+
property :interval
|
14
|
+
property :usage
|
15
|
+
property :startDate, :date
|
16
|
+
property :endDate, :date
|
17
|
+
|
18
|
+
# @private
|
19
|
+
def self.build_endpoint(endpoint_options)
|
20
|
+
organization_id = endpoint_options[:organization_id]
|
21
|
+
usage_type = endpoint_options[:usage_type]
|
22
|
+
|
23
|
+
"organizations/#{organization_id}/usages/#{usage_type}"
|
24
|
+
end
|
25
|
+
|
26
|
+
# Gets all api usage statistics for a given organization and usage type, filtered by usage period and api.
|
27
|
+
#
|
28
|
+
# @param [Contentful::Management::Client] client
|
29
|
+
# @param [String] organization_id
|
30
|
+
# @param [String] usage_type
|
31
|
+
# @param [Integer] usage_period_id
|
32
|
+
# @param [String] api
|
33
|
+
# @param [Hash] params
|
34
|
+
#
|
35
|
+
# @return [Contentful::Management::Array<Contentful::Management::ApiUsage>]
|
36
|
+
# rubocop:disable Metrics/ParameterLists
|
37
|
+
def self.all(client, organization_id, usage_type, usage_period_id, api, params = {})
|
38
|
+
ClientApiUsageMethodsFactory.new(client, organization_id).all(usage_type, usage_period_id, api, params)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Not supported
|
42
|
+
def self.find(*)
|
43
|
+
fail 'Not supported'
|
44
|
+
end
|
45
|
+
|
46
|
+
# @private
|
47
|
+
def self.endpoint
|
48
|
+
'usages'
|
49
|
+
end
|
50
|
+
|
51
|
+
# Not supported
|
52
|
+
def self.create(*)
|
53
|
+
fail 'Not supported'
|
54
|
+
end
|
55
|
+
|
56
|
+
# Not supported
|
57
|
+
def destroy
|
58
|
+
fail 'Not supported'
|
59
|
+
end
|
60
|
+
|
61
|
+
# Not supported
|
62
|
+
def update(*)
|
63
|
+
fail 'Not supported'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -20,7 +20,9 @@ require 'contentful/management/client_upload_methods_factory'
|
|
20
20
|
require 'contentful/management/client_api_key_methods_factory'
|
21
21
|
require 'contentful/management/client_webhook_methods_factory'
|
22
22
|
require 'contentful/management/client_snapshot_methods_factory'
|
23
|
+
require 'contentful/management/client_api_usage_methods_factory'
|
23
24
|
require 'contentful/management/client_environment_methods_factory'
|
25
|
+
require 'contentful/management/client_usage_period_methods_factory'
|
24
26
|
require 'contentful/management/client_organization_methods_factory'
|
25
27
|
require 'contentful/management/client_content_type_methods_factory'
|
26
28
|
require 'contentful/management/client_ui_extension_methods_factory'
|
@@ -131,6 +133,24 @@ module Contentful
|
|
131
133
|
ClientOrganizationMethodsFactory.new(self)
|
132
134
|
end
|
133
135
|
|
136
|
+
# Allows viewing of usage periods in context of the current client
|
137
|
+
# Allows listing all usage periods for client.
|
138
|
+
# @see _ README for details.
|
139
|
+
#
|
140
|
+
# @return [Contentful::Management::ClientUsagePeriodMethodsFactory]
|
141
|
+
def usage_periods(organization_id)
|
142
|
+
ClientUsagePeriodMethodsFactory.new(self, organization_id)
|
143
|
+
end
|
144
|
+
|
145
|
+
# Allows viewing of api usage in context of the current client
|
146
|
+
# Allows listing all api usage for client.
|
147
|
+
# @see _ README for details.
|
148
|
+
#
|
149
|
+
# @return [Contentful::Management::ClientApiUsageMethodsFactory]
|
150
|
+
def api_usage(organization_id)
|
151
|
+
ClientApiUsageMethodsFactory.new(self, organization_id)
|
152
|
+
end
|
153
|
+
|
134
154
|
# Allows viewing of users in context of the current client
|
135
155
|
# Allows listing all users for client.
|
136
156
|
# @see _ README for details.
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative 'client_association_methods_factory'
|
2
|
+
|
3
|
+
module Contentful
|
4
|
+
module Management
|
5
|
+
# Wrapper for API Usage for usage from within Client
|
6
|
+
# @private
|
7
|
+
class ClientApiUsageMethodsFactory
|
8
|
+
include Contentful::Management::ClientAssociationMethodsFactory
|
9
|
+
|
10
|
+
def initialize(client, organization_id)
|
11
|
+
super(client)
|
12
|
+
@organization_id = organization_id
|
13
|
+
end
|
14
|
+
|
15
|
+
def all(usage_type, usage_period_id, api, params = {})
|
16
|
+
mandatory_params = {
|
17
|
+
'filters[usagePeriod]' => usage_period_id,
|
18
|
+
'filters[metric]' => api
|
19
|
+
}
|
20
|
+
|
21
|
+
@resource_requester.all(
|
22
|
+
{
|
23
|
+
usage_type: usage_type,
|
24
|
+
organization_id: @organization_id
|
25
|
+
},
|
26
|
+
mandatory_params.merge(params),
|
27
|
+
'x-contentful-enable-alpha-feature' => 'usage-insights'
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def new(*)
|
32
|
+
fail 'Not supported'
|
33
|
+
end
|
34
|
+
|
35
|
+
def find(*)
|
36
|
+
fail 'Not supported'
|
37
|
+
end
|
38
|
+
|
39
|
+
def create(*)
|
40
|
+
fail 'Not supported'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative 'client_association_methods_factory'
|
2
|
+
|
3
|
+
module Contentful
|
4
|
+
module Management
|
5
|
+
# Wrapper for Usage Period for usage from within Client
|
6
|
+
# @private
|
7
|
+
class ClientUsagePeriodMethodsFactory
|
8
|
+
include Contentful::Management::ClientAssociationMethodsFactory
|
9
|
+
|
10
|
+
def initialize(client, organization_id)
|
11
|
+
super(client)
|
12
|
+
@organization_id = organization_id
|
13
|
+
end
|
14
|
+
|
15
|
+
def all(params = {})
|
16
|
+
@resource_requester.all(
|
17
|
+
{
|
18
|
+
organization_id: @organization_id
|
19
|
+
},
|
20
|
+
params,
|
21
|
+
'x-contentful-enable-alpha-feature' => 'usage-insights'
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def new(*)
|
26
|
+
fail 'Not supported'
|
27
|
+
end
|
28
|
+
|
29
|
+
def find(*)
|
30
|
+
fail 'Not supported'
|
31
|
+
end
|
32
|
+
|
33
|
+
def create(*)
|
34
|
+
fail 'Not supported'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -15,6 +15,22 @@ module Contentful
|
|
15
15
|
def self.build_endpoint(_endpoint_options)
|
16
16
|
'organizations'
|
17
17
|
end
|
18
|
+
|
19
|
+
# Allows listing all usage periods for organization.
|
20
|
+
# @see _ README for details.
|
21
|
+
#
|
22
|
+
# @return [Contentful::Management::ClientApiUsageMethodsFactory]
|
23
|
+
def usage_periods
|
24
|
+
ClientApiUsageMethodsFactory.new(client, id)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Allows listing all api usage for organization.
|
28
|
+
# @see _ README for details.
|
29
|
+
#
|
30
|
+
# @return [Contentful::Management::ClientApiUsageMethodsFactory]
|
31
|
+
def api_usage
|
32
|
+
ClientApiUsageMethodsFactory.new(client, id)
|
33
|
+
end
|
18
34
|
end
|
19
35
|
end
|
20
36
|
end
|
@@ -12,7 +12,9 @@ require_relative 'webhook'
|
|
12
12
|
require_relative 'api_key'
|
13
13
|
require_relative 'resource'
|
14
14
|
require_relative 'snapshot'
|
15
|
+
require_relative 'api_usage'
|
15
16
|
require_relative 'environment'
|
17
|
+
require_relative 'usage_period'
|
16
18
|
require_relative 'organization'
|
17
19
|
require_relative 'content_type'
|
18
20
|
require_relative 'webhook_call'
|
@@ -35,6 +37,8 @@ module Contentful
|
|
35
37
|
'Space' => Contentful::Management::Space,
|
36
38
|
'SpaceMembership' => Contentful::Management::SpaceMembership,
|
37
39
|
'Organization' => Contentful::Management::Organization,
|
40
|
+
'ApiUsage' => Contentful::Management::ApiUsage,
|
41
|
+
'UsagePeriod' => Contentful::Management::UsagePeriod,
|
38
42
|
'User' => Contentful::Management::User,
|
39
43
|
'Environment' => Contentful::Management::Environment,
|
40
44
|
'ContentType' => Contentful::Management::ContentType,
|
@@ -10,9 +10,9 @@ module Contentful
|
|
10
10
|
@resource_class = resource_class
|
11
11
|
end
|
12
12
|
|
13
|
-
def all(endpoint_options = {}, query = {})
|
13
|
+
def all(endpoint_options = {}, query = {}, headers = {})
|
14
14
|
query = resource_class.pre_process_params(query)
|
15
|
-
get(endpoint_options, query)
|
15
|
+
get(endpoint_options, query, headers)
|
16
16
|
end
|
17
17
|
|
18
18
|
def find(endpoint_options = {})
|
@@ -60,11 +60,13 @@ module Contentful
|
|
60
60
|
false
|
61
61
|
end
|
62
62
|
|
63
|
-
def get(endpoint_options = {}, query = {})
|
63
|
+
def get(endpoint_options = {}, query = {}, headers = {})
|
64
64
|
request = Request.new(
|
65
65
|
client,
|
66
66
|
resource_class.build_endpoint(endpoint_options),
|
67
|
-
query
|
67
|
+
query,
|
68
|
+
nil,
|
69
|
+
headers
|
68
70
|
)
|
69
71
|
ResourceBuilder.new(request.get, client).run
|
70
72
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require_relative 'resource'
|
2
|
+
|
3
|
+
module Contentful
|
4
|
+
module Management
|
5
|
+
# Resource class for UsagePeriod.
|
6
|
+
# @see _ https://www.contentful.com/developers/docs/references/content-management-api/#/reference/api-usages
|
7
|
+
class UsagePeriod
|
8
|
+
include Contentful::Management::Resource
|
9
|
+
include Contentful::Management::Resource::Refresher
|
10
|
+
include Contentful::Management::Resource::SystemProperties
|
11
|
+
|
12
|
+
property :startDate, :date
|
13
|
+
property :endDate, :date
|
14
|
+
|
15
|
+
# @private
|
16
|
+
def self.build_endpoint(endpoint_options)
|
17
|
+
organization_id = endpoint_options[:organization_id]
|
18
|
+
|
19
|
+
"organizations/#{organization_id}/usage_periods"
|
20
|
+
end
|
21
|
+
|
22
|
+
# Gets all usage periods for a given organization.
|
23
|
+
#
|
24
|
+
# @param [Contentful::Management::Client] client
|
25
|
+
# @param [String] organization_id
|
26
|
+
# @param [Hash] params
|
27
|
+
#
|
28
|
+
# @return [Contentful::Management::Array<Contentful::Management::UsagePeriod>]
|
29
|
+
def self.all(client, organization_id, params = {})
|
30
|
+
ClientUsagePeriodMethodsFactory.new(client, organization_id).all(params)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Not supported
|
34
|
+
def self.find(*)
|
35
|
+
fail 'Not supported'
|
36
|
+
end
|
37
|
+
|
38
|
+
# @private
|
39
|
+
def self.endpoint
|
40
|
+
'usages'
|
41
|
+
end
|
42
|
+
|
43
|
+
# Not supported
|
44
|
+
def self.create(*)
|
45
|
+
fail 'Not supported'
|
46
|
+
end
|
47
|
+
|
48
|
+
# Not supported
|
49
|
+
def destroy
|
50
|
+
fail 'Not supported'
|
51
|
+
end
|
52
|
+
|
53
|
+
# Not supported
|
54
|
+
def update(*)
|
55
|
+
fail 'Not supported'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.contentful.com/organizations/org_id/usages/organization?filters%5Bmetric%5D=cda&filters%5BusagePeriod%5D=1
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
X-Contentful-User-Agent:
|
11
|
+
- sdk contentful-management.rb/2.5.0; platform ruby/2.4.1; os macOS/16;
|
12
|
+
Authorization:
|
13
|
+
- Bearer <ACCESS_TOKEN>
|
14
|
+
Content-Type:
|
15
|
+
- application/vnd.contentful.management.v1+json
|
16
|
+
X-Contentful-Enable-Alpha-Feature:
|
17
|
+
- usage-insights
|
18
|
+
Connection:
|
19
|
+
- close
|
20
|
+
Host:
|
21
|
+
- api.contentful.com
|
22
|
+
User-Agent:
|
23
|
+
- http.rb/2.2.2
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 200
|
27
|
+
message: OK
|
28
|
+
headers:
|
29
|
+
Accept-Ranges:
|
30
|
+
- bytes
|
31
|
+
Access-Control-Allow-Headers:
|
32
|
+
- Accept,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation,X-Contentful-User-Agent,X-Contentful-Enable-Alpha-Feature
|
33
|
+
Access-Control-Allow-Methods:
|
34
|
+
- DELETE,GET,HEAD,POST,PUT,OPTIONS
|
35
|
+
Access-Control-Allow-Origin:
|
36
|
+
- "*"
|
37
|
+
Access-Control-Expose-Headers:
|
38
|
+
- Etag
|
39
|
+
Access-Control-Max-Age:
|
40
|
+
- '1728000'
|
41
|
+
Cache-Control:
|
42
|
+
- max-age=0
|
43
|
+
Content-Type:
|
44
|
+
- application/vnd.contentful.management.v1+json
|
45
|
+
Contentful-Api:
|
46
|
+
- cma
|
47
|
+
Date:
|
48
|
+
- Sat, 10 Nov 2018 10:47:53 GMT
|
49
|
+
Etag:
|
50
|
+
- W/"efdf341b30e8c442ecb1bfe1b7f21817"
|
51
|
+
Referrer-Policy:
|
52
|
+
- strict-origin-when-cross-origin
|
53
|
+
Server:
|
54
|
+
- Contentful
|
55
|
+
Strict-Transport-Security:
|
56
|
+
- max-age=15768000
|
57
|
+
X-Content-Type-Options:
|
58
|
+
- nosniff
|
59
|
+
X-Contentful-Request-Id:
|
60
|
+
- 26c4437bd5b8c12ee6b71ad955dd7339
|
61
|
+
X-Download-Options:
|
62
|
+
- noopen
|
63
|
+
X-Frame-Options:
|
64
|
+
- ALLOWALL
|
65
|
+
X-Permitted-Cross-Domain-Policies:
|
66
|
+
- none
|
67
|
+
X-Xss-Protection:
|
68
|
+
- 1; mode=block
|
69
|
+
Content-Length:
|
70
|
+
- '959'
|
71
|
+
Connection:
|
72
|
+
- Close
|
73
|
+
Set-Cookie:
|
74
|
+
- incap_ses_728_673446=17XUL5vN1wivb82OzmAaCli35lsAAAAAbBLg2M0OjfGoassR05osmA==;
|
75
|
+
path=/; Domain=.contentful.com
|
76
|
+
- nlbi_673446=r1SmH3jioiwG5xWr6lKYhQAAAAB3pI+2F+Uz7kJVuxNgDetk; path=/; Domain=.contentful.com
|
77
|
+
- visid_incap_673446=BbPQYzUTTGyyIO44A0XYili35lsAAAAAQUIPAAAAAABSSTQWr6HEWN7pTaZKxfmU;
|
78
|
+
expires=Sat, 09 Nov 2019 14:12:09 GMT; path=/; Domain=.contentful.com
|
79
|
+
X-Iinfo:
|
80
|
+
- 3-12615349-12615354 NNNN CT(0 0 0) RT(1541846872399 65) q(0 0 0 -1) r(1 1)
|
81
|
+
U5
|
82
|
+
X-Cdn:
|
83
|
+
- Incapsula
|
84
|
+
body:
|
85
|
+
encoding: ASCII-8BIT
|
86
|
+
string: |+
|
87
|
+
{
|
88
|
+
"total":1,
|
89
|
+
"limit":25,
|
90
|
+
"skip":0,
|
91
|
+
"sys":{
|
92
|
+
"type":"Array"
|
93
|
+
},
|
94
|
+
"items":[
|
95
|
+
{
|
96
|
+
"unitOfMeasure":"apiRequests",
|
97
|
+
"interval":"daily",
|
98
|
+
"usage":[
|
99
|
+
0,
|
100
|
+
0,
|
101
|
+
0,
|
102
|
+
0,
|
103
|
+
0,
|
104
|
+
0,
|
105
|
+
0,
|
106
|
+
0,
|
107
|
+
0,
|
108
|
+
0,
|
109
|
+
9423,
|
110
|
+
49300,
|
111
|
+
12546,
|
112
|
+
0,
|
113
|
+
0,
|
114
|
+
0,
|
115
|
+
0,
|
116
|
+
0,
|
117
|
+
0,
|
118
|
+
0,
|
119
|
+
0,
|
120
|
+
0,
|
121
|
+
0,
|
122
|
+
0,
|
123
|
+
0,
|
124
|
+
0,
|
125
|
+
0,
|
126
|
+
0,
|
127
|
+
0,
|
128
|
+
0,
|
129
|
+
0
|
130
|
+
],
|
131
|
+
"sys":{
|
132
|
+
"type":"ApiUsage",
|
133
|
+
"id":"1_org_id",
|
134
|
+
"organization":{
|
135
|
+
"sys":{
|
136
|
+
"type":"Link",
|
137
|
+
"linkType":"Organization",
|
138
|
+
"id":"org_id"
|
139
|
+
}
|
140
|
+
},
|
141
|
+
"usagePeriod":{
|
142
|
+
"sys":{
|
143
|
+
"type":"Link",
|
144
|
+
"linkType":"UsagePeriod",
|
145
|
+
"id":"1"
|
146
|
+
}
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
]
|
151
|
+
}
|
152
|
+
|
153
|
+
http_version:
|
154
|
+
recorded_at: Sat, 10 Nov 2018 10:47:53 GMT
|
155
|
+
recorded_with: VCR 4.0.0
|
@@ -0,0 +1,114 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.contentful.com/organizations/org_id/usage_periods
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
X-Contentful-User-Agent:
|
11
|
+
- sdk contentful-management.rb/2.5.0; platform ruby/2.4.1; os macOS/16;
|
12
|
+
Authorization:
|
13
|
+
- Bearer <ACCESS_TOKEN>
|
14
|
+
Content-Type:
|
15
|
+
- application/vnd.contentful.management.v1+json
|
16
|
+
X-Contentful-Enable-Alpha-Feature:
|
17
|
+
- usage-insights
|
18
|
+
Connection:
|
19
|
+
- close
|
20
|
+
Host:
|
21
|
+
- api.contentful.com
|
22
|
+
User-Agent:
|
23
|
+
- http.rb/2.2.2
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 200
|
27
|
+
message: OK
|
28
|
+
headers:
|
29
|
+
Accept-Ranges:
|
30
|
+
- bytes
|
31
|
+
Access-Control-Allow-Headers:
|
32
|
+
- Accept,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,Content-Type,DNT,Destination,Expires,If-Match,If-Modified-Since,If-None-Match,Keep-Alive,Last-Modified,Origin,Pragma,Range,User-Agent,X-Http-Method-Override,X-Mx-ReqToken,X-Requested-With,X-Contentful-Version,X-Contentful-Content-Type,X-Contentful-Organization,X-Contentful-Skip-Transformation,X-Contentful-User-Agent,X-Contentful-Enable-Alpha-Feature
|
33
|
+
Access-Control-Allow-Methods:
|
34
|
+
- DELETE,GET,HEAD,POST,PUT,OPTIONS
|
35
|
+
Access-Control-Allow-Origin:
|
36
|
+
- "*"
|
37
|
+
Access-Control-Expose-Headers:
|
38
|
+
- Etag
|
39
|
+
Access-Control-Max-Age:
|
40
|
+
- '1728000'
|
41
|
+
Cache-Control:
|
42
|
+
- max-age=0
|
43
|
+
Content-Type:
|
44
|
+
- application/vnd.contentful.management.v1+json
|
45
|
+
Contentful-Api:
|
46
|
+
- cma
|
47
|
+
Date:
|
48
|
+
- Sat, 10 Nov 2018 10:59:12 GMT
|
49
|
+
Etag:
|
50
|
+
- W/"0e32a37f3690af7bd68571521823b4c3"
|
51
|
+
Referrer-Policy:
|
52
|
+
- strict-origin-when-cross-origin
|
53
|
+
Server:
|
54
|
+
- Contentful
|
55
|
+
Strict-Transport-Security:
|
56
|
+
- max-age=15768000
|
57
|
+
X-Content-Type-Options:
|
58
|
+
- nosniff
|
59
|
+
X-Contentful-Request-Id:
|
60
|
+
- 9e2af1c902719cf6251824eb8bad9a5b
|
61
|
+
X-Download-Options:
|
62
|
+
- noopen
|
63
|
+
X-Frame-Options:
|
64
|
+
- ALLOWALL
|
65
|
+
X-Permitted-Cross-Domain-Policies:
|
66
|
+
- none
|
67
|
+
X-Xss-Protection:
|
68
|
+
- 1; mode=block
|
69
|
+
Content-Length:
|
70
|
+
- '347'
|
71
|
+
Connection:
|
72
|
+
- Close
|
73
|
+
Set-Cookie:
|
74
|
+
- incap_ses_728_673446=emwoQG4P7gsAZ9COzmAaCv+55lsAAAAA12p7HXlIfXdD2z8IqJzDPw==;
|
75
|
+
path=/; Domain=.contentful.com
|
76
|
+
- nlbi_673446=JuK/CqPU8mAD0NE+6lKYhQAAAAAeh+9STttZdZDE0eCH49c3; path=/; Domain=.contentful.com
|
77
|
+
- visid_incap_673446=3rYhv3e6Tf2l54SFmGsgOP+55lsAAAAAQUIPAAAAAAA6Tug0qWXjQ5TjaPxx4YJR;
|
78
|
+
expires=Sat, 09 Nov 2019 14:12:09 GMT; path=/; Domain=.contentful.com
|
79
|
+
X-Iinfo:
|
80
|
+
- 6-10352937-10352945 NNNN CT(90 182 0) RT(1541847550884 85) q(0 0 3 -1) r(5
|
81
|
+
5) U5
|
82
|
+
X-Cdn:
|
83
|
+
- Incapsula
|
84
|
+
body:
|
85
|
+
encoding: ASCII-8BIT
|
86
|
+
string: |+
|
87
|
+
{
|
88
|
+
"total":2,
|
89
|
+
"sys":{
|
90
|
+
"type":"Array"
|
91
|
+
},
|
92
|
+
"items":[
|
93
|
+
{
|
94
|
+
"startDate":"2018-11-01",
|
95
|
+
"endDate":null,
|
96
|
+
"sys":{
|
97
|
+
"type":"UsagePeriod",
|
98
|
+
"id":"2"
|
99
|
+
}
|
100
|
+
},
|
101
|
+
{
|
102
|
+
"startDate":"2018-10-01",
|
103
|
+
"endDate":"2018-10-31",
|
104
|
+
"sys":{
|
105
|
+
"type":"UsagePeriod",
|
106
|
+
"id":"1"
|
107
|
+
}
|
108
|
+
}
|
109
|
+
]
|
110
|
+
}
|
111
|
+
|
112
|
+
http_version:
|
113
|
+
recorded_at: Sat, 10 Nov 2018 10:59:12 GMT
|
114
|
+
recorded_with: VCR 4.0.0
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'contentful/management/space'
|
3
|
+
require 'contentful/management/client'
|
4
|
+
|
5
|
+
module Contentful
|
6
|
+
module Management
|
7
|
+
describe ApiKey do
|
8
|
+
let(:token) { ENV.fetch('CF_TEST_CMA_TOKEN', '<ACCESS_TOKEN>') }
|
9
|
+
let(:organization_id) { 'org_id' }
|
10
|
+
|
11
|
+
let!(:client) { Client.new(token ) }
|
12
|
+
|
13
|
+
subject { client.api_usage(organization_id) }
|
14
|
+
|
15
|
+
describe '.all' do
|
16
|
+
it 'class method also works' do
|
17
|
+
vcr('api_usage/all') { expect(Contentful::Management::ApiUsage.all(client, organization_id, 'organization', 1, 'cda')).to be_kind_of Contentful::Management::Array }
|
18
|
+
end
|
19
|
+
it 'returns a Contentful::Array' do
|
20
|
+
vcr('api_usage/all') { expect(subject.all('organization', 1, 'cda')).to be_kind_of Contentful::Management::Array }
|
21
|
+
end
|
22
|
+
it 'builds a Contentful::Management::ApiUsage object' do
|
23
|
+
vcr('api_usage/all') { expect(subject.all('organization', 1, 'cda').first).to be_kind_of Contentful::Management::ApiUsage }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'contentful/management/client'
|
3
|
+
|
4
|
+
module Contentful
|
5
|
+
module Management
|
6
|
+
describe ApiKey do
|
7
|
+
let(:token) { ENV.fetch('CF_TEST_CMA_TOKEN', '<ACCESS_TOKEN>') }
|
8
|
+
let(:organization_id) { 'org_id' }
|
9
|
+
|
10
|
+
let!(:client) { Client.new(token ) }
|
11
|
+
|
12
|
+
subject { client.usage_periods(organization_id) }
|
13
|
+
|
14
|
+
describe '.all' do
|
15
|
+
it 'class method also works' do
|
16
|
+
vcr('usage_period/all') { expect(Contentful::Management::UsagePeriod.all(client, organization_id)).to be_kind_of Contentful::Management::Array }
|
17
|
+
end
|
18
|
+
it 'returns a Contentful::Array' do
|
19
|
+
vcr('usage_period/all') { expect(subject.all).to be_kind_of Contentful::Management::Array }
|
20
|
+
end
|
21
|
+
it 'builds a Contentful::Management::UsagePeriod object' do
|
22
|
+
vcr('usage_period/all') { expect(subject.all.first).to be_kind_of Contentful::Management::UsagePeriod }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contentful-management
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Protas
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-11-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: http
|
@@ -293,10 +293,12 @@ files:
|
|
293
293
|
- examples/create_space.rb
|
294
294
|
- lib/contentful/management.rb
|
295
295
|
- lib/contentful/management/api_key.rb
|
296
|
+
- lib/contentful/management/api_usage.rb
|
296
297
|
- lib/contentful/management/array.rb
|
297
298
|
- lib/contentful/management/asset.rb
|
298
299
|
- lib/contentful/management/client.rb
|
299
300
|
- lib/contentful/management/client_api_key_methods_factory.rb
|
301
|
+
- lib/contentful/management/client_api_usage_methods_factory.rb
|
300
302
|
- lib/contentful/management/client_asset_methods_factory.rb
|
301
303
|
- lib/contentful/management/client_association_all_published_method_factory.rb
|
302
304
|
- lib/contentful/management/client_association_methods_factory.rb
|
@@ -314,6 +316,7 @@ files:
|
|
314
316
|
- lib/contentful/management/client_space_methods_factory.rb
|
315
317
|
- lib/contentful/management/client_ui_extension_methods_factory.rb
|
316
318
|
- lib/contentful/management/client_upload_methods_factory.rb
|
319
|
+
- lib/contentful/management/client_usage_period_methods_factory.rb
|
317
320
|
- lib/contentful/management/client_user_methods_factory.rb
|
318
321
|
- lib/contentful/management/client_webhook_call_methods_factory.rb
|
319
322
|
- lib/contentful/management/client_webhook_health_methods_factory.rb
|
@@ -374,6 +377,7 @@ files:
|
|
374
377
|
- lib/contentful/management/support.rb
|
375
378
|
- lib/contentful/management/ui_extension.rb
|
376
379
|
- lib/contentful/management/upload.rb
|
380
|
+
- lib/contentful/management/usage_period.rb
|
377
381
|
- lib/contentful/management/user.rb
|
378
382
|
- lib/contentful/management/validation.rb
|
379
383
|
- lib/contentful/management/version.rb
|
@@ -414,6 +418,7 @@ files:
|
|
414
418
|
- spec/fixtures/vcr_cassettes/api_key/find.yml
|
415
419
|
- spec/fixtures/vcr_cassettes/api_key/find_for_space_not_found.yml
|
416
420
|
- spec/fixtures/vcr_cassettes/api_key/preview.yml
|
421
|
+
- spec/fixtures/vcr_cassettes/api_usage/all.yml
|
417
422
|
- spec/fixtures/vcr_cassettes/array_page_1.yml
|
418
423
|
- spec/fixtures/vcr_cassettes/asset/143_assets_next_page.yml
|
419
424
|
- spec/fixtures/vcr_cassettes/asset/all.yml
|
@@ -703,6 +708,7 @@ files:
|
|
703
708
|
- spec/fixtures/vcr_cassettes/upload/destroy.yml
|
704
709
|
- spec/fixtures/vcr_cassettes/upload/find.yml
|
705
710
|
- spec/fixtures/vcr_cassettes/upload/find_not_found.yml
|
711
|
+
- spec/fixtures/vcr_cassettes/usage_period/all.yml
|
706
712
|
- spec/fixtures/vcr_cassettes/user/find.yml
|
707
713
|
- spec/fixtures/vcr_cassettes/webhook/all.yml
|
708
714
|
- spec/fixtures/vcr_cassettes/webhook/create.yml
|
@@ -720,6 +726,7 @@ files:
|
|
720
726
|
- spec/fixtures/vcr_cassettes/webhook_call/find_not_found.yml
|
721
727
|
- spec/fixtures/vcr_cassettes/webhook_health/find.yml
|
722
728
|
- spec/lib/contentful/management/api_key_spec.rb
|
729
|
+
- spec/lib/contentful/management/api_usage_spec.rb
|
723
730
|
- spec/lib/contentful/management/array_spec.rb
|
724
731
|
- spec/lib/contentful/management/asset_spec.rb
|
725
732
|
- spec/lib/contentful/management/client_spec.rb
|
@@ -737,6 +744,7 @@ files:
|
|
737
744
|
- spec/lib/contentful/management/space_spec.rb
|
738
745
|
- spec/lib/contentful/management/ui_extension_spec.rb
|
739
746
|
- spec/lib/contentful/management/upload_spec.rb
|
747
|
+
- spec/lib/contentful/management/usage_period_spec.rb
|
740
748
|
- spec/lib/contentful/management/user_spec.rb
|
741
749
|
- spec/lib/contentful/management/webhook_calls_spec.rb
|
742
750
|
- spec/lib/contentful/management/webhook_health_spec.rb
|
@@ -801,6 +809,7 @@ test_files:
|
|
801
809
|
- spec/fixtures/vcr_cassettes/api_key/find.yml
|
802
810
|
- spec/fixtures/vcr_cassettes/api_key/find_for_space_not_found.yml
|
803
811
|
- spec/fixtures/vcr_cassettes/api_key/preview.yml
|
812
|
+
- spec/fixtures/vcr_cassettes/api_usage/all.yml
|
804
813
|
- spec/fixtures/vcr_cassettes/array_page_1.yml
|
805
814
|
- spec/fixtures/vcr_cassettes/asset/143_assets_next_page.yml
|
806
815
|
- spec/fixtures/vcr_cassettes/asset/all.yml
|
@@ -1090,6 +1099,7 @@ test_files:
|
|
1090
1099
|
- spec/fixtures/vcr_cassettes/upload/destroy.yml
|
1091
1100
|
- spec/fixtures/vcr_cassettes/upload/find.yml
|
1092
1101
|
- spec/fixtures/vcr_cassettes/upload/find_not_found.yml
|
1102
|
+
- spec/fixtures/vcr_cassettes/usage_period/all.yml
|
1093
1103
|
- spec/fixtures/vcr_cassettes/user/find.yml
|
1094
1104
|
- spec/fixtures/vcr_cassettes/webhook/all.yml
|
1095
1105
|
- spec/fixtures/vcr_cassettes/webhook/create.yml
|
@@ -1107,6 +1117,7 @@ test_files:
|
|
1107
1117
|
- spec/fixtures/vcr_cassettes/webhook_call/find_not_found.yml
|
1108
1118
|
- spec/fixtures/vcr_cassettes/webhook_health/find.yml
|
1109
1119
|
- spec/lib/contentful/management/api_key_spec.rb
|
1120
|
+
- spec/lib/contentful/management/api_usage_spec.rb
|
1110
1121
|
- spec/lib/contentful/management/array_spec.rb
|
1111
1122
|
- spec/lib/contentful/management/asset_spec.rb
|
1112
1123
|
- spec/lib/contentful/management/client_spec.rb
|
@@ -1124,6 +1135,7 @@ test_files:
|
|
1124
1135
|
- spec/lib/contentful/management/space_spec.rb
|
1125
1136
|
- spec/lib/contentful/management/ui_extension_spec.rb
|
1126
1137
|
- spec/lib/contentful/management/upload_spec.rb
|
1138
|
+
- spec/lib/contentful/management/usage_period_spec.rb
|
1127
1139
|
- spec/lib/contentful/management/user_spec.rb
|
1128
1140
|
- spec/lib/contentful/management/webhook_calls_spec.rb
|
1129
1141
|
- spec/lib/contentful/management/webhook_health_spec.rb
|