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

DXCDT-337: Add support for segment log stream #151

Merged
merged 3 commits into from
Jan 24, 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
12 changes: 11 additions & 1 deletion management/log_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const (
LogStreamTypeSumo = "sumo"
// LogStreamTypeMixpanel constant.
LogStreamTypeMixpanel = "mixpanel"
// LogStreamTypeSegment constant.
LogStreamTypeSegment = "segment"
)

// LogStream is used to export tenant log
Expand All @@ -34,7 +36,7 @@ type LogStream struct {
Name *string `json:"name,omitempty"`

// The type of the log-stream. Can be one of "http", "eventbridge",
// "eventgrid", "datadog" or "splunk".
// "eventgrid", "datadog", "splunk", "sumo", "mixpanel", "segment.
Type *string `json:"type,omitempty"`

// The status of the log-stream. Can be one of "active", "paused", or "suspended".
Expand Down Expand Up @@ -102,6 +104,8 @@ func (ls *LogStream) UnmarshalJSON(b []byte) error {
v = &LogStreamSinkSumo{}
case LogStreamTypeMixpanel:
v = &LogStreamSinkMixpanel{}
case LogStreamTypeSegment:
v = &LogStreamSinkSegment{}
default:
v = make(map[string]interface{})
}
Expand Down Expand Up @@ -161,6 +165,12 @@ type LogStreamSinkDatadog struct {
APIKey *string `json:"datadogApiKey,omitempty"`
}

// LogStreamSinkSegment is used to export logs to Segment.
type LogStreamSinkSegment struct {
// Segment Write Key
WriteKey *string `json:"segmentWriteKey,omitempty"`
}

// LogStreamSinkSplunk is used to export logs to Splunk.
type LogStreamSinkSplunk struct {
// Splunk Domain
Expand Down
10 changes: 10 additions & 0 deletions management/log_stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ var logStreamTestCases = []logStreamTestCase{
},
},
},
{
name: "Segment LogStream",
logStream: LogStream{
Name: auth0.Stringf("Test-LogStream-%d", time.Now().Unix()),
Type: auth0.String(LogStreamTypeSegment),
Sink: &LogStreamSinkSegment{
WriteKey: auth0.String("121233123455"),
},
},
},
{
name: "Splunk LogStream",
logStream: LogStream{
Expand Down
13 changes: 13 additions & 0 deletions management/management.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions management/management.gen_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
version: 1
interactions:
- request:
body: |
{"name":"Test-LogStream-1674586425","type":"segment","sink":{"segmentWriteKey":"121233123455"}}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/log-streams
method: POST
response:
body: '{"id":"lst_0000000000011465","name":"Test-LogStream-1674586425","type":"segment","status":"active","sink":{"segmentWriteKey":"121233123455"}}'
headers:
Access-Control-Expose-Headers:
- WWW-Authenticate,Server-Authorization
Content-Type:
- application/json; charset=utf-8
status: 200 OK
code: 200
duration: 1ms
- request:
body: ""
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/log-streams/lst_0000000000011465
method: DELETE
response:
body: ""
headers:
Access-Control-Expose-Headers:
- WWW-Authenticate,Server-Authorization
Content-Type:
- application/json; charset=utf-8
status: 204 No Content
code: 204
duration: 1ms
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
version: 1
interactions:
- request:
body: |
{"name":"Test-LogStream-1674586425","type":"segment","sink":{"segmentWriteKey":"121233123455"}}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/log-streams
method: POST
response:
body: '{"id":"lst_0000000000011468","name":"Test-LogStream-1674586425","type":"segment","status":"active","sink":{"segmentWriteKey":"121233123455"}}'
headers:
Access-Control-Expose-Headers:
- WWW-Authenticate,Server-Authorization
Content-Type:
- application/json; charset=utf-8
status: 200 OK
code: 200
duration: 1ms
- request:
body: ""
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/log-streams/lst_0000000000011468
method: DELETE
response:
body: ""
headers:
Access-Control-Expose-Headers:
- WWW-Authenticate,Server-Authorization
Content-Type:
- application/json; charset=utf-8
status: 204 No Content
code: 204
duration: 1ms
- request:
body: |
null
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/log-streams/lst_0000000000011468
method: GET
response:
body: '{"statusCode":404,"error":"Not Found","message":"The log stream does not exist."}'
headers:
Access-Control-Expose-Headers:
- WWW-Authenticate,Server-Authorization
Content-Type:
- application/json; charset=utf-8
status: 404 Not Found
code: 404
duration: 1ms
- request:
body: ""
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/log-streams/lst_0000000000011468
method: DELETE
response:
body: ""
headers:
Access-Control-Expose-Headers:
- WWW-Authenticate,Server-Authorization
Content-Type:
- application/json; charset=utf-8
status: 204 No Content
code: 204
duration: 1ms
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
version: 1
interactions:
- request:
body: |
{"name":"Test-LogStream-1674586425","type":"segment","sink":{"segmentWriteKey":"121233123455"}}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/log-streams
method: POST
response:
body: '{"id":"lst_0000000000011466","name":"Test-LogStream-1674586425","type":"segment","status":"active","sink":{"segmentWriteKey":"121233123455"}}'
headers:
Access-Control-Expose-Headers:
- WWW-Authenticate,Server-Authorization
Content-Type:
- application/json; charset=utf-8
status: 200 OK
code: 200
duration: 1ms
- request:
body: |
null
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/log-streams/lst_0000000000011466
method: GET
response:
body: '{"id":"lst_0000000000011466","name":"Test-LogStream-1674586425","type":"segment","status":"active","sink":{"segmentWriteKey":"121233123455"}}'
headers:
Access-Control-Expose-Headers:
- WWW-Authenticate,Server-Authorization
Content-Type:
- application/json; charset=utf-8
status: 200 OK
code: 200
duration: 1ms
- request:
body: ""
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/log-streams/lst_0000000000011466
method: DELETE
response:
body: ""
headers:
Access-Control-Expose-Headers:
- WWW-Authenticate,Server-Authorization
Content-Type:
- application/json; charset=utf-8
status: 204 No Content
code: 204
duration: 1ms
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
---
version: 1
interactions:
- request:
body: |
{"name":"Test-LogStream-1674586425","type":"segment","sink":{"segmentWriteKey":"121233123455"}}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/log-streams
method: POST
response:
body: '{"id":"lst_0000000000011467","name":"Test-LogStream-1674586425","type":"segment","status":"active","sink":{"segmentWriteKey":"121233123455"}}'
headers:
Access-Control-Expose-Headers:
- WWW-Authenticate,Server-Authorization
Content-Type:
- application/json; charset=utf-8
status: 200 OK
code: 200
duration: 1ms
- request:
body: |
{"filters":[{"name":"auth.login.fail","type":"category"}]}
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/log-streams/lst_0000000000011467
method: PATCH
response:
body: '{"id":"lst_0000000000011467","name":"Test-LogStream-1674586425","type":"segment","status":"active","sink":{"segmentWriteKey":"121233123455"},"filters":[{"name":"auth.login.fail","type":"category"}]}'
headers:
Access-Control-Expose-Headers:
- WWW-Authenticate,Server-Authorization
Content-Type:
- application/json; charset=utf-8
status: 200 OK
code: 200
duration: 1ms
- request:
body: |
null
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/log-streams/lst_0000000000011467
method: GET
response:
body: '{"id":"lst_0000000000011467","name":"Test-LogStream-1674586425","type":"segment","status":"active","sink":{"segmentWriteKey":"121233123455"},"filters":[{"name":"auth.login.fail","type":"category"}]}'
headers:
Access-Control-Expose-Headers:
- WWW-Authenticate,Server-Authorization
Content-Type:
- application/json; charset=utf-8
status: 200 OK
code: 200
duration: 1ms
- request:
body: ""
form: {}
headers:
Content-Type:
- application/json
User-Agent:
- Go-Auth0-SDK/latest
url: https://go-auth0-dev.eu.auth0.com/api/v2/log-streams/lst_0000000000011467
method: DELETE
response:
body: ""
headers:
Access-Control-Expose-Headers:
- WWW-Authenticate,Server-Authorization
Content-Type:
- application/json; charset=utf-8
status: 204 No Content
code: 204
duration: 1ms