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

Update AWS integration endpoints #274

Merged
merged 5 commits into from
Oct 23, 2019
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
155 changes: 155 additions & 0 deletions datadog-accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -10089,6 +10089,161 @@ func (i *IntegrationAWSAccountDeleteRequest) SetRoleName(v string) {
i.RoleName = &v
}

// GetLambdaARN returns the LambdaARN field if non-nil, zero value otherwise.
func (i *IntegrationAWSLambdaARN) GetLambdaARN() string {
bkabrda marked this conversation as resolved.
Show resolved Hide resolved
if i == nil || i.LambdaARN == nil {
return ""
}
return *i.LambdaARN
}

// GetLambdaARNOk returns a tuple with the LambdaARN field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (i *IntegrationAWSLambdaARN) GetLambdaARNOk() (string, bool) {
if i == nil || i.LambdaARN == nil {
return "", false
}
return *i.LambdaARN, true
}

// HasLambdaARN returns a boolean if a field has been set.
func (i *IntegrationAWSLambdaARN) HasLambdaARN() bool {
if i != nil && i.LambdaARN != nil {
return true
}

return false
}

// SetLambdaARN allocates a new i.LambdaARN and returns the pointer to it.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't allocate anything nor return anything.

Suggested change
// SetLambdaARN allocates a new i.LambdaARN and returns the pointer to it.
// SetLambdaARN set LambdaARN to point to the given string.

func (i *IntegrationAWSLambdaARN) SetLambdaARN(v string) {
i.LambdaARN = &v
}

// GetAccountID returns the AccountID field if non-nil, zero value otherwise.
func (i *IntegrationAWSLambdaARNRequest) GetAccountID() string {
bkabrda marked this conversation as resolved.
Show resolved Hide resolved
if i == nil || i.AccountID == nil {
return ""
}
return *i.AccountID
}

// GetAccountIDOk returns a tuple with the AccountID field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (i *IntegrationAWSLambdaARNRequest) GetAccountIDOk() (string, bool) {
if i == nil || i.AccountID == nil {
return "", false
}
return *i.AccountID, true
}

// HasAccountID returns a boolean if a field has been set.
func (i *IntegrationAWSLambdaARNRequest) HasAccountID() bool {
if i != nil && i.AccountID != nil {
return true
}

return false
}

// SetAccountID allocates a new i.AccountID and returns the pointer to it.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't allocate anything nor return anything.

Suggested change
// SetAccountID allocates a new i.AccountID and returns the pointer to it.
// SetAccountID set AccountID to point to the given string.

func (i *IntegrationAWSLambdaARNRequest) SetAccountID(v string) {
i.AccountID = &v
}

// GetLambdaARN returns the LambdaARN field if non-nil, zero value otherwise.
func (i *IntegrationAWSLambdaARNRequest) GetLambdaARN() string {
bkabrda marked this conversation as resolved.
Show resolved Hide resolved
if i == nil || i.LambdaARN == nil {
return ""
}
return *i.LambdaARN
}

// GetLambdaARNOk returns a tuple with the LambdaARN field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (i *IntegrationAWSLambdaARNRequest) GetLambdaARNOk() (string, bool) {
if i == nil || i.LambdaARN == nil {
return "", false
}
return *i.LambdaARN, true
}

// HasLambdaARN returns a boolean if a field has been set.
func (i *IntegrationAWSLambdaARNRequest) HasLambdaARN() bool {
if i != nil && i.LambdaARN != nil {
return true
}

return false
}

// SetLambdaARN allocates a new i.LambdaARN and returns the pointer to it.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't allocate anything nor return anything.

Suggested change
// SetLambdaARN allocates a new i.LambdaARN and returns the pointer to it.
// SetLambdaARN set LambdaARN to point to the given string.

func (i *IntegrationAWSLambdaARNRequest) SetLambdaARN(v string) {
i.LambdaARN = &v
}

// GetAccountID returns the AccountID field if non-nil, zero value otherwise.
func (i *IntegrationAWSLogCollection) GetAccountID() string {
bkabrda marked this conversation as resolved.
Show resolved Hide resolved
if i == nil || i.AccountID == nil {
return ""
}
return *i.AccountID
}

// GetAccountIDOk returns a tuple with the AccountID field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (i *IntegrationAWSLogCollection) GetAccountIDOk() (string, bool) {
if i == nil || i.AccountID == nil {
return "", false
}
return *i.AccountID, true
}

// HasAccountID returns a boolean if a field has been set.
func (i *IntegrationAWSLogCollection) HasAccountID() bool {
if i != nil && i.AccountID != nil {
return true
}

return false
}

// SetAccountID allocates a new i.AccountID and returns the pointer to it.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't allocate anything nor return anything.

Suggested change
// SetAccountID allocates a new i.AccountID and returns the pointer to it.
// SetAccountID set AccountID to point to the given string.

func (i *IntegrationAWSLogCollection) SetAccountID(v string) {
i.AccountID = &v
}

