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

Add region support to logentries logging endpoint #243

Merged
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
24 changes: 12 additions & 12 deletions fastly/fixtures/logentries/create.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
version: 1
interactions:
- request:
body: ServiceID=7i6HN3TK9wS159v2gPAZ8A&ServiceVersion=50&format=format&name=test-logentries&placement=waf_debug&port=1234&token=abcd1234&use_tls=1
body: ServiceID=7i6HN3TK9wS159v2gPAZ8A&ServiceVersion=113&format=format&name=test-logentries&placement=waf_debug&region=us&token=abcd1234&use_tls=1
form:
ServiceID:
- 7i6HN3TK9wS159v2gPAZ8A
ServiceVersion:
- "50"
- "113"
format:
- format
name:
- test-logentries
placement:
- waf_debug
port:
- "1234"
region:
- us
token:
- abcd1234
use_tls:
Expand All @@ -24,11 +24,11 @@ interactions:
Content-Type:
- application/x-www-form-urlencoded
User-Agent:
- FastlyGo/2.1.0 (+github.com/fastly/go-fastly; go1.15.4)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/50/logging/logentries
- FastlyGo/2.1.0 (+github.com/fastly/go-fastly; go1.15.2)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/113/logging/logentries
method: POST
response:
body: '{"format":"format","name":"test-logentries","placement":"waf_debug","port":"1234","token":"abcd1234","use_tls":"1","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":"50","hostname":"api.logentries.com","response_condition":"","format_version":"2","public_key":null,"region":null,"deleted_at":null,"updated_at":"2021-01-14T10:44:09Z","created_at":"2021-01-14T10:44:09Z"}'
body: '{"format":"format","name":"test-logentries","placement":"waf_debug","region":"us","token":"abcd1234","use_tls":"1","service_id":"7i6HN3TK9wS159v2gPAZ8A","version":"113","port":"0","hostname":null,"updated_at":"2021-01-19T16:02:30Z","public_key":null,"format_version":"2","response_condition":"","deleted_at":null,"created_at":"2021-01-19T16:02:30Z"}'
headers:
Accept-Ranges:
- bytes
Expand All @@ -37,11 +37,11 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 14 Jan 2021 10:44:10 GMT
- Tue, 19 Jan 2021 16:02:30 GMT
Fastly-Ratelimit-Remaining:
- "676"
- "998"
Fastly-Ratelimit-Reset:
- "1610622000"
- "1611075600"
Status:
- 200 OK
Strict-Transport-Security:
Expand All @@ -55,9 +55,9 @@ interactions:
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-control-slwdc9037-CONTROL-SLWDC, cache-man4120-MAN
- cache-control-slwdc9037-CONTROL-SLWDC, cache-den8268-DEN
X-Timer:
- S1610621050.830924,VS0,VE530
- S1611072150.865647,VS0,VE722
status: 200 OK
code: 200
duration: ""
14 changes: 7 additions & 7 deletions fastly/fixtures/logentries/delete.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ interactions:
form: {}
headers:
User-Agent:
- FastlyGo/2.1.0 (+github.com/fastly/go-fastly; go1.15.4)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/50/logging/logentries/new-test-logentries
- FastlyGo/2.1.0 (+github.com/fastly/go-fastly; go1.15.2)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/113/logging/logentries/new-test-logentries
method: DELETE
response:
body: '{"status":"ok"}'
Expand All @@ -19,11 +19,11 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 14 Jan 2021 10:44:11 GMT
- Tue, 19 Jan 2021 16:02:31 GMT
Fastly-Ratelimit-Remaining:
- "674"
- "996"
Fastly-Ratelimit-Reset:
- "1610622000"
- "1611075600"
Status:
- 200 OK
Strict-Transport-Security:
Expand All @@ -37,9 +37,9 @@ interactions:
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-control-slwdc9036-CONTROL-SLWDC, cache-man4120-MAN
- cache-control-slwdc9037-CONTROL-SLWDC, cache-den8268-DEN
X-Timer:
- S1610621052.574739,VS0,VE245
- S1611072152.662937,VS0,VE219
status: 200 OK
code: 200
duration: ""
12 changes: 6 additions & 6 deletions fastly/fixtures/logentries/get.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ interactions:
form: {}
headers:
User-Agent:
- FastlyGo/2.1.0 (+github.com/fastly/go-fastly; go1.15.4)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/50/logging/logentries/test-logentries
- FastlyGo/2.1.0 (+github.com/fastly/go-fastly; go1.15.2)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/113/logging/logentries/test-logentries
method: GET
response:
body: '{"service_id":"7i6HN3TK9wS159v2gPAZ8A","region":null,"name":"test-logentries","format_version":"2","updated_at":"2021-01-14T10:44:09Z","format":"format","response_condition":"","created_at":"2021-01-14T10:44:09Z","hostname":"api.logentries.com","deleted_at":null,"port":"1234","placement":"waf_debug","token":"abcd1234","version":"50","public_key":null,"use_tls":"1"}'
body: '{"deleted_at":null,"hostname":null,"version":"113","port":"0","token":"abcd1234","public_key":null,"response_condition":"","name":"test-logentries","updated_at":"2021-01-19T16:02:30Z","region":"us","placement":"waf_debug","created_at":"2021-01-19T16:02:30Z","service_id":"7i6HN3TK9wS159v2gPAZ8A","format":"format","format_version":"2","use_tls":"1"}'
headers:
Accept-Ranges:
- bytes
Expand All @@ -19,7 +19,7 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 14 Jan 2021 10:44:10 GMT
- Tue, 19 Jan 2021 16:02:30 GMT
Status:
- 200 OK
Strict-Transport-Security:
Expand All @@ -33,9 +33,9 @@ interactions:
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-control-slwdc9037-CONTROL-SLWDC, cache-man4120-MAN
- cache-control-slwdc9036-CONTROL-SLWDC, cache-den8268-DEN
X-Timer:
- S1610621051.678566,VS0,VE169
- S1611072151.841627,VS0,VE141
status: 200 OK
code: 200
duration: ""
12 changes: 6 additions & 6 deletions fastly/fixtures/logentries/list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ interactions:
form: {}
headers:
User-Agent:
- FastlyGo/2.1.0 (+github.com/fastly/go-fastly; go1.15.4)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/50/logging/logentries
- FastlyGo/2.1.0 (+github.com/fastly/go-fastly; go1.15.2)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/113/logging/logentries
method: GET
response:
body: '[{"use_tls":"1","port":"1234","public_key":null,"format_version":"2","format":"format","version":"50","updated_at":"2021-01-14T10:44:09Z","token":"abcd1234","placement":"waf_debug","region":null,"created_at":"2021-01-14T10:44:09Z","name":"test-logentries","response_condition":"","deleted_at":null,"hostname":"api.logentries.com","service_id":"7i6HN3TK9wS159v2gPAZ8A"}]'
body: '[{"format_version":"2","region":"us","name":"test-logentries","placement":"waf_debug","use_tls":"1","port":"0","updated_at":"2021-01-19T16:02:30Z","response_condition":"","version":"113","public_key":null,"deleted_at":null,"created_at":"2021-01-19T16:02:30Z","token":"abcd1234","hostname":null,"format":"format","service_id":"7i6HN3TK9wS159v2gPAZ8A"}]'
headers:
Accept-Ranges:
- bytes
Expand All @@ -19,7 +19,7 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 14 Jan 2021 10:44:10 GMT
- Tue, 19 Jan 2021 16:02:30 GMT
Status:
- 200 OK
Strict-Transport-Security:
Expand All @@ -33,9 +33,9 @@ interactions:
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-control-slwdc9035-CONTROL-SLWDC, cache-man4120-MAN
- cache-control-slwdc9037-CONTROL-SLWDC, cache-den8268-DEN
X-Timer:
- S1610621050.445759,VS0,VE189
- S1611072151.640918,VS0,VE152
status: 200 OK
code: 200
duration: ""
22 changes: 12 additions & 10 deletions fastly/fixtures/logentries/update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@
version: 1
interactions:
- request:
body: Name=test-logentries&ServiceID=7i6HN3TK9wS159v2gPAZ8A&ServiceVersion=50&format_version=2&name=new-test-logentries
body: Name=test-logentries&ServiceID=7i6HN3TK9wS159v2gPAZ8A&ServiceVersion=113&format_version=2&name=new-test-logentries&region=ap
form:
Name:
- test-logentries
ServiceID:
- 7i6HN3TK9wS159v2gPAZ8A
ServiceVersion:
- "50"
- "113"
format_version:
- "2"
name:
- new-test-logentries
region:
- ap
headers:
Content-Type:
- application/x-www-form-urlencoded
User-Agent:
- FastlyGo/2.1.0 (+github.com/fastly/go-fastly; go1.15.4)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/50/logging/logentries/test-logentries
- FastlyGo/2.1.0 (+github.com/fastly/go-fastly; go1.15.2)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version/113/logging/logentries/test-logentries
method: PUT
response:
body: '{"public_key":null,"format_version":"2","use_tls":"1","placement":"waf_debug","port":"1234","hostname":"api.logentries.com","created_at":"2021-01-14T10:44:09Z","token":"abcd1234","response_condition":"","version":"50","name":"new-test-logentries","updated_at":"2021-01-14T10:44:09Z","region":null,"deleted_at":null,"service_id":"7i6HN3TK9wS159v2gPAZ8A","format":"format"}'
body: '{"hostname":"","port":0,"name":"new-test-logentries","format_version":"2","use_tls":"1","region":"ap","deleted_at":null,"updated_at":"2021-01-19T16:02:30Z","public_key":null,"created_at":"2021-01-19T16:02:30Z","service_id":"7i6HN3TK9wS159v2gPAZ8A","placement":"waf_debug","version":"113","token":"abcd1234","response_condition":"","format":"format"}'
headers:
Accept-Ranges:
- bytes
Expand All @@ -31,11 +33,11 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 14 Jan 2021 10:44:11 GMT
- Tue, 19 Jan 2021 16:02:31 GMT
Fastly-Ratelimit-Remaining:
- "675"
- "997"
Fastly-Ratelimit-Reset:
- "1610622000"
- "1611075600"
Status:
- 200 OK
Strict-Transport-Security:
Expand All @@ -49,9 +51,9 @@ interactions:
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-control-slwdc9035-CONTROL-SLWDC, cache-man4120-MAN
- cache-control-slwdc9037-CONTROL-SLWDC, cache-den8268-DEN
X-Timer:
- S1610621051.870507,VS0,VE660
- S1611072151.024689,VS0,VE527
status: 200 OK
code: 200
duration: ""
14 changes: 7 additions & 7 deletions fastly/fixtures/logentries/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ interactions:
Content-Type:
- application/x-www-form-urlencoded
User-Agent:
- FastlyGo/2.1.0 (+github.com/fastly/go-fastly; go1.15.4)
- FastlyGo/2.1.0 (+github.com/fastly/go-fastly; go1.15.2)
url: https://api.fastly.com/service/7i6HN3TK9wS159v2gPAZ8A/version
method: POST
response:
body: '{"service_id":"7i6HN3TK9wS159v2gPAZ8A","number":50}'
body: '{"service_id":"7i6HN3TK9wS159v2gPAZ8A","number":113}'
headers:
Accept-Ranges:
- bytes
Expand All @@ -23,11 +23,11 @@ interactions:
Content-Type:
- application/json
Date:
- Thu, 14 Jan 2021 10:44:09 GMT
- Tue, 19 Jan 2021 16:02:29 GMT
Fastly-Ratelimit-Remaining:
- "677"
- "999"
Fastly-Ratelimit-Reset:
- "1610622000"
- "1611075600"
Status:
- 200 OK
Strict-Transport-Security:
Expand All @@ -41,9 +41,9 @@ interactions:
X-Cache-Hits:
- 0, 0
X-Served-By:
- cache-control-slwdc9037-CONTROL-SLWDC, cache-man4120-MAN
- cache-control-slwdc9037-CONTROL-SLWDC, cache-den8268-DEN
X-Timer:
- S1610621049.402860,VS0,VE285
- S1611072150.549924,VS0,VE263
status: 200 OK
code: 200
duration: ""
3 changes: 3 additions & 0 deletions fastly/logentries.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Logentries struct {
Format string `mapstructure:"format"`
FormatVersion uint `mapstructure:"format_version"`
ResponseCondition string `mapstructure:"response_condition"`
Region string `mapstructure:"region"`
CreatedAt *time.Time `mapstructure:"created_at"`
UpdatedAt *time.Time `mapstructure:"updated_at"`
DeletedAt *time.Time `mapstructure:"deleted_at"`
Expand Down Expand Up @@ -83,6 +84,7 @@ type CreateLogentriesInput struct {
Format string `form:"format,omitempty"`
FormatVersion uint `form:"format_version,omitempty"`
ResponseCondition string `form:"response_condition,omitempty"`
Region string `form:"region,omitempty"`
Placement string `form:"placement,omitempty"`
}

Expand Down Expand Up @@ -166,6 +168,7 @@ type UpdateLogentriesInput struct {
Format *string `form:"format,omitempty"`
FormatVersion *uint `form:"format_version,omitempty"`
ResponseCondition *string `form:"response_condition,omitempty"`
Region *string `form:"region,omitempty"`
Placement *string `form:"placement,omitempty"`
}

Expand Down
12 changes: 10 additions & 2 deletions fastly/logentries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ func TestClient_Logentries(t *testing.T) {
ServiceID: testServiceID,
ServiceVersion: tv.Number,
Name: "test-logentries",
Port: 1234,
Port: 0,
UseTLS: true,
Token: "abcd1234",
Format: "format",
Placement: "waf_debug",
Region: "us",
})
})
if err != nil {
Expand All @@ -49,7 +50,7 @@ func TestClient_Logentries(t *testing.T) {
if le.Name != "test-logentries" {
t.Errorf("bad name: %q", le.Name)
}
if le.Port != 1234 {
if le.Port != 0 {
t.Errorf("bad port: %q", le.Port)
}
if le.UseTLS != true {
Expand All @@ -67,6 +68,9 @@ func TestClient_Logentries(t *testing.T) {
if le.Placement != "waf_debug" {
t.Errorf("bad placement: %q", le.Placement)
}
if le.Region != "us" {
t.Errorf("bad region: %q", le.Region)
}

// List
var les []*Logentries
Expand Down Expand Up @@ -126,6 +130,7 @@ func TestClient_Logentries(t *testing.T) {
Name: "test-logentries",
NewName: String("new-test-logentries"),
FormatVersion: Uint(2),
Region: String("ap"),
Integralist marked this conversation as resolved.
Show resolved Hide resolved
})
})
if err != nil {
Expand All @@ -137,6 +142,9 @@ func TestClient_Logentries(t *testing.T) {
if ule.FormatVersion != 2 {
t.Errorf("bad format_version: %q", ule.FormatVersion)
}
if ule.Region != "ap" {
t.Errorf("bad region: %q", ule.Region)
}

// Delete
record(t, "logentries/delete", func(c *Client) {
Expand Down