Skip to content

Commit

Permalink
add event integrations and fragments, updates and testing needed (#468)
Browse files Browse the repository at this point in the history
* WIP: add event integrations and fragments, updates and testing needed

* cleanup fragments and fix tests

* latest WIP

* WIP: add event integrations and fragments, updates and testing needed

* cleanup fragments and fix tests

* latest WIP

---------

Co-authored-by: Rocktavious <[email protected]>
  • Loading branch information
davidbloss and rocktavious authored Oct 11, 2024
1 parent 5af528d commit 76ffa6b
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 18 deletions.
2 changes: 1 addition & 1 deletion cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestCache(t *testing.T) {
`{"data":{"account":{ "filters":{ "nodes":[{{ template "filter_1" }}] } }}}`,
)
testRequestEight := autopilot.NewTestRequest(
`query IntegrationList($after:String!$first:Int!){account{integrations(after: $after, first: $first){nodes{id,name,type,createdAt,installedAt,... on AwsIntegration{iamRole,externalId,awsTagsOverrideOwnership,ownershipTagKeys,regionOverride},... on AzureResourcesIntegration{aliases,ownershipTagKeys,subscriptionId,tagsOverrideOwnership,tenantId},... on NewRelicIntegration{baseUrl,accountKey},... on GoogleCloudIntegration{aliases,clientEmail,ownershipTagKeys,projects{id,name,url},tagsOverrideOwnership}},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}`,
`query IntegrationList($after:String!$first:Int!){account{integrations(after: $after, first: $first){nodes{{ template "integration_request" }},pageInfo{hasNextPage,hasPreviousPage,startCursor,endCursor},totalCount}}}`,
`{ "after": "", "first": 100 }`,
`{"data":{"account":{ "integrations":{ "nodes":[{{ template "integration_1" }}] } }}}`,
)
Expand Down
72 changes: 72 additions & 0 deletions enum.go

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

12 changes: 12 additions & 0 deletions input.go

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

34 changes: 31 additions & 3 deletions integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
)

type IntegrationId struct {
Id ID `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Id ID `json:"id"` // The unique identifier of the integration.
Name string `json:"name"` // The name of the integration.
Type string `json:"type"` // The type of the integration.
}

type AWSIntegrationFragment struct {
Expand Down Expand Up @@ -89,6 +89,20 @@ func (client *Client) CreateIntegrationAWS(input AWSIntegrationInput) (*Integrat
return m.Payload.Integration, HandleErrors(err, m.Payload.Errors)
}

func (client *Client) CreateEventIntegration(input EventIntegrationInput) (*Integration, error) {
var m struct {
Payload struct {
Integration *Integration
Errors []OpsLevelErrors
} `graphql:"eventIntegrationCreate(input: $input)"`
}
v := PayloadVariables{
"input": input,
}
err := client.Mutate(&m, v, WithName("EventIntegrationCreate"))
return m.Payload.Integration, HandleErrors(err, m.Payload.Errors)
}

func (client *Client) CreateIntegrationNewRelic(input NewRelicIntegrationInput) (*Integration, error) {
var m struct {
Payload struct {
Expand Down Expand Up @@ -160,6 +174,20 @@ func (client *Client) UpdateIntegrationAWS(identifier string, input AWSIntegrati
return m.Payload.Integration, HandleErrors(err, m.Payload.Errors)
}

func (client *Client) UpdateEventIntegration(input EventIntegrationUpdateInput) (*Integration, error) {
var m struct {
Payload struct {
Integration *Integration
Errors []OpsLevelErrors
} `graphql:"eventIntegrationUpdate(input: $input)"`
}
v := PayloadVariables{
"input": input,
}
err := client.Mutate(&m, v, WithName("EventIntegrationUpdate"))
return m.Payload.Integration, HandleErrors(err, m.Payload.Errors)
}

func (client *Client) UpdateIntegrationNewRelic(identifier string, input NewRelicIntegrationInput) (*Integration, error) {
var m struct {
Payload struct {
Expand Down
Loading

0 comments on commit 76ffa6b

Please sign in to comment.