// GetAccountID returns the AccountID field if non-nil, zero value otherwise.
func (i *IntegrationAWSServicesLogCollection) GetAccountID() string {
bkabrda marked this conversation as resolved.
Show resolved Hide resolved
if i == nil || i.AccountID == nil {
return ""
}
return *i.AccountID
}

// GetAccountIDOk returns a tuple with the AccountID field if it's non-nil, zero value otherwise
// and a boolean to check if the value has been set.
func (i *IntegrationAWSServicesLogCollection) GetAccountIDOk() (string, bool) {
if i == nil || i.AccountID == nil {
return "", false
}
return *i.AccountID, true
}

// HasAccountID returns a boolean if a field has been set.
func (i *IntegrationAWSServicesLogCollection) HasAccountID() bool {
if i != nil && i.AccountID != nil {
return true
}

return false
}

// SetAccountID allocates a new i.AccountID and returns the pointer to it.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't allocate anything nor return anything.

Suggested change
// SetAccountID allocates a new i.AccountID and returns the pointer to it.
// SetAccountID set AccountID to point to the given string.

func (i *IntegrationAWSServicesLogCollection) SetAccountID(v string) {
i.AccountID = &v
}

// GetClientEmail returns the ClientEmail field if non-nil, zero value otherwise.
func (i *IntegrationGCP) GetClientEmail() string {
if i == nil || i.ClientEmail == nil {
Expand Down
57 changes: 57 additions & 0 deletions integrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

package datadog

import "net/url"

/*
PagerDuty Integration
*/
Expand Down Expand Up @@ -185,6 +187,28 @@ type IntegrationAWSAccountDeleteRequest struct {
RoleName *string `json:"role_name"`
}

type IntegrationAWSLambdaARNRequest struct {
AccountID *string `json:"account_id"`
LambdaARN *string `json:"lambda_arn"`
}

// IntegrationAWSLambdaARN is only defined to properly parse the AWS logs GET response
type IntegrationAWSLambdaARN struct {
LambdaARN *string `json:"arn"`
}

type IntegrationAWSServicesLogCollection struct {
AccountID *string `json:"account_id"`
Services []string `json:"services"`
}

// IntegrationAWSLogs is only defined to properly parse the AWS logs GET response
type IntegrationAWSLogCollection struct {
AccountID *string `json:"account_id"`
LambdaARNs []IntegrationAWSLambdaARN `json:"lambdas"`
Services []string `json:"services"`
}

// CreateIntegrationAWS adds a new AWS Account in the AWS Integrations.
// Use this if you want to setup the integration for the first time
// or to add more accounts.
Expand All @@ -197,6 +221,14 @@ func (client *Client) CreateIntegrationAWS(awsAccount *IntegrationAWSAccount) (*
return &out, nil
}

// UpdateIntegrationAWS updates an already existing AWS Account in the AWS Integration
func (client *Client) UpdateIntegrationAWS(awsAccount *IntegrationAWSAccount) error {
additionalParameters := url.Values{}
additionalParameters.Set("account_id", *awsAccount.AccountID)
additionalParameters.Add("role_name", *awsAccount.RoleName)
return client.doJsonRequest("PUT", "/v1/integration/aws?"+additionalParameters.Encode(), awsAccount, nil)
}

// GetIntegrationAWS gets all the AWS Accounts in the AWS Integrations from Datadog.
func (client *Client) GetIntegrationAWS() (*[]IntegrationAWSAccount, error) {
var response IntegrationAWSAccountGetResponse
Expand All @@ -212,6 +244,31 @@ func (client *Client) DeleteIntegrationAWS(awsAccount *IntegrationAWSAccountDele
return client.doJsonRequest("DELETE", "/v1/integration/aws", awsAccount, nil)
}

// AttachLambdaARNIntegrationAWS attach a lambda ARN to an AWS account ID to enable log collection
func (client *Client) AttachLambdaARNIntegrationAWS(lambdaARN *IntegrationAWSLambdaARNRequest) error {
return client.doJsonRequest("POST", "/v1/integration/aws/logs", lambdaARN, nil)
}

// EnableLogCollectionAWSServices enables the log collection for the given AWS services
func (client *Client) EnableLogCollectionAWSServices(services *IntegrationAWSServicesLogCollection) error {
return client.doJsonRequest("POST", "/v1/integration/aws/logs/services", services, nil)
}

// GetIntegrationAWSLogCollection gets all the configuration for the AWS log collection
func (client *Client) GetIntegrationAWSLogCollection() (*[]IntegrationAWSLogCollection, error) {
var response []IntegrationAWSLogCollection
if err := client.doJsonRequest("GET", "/v1/integration/aws/logs", nil, &response); err != nil {
return nil, err
}

return &response, nil
}

// DeleteAWSLogCollection removes the log collection configuration for a given ARN and AWS account
func (client *Client) DeleteAWSLogCollection(lambdaARN *IntegrationAWSLambdaARNRequest) error {
return client.doJsonRequest("DELETE", "/v1/integration/aws/logs", lambdaARN, nil)
}

/*
Google Cloud Platform Integration
*/
Expand Down