-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
829 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed | ||
// under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
// Copyright 2016-present Datadog, Inc. | ||
|
||
// Package api provides test helpers to interact with the Datadog API | ||
package api | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
|
||
"github.com/DataDog/datadog-api-client-go/v2/api/datadog" | ||
|
||
"github.com/DataDog/datadog-agent/test/new-e2e/pkg/runner" | ||
"github.com/DataDog/datadog-agent/test/new-e2e/pkg/runner/parameters" | ||
) | ||
|
||
// Client represents the datadog API context | ||
type Client struct { | ||
api *datadog.APIClient | ||
ctx context.Context | ||
http http.Client | ||
apiKey string | ||
appKey string | ||
} | ||
|
||
// NewClient initialise a client with the API and APP keys | ||
func NewClient() *Client { | ||
apiKey, _ := runner.GetProfile().SecretStore().Get(parameters.APIKey) | ||
appKey, _ := runner.GetProfile().SecretStore().Get(parameters.APPKey) | ||
ctx := context.WithValue( | ||
context.Background(), | ||
datadog.ContextAPIKeys, | ||
map[string]datadog.APIKey{ | ||
"apiKeyAuth": { | ||
Key: apiKey, | ||
}, | ||
"appKeyAuth": { | ||
Key: appKey, | ||
}, | ||
}, | ||
) | ||
|
||
cfg := datadog.NewConfiguration() | ||
|
||
return &Client{ | ||
api: datadog.NewAPIClient(cfg), | ||
ctx: ctx, | ||
http: http.Client{}, | ||
apiKey: apiKey, | ||
appKey: appKey, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.