contentful-management 2.9.1 → 2.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +40 -0
  3. data/README.md +30 -13
  4. data/contentful-management.gemspec +6 -5
  5. data/lib/contentful/management/client.rb +10 -12
  6. data/lib/contentful/management/{client_usage_period_methods_factory.rb → client_organization_periodic_usage_methods_factory.rb} +3 -4
  7. data/lib/contentful/management/client_space_methods_factory.rb +2 -2
  8. data/lib/contentful/management/{client_api_usage_methods_factory.rb → client_space_periodic_usage_methods_factory.rb} +4 -11
  9. data/lib/contentful/management/entry.rb +14 -12
  10. data/lib/contentful/management/field.rb +3 -1
  11. data/lib/contentful/management/organization.rb +18 -8
  12. data/lib/contentful/management/{api_usage.rb → organization_periodic_usage.rb} +13 -18
  13. data/lib/contentful/management/organization_user_methods_factory.rb +18 -0
  14. data/lib/contentful/management/resource.rb +3 -2
  15. data/lib/contentful/management/resource/environment_aware.rb +11 -8
  16. data/lib/contentful/management/resource_builder.rb +4 -4
  17. data/lib/contentful/management/space.rb +12 -2
  18. data/lib/contentful/management/{usage_period.rb → space_periodic_usage.rb} +12 -9
  19. data/lib/contentful/management/space_user_methods_factory.rb +19 -0
  20. data/lib/contentful/management/user.rb +7 -1
  21. data/lib/contentful/management/validation.rb +6 -1
  22. data/lib/contentful/management/version.rb +1 -1
  23. data/spec/fixtures/vcr_cassettes/asset/196_environment_id.yml +140 -0
  24. data/spec/fixtures/vcr_cassettes/content_type/196_retain_environment_id.yml +150 -0
  25. data/spec/fixtures/vcr_cassettes/entry/issue_215_1.yml +905 -0
  26. data/spec/fixtures/vcr_cassettes/entry/issue_215_2.yml +899 -0
  27. data/spec/fixtures/vcr_cassettes/entry/issue_215_3.yml +893 -0
  28. data/spec/fixtures/vcr_cassettes/organization/user.yml +238 -0
  29. data/spec/fixtures/vcr_cassettes/organization_periodic_usage/all.yml +368 -0
  30. data/spec/fixtures/vcr_cassettes/organization_periodic_usage/filters.yml +167 -0
  31. data/spec/fixtures/vcr_cassettes/space/user.yml +254 -0
  32. data/spec/fixtures/vcr_cassettes/space_periodic_usage/all.yml +6800 -0
  33. data/spec/fixtures/vcr_cassettes/space_periodic_usage/filters.yml +1976 -0
  34. data/spec/lib/contentful/management/asset_spec.rb +8 -0
  35. data/spec/lib/contentful/management/content_type_spec.rb +6 -0
  36. data/spec/lib/contentful/management/entry_spec.rb +48 -0
  37. data/spec/lib/contentful/management/organization_periodic_usage_spec.rb +36 -0
  38. data/spec/lib/contentful/management/organization_spec.rb +20 -0
  39. data/spec/lib/contentful/management/space_periodic_usage_spec.rb +36 -0
  40. data/spec/lib/contentful/management/space_spec.rb +20 -0
  41. metadata +68 -34
  42. data/spec/fixtures/vcr_cassettes/api_usage/all.yml +0 -155
  43. data/spec/fixtures/vcr_cassettes/usage_period/all.yml +0 -114
  44. data/spec/lib/contentful/management/api_usage_spec.rb +0 -28
  45. data/spec/lib/contentful/management/usage_period_spec.rb +0 -27
@@ -1,155 +0,0 @@
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
@@ -1,114 +0,0 @@
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
@@ -1,28 +0,0 @@
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
@@ -1,27 +0,0 @@
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