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 2a32d3eb..ab1dfc28 100644 --- a/jupiterone/internal/client/generated.go +++ b/jupiterone/internal/client/generated.go @@ -752,12 +752,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"` - PollingInterval IntegrationPollingInterval `json:"pollingInterval"` - IntegrationDefinitionId string `json:"integrationDefinitionId"` - Description string `json:"description"` - Config map[string]interface{} `json:"config"` + 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. @@ -786,17 +791,74 @@ func (v *CreateIntegrationInstanceCreateIntegrationInstance) GetConfig() map[str return v.Config } +// GetIngestionSourcesOverrides returns CreateIntegrationInstanceCreateIntegrationInstance.IngestionSourcesOverrides, and is useful for accessing the field via an interface. +func (v *CreateIntegrationInstanceCreateIntegrationInstance) GetIngestionSourcesOverrides() []CreateIntegrationInstanceCreateIntegrationInstanceIngestionSourcesOverrides { + return v.IngestionSourcesOverrides +} + +// 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. +func (v *CreateIntegrationInstanceCreateIntegrationInstance) GetCollectorPoolId() string { + 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. @@ -1653,12 +1715,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"` - PollingInterval IntegrationPollingInterval `json:"pollingInterval"` - IntegrationDefinitionId string `json:"integrationDefinitionId"` - Description string `json:"description"` - Config map[string]interface{} `json:"config"` + 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. @@ -1685,6 +1752,63 @@ func (v *GetIntegrationInstanceIntegrationInstance) GetConfig() map[string]inter return v.Config } +// GetIngestionSourcesOverrides returns GetIntegrationInstanceIntegrationInstance.IngestionSourcesOverrides, and is useful for accessing the field via an interface. +func (v *GetIntegrationInstanceIntegrationInstance) GetIngestionSourcesOverrides() []GetIntegrationInstanceIntegrationInstanceIngestionSourcesOverrides { + return v.IngestionSourcesOverrides +} + +// 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. +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"` @@ -2972,14 +3096,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. @@ -3029,12 +3153,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"` - PollingInterval IntegrationPollingInterval `json:"pollingInterval"` - IntegrationDefinitionId string `json:"integrationDefinitionId"` - Description string `json:"description"` - Config map[string]interface{} `json:"config"` + 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. @@ -3063,6 +3192,63 @@ func (v *UpdateIntegrationInstanceUpdateIntegrationInstance) GetConfig() map[str return v.Config } +// GetIngestionSourcesOverrides returns UpdateIntegrationInstanceUpdateIntegrationInstance.IngestionSourcesOverrides, and is useful for accessing the field via an interface. +func (v *UpdateIntegrationInstanceUpdateIntegrationInstance) GetIngestionSourcesOverrides() []UpdateIntegrationInstanceUpdateIntegrationInstanceIngestionSourcesOverrides { + return v.IngestionSourcesOverrides +} + +// 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. +func (v *UpdateIntegrationInstanceUpdateIntegrationInstance) GetCollectorPoolId() string { + 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"` @@ -4074,6 +4260,17 @@ mutation CreateIntegrationInstance ($instance: CreateIntegrationInstanceInput!) integrationDefinitionId description config + ingestionSourcesOverrides { + ingestionSourceId + enabled + } + sourceIntegrationInstanceId + collectorPoolId + pollingIntervalCronExpression { + hour + dayOfWeek + } + offsiteComplete } } `, @@ -4887,6 +5084,17 @@ query GetIntegrationInstance ($id: String!) { integrationDefinitionId description config + ingestionSourcesOverrides { + ingestionSourceId + enabled + } + sourceIntegrationInstanceId + collectorPoolId + pollingIntervalCronExpression { + hour + dayOfWeek + } + offsiteComplete } } `, @@ -5540,6 +5748,17 @@ mutation UpdateIntegrationInstance ($id: String!, $update: UpdateIntegrationInst integrationDefinitionId description config + 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, + }, + }, + }, }, } }