Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(resource): implement Resource API #390

Merged
merged 5 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions fastly/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ var ErrMissingMonth = NewFieldError("Month")
// requires a "Name" key, but one was not set.
var ErrMissingName = NewFieldError("Name")

// ErrMissingResourceID is an error that is returned when an input struct
// requires a "ResourceID" key, but one was not set.
var ErrMissingResourceID = NewFieldError("ResourceID")

// ErrMissingNameValue is an error that is returned when an input struct
// requires a "Name" key, but one was not set.
var ErrMissingNameValue = NewFieldError("Name").Message("service name can't be an empty value")
Expand Down
33 changes: 33 additions & 0 deletions fastly/fixtures/resources/cleanup-object-store.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- FastlyGo/7.0.0 (+github.com/fastly/go-fastly; go1.16.15)
url: https://api.fastly.com/resources/stores/object/2dem3bjbpie7k1vyy70fh5
method: DELETE
response:
body: ""
headers:
Accept-Ranges:
- bytes
Date:
- Thu, 19 Jan 2023 11:28:16 GMT
Strict-Transport-Security:
- max-age=31536000
Via:
- 1.1 varnish
X-Cache:
- MISS
X-Cache-Hits:
- "0"
X-Served-By:
- cache-fty21339-FTY, cache-man4131-MAN
X-Timer:
- S1674127696.810292,VS0,VE563
status: 204 No Content
code: 204
duration: ""
47 changes: 47 additions & 0 deletions fastly/fixtures/resources/cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- FastlyGo/7.0.0 (+github.com/fastly/go-fastly; go1.16.15)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/5/resource/rn6c7YSyRxBJMejpyvoQa1
method: DELETE
response:
body: '{"msg":"Record not found","detail":"Couldn''t find Link ''{ deleted =\u003e
0000-00-00 00:00:00, id =\u003e rn6c7YSyRxBJMejpyvoQa1, service =\u003e 7i6HN3TK9wS159v2gPAZ8A,
version =\u003e 5 }''"}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Thu, 19 Jan 2023 11:28:15 GMT
Fastly-Ratelimit-Remaining:
- "9990"
Fastly-Ratelimit-Reset:
- "1674129600"
Status:
- 404 Not Found
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
Via:
- 1.1 varnish, 1.1 varnish
X-Cache:
- MISS, MISS
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-control-cp-aws-us-east-1-prod-5-CONTROL-AWS, cache-man4131-MAN
X-Timer:
- S1674127695.461054,VS0,VE322
status: 404 Not Found
code: 404
duration: ""
39 changes: 39 additions & 0 deletions fastly/fixtures/resources/create-object-store.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
version: 1
interactions:
- request:
body: '{"name":"test-object-store"}'
form: {}
headers:
Accept:
- application/json
Content-Type:
- application/json
User-Agent:
- FastlyGo/7.0.0 (+github.com/fastly/go-fastly; go1.16.15)
url: https://api.fastly.com/resources/stores/object
method: POST
response:
body: '{"id":"2dem3bjbpie7k1vyy70fh5","name":"test-object-store","created_at":"2023-01-19T11:28:13.754Z","updated_at":"2023-01-19T11:28:13.754Z"}'
headers:
Accept-Ranges:
- bytes
Content-Type:
- application/json
Date:
- Thu, 19 Jan 2023 11:28:13 GMT
Strict-Transport-Security:
- max-age=31536000
Via:
- 1.1 varnish
X-Cache:
- MISS
X-Cache-Hits:
- "0"
X-Served-By:
- cache-fty21339-FTY, cache-man4131-MAN
X-Timer:
- S1674127692.140623,VS0,VE1665
status: 201 Created
code: 201
duration: ""
51 changes: 51 additions & 0 deletions fastly/fixtures/resources/create.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
version: 1
interactions:
- request:
body: name=test-object-store-name-for-linking&resource_id=2dem3bjbpie7k1vyy70fh5
form:
name:
- test-object-store-name-for-linking
resource_id:
- 2dem3bjbpie7k1vyy70fh5
headers:
Content-Type:
- application/x-www-form-urlencoded
User-Agent:
- FastlyGo/7.0.0 (+github.com/fastly/go-fastly; go1.16.15)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/5/resource
method: POST
response:
body: '{"id":"rn6c7YSyRxBJMejpyvoQa1","name":"test-object-store-name-for-linking","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":5,"created_at":"2023-01-19T11:28:14Z","updated_at":"2023-01-19T11:28:14Z","deleted_at":null,"resource_id":"2dem3bjbpie7k1vyy70fh5","resource_type":"object-store","href":null}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Thu, 19 Jan 2023 11:28:14 GMT
Fastly-Ratelimit-Remaining:
- "9993"
Fastly-Ratelimit-Reset:
- "1674129600"
Status:
- 200 OK
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
Via:
- 1.1 varnish, 1.1 varnish
X-Cache:
- MISS, MISS
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-control-cp-aws-us-east-1-prod-3-CONTROL-AWS, cache-man4131-MAN
X-Timer:
- S1674127694.832397,VS0,VE381
status: 200 OK
code: 200
duration: ""
45 changes: 45 additions & 0 deletions fastly/fixtures/resources/delete.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- FastlyGo/7.0.0 (+github.com/fastly/go-fastly; go1.16.15)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/5/resource/rn6c7YSyRxBJMejpyvoQa1
method: DELETE
response:
body: '{"status":"ok"}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Thu, 19 Jan 2023 11:28:15 GMT
Fastly-Ratelimit-Remaining:
- "9991"
Fastly-Ratelimit-Reset:
- "1674129600"
Status:
- 200 OK
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
Via:
- 1.1 varnish, 1.1 varnish
X-Cache:
- MISS, MISS
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-control-cp-aws-us-east-1-prod-5-CONTROL-AWS, cache-man4131-MAN
X-Timer:
- S1674127695.215445,VS0,VE220
status: 200 OK
code: 200
duration: ""
41 changes: 41 additions & 0 deletions fastly/fixtures/resources/get.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- FastlyGo/7.0.0 (+github.com/fastly/go-fastly; go1.16.15)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/5/resource/rn6c7YSyRxBJMejpyvoQa1
method: GET
response:
body: '{"id":"rn6c7YSyRxBJMejpyvoQa1","name":"test-object-store-name-for-linking","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":5,"created_at":"2023-01-19T11:28:14Z","updated_at":"2023-01-19T11:28:14Z","deleted_at":null,"resource_id":"2dem3bjbpie7k1vyy70fh5","resource_type":"object-store","href":null}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Thu, 19 Jan 2023 11:28:14 GMT
Status:
- 200 OK
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
Via:
- 1.1 varnish, 1.1 varnish
X-Cache:
- MISS, MISS
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-control-cp-aws-us-east-1-prod-3-CONTROL-AWS, cache-man4131-MAN
X-Timer:
- S1674127695.594823,VS0,VE341
status: 200 OK
code: 200
duration: ""
41 changes: 41 additions & 0 deletions fastly/fixtures/resources/list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
version: 1
interactions:
- request:
body: ""
form: {}
headers:
User-Agent:
- FastlyGo/7.0.0 (+github.com/fastly/go-fastly; go1.16.15)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/5/resource
method: GET
response:
body: '[{"id":"rn6c7YSyRxBJMejpyvoQa1","name":"test-object-store-name-for-linking","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":5,"created_at":"2023-01-19T11:28:14Z","updated_at":"2023-01-19T11:28:14Z","deleted_at":null,"resource_id":"2dem3bjbpie7k1vyy70fh5","resource_type":"object-store","href":null}]'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Thu, 19 Jan 2023 11:28:14 GMT
Status:
- 200 OK
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
Via:
- 1.1 varnish, 1.1 varnish
X-Cache:
- MISS, MISS
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-control-cp-aws-us-east-1-prod-1-CONTROL-AWS, cache-man4131-MAN
X-Timer:
- S1674127694.241459,VS0,VE328
status: 200 OK
code: 200
duration: ""
49 changes: 49 additions & 0 deletions fastly/fixtures/resources/update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
version: 1
interactions:
- request:
body: name=new-object-store-alias-for-my-service
form:
name:
- new-object-store-alias-for-my-service
headers:
Content-Type:
- application/x-www-form-urlencoded
User-Agent:
- FastlyGo/7.0.0 (+github.com/fastly/go-fastly; go1.16.15)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/5/resource/rn6c7YSyRxBJMejpyvoQa1
method: PUT
response:
body: '{"id":"rn6c7YSyRxBJMejpyvoQa1","name":"new-object-store-alias-for-my-service","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":5,"created_at":"2023-01-19T11:28:14Z","updated_at":"2023-01-19T11:28:14Z","deleted_at":null,"resource_id":"2dem3bjbpie7k1vyy70fh5","resource_type":"object-store","href":null}'
headers:
Accept-Ranges:
- bytes
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Thu, 19 Jan 2023 11:28:15 GMT
Fastly-Ratelimit-Remaining:
- "9992"
Fastly-Ratelimit-Reset:
- "1674129600"
Status:
- 200 OK
Strict-Transport-Security:
- max-age=31536000
Vary:
- Accept-Encoding
Via:
- 1.1 varnish, 1.1 varnish
X-Cache:
- MISS, MISS
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-control-cp-aws-us-east-1-prod-1-CONTROL-AWS, cache-man4131-MAN
X-Timer:
- S1674127695.965974,VS0,VE222
status: 200 OK
code: 200
duration: ""
Loading