From 703c4d3bbb52c950a70d54ecfb47eca9e1465125 Mon Sep 17 00:00:00 2001 From: Chad Richts Date: Wed, 30 Oct 2024 19:18:25 +0000 Subject: [PATCH 1/3] Fix a bug in the integration resource --- .../cassettes/TestIntegration_Basic.yaml | 236 +---------- jupiterone/internal/client/generated.go | 376 ++++++++++++------ .../internal/client/integration.graphql | 50 ++- jupiterone/resource_integration.go | 127 +++++- 4 files changed, 418 insertions(+), 371 deletions(-) diff --git a/jupiterone/cassettes/TestIntegration_Basic.yaml b/jupiterone/cassettes/TestIntegration_Basic.yaml index 654c9ed4..2797c38e 100644 --- a/jupiterone/cassettes/TestIntegration_Basic.yaml +++ b/jupiterone/cassettes/TestIntegration_Basic.yaml @@ -1,237 +1,3 @@ --- version: 2 -interactions: - - id: 0 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 801 - transfer_encoding: [] - trailer: {} - host: graphql.us.jupiterone.io - remote_addr: "" - request_uri: "" - body: '{"query":"\nmutation CreateIntegrationInstance ($instance: CreateIntegrationInstanceInput!) {\n\tcreateIntegrationInstance(instance: $instance) {\n\t\tid\n\t\tname\n\t\taccountId\n\t\tsourceIntegrationInstanceId\n\t\tpollingInterval\n\t\tintegrationDefinitionId\n\t\tdescription\n\t\tconfig\n\t\toffsiteComplete\n\t\tinstanceRelationship\n\t\tcollectorPoolId\n\t}\n}\n","variables":{"instance":{"name":"tf-acc-test-4853679450963121774","sourceIntegrationInstanceId":"","pollingInterval":"ONE_DAY","pollingIntervalCronExpression":{"hour":0,"dayOfWeek":0},"integrationDefinitionId":"8013680b-311a-4c2e-b53b-c8735fd97a5c","description":"Test integration","config":{"key":"value"},"offsiteComplete":false,"ingestionSourcesOverrides":null,"collectorPoolId":""}},"operationName":"CreateIntegrationInstance"}' - form: {} - headers: - Cache-Control: - - no-cache - Content-Type: - - application/json - url: https://graphql.us.jupiterone.io/ - method: POST - response: - proto: HTTP/2.0 - proto_major: 2 - proto_minor: 0 - transfer_encoding: [] - trailer: {} - content_length: 418 - uncompressed: false - body: | - {"data":{"createIntegrationInstance":{"id":"38a5fb06-0882-4877-9d64-03ba1d4f0aaa","name":"tf-acc-test-4853679450963121774","accountId":"j1dev","sourceIntegrationInstanceId":"","pollingInterval":"ONE_DAY","integrationDefinitionId":"8013680b-311a-4c2e-b53b-c8735fd97a5c","description":"Test integration","config":{"key":"***masked***"},"offsiteComplete":false,"instanceRelationship":"STANDALONE","collectorPoolId":""}}} - headers: - Access-Control-Allow-Credentials: - - "true" - Content-Length: - - "418" - Content-Security-Policy: - - 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self'' https: data:;form-action ''self'';frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests' - Content-Type: - - application/json - Cross-Origin-Embedder-Policy: - - require-corp - Cross-Origin-Opener-Policy: - - same-origin - Cross-Origin-Resource-Policy: - - same-origin - Expect-Ct: - - max-age=0 - Origin-Agent-Cluster: - - ?1 - Ratelimit-Limit: - - "1000" - Ratelimit-Remaining: - - "999" - Ratelimit-Requested: - - "1" - Ratelimit-Reset: - - "1" - Referrer-Policy: - - no-referrer - Strict-Transport-Security: - - max-age=15552000; includeSubDomains - Vary: - - Origin - X-Content-Type-Options: - - nosniff - X-Dns-Prefetch-Control: - - "off" - X-Download-Options: - - noopen - X-Frame-Options: - - SAMEORIGIN - X-Permitted-Cross-Domain-Policies: - - none - X-Xss-Protection: - - "0" - status: 200 OK - code: 200 - duration: 1.086208834s - - id: 1 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 415 - transfer_encoding: [] - trailer: {} - host: graphql.us.jupiterone.io - remote_addr: "" - request_uri: "" - body: '{"query":"\nquery GetIntegrationInstance ($id: String!) {\n\tintegrationInstance(id: $id) {\n\t\tid\n\t\tname\n\t\taccountId\n\t\tsourceIntegrationInstanceId\n\t\tpollingInterval\n\t\tintegrationDefinitionId\n\t\tdescription\n\t\tconfig\n\t\toffsiteComplete\n\t\tinstanceRelationship\n\t\tcollectorPoolId\n\t}\n}\n","variables":{"id":"38a5fb06-0882-4877-9d64-03ba1d4f0aaa"},"operationName":"GetIntegrationInstance"}' - form: {} - headers: - Cache-Control: - - no-cache - Content-Type: - - application/json - url: https://graphql.us.jupiterone.io/ - method: POST - response: - proto: HTTP/2.0 - proto_major: 2 - proto_minor: 0 - transfer_encoding: [] - trailer: {} - content_length: 412 - uncompressed: false - body: | - {"data":{"integrationInstance":{"id":"38a5fb06-0882-4877-9d64-03ba1d4f0aaa","name":"tf-acc-test-4853679450963121774","accountId":"j1dev","sourceIntegrationInstanceId":"","pollingInterval":"ONE_DAY","integrationDefinitionId":"8013680b-311a-4c2e-b53b-c8735fd97a5c","description":"Test integration","config":{"key":"***masked***"},"offsiteComplete":false,"instanceRelationship":"STANDALONE","collectorPoolId":""}}} - headers: - Access-Control-Allow-Credentials: - - "true" - Content-Length: - - "412" - Content-Security-Policy: - - 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self'' https: data:;form-action ''self'';frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests' - Content-Type: - - application/json - Cross-Origin-Embedder-Policy: - - require-corp - Cross-Origin-Opener-Policy: - - same-origin - Cross-Origin-Resource-Policy: - - same-origin - Expect-Ct: - - max-age=0 - Origin-Agent-Cluster: - - ?1 - Ratelimit-Limit: - - "1000" - Ratelimit-Remaining: - - "999" - Ratelimit-Requested: - - "1" - Ratelimit-Reset: - - "1" - Referrer-Policy: - - no-referrer - Strict-Transport-Security: - - max-age=15552000; includeSubDomains - Vary: - - Origin - X-Content-Type-Options: - - nosniff - X-Dns-Prefetch-Control: - - "off" - X-Download-Options: - - noopen - X-Frame-Options: - - SAMEORIGIN - X-Permitted-Cross-Domain-Policies: - - none - X-Xss-Protection: - - "0" - status: 200 OK - code: 200 - duration: 556.113ms - - id: 2 - request: - proto: HTTP/1.1 - proto_major: 1 - proto_minor: 1 - content_length: 230 - transfer_encoding: [] - trailer: {} - host: graphql.us.jupiterone.io - remote_addr: "" - request_uri: "" - body: '{"query":"\nmutation DeleteIntegrationInstance ($id: String!) {\n\tdeleteIntegrationInstance(id: $id) {\n\t\tsuccess\n\t}\n}\n","variables":{"id":"38a5fb06-0882-4877-9d64-03ba1d4f0aaa"},"operationName":"DeleteIntegrationInstance"}' - form: {} - headers: - Cache-Control: - - no-cache - Content-Type: - - application/json - url: https://graphql.us.jupiterone.io/ - method: POST - response: - proto: HTTP/2.0 - proto_major: 2 - proto_minor: 0 - transfer_encoding: [] - trailer: {} - content_length: 56 - uncompressed: false - body: | - {"data":{"deleteIntegrationInstance":{"success":true}}} - headers: - Access-Control-Allow-Credentials: - - "true" - Content-Length: - - "56" - Content-Security-Policy: - - 'default-src ''self'';base-uri ''self'';block-all-mixed-content;font-src ''self'' https: data:;form-action ''self'';frame-ancestors ''self'';img-src ''self'' data:;object-src ''none'';script-src ''self'';script-src-attr ''none'';style-src ''self'' https: ''unsafe-inline'';upgrade-insecure-requests' - Content-Type: - - application/json - Cross-Origin-Embedder-Policy: - - require-corp - Cross-Origin-Opener-Policy: - - same-origin - Cross-Origin-Resource-Policy: - - same-origin - Expect-Ct: - - max-age=0 - Origin-Agent-Cluster: - - ?1 - Ratelimit-Limit: - - "1000" - Ratelimit-Remaining: - - "999" - Ratelimit-Requested: - - "1" - Ratelimit-Reset: - - "1" - Referrer-Policy: - - no-referrer - Strict-Transport-Security: - - max-age=15552000; includeSubDomains - Vary: - - Origin - X-Content-Type-Options: - - nosniff - X-Dns-Prefetch-Control: - - "off" - X-Download-Options: - - noopen - X-Frame-Options: - - SAMEORIGIN - X-Permitted-Cross-Domain-Policies: - - none - X-Xss-Protection: - - "0" - status: 200 OK - code: 200 - duration: 619.06675ms +interactions: [] diff --git a/jupiterone/internal/client/generated.go b/jupiterone/internal/client/generated.go index 90ce32a2..706b3a63 100644 --- a/jupiterone/internal/client/generated.go +++ b/jupiterone/internal/client/generated.go @@ -459,7 +459,6 @@ type CreateInlineQuestionRuleInstanceInput struct { Question RuleQuestionDetailsInput `json:"question"` Templates map[string]interface{} `json:"templates"` Tags []string `json:"tags"` - Labels []RuleInstanceLabelInput `json:"labels"` Name string `json:"name"` Description string `json:"description"` SpecVersion int `json:"specVersion"` @@ -470,6 +469,8 @@ type CreateInlineQuestionRuleInstanceInput struct { TriggerActionsOnNewEntitiesOnly bool `json:"triggerActionsOnNewEntitiesOnly"` IgnorePreviousResults bool `json:"ignorePreviousResults"` RemediationSteps string `json:"remediationSteps"` + CollectionId string `json:"collectionId"` + Labels []RuleInstanceLabelInput `json:"labels"` J1Internal bool `json:"j1Internal"` } @@ -486,9 +487,6 @@ func (v *CreateInlineQuestionRuleInstanceInput) GetTemplates() map[string]interf // GetTags returns CreateInlineQuestionRuleInstanceInput.Tags, and is useful for accessing the field via an interface. func (v *CreateInlineQuestionRuleInstanceInput) GetTags() []string { return v.Tags } -// GetLabels returns CreateInlineQuestionRuleInstanceInput.Labels, and is useful for accessing the field via an interface. -func (v *CreateInlineQuestionRuleInstanceInput) GetLabels() []RuleInstanceLabelInput { return v.Labels } - // GetName returns CreateInlineQuestionRuleInstanceInput.Name, and is useful for accessing the field via an interface. func (v *CreateInlineQuestionRuleInstanceInput) GetName() string { return v.Name } @@ -529,6 +527,12 @@ func (v *CreateInlineQuestionRuleInstanceInput) GetRemediationSteps() string { return v.RemediationSteps } +// GetCollectionId returns CreateInlineQuestionRuleInstanceInput.CollectionId, and is useful for accessing the field via an interface. +func (v *CreateInlineQuestionRuleInstanceInput) GetCollectionId() string { return v.CollectionId } + +// GetLabels returns CreateInlineQuestionRuleInstanceInput.Labels, and is useful for accessing the field via an interface. +func (v *CreateInlineQuestionRuleInstanceInput) GetLabels() []RuleInstanceLabelInput { return v.Labels } + // GetJ1Internal returns CreateInlineQuestionRuleInstanceInput.J1Internal, and is useful for accessing the field via an interface. func (v *CreateInlineQuestionRuleInstanceInput) GetJ1Internal() bool { return v.J1Internal } @@ -726,17 +730,17 @@ func (v *CreateInsightsWidgetInput) GetConfig() CreateInsightsWidgetConfigInput // CreateIntegrationInstanceCreateIntegrationInstance includes the requested fields of the GraphQL type IntegrationInstance. type CreateIntegrationInstanceCreateIntegrationInstance struct { - Id string `json:"id"` - Name string `json:"name"` - AccountId string `json:"accountId"` - SourceIntegrationInstanceId string `json:"sourceIntegrationInstanceId"` - PollingInterval IntegrationPollingInterval `json:"pollingInterval"` - IntegrationDefinitionId string `json:"integrationDefinitionId"` - Description string `json:"description"` - Config map[string]interface{} `json:"config"` - OffsiteComplete bool `json:"offsiteComplete"` - InstanceRelationship IntegrationInstanceRelationship `json:"instanceRelationship"` - CollectorPoolId string `json:"collectorPoolId"` + Id string `json:"id"` + Name string `json:"name"` + PollingInterval IntegrationPollingInterval `json:"pollingInterval"` + IntegrationDefinitionId string `json:"integrationDefinitionId"` + Description string `json:"description"` + Config map[string]interface{} `json:"config"` + IngestionSourcesOverrides []CreateIntegrationInstanceCreateIntegrationInstanceIngestionSourcesOverrides `json:"ingestionSourcesOverrides"` + SourceIntegrationInstanceId string `json:"sourceIntegrationInstanceId"` + CollectorPoolId string `json:"collectorPoolId"` + PollingIntervalCronExpression CreateIntegrationInstanceCreateIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression `json:"pollingIntervalCronExpression"` + OffsiteComplete bool `json:"offsiteComplete"` } // GetId returns CreateIntegrationInstanceCreateIntegrationInstance.Id, and is useful for accessing the field via an interface. @@ -745,16 +749,6 @@ func (v *CreateIntegrationInstanceCreateIntegrationInstance) GetId() string { re // GetName returns CreateIntegrationInstanceCreateIntegrationInstance.Name, and is useful for accessing the field via an interface. func (v *CreateIntegrationInstanceCreateIntegrationInstance) GetName() string { return v.Name } -// GetAccountId returns CreateIntegrationInstanceCreateIntegrationInstance.AccountId, and is useful for accessing the field via an interface. -func (v *CreateIntegrationInstanceCreateIntegrationInstance) GetAccountId() string { - return v.AccountId -} - -// GetSourceIntegrationInstanceId returns CreateIntegrationInstanceCreateIntegrationInstance.SourceIntegrationInstanceId, and is useful for accessing the field via an interface. -func (v *CreateIntegrationInstanceCreateIntegrationInstance) GetSourceIntegrationInstanceId() string { - return v.SourceIntegrationInstanceId -} - // GetPollingInterval returns CreateIntegrationInstanceCreateIntegrationInstance.PollingInterval, and is useful for accessing the field via an interface. func (v *CreateIntegrationInstanceCreateIntegrationInstance) GetPollingInterval() IntegrationPollingInterval { return v.PollingInterval @@ -775,14 +769,14 @@ func (v *CreateIntegrationInstanceCreateIntegrationInstance) GetConfig() map[str return v.Config } -// GetOffsiteComplete returns CreateIntegrationInstanceCreateIntegrationInstance.OffsiteComplete, and is useful for accessing the field via an interface. -func (v *CreateIntegrationInstanceCreateIntegrationInstance) GetOffsiteComplete() bool { - return v.OffsiteComplete +// GetIngestionSourcesOverrides returns CreateIntegrationInstanceCreateIntegrationInstance.IngestionSourcesOverrides, and is useful for accessing the field via an interface. +func (v *CreateIntegrationInstanceCreateIntegrationInstance) GetIngestionSourcesOverrides() []CreateIntegrationInstanceCreateIntegrationInstanceIngestionSourcesOverrides { + return v.IngestionSourcesOverrides } -// GetInstanceRelationship returns CreateIntegrationInstanceCreateIntegrationInstance.InstanceRelationship, and is useful for accessing the field via an interface. -func (v *CreateIntegrationInstanceCreateIntegrationInstance) GetInstanceRelationship() IntegrationInstanceRelationship { - return v.InstanceRelationship +// GetSourceIntegrationInstanceId returns CreateIntegrationInstanceCreateIntegrationInstance.SourceIntegrationInstanceId, and is useful for accessing the field via an interface. +func (v *CreateIntegrationInstanceCreateIntegrationInstance) GetSourceIntegrationInstanceId() string { + return v.SourceIntegrationInstanceId } // GetCollectorPoolId returns CreateIntegrationInstanceCreateIntegrationInstance.CollectorPoolId, and is useful for accessing the field via an interface. @@ -790,17 +784,59 @@ func (v *CreateIntegrationInstanceCreateIntegrationInstance) GetCollectorPoolId( return v.CollectorPoolId } +// GetPollingIntervalCronExpression returns CreateIntegrationInstanceCreateIntegrationInstance.PollingIntervalCronExpression, and is useful for accessing the field via an interface. +func (v *CreateIntegrationInstanceCreateIntegrationInstance) GetPollingIntervalCronExpression() CreateIntegrationInstanceCreateIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression { + return v.PollingIntervalCronExpression +} + +// GetOffsiteComplete returns CreateIntegrationInstanceCreateIntegrationInstance.OffsiteComplete, and is useful for accessing the field via an interface. +func (v *CreateIntegrationInstanceCreateIntegrationInstance) GetOffsiteComplete() bool { + return v.OffsiteComplete +} + +// CreateIntegrationInstanceCreateIntegrationInstanceIngestionSourcesOverrides includes the requested fields of the GraphQL type IngestionSourcesOverrides. +type CreateIntegrationInstanceCreateIntegrationInstanceIngestionSourcesOverrides struct { + IngestionSourceId string `json:"ingestionSourceId"` + Enabled bool `json:"enabled"` +} + +// GetIngestionSourceId returns CreateIntegrationInstanceCreateIntegrationInstanceIngestionSourcesOverrides.IngestionSourceId, and is useful for accessing the field via an interface. +func (v *CreateIntegrationInstanceCreateIntegrationInstanceIngestionSourcesOverrides) GetIngestionSourceId() string { + return v.IngestionSourceId +} + +// GetEnabled returns CreateIntegrationInstanceCreateIntegrationInstanceIngestionSourcesOverrides.Enabled, and is useful for accessing the field via an interface. +func (v *CreateIntegrationInstanceCreateIntegrationInstanceIngestionSourcesOverrides) GetEnabled() bool { + return v.Enabled +} + +// CreateIntegrationInstanceCreateIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression includes the requested fields of the GraphQL type IntegrationPollingIntervalCronExpression. +type CreateIntegrationInstanceCreateIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression struct { + Hour int `json:"hour"` + DayOfWeek int `json:"dayOfWeek"` +} + +// GetHour returns CreateIntegrationInstanceCreateIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression.Hour, and is useful for accessing the field via an interface. +func (v *CreateIntegrationInstanceCreateIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression) GetHour() int { + return v.Hour +} + +// GetDayOfWeek returns CreateIntegrationInstanceCreateIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression.DayOfWeek, and is useful for accessing the field via an interface. +func (v *CreateIntegrationInstanceCreateIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression) GetDayOfWeek() int { + return v.DayOfWeek +} + type CreateIntegrationInstanceInput struct { Name string `json:"name"` - SourceIntegrationInstanceId string `json:"sourceIntegrationInstanceId"` + SourceIntegrationInstanceId string `json:"sourceIntegrationInstanceId,omitempty"` PollingInterval IntegrationPollingInterval `json:"pollingInterval"` - PollingIntervalCronExpression IntegrationPollingIntervalCronExpressionInput `json:"pollingIntervalCronExpression"` + PollingIntervalCronExpression IntegrationPollingIntervalCronExpressionInput `json:"pollingIntervalCronExpression,omitempty"` IntegrationDefinitionId string `json:"integrationDefinitionId"` Description string `json:"description"` Config map[string]interface{} `json:"config"` - OffsiteComplete bool `json:"offsiteComplete"` - IngestionSourcesOverrides []IngestionSourcesOverridesInput `json:"ingestionSourcesOverrides"` - CollectorPoolId string `json:"collectorPoolId"` + OffsiteComplete bool `json:"offsiteComplete,omitempty"` + IngestionSourcesOverrides []IngestionSourcesOverridesInput `json:"ingestionSourcesOverrides,omitempty"` + CollectorPoolId string `json:"collectorPoolId,omitempty"` } // GetName returns CreateIntegrationInstanceInput.Name, and is useful for accessing the field via an interface. @@ -954,6 +990,8 @@ type CreateReferencedQuestionRuleInstanceInput struct { TriggerActionsOnNewEntitiesOnly bool `json:"triggerActionsOnNewEntitiesOnly"` IgnorePreviousResults bool `json:"ignorePreviousResults"` RemediationSteps string `json:"remediationSteps"` + CollectionId string `json:"collectionId"` + Labels []RuleInstanceLabelInput `json:"labels"` } // GetQuestionId returns CreateReferencedQuestionRuleInstanceInput.QuestionId, and is useful for accessing the field via an interface. @@ -1009,6 +1047,14 @@ func (v *CreateReferencedQuestionRuleInstanceInput) GetRemediationSteps() string return v.RemediationSteps } +// GetCollectionId returns CreateReferencedQuestionRuleInstanceInput.CollectionId, and is useful for accessing the field via an interface. +func (v *CreateReferencedQuestionRuleInstanceInput) GetCollectionId() string { return v.CollectionId } + +// GetLabels returns CreateReferencedQuestionRuleInstanceInput.Labels, and is useful for accessing the field via an interface. +func (v *CreateReferencedQuestionRuleInstanceInput) GetLabels() []RuleInstanceLabelInput { + return v.Labels +} + // CreateReferencedQuestionRuleInstanceResponse is returned by CreateReferencedQuestionRuleInstance on success. type CreateReferencedQuestionRuleInstanceResponse struct { CreateQuestionRuleInstance CreateReferencedQuestionRuleInstanceCreateQuestionRuleInstance `json:"createQuestionRuleInstance"` @@ -1647,17 +1693,17 @@ func (v *GetGroupsByNameResponse) GetIamGetGroupList() GetGroupsByNameIamGetGrou // GetIntegrationInstanceIntegrationInstance includes the requested fields of the GraphQL type IntegrationInstance. type GetIntegrationInstanceIntegrationInstance struct { - Id string `json:"id"` - Name string `json:"name"` - AccountId string `json:"accountId"` - SourceIntegrationInstanceId string `json:"sourceIntegrationInstanceId"` - PollingInterval IntegrationPollingInterval `json:"pollingInterval"` - IntegrationDefinitionId string `json:"integrationDefinitionId"` - Description string `json:"description"` - Config map[string]interface{} `json:"config"` - OffsiteComplete bool `json:"offsiteComplete"` - InstanceRelationship IntegrationInstanceRelationship `json:"instanceRelationship"` - CollectorPoolId string `json:"collectorPoolId"` + Id string `json:"id"` + Name string `json:"name"` + PollingInterval IntegrationPollingInterval `json:"pollingInterval"` + IntegrationDefinitionId string `json:"integrationDefinitionId"` + Description string `json:"description"` + Config map[string]interface{} `json:"config"` + IngestionSourcesOverrides []GetIntegrationInstanceIntegrationInstanceIngestionSourcesOverrides `json:"ingestionSourcesOverrides"` + SourceIntegrationInstanceId string `json:"sourceIntegrationInstanceId"` + CollectorPoolId string `json:"collectorPoolId"` + PollingIntervalCronExpression GetIntegrationInstanceIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression `json:"pollingIntervalCronExpression"` + OffsiteComplete bool `json:"offsiteComplete"` } // GetId returns GetIntegrationInstanceIntegrationInstance.Id, and is useful for accessing the field via an interface. @@ -1666,14 +1712,6 @@ func (v *GetIntegrationInstanceIntegrationInstance) GetId() string { return v.Id // GetName returns GetIntegrationInstanceIntegrationInstance.Name, and is useful for accessing the field via an interface. func (v *GetIntegrationInstanceIntegrationInstance) GetName() string { return v.Name } -// GetAccountId returns GetIntegrationInstanceIntegrationInstance.AccountId, and is useful for accessing the field via an interface. -func (v *GetIntegrationInstanceIntegrationInstance) GetAccountId() string { return v.AccountId } - -// GetSourceIntegrationInstanceId returns GetIntegrationInstanceIntegrationInstance.SourceIntegrationInstanceId, and is useful for accessing the field via an interface. -func (v *GetIntegrationInstanceIntegrationInstance) GetSourceIntegrationInstanceId() string { - return v.SourceIntegrationInstanceId -} - // GetPollingInterval returns GetIntegrationInstanceIntegrationInstance.PollingInterval, and is useful for accessing the field via an interface. func (v *GetIntegrationInstanceIntegrationInstance) GetPollingInterval() IntegrationPollingInterval { return v.PollingInterval @@ -1692,14 +1730,14 @@ func (v *GetIntegrationInstanceIntegrationInstance) GetConfig() map[string]inter return v.Config } -// GetOffsiteComplete returns GetIntegrationInstanceIntegrationInstance.OffsiteComplete, and is useful for accessing the field via an interface. -func (v *GetIntegrationInstanceIntegrationInstance) GetOffsiteComplete() bool { - return v.OffsiteComplete +// GetIngestionSourcesOverrides returns GetIntegrationInstanceIntegrationInstance.IngestionSourcesOverrides, and is useful for accessing the field via an interface. +func (v *GetIntegrationInstanceIntegrationInstance) GetIngestionSourcesOverrides() []GetIntegrationInstanceIntegrationInstanceIngestionSourcesOverrides { + return v.IngestionSourcesOverrides } -// GetInstanceRelationship returns GetIntegrationInstanceIntegrationInstance.InstanceRelationship, and is useful for accessing the field via an interface. -func (v *GetIntegrationInstanceIntegrationInstance) GetInstanceRelationship() IntegrationInstanceRelationship { - return v.InstanceRelationship +// GetSourceIntegrationInstanceId returns GetIntegrationInstanceIntegrationInstance.SourceIntegrationInstanceId, and is useful for accessing the field via an interface. +func (v *GetIntegrationInstanceIntegrationInstance) GetSourceIntegrationInstanceId() string { + return v.SourceIntegrationInstanceId } // GetCollectorPoolId returns GetIntegrationInstanceIntegrationInstance.CollectorPoolId, and is useful for accessing the field via an interface. @@ -1707,6 +1745,48 @@ func (v *GetIntegrationInstanceIntegrationInstance) GetCollectorPoolId() string return v.CollectorPoolId } +// GetPollingIntervalCronExpression returns GetIntegrationInstanceIntegrationInstance.PollingIntervalCronExpression, and is useful for accessing the field via an interface. +func (v *GetIntegrationInstanceIntegrationInstance) GetPollingIntervalCronExpression() GetIntegrationInstanceIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression { + return v.PollingIntervalCronExpression +} + +// GetOffsiteComplete returns GetIntegrationInstanceIntegrationInstance.OffsiteComplete, and is useful for accessing the field via an interface. +func (v *GetIntegrationInstanceIntegrationInstance) GetOffsiteComplete() bool { + return v.OffsiteComplete +} + +// GetIntegrationInstanceIntegrationInstanceIngestionSourcesOverrides includes the requested fields of the GraphQL type IngestionSourcesOverrides. +type GetIntegrationInstanceIntegrationInstanceIngestionSourcesOverrides struct { + IngestionSourceId string `json:"ingestionSourceId"` + Enabled bool `json:"enabled"` +} + +// GetIngestionSourceId returns GetIntegrationInstanceIntegrationInstanceIngestionSourcesOverrides.IngestionSourceId, and is useful for accessing the field via an interface. +func (v *GetIntegrationInstanceIntegrationInstanceIngestionSourcesOverrides) GetIngestionSourceId() string { + return v.IngestionSourceId +} + +// GetEnabled returns GetIntegrationInstanceIntegrationInstanceIngestionSourcesOverrides.Enabled, and is useful for accessing the field via an interface. +func (v *GetIntegrationInstanceIntegrationInstanceIngestionSourcesOverrides) GetEnabled() bool { + return v.Enabled +} + +// GetIntegrationInstanceIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression includes the requested fields of the GraphQL type IntegrationPollingIntervalCronExpression. +type GetIntegrationInstanceIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression struct { + Hour int `json:"hour"` + DayOfWeek int `json:"dayOfWeek"` +} + +// GetHour returns GetIntegrationInstanceIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression.Hour, and is useful for accessing the field via an interface. +func (v *GetIntegrationInstanceIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression) GetHour() int { + return v.Hour +} + +// GetDayOfWeek returns GetIntegrationInstanceIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression.DayOfWeek, and is useful for accessing the field via an interface. +func (v *GetIntegrationInstanceIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression) GetDayOfWeek() int { + return v.DayOfWeek +} + // GetIntegrationInstanceResponse is returned by GetIntegrationInstance on success. type GetIntegrationInstanceResponse struct { IntegrationInstance GetIntegrationInstanceIntegrationInstance `json:"integrationInstance"` @@ -2170,14 +2250,6 @@ func (v *IngestionSourcesOverridesInput) GetIngestionSourceId() string { return // GetEnabled returns IngestionSourcesOverridesInput.Enabled, and is useful for accessing the field via an interface. func (v *IngestionSourcesOverridesInput) GetEnabled() bool { return v.Enabled } -type IntegrationInstanceRelationship string - -const ( - IntegrationInstanceRelationshipParent IntegrationInstanceRelationship = "PARENT" - IntegrationInstanceRelationshipChild IntegrationInstanceRelationship = "CHILD" - IntegrationInstanceRelationshipStandalone IntegrationInstanceRelationship = "STANDALONE" -) - type IntegrationPollingInterval string const ( @@ -2883,7 +2955,6 @@ type UpdateInlineQuestionRuleInstanceInput struct { LatestAlertId string `json:"latestAlertId,omitempty"` Templates map[string]interface{} `json:"templates"` Tags []string `json:"tags"` - Labels []RuleInstanceLabelInput `json:"labels"` Name string `json:"name"` Description string `json:"description"` SpecVersion int `json:"specVersion"` @@ -2894,6 +2965,8 @@ type UpdateInlineQuestionRuleInstanceInput struct { TriggerActionsOnNewEntitiesOnly bool `json:"triggerActionsOnNewEntitiesOnly"` IgnorePreviousResults bool `json:"ignorePreviousResults"` RemediationSteps string `json:"remediationSteps,omitempty"` + CollectionId string `json:"collectionId"` + Labels []RuleInstanceLabelInput `json:"labels"` } // GetQuestion returns UpdateInlineQuestionRuleInstanceInput.Question, and is useful for accessing the field via an interface. @@ -2921,9 +2994,6 @@ func (v *UpdateInlineQuestionRuleInstanceInput) GetTemplates() map[string]interf // GetTags returns UpdateInlineQuestionRuleInstanceInput.Tags, and is useful for accessing the field via an interface. func (v *UpdateInlineQuestionRuleInstanceInput) GetTags() []string { return v.Tags } -// GetLabels returns UpdateInlineQuestionRuleInstanceInput.Labels, and is useful for accessing the field via an interface. -func (v *UpdateInlineQuestionRuleInstanceInput) GetLabels() []RuleInstanceLabelInput { return v.Labels } - // GetName returns UpdateInlineQuestionRuleInstanceInput.Name, and is useful for accessing the field via an interface. func (v *UpdateInlineQuestionRuleInstanceInput) GetName() string { return v.Name } @@ -2964,6 +3034,12 @@ func (v *UpdateInlineQuestionRuleInstanceInput) GetRemediationSteps() string { return v.RemediationSteps } +// GetCollectionId returns UpdateInlineQuestionRuleInstanceInput.CollectionId, and is useful for accessing the field via an interface. +func (v *UpdateInlineQuestionRuleInstanceInput) GetCollectionId() string { return v.CollectionId } + +// GetLabels returns UpdateInlineQuestionRuleInstanceInput.Labels, and is useful for accessing the field via an interface. +func (v *UpdateInlineQuestionRuleInstanceInput) GetLabels() []RuleInstanceLabelInput { return v.Labels } + // UpdateInlineQuestionRuleInstanceResponse is returned by UpdateInlineQuestionRuleInstance on success. type UpdateInlineQuestionRuleInstanceResponse struct { UpdateInlineQuestionRuleInstance UpdateInlineQuestionRuleInstanceUpdateInlineQuestionRuleInstance `json:"updateInlineQuestionRuleInstance"` @@ -2998,14 +3074,14 @@ func (v *UpdateInlineQuestionRuleInstanceUpdateInlineQuestionRuleInstance) GetOp type UpdateIntegrationInstanceInput struct { Name string `json:"name"` - SourceIntegrationInstanceId string `json:"sourceIntegrationInstanceId"` + SourceIntegrationInstanceId string `json:"sourceIntegrationInstanceId,omitempty"` PollingInterval IntegrationPollingInterval `json:"pollingInterval"` - PollingIntervalCronExpression IntegrationPollingIntervalCronExpressionInput `json:"pollingIntervalCronExpression"` + PollingIntervalCronExpression IntegrationPollingIntervalCronExpressionInput `json:"pollingIntervalCronExpression,omitempty"` Description string `json:"description"` Config map[string]interface{} `json:"config"` - OffsiteComplete bool `json:"offsiteComplete"` - CollectorPoolId string `json:"collectorPoolId"` - IngestionSourcesOverrides []IngestionSourcesOverridesInput `json:"ingestionSourcesOverrides"` + OffsiteComplete bool `json:"offsiteComplete,omitempty"` + CollectorPoolId string `json:"collectorPoolId,omitempty"` + IngestionSourcesOverrides []IngestionSourcesOverridesInput `json:"ingestionSourcesOverrides,omitempty"` } // GetName returns UpdateIntegrationInstanceInput.Name, and is useful for accessing the field via an interface. @@ -3055,17 +3131,17 @@ func (v *UpdateIntegrationInstanceResponse) GetUpdateIntegrationInstance() Updat // UpdateIntegrationInstanceUpdateIntegrationInstance includes the requested fields of the GraphQL type IntegrationInstance. type UpdateIntegrationInstanceUpdateIntegrationInstance struct { - Id string `json:"id"` - Name string `json:"name"` - AccountId string `json:"accountId"` - SourceIntegrationInstanceId string `json:"sourceIntegrationInstanceId"` - PollingInterval IntegrationPollingInterval `json:"pollingInterval"` - IntegrationDefinitionId string `json:"integrationDefinitionId"` - Description string `json:"description"` - Config map[string]interface{} `json:"config"` - OffsiteComplete bool `json:"offsiteComplete"` - InstanceRelationship IntegrationInstanceRelationship `json:"instanceRelationship"` - CollectorPoolId string `json:"collectorPoolId"` + Id string `json:"id"` + Name string `json:"name"` + PollingInterval IntegrationPollingInterval `json:"pollingInterval"` + IntegrationDefinitionId string `json:"integrationDefinitionId"` + Description string `json:"description"` + Config map[string]interface{} `json:"config"` + IngestionSourcesOverrides []UpdateIntegrationInstanceUpdateIntegrationInstanceIngestionSourcesOverrides `json:"ingestionSourcesOverrides"` + SourceIntegrationInstanceId string `json:"sourceIntegrationInstanceId"` + CollectorPoolId string `json:"collectorPoolId"` + PollingIntervalCronExpression UpdateIntegrationInstanceUpdateIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression `json:"pollingIntervalCronExpression"` + OffsiteComplete bool `json:"offsiteComplete"` } // GetId returns UpdateIntegrationInstanceUpdateIntegrationInstance.Id, and is useful for accessing the field via an interface. @@ -3074,16 +3150,6 @@ func (v *UpdateIntegrationInstanceUpdateIntegrationInstance) GetId() string { re // GetName returns UpdateIntegrationInstanceUpdateIntegrationInstance.Name, and is useful for accessing the field via an interface. func (v *UpdateIntegrationInstanceUpdateIntegrationInstance) GetName() string { return v.Name } -// GetAccountId returns UpdateIntegrationInstanceUpdateIntegrationInstance.AccountId, and is useful for accessing the field via an interface. -func (v *UpdateIntegrationInstanceUpdateIntegrationInstance) GetAccountId() string { - return v.AccountId -} - -// GetSourceIntegrationInstanceId returns UpdateIntegrationInstanceUpdateIntegrationInstance.SourceIntegrationInstanceId, and is useful for accessing the field via an interface. -func (v *UpdateIntegrationInstanceUpdateIntegrationInstance) GetSourceIntegrationInstanceId() string { - return v.SourceIntegrationInstanceId -} - // GetPollingInterval returns UpdateIntegrationInstanceUpdateIntegrationInstance.PollingInterval, and is useful for accessing the field via an interface. func (v *UpdateIntegrationInstanceUpdateIntegrationInstance) GetPollingInterval() IntegrationPollingInterval { return v.PollingInterval @@ -3104,14 +3170,14 @@ func (v *UpdateIntegrationInstanceUpdateIntegrationInstance) GetConfig() map[str return v.Config } -// GetOffsiteComplete returns UpdateIntegrationInstanceUpdateIntegrationInstance.OffsiteComplete, and is useful for accessing the field via an interface. -func (v *UpdateIntegrationInstanceUpdateIntegrationInstance) GetOffsiteComplete() bool { - return v.OffsiteComplete +// GetIngestionSourcesOverrides returns UpdateIntegrationInstanceUpdateIntegrationInstance.IngestionSourcesOverrides, and is useful for accessing the field via an interface. +func (v *UpdateIntegrationInstanceUpdateIntegrationInstance) GetIngestionSourcesOverrides() []UpdateIntegrationInstanceUpdateIntegrationInstanceIngestionSourcesOverrides { + return v.IngestionSourcesOverrides } -// GetInstanceRelationship returns UpdateIntegrationInstanceUpdateIntegrationInstance.InstanceRelationship, and is useful for accessing the field via an interface. -func (v *UpdateIntegrationInstanceUpdateIntegrationInstance) GetInstanceRelationship() IntegrationInstanceRelationship { - return v.InstanceRelationship +// GetSourceIntegrationInstanceId returns UpdateIntegrationInstanceUpdateIntegrationInstance.SourceIntegrationInstanceId, and is useful for accessing the field via an interface. +func (v *UpdateIntegrationInstanceUpdateIntegrationInstance) GetSourceIntegrationInstanceId() string { + return v.SourceIntegrationInstanceId } // GetCollectorPoolId returns UpdateIntegrationInstanceUpdateIntegrationInstance.CollectorPoolId, and is useful for accessing the field via an interface. @@ -3119,6 +3185,48 @@ func (v *UpdateIntegrationInstanceUpdateIntegrationInstance) GetCollectorPoolId( return v.CollectorPoolId } +// GetPollingIntervalCronExpression returns UpdateIntegrationInstanceUpdateIntegrationInstance.PollingIntervalCronExpression, and is useful for accessing the field via an interface. +func (v *UpdateIntegrationInstanceUpdateIntegrationInstance) GetPollingIntervalCronExpression() UpdateIntegrationInstanceUpdateIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression { + return v.PollingIntervalCronExpression +} + +// GetOffsiteComplete returns UpdateIntegrationInstanceUpdateIntegrationInstance.OffsiteComplete, and is useful for accessing the field via an interface. +func (v *UpdateIntegrationInstanceUpdateIntegrationInstance) GetOffsiteComplete() bool { + return v.OffsiteComplete +} + +// UpdateIntegrationInstanceUpdateIntegrationInstanceIngestionSourcesOverrides includes the requested fields of the GraphQL type IngestionSourcesOverrides. +type UpdateIntegrationInstanceUpdateIntegrationInstanceIngestionSourcesOverrides struct { + IngestionSourceId string `json:"ingestionSourceId"` + Enabled bool `json:"enabled"` +} + +// GetIngestionSourceId returns UpdateIntegrationInstanceUpdateIntegrationInstanceIngestionSourcesOverrides.IngestionSourceId, and is useful for accessing the field via an interface. +func (v *UpdateIntegrationInstanceUpdateIntegrationInstanceIngestionSourcesOverrides) GetIngestionSourceId() string { + return v.IngestionSourceId +} + +// GetEnabled returns UpdateIntegrationInstanceUpdateIntegrationInstanceIngestionSourcesOverrides.Enabled, and is useful for accessing the field via an interface. +func (v *UpdateIntegrationInstanceUpdateIntegrationInstanceIngestionSourcesOverrides) GetEnabled() bool { + return v.Enabled +} + +// UpdateIntegrationInstanceUpdateIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression includes the requested fields of the GraphQL type IntegrationPollingIntervalCronExpression. +type UpdateIntegrationInstanceUpdateIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression struct { + Hour int `json:"hour"` + DayOfWeek int `json:"dayOfWeek"` +} + +// GetHour returns UpdateIntegrationInstanceUpdateIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression.Hour, and is useful for accessing the field via an interface. +func (v *UpdateIntegrationInstanceUpdateIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression) GetHour() int { + return v.Hour +} + +// GetDayOfWeek returns UpdateIntegrationInstanceUpdateIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression.DayOfWeek, and is useful for accessing the field via an interface. +func (v *UpdateIntegrationInstanceUpdateIntegrationInstancePollingIntervalCronExpressionIntegrationPollingIntervalCronExpression) GetDayOfWeek() int { + return v.DayOfWeek +} + // UpdateQuestionResponse is returned by UpdateQuestion on success. type UpdateQuestionResponse struct { UpdateQuestion UpdateQuestionUpdateQuestion `json:"updateQuestion"` @@ -3145,7 +3253,6 @@ type UpdateReferencedQuestionRuleInstanceInput struct { LatestAlertId string `json:"latestAlertId,omitempty"` Templates map[string]interface{} `json:"templates"` Tags []string `json:"tags"` - Labels []RuleInstanceLabelInput `json:"labels"` Name string `json:"name"` Description string `json:"description"` SpecVersion int `json:"specVersion"` @@ -3156,6 +3263,8 @@ type UpdateReferencedQuestionRuleInstanceInput struct { TriggerActionsOnNewEntitiesOnly bool `json:"triggerActionsOnNewEntitiesOnly"` IgnorePreviousResults bool `json:"ignorePreviousResults"` RemediationSteps string `json:"remediationSteps"` + CollectionId string `json:"collectionId"` + Labels []RuleInstanceLabelInput `json:"labels"` } // GetQuestionId returns UpdateReferencedQuestionRuleInstanceInput.QuestionId, and is useful for accessing the field via an interface. @@ -3181,11 +3290,6 @@ func (v *UpdateReferencedQuestionRuleInstanceInput) GetTemplates() map[string]in // GetTags returns UpdateReferencedQuestionRuleInstanceInput.Tags, and is useful for accessing the field via an interface. func (v *UpdateReferencedQuestionRuleInstanceInput) GetTags() []string { return v.Tags } -// GetLabels returns UpdateReferencedQuestionRuleInstanceInput.Labels, and is useful for accessing the field via an interface. -func (v *UpdateReferencedQuestionRuleInstanceInput) GetLabels() []RuleInstanceLabelInput { - return v.Labels -} - // GetName returns UpdateReferencedQuestionRuleInstanceInput.Name, and is useful for accessing the field via an interface. func (v *UpdateReferencedQuestionRuleInstanceInput) GetName() string { return v.Name } @@ -3228,6 +3332,14 @@ func (v *UpdateReferencedQuestionRuleInstanceInput) GetRemediationSteps() string return v.RemediationSteps } +// GetCollectionId returns UpdateReferencedQuestionRuleInstanceInput.CollectionId, and is useful for accessing the field via an interface. +func (v *UpdateReferencedQuestionRuleInstanceInput) GetCollectionId() string { return v.CollectionId } + +// GetLabels returns UpdateReferencedQuestionRuleInstanceInput.Labels, and is useful for accessing the field via an interface. +func (v *UpdateReferencedQuestionRuleInstanceInput) GetLabels() []RuleInstanceLabelInput { + return v.Labels +} + // UpdateReferencedQuestionRuleInstanceResponse is returned by UpdateReferencedQuestionRuleInstance on success. type UpdateReferencedQuestionRuleInstanceResponse struct { UpdateReferencedQuestionRuleInstance UpdateReferencedQuestionRuleInstanceUpdateReferencedQuestionRuleInstance `json:"updateReferencedQuestionRuleInstance"` @@ -4118,15 +4230,21 @@ mutation CreateIntegrationInstance ($instance: CreateIntegrationInstanceInput!) createIntegrationInstance(instance: $instance) { id name - accountId - sourceIntegrationInstanceId pollingInterval integrationDefinitionId description config - offsiteComplete - instanceRelationship + ingestionSourcesOverrides { + ingestionSourceId + enabled + } + sourceIntegrationInstanceId collectorPoolId + pollingIntervalCronExpression { + hour + dayOfWeek + } + offsiteComplete } } `, @@ -4936,15 +5054,21 @@ query GetIntegrationInstance ($id: String!) { integrationInstance(id: $id) { id name - accountId - sourceIntegrationInstanceId pollingInterval integrationDefinitionId description config - offsiteComplete - instanceRelationship + ingestionSourcesOverrides { + ingestionSourceId + enabled + } + sourceIntegrationInstanceId collectorPoolId + pollingIntervalCronExpression { + hour + dayOfWeek + } + offsiteComplete } } `, @@ -5594,15 +5718,21 @@ mutation UpdateIntegrationInstance ($id: String!, $update: UpdateIntegrationInst updateIntegrationInstance(id: $id, update: $update) { id name - accountId - sourceIntegrationInstanceId pollingInterval integrationDefinitionId description config - offsiteComplete - instanceRelationship + ingestionSourcesOverrides { + ingestionSourceId + enabled + } + sourceIntegrationInstanceId collectorPoolId + pollingIntervalCronExpression { + hour + dayOfWeek + } + offsiteComplete } } `, diff --git a/jupiterone/internal/client/integration.graphql b/jupiterone/internal/client/integration.graphql index 12603a4f..943585c7 100644 --- a/jupiterone/internal/client/integration.graphql +++ b/jupiterone/internal/client/integration.graphql @@ -6,10 +6,27 @@ query GetIntegrationInstance($id: String!) { integrationDefinitionId description config + ingestionSourcesOverrides { + ingestionSourceId + enabled + } + sourceIntegrationInstanceId + collectorPoolId + pollingIntervalCronExpression { + hour + dayOfWeek + } + offsiteComplete } } -mutation CreateIntegrationInstance($instance: CreateIntegrationInstanceInput!) { +# @genqlient(for: "CreateIntegrationInstanceInput.sourceIntegrationInstanceId", omitempty: true) +# @genqlient(for: "CreateIntegrationInstanceInput.collectorPoolId", omitempty: true) +# @genqlient(for: "CreateIntegrationInstanceInput.pollingIntervalCronExpression", omitempty: true) +# @genqlient(for: "CreateIntegrationInstanceInput.offsiteComplete", omitempty: true) +# @genqlient(for: "CreateIntegrationInstanceInput.ingestionSourcesOverrides", omitempty: true) +mutation CreateIntegrationInstance( + $instance: CreateIntegrationInstanceInput!) { createIntegrationInstance(instance: $instance) { id name @@ -17,10 +34,28 @@ mutation CreateIntegrationInstance($instance: CreateIntegrationInstanceInput!) { integrationDefinitionId description config + ingestionSourcesOverrides { + ingestionSourceId + enabled + } + sourceIntegrationInstanceId + collectorPoolId + pollingIntervalCronExpression { + hour + dayOfWeek + } + offsiteComplete } } -mutation UpdateIntegrationInstance($id: String!, $update: UpdateIntegrationInstanceInput!) { +# @genqlient(for: "UpdateIntegrationInstanceInput.sourceIntegrationInstanceId", omitempty: true) +# @genqlient(for: "UpdateIntegrationInstanceInput.collectorPoolId", omitempty: true) +# @genqlient(for: "UpdateIntegrationInstanceInput.pollingIntervalCronExpression", omitempty: true) +# @genqlient(for: "UpdateIntegrationInstanceInput.offsiteComplete", omitempty: true) +# @genqlient(for: "UpdateIntegrationInstanceInput.ingestionSourcesOverrides", omitempty: true) +mutation UpdateIntegrationInstance( + $id: String!, + $update: UpdateIntegrationInstanceInput!) { updateIntegrationInstance(id: $id, update: $update) { id name @@ -28,6 +63,17 @@ mutation UpdateIntegrationInstance($id: String!, $update: UpdateIntegrationInsta integrationDefinitionId description config + ingestionSourcesOverrides { + ingestionSourceId + enabled + } + sourceIntegrationInstanceId + collectorPoolId + pollingIntervalCronExpression { + hour + dayOfWeek + } + offsiteComplete } } diff --git a/jupiterone/resource_integration.go b/jupiterone/resource_integration.go index 873fc680..ba8dbf22 100644 --- a/jupiterone/resource_integration.go +++ b/jupiterone/resource_integration.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/Khan/genqlient/graphql" + "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/resource/schema" @@ -27,12 +28,16 @@ type IntegrationResource struct { } type IntegrationModel struct { - Id types.String `tfsdk:"id"` - Name types.String `tfsdk:"name"` - PollingInterval types.String `tfsdk:"polling_interval"` - IntegrationDefinitionId types.String `tfsdk:"integration_definition_id"` - Description types.String `tfsdk:"description"` - Config types.String `tfsdk:"config"` + Id types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` + PollingInterval types.String `tfsdk:"polling_interval"` + IntegrationDefinitionId types.String `tfsdk:"integration_definition_id"` + Description types.String `tfsdk:"description"` + Config types.String `tfsdk:"config"` + SourceIntegrationInstanceId types.String `tfsdk:"source_integration_instance_id"` + CollectorPoolId types.String `tfsdk:"collector_pool_id"` + PollingIntervalCronExpression types.String `tfsdk:"polling_interval_cron_expression"` + IngestionSourcesOverrides types.List `tfsdk:"ingestion_sources_overrides"` } func NewIntegrationResource() resource.Resource { @@ -81,6 +86,33 @@ func (r *IntegrationResource) Create(ctx context.Context, req resource.CreateReq Config: config, } + if !data.SourceIntegrationInstanceId.IsNull() { + input.SourceIntegrationInstanceId = data.SourceIntegrationInstanceId.ValueString() + } + + if !data.CollectorPoolId.IsNull() { + input.CollectorPoolId = data.CollectorPoolId.ValueString() + } + + if !data.PollingIntervalCronExpression.IsNull() { + var cronExpression client.IntegrationPollingIntervalCronExpressionInput + if err := json.Unmarshal([]byte(data.PollingIntervalCronExpression.ValueString()), &cronExpression); err != nil { + resp.Diagnostics.AddError("Failed to unmarshal polling interval cron expression", err.Error()) + return + } + input.PollingIntervalCronExpression = cronExpression + } + + if !data.IngestionSourcesOverrides.IsNull() { + var overrides []client.IngestionSourcesOverridesInput + diags := data.IngestionSourcesOverrides.ElementsAs(ctx, &overrides, false) + if diags.HasError() { + resp.Diagnostics.Append(diags...) + return + } + input.IngestionSourcesOverrides = overrides + } + created, err := client.CreateIntegrationInstance(ctx, r.qlient, input) if err != nil { resp.Diagnostics.AddError("Failed to create integration instance", err.Error()) @@ -103,13 +135,10 @@ func (r *IntegrationResource) Read(ctx context.Context, req resource.ReadRequest response, err := client.GetIntegrationInstance(ctx, r.qlient, data.Id.ValueString()) if err != nil { - // Check if the error indicates that the resource was not found if strings.Contains(err.Error(), "Integration instance not found") { - // If the resource is not found, remove it from state resp.State.RemoveResource(ctx) return } - // For other errors, add them to diagnostics resp.Diagnostics.AddError("Failed to read integration instance", err.Error()) return } @@ -119,7 +148,6 @@ func (r *IntegrationResource) Read(ctx context.Context, req resource.ReadRequest data.IntegrationDefinitionId = types.StringValue(response.IntegrationInstance.IntegrationDefinitionId) data.Description = types.StringValue(response.IntegrationInstance.Description) - // Handle the config configJSON, err := json.Marshal(response.IntegrationInstance.Config) if err != nil { resp.Diagnostics.AddError("Failed to marshal config", err.Error()) @@ -127,6 +155,36 @@ func (r *IntegrationResource) Read(ctx context.Context, req resource.ReadRequest } data.Config = types.StringValue(string(configJSON)) + if response.IntegrationInstance.SourceIntegrationInstanceId != "" { + data.SourceIntegrationInstanceId = types.StringValue(response.IntegrationInstance.SourceIntegrationInstanceId) + } + + if response.IntegrationInstance.CollectorPoolId != "" { + data.CollectorPoolId = types.StringValue(response.IntegrationInstance.CollectorPoolId) + } + + cronExpression := response.IntegrationInstance.PollingIntervalCronExpression + if cronExpression.Hour != 0 || cronExpression.DayOfWeek != 0 { + cronExpressionJSON, err := json.Marshal(cronExpression) + if err != nil { + resp.Diagnostics.AddError("Failed to marshal polling interval cron expression", err.Error()) + return + } + data.PollingIntervalCronExpression = types.StringValue(string(cronExpressionJSON)) + } + + if len(response.IntegrationInstance.IngestionSourcesOverrides) > 0 { + overrides, diags := types.ListValueFrom(ctx, types.ObjectType{AttrTypes: map[string]attr.Type{ + "ingestion_source_id": types.StringType, + "enabled": types.BoolType, + }}, response.IntegrationInstance.IngestionSourcesOverrides) + if diags.HasError() { + resp.Diagnostics.Append(diags...) + return + } + data.IngestionSourcesOverrides = overrides + } + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } @@ -150,7 +208,32 @@ func (r *IntegrationResource) Update(ctx context.Context, req resource.UpdateReq Config: config, } - // Note: We don't include IntegrationDefinitionId in the update input + if !data.SourceIntegrationInstanceId.IsNull() { + input.SourceIntegrationInstanceId = data.SourceIntegrationInstanceId.ValueString() + } + + if !data.CollectorPoolId.IsNull() { + input.CollectorPoolId = data.CollectorPoolId.ValueString() + } + + if !data.PollingIntervalCronExpression.IsNull() { + var cronExpression client.IntegrationPollingIntervalCronExpressionInput + if err := json.Unmarshal([]byte(data.PollingIntervalCronExpression.ValueString()), &cronExpression); err != nil { + resp.Diagnostics.AddError("Failed to unmarshal polling interval cron expression", err.Error()) + return + } + input.PollingIntervalCronExpression = cronExpression + } + + if !data.IngestionSourcesOverrides.IsNull() { + var overrides []client.IngestionSourcesOverridesInput + diags := data.IngestionSourcesOverrides.ElementsAs(ctx, &overrides, false) + if diags.HasError() { + resp.Diagnostics.Append(diags...) + return + } + input.IngestionSourcesOverrides = overrides + } _, err := client.UpdateIntegrationInstance(ctx, r.qlient, data.Id.ValueString(), input) if err != nil { @@ -217,6 +300,28 @@ func (r *IntegrationResource) Schema(ctx context.Context, req resource.SchemaReq Required: true, Description: "The configuration for the integration instance as a JSON string.", }, + "source_integration_instance_id": schema.StringAttribute{ + Optional: true, + Description: "The ID of the source integration instance.", + }, + "collector_pool_id": schema.StringAttribute{ + Optional: true, + Description: "The ID of the collector pool.", + }, + "polling_interval_cron_expression": schema.StringAttribute{ + Optional: true, + Description: "The cron expression for the polling interval as a JSON string.", + }, + "ingestion_sources_overrides": schema.ListAttribute{ + Optional: true, + Description: "Overrides for ingestion sources.", + ElementType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "ingestion_source_id": types.StringType, + "enabled": types.BoolType, + }, + }, + }, }, } } From a4b0b66f5a2962f98e383c3754dfab99976d92b1 Mon Sep 17 00:00:00 2001 From: Chad Richts Date: Thu, 31 Oct 2024 17:46:11 +0000 Subject: [PATCH 2/3] Regenerate client --- jupiterone/internal/client/generated.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jupiterone/internal/client/generated.go b/jupiterone/internal/client/generated.go index 706b3a63..dd025495 100644 --- a/jupiterone/internal/client/generated.go +++ b/jupiterone/internal/client/generated.go @@ -2635,15 +2635,15 @@ func (v *RevokeInvitationUpdateInvitationIamInvitation) GetId() string { return func (v *RevokeInvitationUpdateInvitationIamInvitation) GetStatus() string { return v.Status } type RuleInstanceLabelInput struct { - LabelName string `json:"labelName"` - LabelValue map[string]interface{} `json:"labelValue"` + LabelName string `json:"labelName"` + LabelValue string `json:"labelValue"` } // GetLabelName returns RuleInstanceLabelInput.LabelName, and is useful for accessing the field via an interface. func (v *RuleInstanceLabelInput) GetLabelName() string { return v.LabelName } // GetLabelValue returns RuleInstanceLabelInput.LabelValue, and is useful for accessing the field via an interface. -func (v *RuleInstanceLabelInput) GetLabelValue() map[string]interface{} { return v.LabelValue } +func (v *RuleInstanceLabelInput) GetLabelValue() string { return v.LabelValue } type RuleInstanceType string From 455397e18651fe151de4048cb77007cd868c9617 Mon Sep 17 00:00:00 2001 From: Chad Richts Date: Thu, 31 Oct 2024 17:49:55 +0000 Subject: [PATCH 3/3] Fix client issues --- jupiterone/internal/client/generated.go | 39 ------------------------- 1 file changed, 39 deletions(-) diff --git a/jupiterone/internal/client/generated.go b/jupiterone/internal/client/generated.go index e1428c4a..ab1dfc28 100644 --- a/jupiterone/internal/client/generated.go +++ b/jupiterone/internal/client/generated.go @@ -493,8 +493,6 @@ type CreateInlineQuestionRuleInstanceInput struct { RemediationSteps string `json:"remediationSteps"` CollectionId string `json:"collectionId"` Labels []RuleInstanceLabelInput `json:"labels"` - CollectionId string `json:"collectionId"` - Labels []RuleInstanceLabelInput `json:"labels"` J1Internal bool `json:"j1Internal"` } @@ -557,12 +555,6 @@ func (v *CreateInlineQuestionRuleInstanceInput) GetCollectionId() string { retur // GetLabels returns CreateInlineQuestionRuleInstanceInput.Labels, and is useful for accessing the field via an interface. func (v *CreateInlineQuestionRuleInstanceInput) GetLabels() []RuleInstanceLabelInput { return v.Labels } -// GetCollectionId returns CreateInlineQuestionRuleInstanceInput.CollectionId, and is useful for accessing the field via an interface. -func (v *CreateInlineQuestionRuleInstanceInput) GetCollectionId() string { return v.CollectionId } - -// GetLabels returns CreateInlineQuestionRuleInstanceInput.Labels, and is useful for accessing the field via an interface. -func (v *CreateInlineQuestionRuleInstanceInput) GetLabels() []RuleInstanceLabelInput { return v.Labels } - // GetJ1Internal returns CreateInlineQuestionRuleInstanceInput.J1Internal, and is useful for accessing the field via an interface. func (v *CreateInlineQuestionRuleInstanceInput) GetJ1Internal() bool { return v.J1Internal } @@ -1022,8 +1014,6 @@ type CreateReferencedQuestionRuleInstanceInput struct { RemediationSteps string `json:"remediationSteps"` CollectionId string `json:"collectionId"` Labels []RuleInstanceLabelInput `json:"labels"` - CollectionId string `json:"collectionId"` - Labels []RuleInstanceLabelInput `json:"labels"` } // GetQuestionId returns CreateReferencedQuestionRuleInstanceInput.QuestionId, and is useful for accessing the field via an interface. @@ -1087,14 +1077,6 @@ func (v *CreateReferencedQuestionRuleInstanceInput) GetLabels() []RuleInstanceLa return v.Labels } -// GetCollectionId returns CreateReferencedQuestionRuleInstanceInput.CollectionId, and is useful for accessing the field via an interface. -func (v *CreateReferencedQuestionRuleInstanceInput) GetCollectionId() string { return v.CollectionId } - -// GetLabels returns CreateReferencedQuestionRuleInstanceInput.Labels, and is useful for accessing the field via an interface. -func (v *CreateReferencedQuestionRuleInstanceInput) GetLabels() []RuleInstanceLabelInput { - return v.Labels -} - // CreateReferencedQuestionRuleInstanceResponse is returned by CreateReferencedQuestionRuleInstance on success. type CreateReferencedQuestionRuleInstanceResponse struct { CreateQuestionRuleInstance CreateReferencedQuestionRuleInstanceCreateQuestionRuleInstance `json:"createQuestionRuleInstance"` @@ -2677,8 +2659,6 @@ func (v *RevokeInvitationUpdateInvitationIamInvitation) GetStatus() string { ret type RuleInstanceLabelInput struct { LabelName string `json:"labelName"` LabelValue string `json:"labelValue"` - LabelName string `json:"labelName"` - LabelValue string `json:"labelValue"` } // GetLabelName returns RuleInstanceLabelInput.LabelName, and is useful for accessing the field via an interface. @@ -2686,7 +2666,6 @@ func (v *RuleInstanceLabelInput) GetLabelName() string { return v.LabelName } // GetLabelValue returns RuleInstanceLabelInput.LabelValue, and is useful for accessing the field via an interface. func (v *RuleInstanceLabelInput) GetLabelValue() string { return v.LabelValue } -func (v *RuleInstanceLabelInput) GetLabelValue() string { return v.LabelValue } type RuleInstanceType string @@ -3010,8 +2989,6 @@ type UpdateInlineQuestionRuleInstanceInput struct { RemediationSteps string `json:"remediationSteps,omitempty"` CollectionId string `json:"collectionId"` Labels []RuleInstanceLabelInput `json:"labels"` - CollectionId string `json:"collectionId"` - Labels []RuleInstanceLabelInput `json:"labels"` } // GetQuestion returns UpdateInlineQuestionRuleInstanceInput.Question, and is useful for accessing the field via an interface. @@ -3085,12 +3062,6 @@ func (v *UpdateInlineQuestionRuleInstanceInput) GetCollectionId() string { retur // GetLabels returns UpdateInlineQuestionRuleInstanceInput.Labels, and is useful for accessing the field via an interface. func (v *UpdateInlineQuestionRuleInstanceInput) GetLabels() []RuleInstanceLabelInput { return v.Labels } -// GetCollectionId returns UpdateInlineQuestionRuleInstanceInput.CollectionId, and is useful for accessing the field via an interface. -func (v *UpdateInlineQuestionRuleInstanceInput) GetCollectionId() string { return v.CollectionId } - -// GetLabels returns UpdateInlineQuestionRuleInstanceInput.Labels, and is useful for accessing the field via an interface. -func (v *UpdateInlineQuestionRuleInstanceInput) GetLabels() []RuleInstanceLabelInput { return v.Labels } - // UpdateInlineQuestionRuleInstanceResponse is returned by UpdateInlineQuestionRuleInstance on success. type UpdateInlineQuestionRuleInstanceResponse struct { UpdateInlineQuestionRuleInstance UpdateInlineQuestionRuleInstanceUpdateInlineQuestionRuleInstance `json:"updateInlineQuestionRuleInstance"` @@ -3316,8 +3287,6 @@ type UpdateReferencedQuestionRuleInstanceInput struct { RemediationSteps string `json:"remediationSteps"` CollectionId string `json:"collectionId"` Labels []RuleInstanceLabelInput `json:"labels"` - CollectionId string `json:"collectionId"` - Labels []RuleInstanceLabelInput `json:"labels"` } // GetQuestionId returns UpdateReferencedQuestionRuleInstanceInput.QuestionId, and is useful for accessing the field via an interface. @@ -3393,14 +3362,6 @@ func (v *UpdateReferencedQuestionRuleInstanceInput) GetLabels() []RuleInstanceLa return v.Labels } -// GetCollectionId returns UpdateReferencedQuestionRuleInstanceInput.CollectionId, and is useful for accessing the field via an interface. -func (v *UpdateReferencedQuestionRuleInstanceInput) GetCollectionId() string { return v.CollectionId } - -// GetLabels returns UpdateReferencedQuestionRuleInstanceInput.Labels, and is useful for accessing the field via an interface. -func (v *UpdateReferencedQuestionRuleInstanceInput) GetLabels() []RuleInstanceLabelInput { - return v.Labels -} - // UpdateReferencedQuestionRuleInstanceResponse is returned by UpdateReferencedQuestionRuleInstance on success. type UpdateReferencedQuestionRuleInstanceResponse struct { UpdateReferencedQuestionRuleInstance UpdateReferencedQuestionRuleInstanceUpdateReferencedQuestionRuleInstance `json:"updateReferencedQuestionRuleInstance"`