Skip to content

Commit c994a97

Browse files
committed
CRED-2147: Regenerated client code from templates
1 parent 1f4e02d commit c994a97

File tree

5,655 files changed

+10248
-280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,655 files changed

+10248
-280
lines changed

api/datadog/client.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"strconv"
2727
"strings"
2828
"time"
29+
"unicode/utf8"
2930

3031
"golang.org/x/oauth2"
3132
)
@@ -87,12 +88,16 @@ func UseDelegatedTokenAuth(ctx context.Context, headerParams *map[string]string,
8788

8889
// SetAuthKeys sets the appropriate values in the headers parameter.
8990
func SetAuthKeys(ctx context.Context, headerParams *map[string]string, keys ...[2]string) {
90-
if ctx != nil {
91-
for _, key := range keys {
92-
if auth, ok := ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
93-
if apiKey, ok := auth[key[0]]; ok {
94-
(*headerParams)[key[1]] = apiKey.Key
95-
}
91+
if ctx == nil {
92+
return
93+
}
94+
if bearerToken, ok := ctx.Value(ContextBearerToken).(string); ok {
95+
(*headerParams)[authorizationHeader] = fmt.Sprintf(bearerTokenFormat, bearerToken)
96+
}
97+
for _, key := range keys {
98+
if auth, ok := ctx.Value(ContextAPIKeys).(map[string]APIKey); ok {
99+
if apiKey, ok := auth[key[0]]; ok {
100+
(*headerParams)[key[1]] = apiKey.Key
96101
}
97102
}
98103
}
@@ -181,6 +186,10 @@ func (c *APIClient) CallAPI(request *http.Request) (*http.Response, error) {
181186
dump = valueRegex.ReplaceAll(dump, []byte("REDACTED"))
182187
}
183188
}
189+
if bearerToken, ok := newRequest.Context().Value(ContextBearerToken).(string); ok {
190+
valueRegex := regexp.MustCompile(fmt.Sprintf("(?m)%s", bearerToken))
191+
dump = valueRegex.ReplaceAll(dump, []byte("REDACTED"))
192+
}
184193
log.Printf("\n%s\n", string(dump))
185194
}
186195
resp, requestErr := c.Cfg.HTTPClient.Do(newRequest)

api/datadog/configuration.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ var (
6262

6363
// ContextOperationServerVariables overrides a server configuration variables using operation specific values.
6464
ContextOperationServerVariables = contextKey("serverOperationVariables")
65+
66+
// ContextBearerToken takes a bearer token (e.g. PAT) as authentication for the request.
67+
ContextBearerToken = contextKey("bearerToken")
6568
)
6669

6770
// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth.
@@ -1081,6 +1084,9 @@ func NewDefaultContext(ctx context.Context) context.Context {
10811084
if apiKey, ok := os.LookupEnv("DD_APP_KEY"); ok {
10821085
keys["appKeyAuth"] = APIKey{Key: apiKey}
10831086
}
1087+
if bearerToken, ok := os.LookupEnv("DD_BEARER_TOKEN"); ok {
1088+
ctx = context.WithValue(ctx, ContextBearerToken, bearerToken)
1089+
}
10841090
ctx = context.WithValue(
10851091
ctx,
10861092
ContextAPIKeys,

api/datadog/utils.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"reflect"
1212
"strings"
1313
"time"
14-
"unicode/utf8"
1514

1615
"github.com/google/uuid"
1716
)

api/datadog/zstd.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package datadog
88

99
import (
1010
"bytes"
11-
1211
"github.com/DataDog/zstd"
1312
)
1413

api/datadogV1/api_authentication.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
package datadogV1
66

77
import (
8+
"bytes"
89
_context "context"
10+
_fmt "fmt"
11+
_io "io"
12+
_log "log"
913
_nethttp "net/http"
1014
_neturl "net/url"
1115

api/datadogV1/api_aws_integration.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
package datadogV1
66

77
import (
8+
"bytes"
89
_context "context"
10+
_fmt "fmt"
11+
_io "io"
12+
_log "log"
913
_nethttp "net/http"
1014
_neturl "net/url"
1115

api/datadogV1/api_aws_logs_integration.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
package datadogV1
66

77
import (
8+
"bytes"
89
_context "context"
10+
_fmt "fmt"
11+
_io "io"
12+
_log "log"
913
_nethttp "net/http"
1014
_neturl "net/url"
1115

api/datadogV1/api_azure_integration.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
package datadogV1
66

77
import (
8+
"bytes"
89
_context "context"
10+
_fmt "fmt"
11+
_io "io"
12+
_log "log"
913
_nethttp "net/http"
1014
_neturl "net/url"
1115

api/datadogV1/api_dashboard_lists.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
package datadogV1
66

77
import (
8+
"bytes"
89
_context "context"
10+
_fmt "fmt"
11+
_io "io"
12+
_log "log"
913
_nethttp "net/http"
1014
_neturl "net/url"
1115

api/datadogV1/api_dashboards.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
package datadogV1
66

77
import (
8+
"bytes"
89
_context "context"
10+
_fmt "fmt"
11+
_io "io"
12+
_log "log"
913
_nethttp "net/http"
1014
_neturl "net/url"
1115

0 commit comments

Comments
 (0)