diff --git a/Makefile b/Makefile index 6a03fab2b..9cfa5db2f 100644 --- a/Makefile +++ b/Makefile @@ -67,6 +67,8 @@ retry = until [ $$(if [ -z "$$attempt" ]; then echo -n "0"; else echo -n "$$atte backoff=$$((backoff * 2)); \ done +# To run specific test (e.g. TestAccResourceActionConnector) execute `make docker-testacc TESTARGS='-run ^TestAccResourceActionConnector$$'` +# To enable tracing (or debugging), execute `make docker-testacc TFLOG=TRACE` .PHONY: docker-testacc docker-testacc: docker-elasticsearch docker-kibana ## Run acceptance tests in the docker container @ docker run --rm \ @@ -74,10 +76,11 @@ docker-testacc: docker-elasticsearch docker-kibana ## Run acceptance tests in th -e KIBANA_ENDPOINT="$(KIBANA_ENDPOINT)" \ -e ELASTICSEARCH_USERNAME="$(ELASTICSEARCH_USERNAME)" \ -e ELASTICSEARCH_PASSWORD="$(ELASTICSEARCH_PASSWORD)" \ + -e TF_LOG="$(TF_LOG)" \ --network $(ELASTICSEARCH_NETWORK) \ -w "/provider" \ -v "$(SOURCE_LOCATION):/provider" \ - golang:$(GOVERSION) make testacc + golang:$(GOVERSION) make testacc TESTARGS="$(TESTARGS)" .PHONY: docker-elasticsearch docker-elasticsearch: docker-network ## Start Elasticsearch single node cluster in docker container @@ -159,7 +162,6 @@ tools: $(GOBIN) ## Install useful tools for linting, docs generation and develop @ cd tools && go install github.com/goreleaser/goreleaser @ cd tools && go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen - .PHONY: misspell misspell: @ $(GOBIN)/misspell -error -source go ./internal/ @@ -247,11 +249,15 @@ generate-alerting-client: ## generate Kibana alerting client -g go \ -o /local/generated/alerting @ rm -rf generated/alerting/go.mod generated/alerting/go.sum generated/alerting/test - @ go fmt ./generated/... + @ go fmt ./generated/alerting/... +.PHONY: generate-connectors-client +generate-connectors-client: tools ## generate Kibana connectors client + @ cd tools && go generate + @ go fmt ./generated/connectors/... .PHONY: generate-slo-client -generate-slo-client: ## generate Kibana slo client +generate-slo-client: tools ## generate Kibana slo client @ docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate \ -i https://raw.githubusercontent.com/elastic/kibana/master/x-pack/plugins/observability/docs/openapi/slo/bundled.yaml \ --skip-validate-spec \ @@ -266,4 +272,4 @@ generate-slo-client: ## generate Kibana slo client @ go fmt ./generated/... .PHONY: generate-clients -generate-clients: generate-alerting-client generate-slo-client ## generate all clients +generate-clients: generate-alerting-client generate-slo-client generate-connectors-client ## generate all clients diff --git a/README.md b/README.md index 127f5cb9c..2bbe97e53 100644 --- a/README.md +++ b/README.md @@ -129,3 +129,8 @@ go mod tidy ``` Then commit the changes to `go.mod` and `go.sum`. + +### Generating Kibana clients + +Kibana clients for some APIs are generated based on Kibana OpenAPI specs. +Please see [Makefile](./Makefile) tasks for more details. diff --git a/docs/resources/kibana_action_connector.md b/docs/resources/kibana_action_connector.md new file mode 100644 index 000000000..46e152041 --- /dev/null +++ b/docs/resources/kibana_action_connector.md @@ -0,0 +1,58 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "elasticstack_kibana_action_connector Resource - terraform-provider-elasticstack" +subcategory: "" +description: |- + Creates a Kibana action connector. See https://www.elastic.co/guide/en/kibana/8.7/action-types.html +--- + +# elasticstack_kibana_action_connector (Resource) + +Creates a Kibana action connector. See https://www.elastic.co/guide/en/kibana/8.7/action-types.html + +## Example Usage + +```terraform +provider "elasticstack" { + elasticsearch {} +} + +resource "elasticstack_kibana_action_connector" "example" { + name = "%s" + config = jsonencode({ + index = ".kibana" + refresh = true + }) + connector_type_id = ".index" +} +``` + + +## Schema + +### Required + +- `connector_type_id` (String) The ID of the connector type, e.g. `.index`. +- `name` (String) The name of the connector. While this name does not have to be unique, a distinctive name can help you identify a connector. + +### Optional + +- `config` (String) The configuration for the connector. Configuration properties vary depending on the connector type. +- `connector_id` (String) A UUID v1 or v4 to use instead of a randomly generated ID. +- `secrets` (String) The secrets configuration for the connector. Secrets configuration properties vary depending on the connector type. +- `space_id` (String) An identifier for the space. If space_id is not provided, the default space is used. + +### Read-Only + +- `id` (String) The ID of this resource. +- `is_deprecated` (Boolean) Indicates whether the connector type is deprecated. +- `is_missing_secrets` (Boolean) Indicates whether secrets are missing for the connector. +- `is_preconfigured` (Boolean) Indicates whether it is a preconfigured connector. + +## Import + +Import is supported using the following syntax: + +```shell +terraform import elasticstack_kibana_action_connector.my_connector / +``` diff --git a/examples/resources/elasticstack_kibana_action_connector/import.sh b/examples/resources/elasticstack_kibana_action_connector/import.sh new file mode 100644 index 000000000..5a0f458fe --- /dev/null +++ b/examples/resources/elasticstack_kibana_action_connector/import.sh @@ -0,0 +1 @@ +terraform import elasticstack_kibana_action_connector.my_connector / diff --git a/examples/resources/elasticstack_kibana_action_connector/resource.tf b/examples/resources/elasticstack_kibana_action_connector/resource.tf new file mode 100644 index 000000000..21c1447bc --- /dev/null +++ b/examples/resources/elasticstack_kibana_action_connector/resource.tf @@ -0,0 +1,12 @@ +provider "elasticstack" { + elasticsearch {} +} + +resource "elasticstack_kibana_action_connector" "example" { + name = "%s" + config = jsonencode({ + index = ".kibana" + refresh = true + }) + connector_type_id = ".index" +} diff --git a/generated/connectors/README.md b/generated/connectors/README.md new file mode 100644 index 000000000..f17d53e42 --- /dev/null +++ b/generated/connectors/README.md @@ -0,0 +1,39 @@ +[OpenAPI specs](./bundled.yaml) is copied from [Kibana repo](https://raw.githubusercontent.com/elastic/kibana/8.7/x-pack/plugins/actions/docs/openapi/bundled.yaml) with some modifications: + +- added mapping section for discriminator field in `POST` `/s/{spaceId}/api/actions/connector`; +- added explicit object definitions for `400`, `401` and `404` errors (`oapi-codegen` doesn't generate proper code for embedded anonymous objects in some cases) - `bad_request_error`, `authorization_error` and `object_not_found_error`; +- added missing `oneOf` types in `requestBody` for `PUT` `/s/{spaceId}/api/actions/connector/{connectorId}` - the original `bundled.yaml` misses some connector types in the `PUT` `requestBody` defintion: + - `update_connector_request_email`; + - `update_connector_request_pagerduty`; + - `update_connector_request_servicenow_sir`; + - `update_connector_request_slack`; + - `update_connector_request_teams`; + - `update_connector_request_tines`; + - `update_connector_request_webhook`; + - `update_connector_request_xmatters`. +- response definitions of `/s/{spaceId}/api/actions/connector/{connectorId}/_execute` and `/s/{spaceId}/api/actions/action/{actionId}/_execute` are modified from embedded object definitions to named ones `run_connector_general_response` and `legacy_run_connector_general_response`; +- specified properties for following types. The original `bundled.yaml` defines them as dynamic objects (`additionalProperties: true`): + - `config_propeties_email`; + - `config_properties_pagerduty`; + - `config_properties_tines`; + - `config_properties_webhook`; + - `config_properties_xmatters`; +- `is_deprecated` is marked as optional field (it's required field in the vanilla `bundled.yaml`) in the following objects (Kibana responses may omit it): + - `connector_response_properties_cases_webhook`; + - `connector_response_properties_email`; + - `connector_response_properties_index`; + - `connector_response_properties_jira`; + - `connector_response_properties_opsgenie`; + - `connector_response_properties_pagerduty`; + - `connector_response_properties_resilient`; + - `connector_response_properties_serverlog`; + - `connector_response_properties_servicenow`; + - `connector_response_properties_servicenow_itom`; + - `connector_response_properties_servicenow_sir`; + - `connector_response_properties_slack`; + - `connector_response_properties_swimlane`; + - `connector_response_properties_teams`; + - `connector_response_properties_tines`; + - `connector_response_properties_webhook`; + - `connector_response_properties_xmatters`. +- added mapping section for discriminator field in `connector_response_properties`. diff --git a/generated/connectors/bundled.yaml b/generated/connectors/bundled.yaml new file mode 100644 index 000000000..c5ec5a3bb --- /dev/null +++ b/generated/connectors/bundled.yaml @@ -0,0 +1,3450 @@ +openapi: 3.0.1 +info: + title: Connectors + description: OpenAPI schema for Connectors endpoints + version: '0.1' + contact: + name: Connectors Team + license: + name: Elastic License 2.0 + url: https://www.elastic.co/licensing/elastic-license +tags: + - name: connectors + description: Connector APIs enable you to create and manage connectors. +servers: + - url: http://localhost:5601 + description: local +paths: + /s/{spaceId}/api/actions/connector: + post: + summary: Creates a connector. + operationId: createConnector + description: | + You must have `all` privileges for the **Actions and Connectors** feature in the **Management** section of the Kibana feature privileges. + tags: + - connectors + parameters: + - $ref: '#/components/parameters/kbn_xsrf' + - $ref: '#/components/parameters/space_id' + requestBody: + required: true + content: + application/json: + schema: + title: Create connector request body properties + description: The properties vary depending on the connector type. + oneOf: + - $ref: '#/components/schemas/create_connector_request_cases_webhook' + - $ref: '#/components/schemas/create_connector_request_email' + - $ref: '#/components/schemas/create_connector_request_index' + - $ref: '#/components/schemas/create_connector_request_jira' + - $ref: '#/components/schemas/create_connector_request_opsgenie' + - $ref: '#/components/schemas/create_connector_request_pagerduty' + - $ref: '#/components/schemas/create_connector_request_resilient' + - $ref: '#/components/schemas/create_connector_request_serverlog' + - $ref: '#/components/schemas/create_connector_request_servicenow' + - $ref: '#/components/schemas/create_connector_request_servicenow_itom' + - $ref: '#/components/schemas/create_connector_request_servicenow_sir' + - $ref: '#/components/schemas/create_connector_request_slack' + - $ref: '#/components/schemas/create_connector_request_swimlane' + - $ref: '#/components/schemas/create_connector_request_teams' + - $ref: '#/components/schemas/create_connector_request_tines' + - $ref: '#/components/schemas/create_connector_request_webhook' + - $ref: '#/components/schemas/create_connector_request_xmatters' + discriminator: + propertyName: connector_type_id + mapping: + .cases-webhook: '#/components/schemas/create_connector_request_cases_webhook' + .email: '#/components/schemas/create_connector_request_email' + .index: '#/components/schemas/create_connector_request_index' + .jira: '#/components/schemas/create_connector_request_jira' + .opsgenie: '#/components/schemas/create_connector_request_opsgenie' + .pagerduty: '#/components/schemas/create_connector_request_pagerduty' + .resilient: '#/components/schemas/create_connector_request_resilient' + .server-log: '#/components/schemas/create_connector_request_serverlog' + .servicenow: '#/components/schemas/create_connector_request_servicenow' + .servicenow-itom: '#/components/schemas/create_connector_request_servicenow_itom' + .servicenow-sir: '#/components/schemas/create_connector_request_servicenow_sir' + .slack: '#/components/schemas/create_connector_request_slack' + .swimlane: '#/components/schemas/create_connector_request_swimlane' + .teams: '#/components/schemas/create_connector_request_teams' + .tines: '#/components/schemas/create_connector_request_tines' + .webhook: '#/components/schemas/create_connector_request_webhook' + .xmatters: '#/components/schemas/create_connector_request_xmatters' + examples: + createIndexConnectorRequest: + $ref: '#/components/examples/create_index_connector_request' + responses: + '200': + description: Indicates a successful call. + content: + application/json: + schema: + $ref: '#/components/schemas/connector_response_properties' + examples: + createIndexConnectorResponse: + $ref: '#/components/examples/create_index_connector_response' + '400': + description: Indicates a bad request. + content: + application/json: + schema: + $ref: '#/components/schemas/bad_request_error' + '401': + description: Authorization information is missing or invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/authorization_error' + servers: + - url: https://localhost:5601 + servers: + - url: https://localhost:5601 + /s/{spaceId}/api/actions/connector/{connectorId}: + get: + summary: Retrieves a connector by ID. + operationId: getConnector + description: | + You must have `read` privileges for the **Actions and Connectors** feature in the **Management** section of the Kibana feature privileges. + tags: + - connectors + parameters: + - $ref: '#/components/parameters/connector_id' + - $ref: '#/components/parameters/space_id' + responses: + '200': + description: Indicates a successful call. + content: + application/json: + schema: + $ref: '#/components/schemas/connector_response_properties' + examples: + getConnectorResponse: + $ref: '#/components/examples/get_connector_response' + '401': + description: Authorization information is missing or invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/authorization_error' + '404': + description: Object is not found. + content: + application/json: + schema: + type: object + properties: + error: + type: string + example: Not Found + message: + type: string + example: Saved object [action/baf33fc0-920c-11ed-b36a-874bd1548a00] not found + statusCode: + type: integer + example: 404 + servers: + - url: https://localhost:5601 + delete: + summary: Deletes a connector. + operationId: deleteConnector + description: | + You must have `all` privileges for the **Actions and Connectors** feature in the **Management** section of the Kibana feature privileges. WARNING: When you delete a connector, it cannot be recovered. + tags: + - connectors + parameters: + - $ref: '#/components/parameters/kbn_xsrf' + - $ref: '#/components/parameters/connector_id' + - $ref: '#/components/parameters/space_id' + responses: + '204': + description: Indicates a successful call. + '401': + description: Authorization information is missing or invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/authorization_error' + '404': + description: Object is not found. + content: + application/json: + schema: + type: object + properties: + error: + type: string + example: Not Found + message: + type: string + example: Saved object [action/baf33fc0-920c-11ed-b36a-874bd1548a00] not found + statusCode: + type: integer + example: 404 + servers: + - url: https://localhost:5601 + put: + summary: Updates the attributes for a connector. + operationId: updateConnector + description: | + You must have `all` privileges for the **Actions and Connectors** feature in the **Management** section of the Kibana feature privileges. + tags: + - connectors + parameters: + - $ref: '#/components/parameters/kbn_xsrf' + - $ref: '#/components/parameters/connector_id' + - $ref: '#/components/parameters/space_id' + requestBody: + required: true + content: + application/json: + schema: + title: Update connector request body properties + description: The properties vary depending on the connector type. + oneOf: + - $ref: '#/components/schemas/update_connector_request_cases_webhook' + - $ref: '#/components/schemas/update_connector_request_email' + - $ref: '#/components/schemas/update_connector_request_index' + - $ref: '#/components/schemas/update_connector_request_jira' + - $ref: '#/components/schemas/update_connector_request_opsgenie' + - $ref: '#/components/schemas/update_connector_request_pagerduty' + - $ref: '#/components/schemas/update_connector_request_resilient' + - $ref: '#/components/schemas/update_connector_request_serverlog' + - $ref: '#/components/schemas/update_connector_request_servicenow' + - $ref: '#/components/schemas/update_connector_request_servicenow_itom' + - $ref: '#/components/schemas/update_connector_request_servicenow_sir' + - $ref: '#/components/schemas/update_connector_request_slack' + - $ref: '#/components/schemas/update_connector_request_swimlane' + - $ref: '#/components/schemas/update_connector_request_teams' + - $ref: '#/components/schemas/update_connector_request_tines' + - $ref: '#/components/schemas/update_connector_request_webhook' + - $ref: '#/components/schemas/update_connector_request_xmatters' + examples: + updateIndexConnectorRequest: + $ref: '#/components/examples/update_index_connector_request' + responses: + '200': + description: Indicates a successful call. + content: + application/json: + schema: + $ref: '#/components/schemas/connector_response_properties' + '400': + description: Indicates a bad request. + content: + application/json: + schema: + $ref: '#/components/schemas/bad_request_error' + '401': + description: Authorization information is missing or invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/authorization_error' + '404': + description: Object is not found. + content: + application/json: + schema: + $ref: '#/components/schemas/object_not_found_error' + servers: + - url: https://localhost:5601 + servers: + - url: https://localhost:5601 + /s/{spaceId}/api/actions/connectors: + get: + summary: Retrieves all connectors. + operationId: getConnectors + description: | + You must have `read` privileges for the **Actions and Connectors** feature in the **Management** section of the Kibana feature privileges. + tags: + - connectors + parameters: + - $ref: '#/components/parameters/space_id' + responses: + '200': + description: Indicates a successful call. + content: + application/json: + schema: + type: array + items: + title: Get connectors response body properties + description: The properties vary for each connector type. + type: object + required: + - connector_type_id + - id + - is_preconfigured + - name + - referenced_by_count + properties: + connector_type_id: + $ref: '#/components/schemas/connector_types' + config: + type: object + description: The configuration for the connector. Configuration properties vary depending on the connector type. + additionalProperties: true + nullable: true + id: + type: string + description: The identifier for the connector. + example: b0766e10-d190-11ec-b04c-776c77d14fca + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + example: my-connector + referenced_by_count: + type: integer + description: Indicates the number of saved objects that reference the connector. If `is_preconfigured` is true, this value is not calculated. + example: 2 + default: 0 + examples: + getConnectorsResponse: + $ref: '#/components/examples/get_connectors_response' + '401': + description: Authorization information is missing or invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/authorization_error' + servers: + - url: https://localhost:5601 + servers: + - url: https://localhost:5601 + /s/{spaceId}/api/actions/connector_types: + get: + summary: Retrieves a list of all connector types. + operationId: getConnectorTypes + description: | + You do not need any Kibana feature privileges to run this API. + tags: + - connectors + parameters: + - $ref: '#/components/parameters/space_id' + - in: query + name: feature_id + description: A filter to limit the retrieved connector types to those that support a specific feature (such as alerting or cases). + schema: + $ref: '#/components/schemas/features' + responses: + '200': + description: Indicates a successful call. + content: + application/json: + schema: + title: Get connector types response body properties + description: The properties vary for each connector type. + type: array + items: + type: object + properties: + enabled: + type: boolean + description: Indicates whether the connector type is enabled in Kibana. + example: true + enabled_in_config: + type: boolean + description: Indicates whether the connector type is enabled in the Kibana `.yml` file. + example: true + enabled_in_license: + type: boolean + description: Indicates whether the connector is enabled in the license. + example: true + id: + $ref: '#/components/schemas/connector_types' + minimum_license_required: + type: string + description: The license that is required to use the connector type. + example: basic + name: + type: string + description: The name of the connector type. + example: Index + supported_feature_ids: + type: array + description: The Kibana features that are supported by the connector type. + items: + $ref: '#/components/schemas/features' + example: + - alerting + - uptime + - siem + examples: + getConnectorTypesResponse: + $ref: '#/components/examples/get_connector_types_response' + '401': + description: Authorization information is missing or invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/authorization_error' + servers: + - url: https://localhost:5601 + servers: + - url: https://localhost:5601 + /s/{spaceId}/api/actions/connector/{connectorId}/_execute: + post: + summary: Runs a connector. + operationId: runConnector + description: | + You can use this API to test an action that involves interaction with Kibana services or integrations with third-party systems. You must have `read` privileges for the **Actions and Connectors** feature in the **Management** section of the Kibana feature privileges. If you use an index connector, you must also have `all`, `create`, `index`, or `write` indices privileges. + tags: + - connectors + parameters: + - $ref: '#/components/parameters/kbn_xsrf' + - $ref: '#/components/parameters/connector_id' + - $ref: '#/components/parameters/space_id' + requestBody: + required: true + content: + application/json: + schema: + title: Run connector request body properties + description: The properties vary depending on the connector type. + type: object + required: + - params + properties: + params: + oneOf: + - $ref: '#/components/schemas/run_connector_params_documents' + - $ref: '#/components/schemas/run_connector_params_level_message' + - title: Subaction parameters + description: Test an action that involves a subaction. + oneOf: + - $ref: '#/components/schemas/run_connector_subaction_addevent' + - $ref: '#/components/schemas/run_connector_subaction_closealert' + - $ref: '#/components/schemas/run_connector_subaction_createalert' + - $ref: '#/components/schemas/run_connector_subaction_fieldsbyissuetype' + - $ref: '#/components/schemas/run_connector_subaction_getchoices' + - $ref: '#/components/schemas/run_connector_subaction_getfields' + - $ref: '#/components/schemas/run_connector_subaction_getincident' + - $ref: '#/components/schemas/run_connector_subaction_issue' + - $ref: '#/components/schemas/run_connector_subaction_issues' + - $ref: '#/components/schemas/run_connector_subaction_issuetypes' + - $ref: '#/components/schemas/run_connector_subaction_pushtoservice' + discriminator: + propertyName: subAction + examples: + runIndexConnectorRequest: + $ref: '#/components/examples/run_index_connector_request' + runJiraConnectorRequest: + $ref: '#/components/examples/run_jira_connector_request' + runServerLogConnectorRequest: + $ref: '#/components/examples/run_server_log_connector_request' + runServiceNowITOMConnectorRequest: + $ref: '#/components/examples/run_servicenow_itom_connector_request' + runSwimlaneConnectorRequest: + $ref: '#/components/examples/run_swimlane_connector_request' + responses: + '200': + description: Indicates a successful call. + content: + application/json: + schema: + $ref: '#/components/schemas/run_connector_general_response' + examples: + runIndexConnectorResponse: + $ref: '#/components/examples/run_index_connector_response' + runJiraConnectorResponse: + $ref: '#/components/examples/run_jira_connector_response' + runServerLogConnectorResponse: + $ref: '#/components/examples/run_server_log_connector_response' + runServiceNowITOMConnectorResponse: + $ref: '#/components/examples/run_servicenow_itom_connector_response' + runSwimlaneConnectorResponse: + $ref: '#/components/examples/run_swimlane_connector_response' + '401': + description: Authorization information is missing or invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/authorization_error' + servers: + - url: https://localhost:5601 + servers: + - url: https://localhost:5601 + /s/{spaceId}/api/actions/action/{actionId}: + delete: + summary: Deletes a connector. + operationId: legacyDeleteConnector + deprecated: true + description: | + Deprecated in 7.13.0. Use the delete connector API instead. WARNING: When you delete a connector, it cannot be recovered. + tags: + - connectors + parameters: + - $ref: '#/components/parameters/kbn_xsrf' + - $ref: '#/components/parameters/action_id' + - $ref: '#/components/parameters/space_id' + responses: + '204': + description: Indicates a successful call. + '401': + description: Authorization information is missing or invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/authorization_error' + servers: + - url: https://localhost:5601 + get: + summary: Retrieves a connector by ID. + operationId: legacyGetConnector + description: Deprecated in 7.13.0. Use the get connector API instead. + deprecated: true + tags: + - connectors + parameters: + - $ref: '#/components/parameters/action_id' + - $ref: '#/components/parameters/space_id' + responses: + '200': + $ref: '#/components/responses/200_actions' + '401': + description: Authorization information is missing or invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/authorization_error' + servers: + - url: https://localhost:5601 + put: + summary: Updates the attributes for a connector. + operationId: legacyUpdateConnector + deprecated: true + description: Deprecated in 7.13.0. Use the update connector API instead. + tags: + - connectors + parameters: + - $ref: '#/components/parameters/kbn_xsrf' + - $ref: '#/components/parameters/action_id' + - $ref: '#/components/parameters/space_id' + requestBody: + required: true + content: + application/json: + schema: + title: Legacy update connector request body properties + description: The properties vary depending on the connector type. + type: object + properties: + config: + type: object + description: The new connector configuration. Configuration properties vary depending on the connector type. + name: + type: string + description: The new name for the connector. + secrets: + type: object + description: The updated secrets configuration for the connector. Secrets properties vary depending on the connector type. + responses: + '200': + $ref: '#/components/responses/200_actions' + '404': + description: Object is not found. + content: + application/json: + schema: + $ref: '#/components/schemas/object_not_found_error' + servers: + - url: https://localhost:5601 + servers: + - url: https://localhost:5601 + /s/{spaceId}/api/actions: + get: + summary: Retrieves all connectors. + operationId: legacyGetConnectors + deprecated: true + description: Deprecated in 7.13.0. Use the get all connectors API instead. + tags: + - connectors + parameters: + - $ref: '#/components/parameters/space_id' + responses: + '200': + description: Indicates a successful call. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/action_response_properties' + '401': + description: Authorization information is missing or invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/authorization_error' + servers: + - url: https://localhost:5601 + post: + summary: Creates a connector. + operationId: legacyCreateConnector + deprecated: true + description: Deprecated in 7.13.0. Use the create connector API instead. + tags: + - connectors + parameters: + - $ref: '#/components/parameters/kbn_xsrf' + - $ref: '#/components/parameters/space_id' + requestBody: + required: true + content: + application/json: + schema: + title: Legacy create connector request properties + type: object + properties: + actionTypeId: + type: string + description: The connector type identifier. + config: + type: object + description: The configuration for the connector. Configuration properties vary depending on the connector type. + name: + type: string + description: The display name for the connector. + secrets: + type: object + description: | + The secrets configuration for the connector. Secrets configuration properties vary depending on the connector type. NOTE: Remember these values. You must provide them each time you update the connector. + responses: + '200': + $ref: '#/components/responses/200_actions' + '401': + description: Authorization information is missing or invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/authorization_error' + servers: + - url: https://localhost:5601 + servers: + - url: https://localhost:5601 + /s/{spaceId}/api/actions/list_action_types: + get: + summary: Retrieves a list of all connector types. + operationId: legacyGetConnectorTypes + deprecated: true + description: Deprecated in 7.13.0. Use the get all connector types API instead. + tags: + - connectors + parameters: + - $ref: '#/components/parameters/space_id' + responses: + '200': + description: Indicates a successful call. + content: + application/json: + schema: + title: Legacy get connector types response body properties + description: The properties vary for each connector type. + type: array + items: + type: object + properties: + enabled: + type: boolean + description: Indicates whether the connector type is enabled in Kibana. + enabledInConfig: + type: boolean + description: Indicates whether the connector type is enabled in the Kibana `.yml` file. + enabledInLicense: + type: boolean + description: Indicates whether the connector is enabled in the license. + example: true + id: + type: string + description: The unique identifier for the connector type. + minimumLicenseRequired: + type: string + description: The license that is required to use the connector type. + name: + type: string + description: The name of the connector type. + '401': + description: Authorization information is missing or invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/authorization_error' + servers: + - url: https://localhost:5601 + servers: + - url: https://localhost:5601 + /s/{spaceId}/api/actions/action/{actionId}/_execute: + post: + summary: Runs a connector. + operationId: legacyRunConnector + deprecated: true + description: Deprecated in 7.13.0. Use the run connector API instead. + tags: + - connectors + parameters: + - $ref: '#/components/parameters/kbn_xsrf' + - $ref: '#/components/parameters/action_id' + - $ref: '#/components/parameters/space_id' + requestBody: + required: true + content: + application/json: + schema: + title: Legacy run connector request body properties + description: The properties vary depending on the connector type. + type: object + required: + - params + properties: + params: + type: object + description: The parameters of the connector. Parameter properties vary depending on the connector type. + responses: + '200': + description: Indicates a successful call. + content: + application/json: + schema: + $ref: '#/components/schemas/legacy_run_connector_general_response' + '401': + description: Authorization information is missing or invalid. + content: + application/json: + schema: + $ref: '#/components/schemas/authorization_error' + servers: + - url: https://localhost:5601 + servers: + - url: https://localhost:5601 +components: + securitySchemes: + basicAuth: + type: http + scheme: basic + apiKeyAuth: + type: apiKey + in: header + name: ApiKey + parameters: + kbn_xsrf: + schema: + type: string + in: header + name: kbn-xsrf + description: Cross-site request forgery protection + required: true + space_id: + in: path + name: spaceId + description: An identifier for the space. If `/s/` and the identifier are omitted from the path, the default space is used. + required: true + schema: + type: string + example: default + connector_id: + in: path + name: connectorId + description: An identifier for the connector. + required: true + schema: + type: string + example: df770e30-8b8b-11ed-a780-3b746c987a81 + action_id: + in: path + name: actionId + description: An identifier for the action. + required: true + schema: + type: string + example: c55b6eb0-6bad-11eb-9f3b-611eebc6c3ad + schemas: + config_properties_cases_webhook: + title: Connector request properties for Webhook - Case Management connector + required: + - createIncidentJson + - createIncidentResponseKey + - createIncidentUrl + - getIncidentResponseExternalTitleKey + - getIncidentUrl + - updateIncidentJson + - updateIncidentUrl + - viewIncidentUrl + description: Defines properties for connectors when type is `.cases-webhook`. + type: object + properties: + createCommentJson: + type: string + description: | + A JSON payload sent to the create comment URL to create a case comment. You can use variables to add Kibana Cases data to the payload. The required variable is `case.comment`. Due to Mustache template variables (the text enclosed in triple braces, for example, `{{{case.title}}}`), the JSON is not validated when you create the connector. The JSON is validated once the Mustache variables have been placed when the REST method runs. Manually ensure that the JSON is valid, disregarding the Mustache variables, so the later validation will pass. + example: + body: + '[object Object]': null + createCommentMethod: + type: string + description: | + The REST API HTTP request method to create a case comment in the third-party system. Valid values are `patch`, `post`, and `put`. + default: put + enum: + - patch + - post + - put + createCommentUrl: + type: string + description: | + The REST API URL to create a case comment by ID in the third-party system. You can use a variable to add the external system ID to the URL. If you are using the `xpack.actions.allowedHosts setting`, add the hostname to the allowed hosts. + example: https://testing-jira.atlassian.net/rest/api/2/issue/{{{external.system.id}}}/comment + createIncidentJson: + type: string + description: | + A JSON payload sent to the create case URL to create a case. You can use variables to add case data to the payload. Required variables are `case.title` and `case.description`. Due to Mustache template variables (which is the text enclosed in triple braces, for example, `{{{case.title}}}`), the JSON is not validated when you create the connector. The JSON is validated after the Mustache variables have been placed when REST method runs. Manually ensure that the JSON is valid to avoid future validation errors; disregard Mustache variables during your review. + example: + fields: + summary: + '[object Object]': null + description: + '[object Object]': null + labels: + '[object Object]': null + createIncidentMethod: + type: string + description: | + The REST API HTTP request method to create a case in the third-party system. Valid values are `patch`, `post`, and `put`. + enum: + - patch + - post + - put + default: post + createIncidentResponseKey: + type: string + description: The JSON key in the create case response that contains the external case ID. + createIncidentUrl: + type: string + description: | + The REST API URL to create a case in the third-party system. If you are using the `xpack.actions.allowedHosts` setting, add the hostname to the allowed hosts. + getIncidentResponseExternalTitleKey: + type: string + description: The JSON key in get case response that contains the external case title. + getIncidentUrl: + type: string + description: | + The REST API URL to get the case by ID from the third-party system. If you are using the `xpack.actions.allowedHosts` setting, add the hostname to the allowed hosts. You can use a variable to add the external system ID to the URL. Due to Mustache template variables (the text enclosed in triple braces, for example, `{{{case.title}}}`), the JSON is not validated when you create the connector. The JSON is validated after the Mustache variables have been placed when REST method runs. Manually ensure that the JSON is valid, disregarding the Mustache variables, so the later validation will pass. + example: https://testing-jira.atlassian.net/rest/api/2/issue/{{{external.system.id}}} + hasAuth: + type: boolean + description: If true, a username and password for login type authentication must be provided. + default: true + headers: + type: string + description: | + A set of key-value pairs sent as headers with the request URLs for the create case, update case, get case, and create comment methods. + updateIncidentJson: + type: string + description: | + The JSON payload sent to the update case URL to update the case. You can use variables to add Kibana Cases data to the payload. Required variables are `case.title` and `case.description`. Due to Mustache template variables (which is the text enclosed in triple braces, for example, `{{{case.title}}}`), the JSON is not validated when you create the connector. The JSON is validated after the Mustache variables have been placed when REST method runs. Manually ensure that the JSON is valid to avoid future validation errors; disregard Mustache variables during your review. + example: + fields: + summary: + '[object Object]': null + description: + '[object Object]': null + labels: + '[object Object]': null + updateIncidentMethod: + type: string + description: | + The REST API HTTP request method to update the case in the third-party system. Valid values are `patch`, `post`, and `put`. + default: put + enum: + - patch + - post + - put + updateIncidentUrl: + type: string + description: | + The REST API URL to update the case by ID in the third-party system. You can use a variable to add the external system ID to the URL. If you are using the `xpack.actions.allowedHosts` setting, add the hostname to the allowed hosts. + example: https://testing-jira.atlassian.net/rest/api/2/issue/{{{external.system.ID}}} + viewIncidentUrl: + type: string + description: | + The URL to view the case in the external system. You can use variables to add the external system ID or external system title to the URL. + example: https://testing-jira.atlassian.net/browse/{{{external.system.title}}} + secrets_properties_cases_webhook: + title: Connector secrets properties for Webhook - Case Management connector + type: object + properties: + password: + type: string + description: The password for HTTP basic authentication. If `hasAuth` is set to `true`, this property is required. + user: + type: string + description: The username for HTTP basic authentication. If `hasAuth` is set to `true`, this property is required. + create_connector_request_cases_webhook: + title: Create Webhook - Case Managment connector request + description: | + The Webhook - Case Management connector uses axios to send POST, PUT, and GET requests to a case management RESTful API web service. + type: object + required: + - config + - connector_type_id + - name + properties: + config: + $ref: '#/components/schemas/config_properties_cases_webhook' + connector_type_id: + type: string + description: The type of connector. + enum: + - .cases-webhook + example: .cases-webhook + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_cases_webhook' + config_properties_email: + title: Connector request properties for an email connector + description: Defines properties for connectors when type is `.email`. + type: object + properties: + from: + type: string + host: + type: string + port: + type: integer + clientId: + type: string + nullable: true + default: null + hasAuth: + type: boolean + default: true + oauthTokenUrl: + type: string + nullable: true + default: null + secure: + type: boolean + nullable: true + default: null + service: + type: string + default: other + tenantId: + type: string + nullable: true + default: null + secrets_properties_email: + title: Connector secrets properties for an email connector + description: Defines secrets for connectors when type is `.email`. + type: object + additionalProperties: true + create_connector_request_email: + title: Create email connector request + description: | + The email connector uses the SMTP protocol to send mail messages, using an integration of Nodemailer. An exception is Microsoft Exchange, which uses HTTP protocol for sending emails, Send mail. Email message text is sent as both plain text and html text. + type: object + required: + - config + - connector_type_id + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_email' + connector_type_id: + type: string + description: The type of connector. + enum: + - .email + example: .email + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_email' + config_properties_index: + title: Connector request properties for an index connector + required: + - index + description: Defines properties for connectors when type is `.index`. + type: object + properties: + executionTimeField: + description: Specifies a field that will contain the time the alert condition was detected. + default: null + type: string + nullable: true + index: + description: The Elasticsearch index to be written to. + type: string + refresh: + description: | + The refresh policy for the write request, which affects when changes are made visible to search. Refer to the refresh setting for Elasticsearch document APIs. + default: false + type: boolean + create_connector_request_index: + title: Create index connector request + description: The index connector indexes a document into Elasticsearch. + type: object + required: + - config + - connector_type_id + - name + properties: + config: + $ref: '#/components/schemas/config_properties_index' + connector_type_id: + type: string + description: The type of connector. + enum: + - .index + example: .index + name: + type: string + description: The display name for the connector. + example: my-connector + config_properties_jira: + title: Connector request properties for a Jira connector + required: + - apiUrl + - projectKey + description: Defines properties for connectors when type is `.jira`. + type: object + properties: + apiUrl: + description: The Jira instance URL. + type: string + projectKey: + description: The Jira project key. + type: string + secrets_properties_jira: + title: Connector secrets properties for a Jira connector + required: + - apiToken + - email + description: Defines secrets for connectors when type is `.jira`. + type: object + properties: + apiToken: + description: The Jira API authentication token for HTTP basic authentication. + type: string + email: + description: The account email for HTTP Basic authentication. + type: string + create_connector_request_jira: + title: Create Jira connector request + description: The Jira connector uses the REST API v2 to create Jira issues. + type: object + required: + - config + - connector_type_id + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_jira' + connector_type_id: + type: string + description: The type of connector. + enum: + - .jira + example: .jira + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_jira' + config_properties_opsgenie: + title: Connector request properties for an Opsgenie connector + required: + - apiUrl + description: Defines properties for connectors when type is `.opsgenie`. + type: object + properties: + apiUrl: + description: | + The Opsgenie URL. For example, `https://api.opsgenie.com` or `https://api.eu.opsgenie.com`. If you are using the `xpack.actions.allowedHosts` setting, add the hostname to the allowed hosts. + type: string + secrets_properties_opsgenie: + title: Connector secrets properties for an Opsgenie connector + required: + - apiKey + description: Defines secrets for connectors when type is `.opsgenie`. + type: object + properties: + apiKey: + description: The Opsgenie API authentication key for HTTP Basic authentication. + type: string + create_connector_request_opsgenie: + title: Create Opsgenie connector request + description: The Opsgenie connector uses the Opsgenie alert API. + type: object + required: + - config + - connector_type_id + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_opsgenie' + connector_type_id: + type: string + description: The type of connector. + enum: + - .opsgenie + example: .opsgenie + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_opsgenie' + config_properties_pagerduty: + title: Connector request properties for a PagerDuty connector + description: Defines properties for connectors when type is `.pagerduty`. + type: object + properties: + apiUrl: + type: string + nullable: true + secrets_properties_pagerduty: + title: Connector secrets properties for a PagerDuty connector + description: Defines secrets for connectors when type is `.pagerduty`. + type: object + additionalProperties: true + create_connector_request_pagerduty: + title: Create PagerDuty connector request + description: | + The PagerDuty connector uses the v2 Events API to trigger, acknowledge, and resolve PagerDuty alerts. + type: object + required: + - config + - connector_type_id + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_pagerduty' + connector_type_id: + type: string + description: The type of connector. + enum: + - .pagerduty + example: .pagerduty + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_pagerduty' + config_properties_resilient: + title: Connector request properties for a IBM Resilient connector + required: + - apiUrl + - orgId + description: Defines properties for connectors when type is `.resilient`. + type: object + properties: + apiUrl: + description: The IBM Resilient instance URL. + type: string + orgId: + description: The IBM Resilient organization ID. + type: string + secrets_properties_resilient: + title: Connector secrets properties for IBM Resilient connector + required: + - apiKeyId + - apiKeySecret + description: Defines secrets for connectors when type is `.resilient`. + type: object + properties: + apiKeyId: + type: string + description: The authentication key ID for HTTP Basic authentication. + apiKeySecret: + type: string + description: The authentication key secret for HTTP Basic authentication. + create_connector_request_resilient: + title: Create IBM Resilient connector request + description: The IBM Resilient connector uses the RESILIENT REST v2 to create IBM Resilient incidents. + type: object + required: + - config + - connector_type_id + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_resilient' + connector_type_id: + description: The type of connector. + type: string + example: .resilient + enum: + - .resilient + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_resilient' + create_connector_request_serverlog: + title: Create server log connector request + description: This connector writes an entry to the Kibana server log. + type: object + required: + - connector_type_id + - name + properties: + connector_type_id: + type: string + description: The type of connector. + enum: + - .server-log + example: .server-log + name: + type: string + description: The display name for the connector. + example: my-connector + config_properties_servicenow: + title: Connector request properties for a ServiceNow ITSM connector + required: + - apiUrl + description: Defines properties for connectors when type is `.servicenow`. + type: object + properties: + apiUrl: + type: string + description: The ServiceNow instance URL. + clientId: + description: | + The client ID assigned to your OAuth application. This property is required when `isOAuth` is `true`. + type: string + isOAuth: + description: | + The type of authentication to use. The default value is false, which means basic authentication is used instead of open authorization (OAuth). + default: false + type: boolean + jwtKeyId: + description: | + The key identifier assigned to the JWT verifier map of your OAuth application. This property is required when `isOAuth` is `true`. + type: string + userIdentifierValue: + description: | + The identifier to use for OAuth authentication. This identifier should be the user field you selected when you created an OAuth JWT API endpoint for external clients in your ServiceNow instance. For example, if the selected user field is `Email`, the user identifier should be the user's email address. This property is required when `isOAuth` is `true`. + type: string + usesTableApi: + description: | + Determines whether the connector uses the Table API or the Import Set API. This property is supported only for ServiceNow ITSM and ServiceNow SecOps connectors. NOTE: If this property is set to `false`, the Elastic application should be installed in ServiceNow. + default: true + type: boolean + secrets_properties_servicenow: + title: Connector secrets properties for ServiceNow ITOM, ServiceNow ITSM, and ServiceNow SecOps connectors + description: Defines secrets for connectors when type is `.servicenow`, `.servicenow-sir`, or `.servicenow-itom`. + type: object + properties: + clientSecret: + type: string + description: The client secret assigned to your OAuth application. This property is required when `isOAuth` is `true`. + password: + type: string + description: The password for HTTP basic authentication. This property is required when `isOAuth` is `false`. + privateKey: + type: string + description: The RSA private key that you created for use in ServiceNow. This property is required when `isOAuth` is `true`. + privateKeyPassword: + type: string + description: The password for the RSA private key. This property is required when `isOAuth` is `true` and you set a password on your private key. + username: + type: string + description: The username for HTTP basic authentication. This property is required when `isOAuth` is `false`. + create_connector_request_servicenow: + title: Create ServiceNow ITSM connector request + description: | + The ServiceNow ITSM connector uses the import set API to create ServiceNow incidents. You can use the connector for rule actions and cases. + type: object + required: + - config + - connector_type_id + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_servicenow' + connector_type_id: + type: string + description: The type of connector. + enum: + - .servicenow + example: .servicenow + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_servicenow' + config_properties_servicenow_itom: + title: Connector request properties for a ServiceNow ITSM connector + required: + - apiUrl + description: Defines properties for connectors when type is `.servicenow`. + type: object + properties: + apiUrl: + type: string + description: The ServiceNow instance URL. + clientId: + description: | + The client ID assigned to your OAuth application. This property is required when `isOAuth` is `true`. + type: string + isOAuth: + description: | + The type of authentication to use. The default value is false, which means basic authentication is used instead of open authorization (OAuth). + default: false + type: boolean + jwtKeyId: + description: | + The key identifier assigned to the JWT verifier map of your OAuth application. This property is required when `isOAuth` is `true`. + type: string + userIdentifierValue: + description: | + The identifier to use for OAuth authentication. This identifier should be the user field you selected when you created an OAuth JWT API endpoint for external clients in your ServiceNow instance. For example, if the selected user field is `Email`, the user identifier should be the user's email address. This property is required when `isOAuth` is `true`. + type: string + create_connector_request_servicenow_itom: + title: Create ServiceNow ITOM connector request + description: | + The ServiceNow ITOM connector uses the event API to create ServiceNow events. You can use the connector for rule actions. + type: object + required: + - config + - connector_type_id + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_servicenow_itom' + connector_type_id: + type: string + description: The type of connector. + enum: + - .servicenow-itom + example: .servicenow-itom + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_servicenow' + create_connector_request_servicenow_sir: + title: Create ServiceNow SecOps connector request + description: | + The ServiceNow SecOps connector uses the import set API to create ServiceNow security incidents. You can use the connector for rule actions and cases. + type: object + required: + - config + - connector_type_id + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_servicenow' + connector_type_id: + type: string + description: The type of connector. + enum: + - .servicenow-sir + example: .servicenow-sir + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_servicenow' + secrets_properties_slack: + title: Connector secrets properties for a Slack connector + description: Defines secrets for connectors when type is `.slack`. + type: object + additionalProperties: true + create_connector_request_slack: + title: Create Slack connector request + description: The Slack connector uses Slack Incoming Webhooks. + type: object + required: + - connector_type_id + - name + - secrets + properties: + connector_type_id: + type: string + description: The type of connector. + enum: + - .slack + example: .slack + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_slack' + config_properties_swimlane: + title: Connector request properties for a Swimlane connector + required: + - apiUrl + - appId + - connectorType + description: Defines properties for connectors when type is `.swimlane`. + type: object + properties: + apiUrl: + description: The Swimlane instance URL. + type: string + appId: + description: The Swimlane application ID. + type: string + connectorType: + description: The type of connector. Valid values are `all`, `alerts`, and `cases`. + type: string + enum: + - all + - alerts + - cases + mappings: + $ref: '#/components/schemas/config_properties_swimlane_mappings' + config_properties_swimlane_mappings: + title: Connector mappings properties for a Swimlane connector + description: The field mapping. + type: object + properties: + alertIdConfig: + title: Alert identifier mapping + description: Mapping for the alert ID. + type: object + required: + - fieldType + - id + - key + - name + properties: + fieldType: + type: string + description: The type of field in Swimlane. + id: + type: string + description: The identifier for the field in Swimlane. + key: + type: string + description: The key for the field in Swimlane. + name: + type: string + description: The name of the field in Swimlane. + caseIdConfig: + title: Case identifier mapping + description: Mapping for the case ID. + type: object + required: + - fieldType + - id + - key + - name + properties: + fieldType: + type: string + description: The type of field in Swimlane. + id: + type: string + description: The identifier for the field in Swimlane. + key: + type: string + description: The key for the field in Swimlane. + name: + type: string + description: The name of the field in Swimlane. + caseNameConfig: + title: Case name mapping + description: Mapping for the case name. + type: object + required: + - fieldType + - id + - key + - name + properties: + fieldType: + type: string + description: The type of field in Swimlane. + id: + type: string + description: The identifier for the field in Swimlane. + key: + type: string + description: The key for the field in Swimlane. + name: + type: string + description: The name of the field in Swimlane. + commentsConfig: + title: Case comment mapping + description: Mapping for the case comments. + type: object + required: + - fieldType + - id + - key + - name + properties: + fieldType: + type: string + description: The type of field in Swimlane. + id: + type: string + description: The identifier for the field in Swimlane. + key: + type: string + description: The key for the field in Swimlane. + name: + type: string + description: The name of the field in Swimlane. + descriptionConfig: + title: Case description mapping + description: Mapping for the case description. + type: object + required: + - fieldType + - id + - key + - name + properties: + fieldType: + type: string + description: The type of field in Swimlane. + id: + type: string + description: The identifier for the field in Swimlane. + key: + type: string + description: The key for the field in Swimlane. + name: + type: string + description: The name of the field in Swimlane. + ruleNameConfig: + title: Rule name mapping + description: Mapping for the name of the alert's rule. + type: object + required: + - fieldType + - id + - key + - name + properties: + fieldType: + type: string + description: The type of field in Swimlane. + id: + type: string + description: The identifier for the field in Swimlane. + key: + type: string + description: The key for the field in Swimlane. + name: + type: string + description: The name of the field in Swimlane. + severityConfig: + title: Severity mapping + description: Mapping for the severity. + type: object + required: + - fieldType + - id + - key + - name + properties: + fieldType: + type: string + description: The type of field in Swimlane. + id: + type: string + description: The identifier for the field in Swimlane. + key: + type: string + description: The key for the field in Swimlane. + name: + type: string + description: The name of the field in Swimlane. + secrets_properties_swimlane: + title: Connector secrets properties for a Swimlane connector + description: Defines secrets for connectors when type is `.swimlane`. + type: object + properties: + apiToken: + description: Swimlane API authentication token. + type: string + create_connector_request_swimlane: + title: Create Swimlane connector request + description: The Swimlane connector uses the Swimlane REST API to create Swimlane records. + type: object + required: + - config + - connector_type_id + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_swimlane' + connector_type_id: + type: string + description: The type of connector. + enum: + - .swimlane + example: .swimlane + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_swimlane' + secrets_properties_teams: + title: Connector secrets properties for a Microsoft Teams connector + description: Defines secrets for connectors when type is `.teams`. + type: object + additionalProperties: true + create_connector_request_teams: + title: Create Microsoft Teams connector request + description: The Microsoft Teams connector uses Incoming Webhooks. + type: object + required: + - connector_type_id + - name + - secrets + properties: + connector_type_id: + type: string + description: The type of connector. + enum: + - .teams + example: .teams + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_teams' + config_properties_tines: + title: Connector request properties for a Tines connector + description: Defines properties for connectors when type is `.tines`. + type: object + required: + - url + properties: + url: + type: string + secrets_properties_tines: + title: Connector secrets properties for a Tines connector + description: Defines secrets for connectors when type is `.tines`. + type: object + additionalProperties: true + create_connector_request_tines: + title: Create Tines connector request + description: | + The Tines connector uses Tines Webhook actions to send events via POST request. + type: object + required: + - config + - connector_type_id + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_tines' + connector_type_id: + type: string + description: The type of connector. + enum: + - .tines + example: .tines + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_tines' + config_properties_webhook: + title: Connector request properties for a Webhook connector + description: Defines properties for connectors when type is `.webhook`. + type: object + required: + - url + properties: + url: + type: string + method: + type: string + default: post + enum: + - patch + - post + - put + headers: + type: object + additionalProperties: true + hasAuth: + type: boolean + default: true + secrets_properties_webhook: + title: Connector secrets properties for a Webhook connector + description: Defines secrets for connectors when type is `.webhook`. + type: object + additionalProperties: true + create_connector_request_webhook: + title: Create Webhook connector request + description: | + The Webhook connector uses axios to send a POST or PUT request to a web service. + type: object + required: + - config + - connector_type_id + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_webhook' + connector_type_id: + type: string + description: The type of connector. + enum: + - .webhook + example: .webhook + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_webhook' + config_properties_xmatters: + title: Connector request properties for a xMatters connector + description: Defines properties for connectors when type is `.xmatters`. + type: object + properties: + configUrl: + type: string + nullable: true + usesBasic: + type: boolean + default: true + secrets_properties_xmatters: + title: Connector secrets properties for an xMatters connector + description: Defines secrets for connectors when type is `.xmatters`. + type: object + additionalProperties: true + create_connector_request_xmatters: + title: Create xMatters connector request + description: | + The xMatters connector uses the xMatters Workflow for Elastic to send actionable alerts to on-call xMatters resources. + type: object + required: + - config + - connector_type_id + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_xmatters' + connector_type_id: + type: string + description: The type of connector. + enum: + - .xmatters + example: .xmatters + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_xmatters' + is_deprecated: + type: boolean + description: Indicates whether the connector type is deprecated. + example: false + is_missing_secrets: + type: boolean + description: Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + example: false + is_preconfigured: + type: boolean + description: Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + example: false + connector_response_properties_cases_webhook: + title: Connector request properties for a Webhook - Case Management connector + type: object + required: + - config + - connector_type_id + - id + - is_preconfigured + - name + properties: + config: + $ref: '#/components/schemas/config_properties_cases_webhook' + connector_type_id: + description: The type of connector. + type: string + enum: + - .cases-webhook + id: + type: string + description: The identifier for the connector. + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + connector_response_properties_email: + title: Connector response properties for an email connector + type: object + required: + - config + - connector_type_id + - id + - is_preconfigured + - name + properties: + config: + $ref: '#/components/schemas/config_properties_email' + connector_type_id: + type: string + description: The type of connector. + enum: + - .email + id: + type: string + description: The identifier for the connector. + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + connector_response_properties_index: + title: Connector response properties for an index connector + type: object + required: + - config + - connector_type_id + - id + - is_preconfigured + - name + properties: + config: + $ref: '#/components/schemas/config_properties_index' + connector_type_id: + type: string + description: The type of connector. + enum: + - .index + id: + type: string + description: The identifier for the connector. + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + connector_response_properties_jira: + title: Connector response properties for a Jira connector + type: object + required: + - config + - connector_type_id + - id + - is_preconfigured + - name + properties: + config: + $ref: '#/components/schemas/config_properties_jira' + connector_type_id: + type: string + description: The type of connector. + enum: + - .jira + id: + type: string + description: The identifier for the connector. + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + connector_response_properties_opsgenie: + title: Connector response properties for an Opsgenie connector + type: object + required: + - config + - connector_type_id + - id + - is_preconfigured + - name + properties: + config: + $ref: '#/components/schemas/config_properties_opsgenie' + connector_type_id: + type: string + description: The type of connector. + enum: + - .opsgenie + id: + type: string + description: The identifier for the connector. + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + connector_response_properties_pagerduty: + title: Connector response properties for a PagerDuty connector + type: object + required: + - config + - connector_type_id + - id + - is_preconfigured + - name + properties: + config: + $ref: '#/components/schemas/config_properties_pagerduty' + connector_type_id: + type: string + description: The type of connector. + enum: + - .pagerduty + id: + type: string + description: The identifier for the connector. + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + connector_response_properties_resilient: + title: Connector response properties for a IBM Resilient connector + type: object + required: + - config + - connector_type_id + - id + - is_preconfigured + - name + properties: + config: + $ref: '#/components/schemas/config_properties_resilient' + connector_type_id: + type: string + description: The type of connector. + enum: + - .resilient + id: + type: string + description: The identifier for the connector. + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + connector_response_properties_serverlog: + title: Connector response properties for a server log connector + type: object + required: + - config + - connector_type_id + - id + - is_preconfigured + - name + properties: + config: + type: object + nullable: true + connector_type_id: + type: string + description: The type of connector. + enum: + - .server-log + id: + type: string + description: The identifier for the connector. + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + connector_response_properties_servicenow: + title: Connector response properties for a ServiceNow ITSM connector + type: object + required: + - config + - connector_type_id + - id + - is_preconfigured + - name + properties: + config: + $ref: '#/components/schemas/config_properties_servicenow' + connector_type_id: + type: string + description: The type of connector. + enum: + - .servicenow + id: + type: string + description: The identifier for the connector. + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + connector_response_properties_servicenow_itom: + title: Connector response properties for a ServiceNow ITOM connector + type: object + required: + - config + - connector_type_id + - id + - is_preconfigured + - name + properties: + config: + $ref: '#/components/schemas/config_properties_servicenow_itom' + connector_type_id: + type: string + description: The type of connector. + enum: + - .servicenow-itom + id: + type: string + description: The identifier for the connector. + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + connector_response_properties_servicenow_sir: + title: Connector response properties for a ServiceNow SecOps connector + type: object + required: + - config + - connector_type_id + - id + - is_preconfigured + - name + properties: + config: + $ref: '#/components/schemas/config_properties_servicenow' + connector_type_id: + type: string + description: The type of connector. + enum: + - .servicenow-sir + id: + type: string + description: The identifier for the connector. + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + connector_response_properties_slack: + title: Connector response properties for a Slack connector + type: object + required: + - connector_type_id + - id + - is_preconfigured + - name + properties: + connector_type_id: + type: string + description: The type of connector. + enum: + - .slack + id: + type: string + description: The identifier for the connector. + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + connector_response_properties_swimlane: + title: Connector response properties for a Swimlane connector + type: object + required: + - config + - connector_type_id + - id + - is_preconfigured + - name + properties: + config: + $ref: '#/components/schemas/config_properties_swimlane' + connector_type_id: + type: string + description: The type of connector. + enum: + - .swimlane + id: + type: string + description: The identifier for the connector. + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + connector_response_properties_teams: + title: Connector response properties for a Microsoft Teams connector + type: object + required: + - connector_type_id + - id + - is_preconfigured + - name + properties: + connector_type_id: + type: string + description: The type of connector. + enum: + - .teams + id: + type: string + description: The identifier for the connector. + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + connector_response_properties_tines: + title: Connector response properties for a Tines connector + type: object + required: + - config + - connector_type_id + - id + - is_preconfigured + - name + properties: + config: + $ref: '#/components/schemas/config_properties_tines' + connector_type_id: + type: string + description: The type of connector. + enum: + - .tines + id: + type: string + description: The identifier for the connector. + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + connector_response_properties_webhook: + title: Connector response properties for a Webhook connector + type: object + required: + - config + - connector_type_id + - id + - is_preconfigured + - name + properties: + config: + $ref: '#/components/schemas/config_properties_webhook' + connector_type_id: + type: string + description: The type of connector. + enum: + - .webhook + id: + type: string + description: The identifier for the connector. + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + connector_response_properties_xmatters: + title: Connector response properties for an xMatters connector + type: object + required: + - config + - connector_type_id + - id + - is_preconfigured + - name + properties: + config: + $ref: '#/components/schemas/config_properties_xmatters' + connector_type_id: + type: string + description: The type of connector. + enum: + - .xmatters + id: + type: string + description: The identifier for the connector. + is_deprecated: + $ref: '#/components/schemas/is_deprecated' + is_missing_secrets: + $ref: '#/components/schemas/is_missing_secrets' + is_preconfigured: + $ref: '#/components/schemas/is_preconfigured' + name: + type: string + description: The display name for the connector. + connector_response_properties: + title: Connector response properties + description: The properties vary depending on the connector type. + oneOf: + - $ref: '#/components/schemas/connector_response_properties_cases_webhook' + - $ref: '#/components/schemas/connector_response_properties_email' + - $ref: '#/components/schemas/connector_response_properties_index' + - $ref: '#/components/schemas/connector_response_properties_jira' + - $ref: '#/components/schemas/connector_response_properties_opsgenie' + - $ref: '#/components/schemas/connector_response_properties_pagerduty' + - $ref: '#/components/schemas/connector_response_properties_resilient' + - $ref: '#/components/schemas/connector_response_properties_serverlog' + - $ref: '#/components/schemas/connector_response_properties_servicenow' + - $ref: '#/components/schemas/connector_response_properties_servicenow_itom' + - $ref: '#/components/schemas/connector_response_properties_servicenow_sir' + - $ref: '#/components/schemas/connector_response_properties_slack' + - $ref: '#/components/schemas/connector_response_properties_swimlane' + - $ref: '#/components/schemas/connector_response_properties_teams' + - $ref: '#/components/schemas/connector_response_properties_tines' + - $ref: '#/components/schemas/connector_response_properties_webhook' + - $ref: '#/components/schemas/connector_response_properties_xmatters' + discriminator: + propertyName: connector_type_id + mapping: + .cases-webhook: '#/components/schemas/connector_response_properties_cases_webhook' + .email: '#/components/schemas/connector_response_properties_email' + .index: '#/components/schemas/connector_response_properties_index' + .jira: '#/components/schemas/connector_response_properties_jira' + .opsgenie: '#/components/schemas/connector_response_properties_opsgenie' + .pagerduty: '#/components/schemas/connector_response_properties_pagerduty' + .resilient: '#/components/schemas/connector_response_properties_resilient' + .server-log: '#/components/schemas/connector_response_properties_serverlog' + .servicenow: '#/components/schemas/connector_response_properties_servicenow' + .servicenow-itom: '#/components/schemas/connector_response_properties_servicenow_itom' + .servicenow-sir: '#/components/schemas/connector_response_properties_servicenow_sir' + .slack: '#/components/schemas/connector_response_properties_slack' + .swimlane: '#/components/schemas/connector_response_properties_swimlane' + .teams: '#/components/schemas/connector_response_properties_teams' + .tines: '#/components/schemas/connector_response_properties_tines' + .webhook: '#/components/schemas/connector_response_properties_webhook' + .xmatters: '#/components/schemas/connector_response_properties_xmatters' + update_connector_request_cases_webhook: + title: Update Webhook - Case Managment connector request + type: object + required: + - config + - name + properties: + config: + $ref: '#/components/schemas/config_properties_cases_webhook' + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_cases_webhook' + update_connector_request_email: + title: Update email connector request + type: object + required: + - config + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_email' + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_email' + update_connector_request_index: + title: Update index connector request + type: object + required: + - config + - name + properties: + config: + $ref: '#/components/schemas/config_properties_index' + name: + type: string + description: The display name for the connector. + update_connector_request_jira: + title: Update Jira connector request + type: object + required: + - config + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_jira' + name: + type: string + description: The display name for the connector. + secrets: + $ref: '#/components/schemas/secrets_properties_jira' + update_connector_request_opsgenie: + title: Update Opsgenie connector request + type: object + required: + - config + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_opsgenie' + name: + type: string + description: The display name for the connector. + secrets: + $ref: '#/components/schemas/secrets_properties_opsgenie' + update_connector_request_pagerduty: + title: Update PagerDuty connector request + description: | + The PagerDuty connector uses the v2 Events API to trigger, acknowledge, and resolve PagerDuty alerts. + type: object + required: + - config + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_pagerduty' + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_pagerduty' + update_connector_request_resilient: + title: Update IBM Resilient connector request + type: object + required: + - config + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_resilient' + name: + type: string + description: The display name for the connector. + secrets: + $ref: '#/components/schemas/secrets_properties_resilient' + update_connector_request_serverlog: + title: Update server log connector request + type: object + required: + - name + properties: + name: + type: string + description: The display name for the connector. + update_connector_request_servicenow: + title: Update ServiceNow ITSM connector or ServiceNow SecOps request + type: object + required: + - config + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_servicenow' + name: + type: string + description: The display name for the connector. + secrets: + $ref: '#/components/schemas/secrets_properties_servicenow' + update_connector_request_servicenow_itom: + title: Update ServiceNow ITOM connector request + type: object + required: + - config + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_servicenow_itom' + name: + type: string + description: The display name for the connector. + secrets: + $ref: '#/components/schemas/secrets_properties_servicenow' + update_connector_request_servicenow_sir: + title: Update ServiceNow SecOps connector request + description: | + The ServiceNow SecOps connector uses the import set API to create ServiceNow security incidents. You can use the connector for rule actions and cases. + type: object + required: + - config + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_servicenow' + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_servicenow' + update_connector_request_slack: + title: Update Slack connector request + description: The Slack connector uses Slack Incoming Webhooks. + type: object + required: + - name + - secrets + properties: + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_slack' + update_connector_request_swimlane: + title: Update Swimlane connector request + type: object + required: + - config + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_swimlane' + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_swimlane' + update_connector_request_teams: + title: Update Microsoft Teams connector request + description: The Microsoft Teams connector uses Incoming Webhooks. + type: object + required: + - name + - secrets + properties: + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_teams' + update_connector_request_tines: + title: Update Tines connector request + description: | + The Tines connector uses Tines Webhook actions to send events via POST request. + type: object + required: + - config + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_tines' + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_tines' + update_connector_request_webhook: + title: Update Webhook connector request + description: | + The Webhook connector uses axios to send a POST or PUT request to a web service. + type: object + required: + - config + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_webhook' + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_webhook' + update_connector_request_xmatters: + title: Update xMatters connector request + description: | + The xMatters connector uses the xMatters Workflow for Elastic to send actionable alerts to on-call xMatters resources. + type: object + required: + - config + - name + - secrets + properties: + config: + $ref: '#/components/schemas/config_properties_xmatters' + name: + type: string + description: The display name for the connector. + example: my-connector + secrets: + $ref: '#/components/schemas/secrets_properties_xmatters' + connector_types: + title: Connector types + type: string + description: The type of connector. For example, `.email`, `.index`, `.jira`, `.opsgenie`, or `.server-log`. + enum: + - .cases-webhook + - .email + - .index + - .jira + - .opsgenie + - .pagerduty + - .resilient + - .servicenow + - .servicenow-itom + - .servicenow-sir + - .server-log + - .slack + - .swimlane + - .teams + - .tines + - .webhook + - .xmatters + example: .server-log + features: + type: string + description: | + The feature that uses the connector. Valid values are `alerting`, `cases`, `uptime`, and `siem`. + enum: + - alerting + - cases + - uptime + - siem + run_connector_params_documents: + title: Index connector parameters + description: Test an action that indexes a document into Elasticsearch. + type: object + required: + - documents + properties: + documents: + type: array + description: The documents in JSON format for index connectors. + items: + type: object + additionalProperties: true + run_connector_params_level_message: + title: Server log connector parameters + description: Test an action that writes an entry to the Kibana server log. + type: object + required: + - message + properties: + level: + type: string + description: The log level of the message for server log connectors. + enum: + - debug + - error + - fatal + - info + - trace + - warn + default: info + message: + type: string + description: The message for server log connectors. + run_connector_subaction_addevent: + title: The addEvent subaction + type: object + required: + - subAction + description: The `addEvent` subaction for ServiceNow ITOM connectors. + properties: + subAction: + type: string + description: The action to test. + enum: + - addEvent + subActionParams: + type: object + description: The set of configuration properties for the action. + properties: + additional_info: + type: string + description: Additional information about the event. + description: + type: string + description: The details about the event. + event_class: + type: string + description: A specific instance of the source. + message_key: + type: string + description: All actions sharing this key are associated with the same ServiceNow alert. The default value is `:`. + metric_name: + type: string + description: The name of the metric. + node: + type: string + description: The host that the event was triggered for. + resource: + type: string + description: The name of the resource. + severity: + type: string + description: The severity of the event. + source: + type: string + description: The name of the event source type. + time_of_event: + type: string + description: The time of the event. + type: + type: string + description: The type of event. + run_connector_subaction_closealert: + title: The closeAlert subaction + type: object + required: + - subAction + - subActionParams + description: The `closeAlert` subaction for Opsgenie connectors. + properties: + subAction: + type: string + description: The action to test. + enum: + - closeAlert + subActionParams: + type: object + required: + - alias + properties: + alias: + type: string + description: The unique identifier used for alert deduplication in Opsgenie. The alias must match the value used when creating the alert. + note: + type: string + description: Additional information for the alert. + source: + type: string + description: The display name for the source of the alert. + user: + type: string + description: The display name for the owner. + run_connector_subaction_createalert: + title: The createAlert subaction + type: object + required: + - subAction + - subActionParams + description: The `createAlert` subaction for Opsgenie connectors. + properties: + subAction: + type: string + description: The action to test. + enum: + - createAlert + subActionParams: + type: object + required: + - message + properties: + actions: + type: array + description: The custom actions available to the alert. + items: + type: string + alias: + type: string + description: The unique identifier used for alert deduplication in Opsgenie. + description: + type: string + description: A description that provides detailed information about the alert. + details: + type: object + description: The custom properties of the alert. + additionalProperties: true + example: + key1: value1 + key2: value2 + entity: + type: string + description: The domain of the alert. For example, the application or server name. + message: + type: string + description: The alert message. + note: + type: string + description: Additional information for the alert. + priority: + type: string + description: The priority level for the alert. + enum: + - P1 + - P2 + - P3 + - P4 + - P5 + responders: + type: array + description: | + The entities to receive notifications about the alert. If `type` is `user`, either `id` or `username` is required. If `type` is `team`, either `id` or `name` is required. + items: + type: object + properties: + id: + type: string + description: The identifier for the entity. + name: + type: string + description: The name of the entity. + type: + type: string + description: The type of responders, in this case `escalation`. + enum: + - escalation + - schedule + - team + - user + username: + type: string + description: A valid email address for the user. + source: + type: string + description: The display name for the source of the alert. + tags: + type: array + description: The tags for the alert. + items: + type: string + user: + type: string + description: The display name for the owner. + visibleTo: + type: array + description: The teams and users that the alert will be visible to without sending a notification. Only one of `id`, `name`, or `username` is required. + items: + type: object + required: + - type + properties: + id: + type: string + description: The identifier for the entity. + name: + type: string + description: The name of the entity. + type: + type: string + description: Valid values are `team` and `user`. + enum: + - team + - user + username: + type: string + description: The user name. This property is required only when the `type` is `user`. + run_connector_subaction_fieldsbyissuetype: + title: The fieldsByIssueType subaction + type: object + required: + - subAction + - subActionParams + description: The `fieldsByIssueType` subaction for Jira connectors. + properties: + subAction: + type: string + description: The action to test. + enum: + - fieldsByIssueType + subActionParams: + type: object + required: + - id + properties: + id: + type: string + description: The Jira issue type identifier. + example: 10024 + run_connector_subaction_getchoices: + title: The getChoices subaction + type: object + required: + - subAction + - subActionParams + description: The `getChoices` subaction for ServiceNow ITOM, ServiceNow ITSM, and ServiceNow SecOps connectors. + properties: + subAction: + type: string + description: The action to test. + enum: + - getChoices + subActionParams: + type: object + description: The set of configuration properties for the action. + required: + - fields + properties: + fields: + type: array + description: An array of fields. + items: + type: string + run_connector_subaction_getfields: + title: The getFields subaction + type: object + required: + - subAction + description: The `getFields` subaction for Jira, ServiceNow ITSM, and ServiceNow SecOps connectors. + properties: + subAction: + type: string + description: The action to test. + enum: + - getFields + run_connector_subaction_getincident: + title: The getIncident subaction + type: object + description: The `getIncident` subaction for Jira, ServiceNow ITSM, and ServiceNow SecOps connectors. + required: + - subAction + - subActionParams + properties: + subAction: + type: string + description: The action to test. + enum: + - getIncident + subActionParams: + type: object + required: + - externalId + properties: + externalId: + type: string + description: The Jira, ServiceNow ITSM, or ServiceNow SecOps issue identifier. + example: 71778 + run_connector_subaction_issue: + title: The issue subaction + type: object + required: + - subAction + description: The `issue` subaction for Jira connectors. + properties: + subAction: + type: string + description: The action to test. + enum: + - issue + subActionParams: + type: object + required: + - id + properties: + id: + type: string + description: The Jira issue identifier. + example: 71778 + run_connector_subaction_issues: + title: The issues subaction + type: object + required: + - subAction + - subActionParams + description: The `issues` subaction for Jira connectors. + properties: + subAction: + type: string + description: The action to test. + enum: + - issues + subActionParams: + type: object + required: + - title + properties: + title: + type: string + description: The title of the Jira issue. + run_connector_subaction_issuetypes: + title: The issueTypes subaction + type: object + required: + - subAction + description: The `issueTypes` subaction for Jira connectors. + properties: + subAction: + type: string + description: The action to test. + enum: + - issueTypes + run_connector_subaction_pushtoservice: + title: The pushToService subaction + type: object + required: + - subAction + - subActionParams + description: The `pushToService` subaction for Jira, ServiceNow ITSM, ServiceNow SecOps, and Swimlane connectors. + properties: + subAction: + type: string + description: The action to test. + enum: + - pushToService + subActionParams: + type: object + description: The set of configuration properties for the action. + properties: + comments: + type: array + description: Additional information that is sent to Jira, ServiceNow ITSM, ServiceNow SecOps, or Swimlane. + items: + type: object + properties: + comment: + type: string + description: A comment related to the incident. For example, describe how to troubleshoot the issue. + commentId: + type: integer + description: A unique identifier for the comment. + incident: + type: object + description: Information necessary to create or update a Jira, ServiceNow ITSM, ServiveNow SecOps, or Swimlane incident. + properties: + alertId: + type: string + description: The alert identifier for Swimlane connectors. + caseId: + type: string + description: The case identifier for the incident for Swimlane connectors. + caseName: + type: string + description: The case name for the incident for Swimlane connectors. + category: + type: string + description: The category of the incident for ServiceNow ITSM and ServiceNow SecOps connectors. + correlation_display: + type: string + description: A descriptive label of the alert for correlation purposes for ServiceNow ITSM and ServiceNow SecOps connectors. + correlation_id: + type: string + description: | + The correlation identifier for the security incident for ServiceNow ITSM and ServiveNow SecOps connectors. Connectors using the same correlation ID are associated with the same ServiceNow incident. This value determines whether a new ServiceNow incident is created or an existing one is updated. Modifying this value is optional; if not modified, the rule ID and alert ID are combined as `{{ruleID}}:{{alert ID}}` to form the correlation ID value in ServiceNow. The maximum character length for this value is 100 characters. NOTE: Using the default configuration of `{{ruleID}}:{{alert ID}}` ensures that ServiceNow creates a separate incident record for every generated alert that uses a unique alert ID. If the rule generates multiple alerts that use the same alert IDs, ServiceNow creates and continually updates a single incident record for the alert. + description: + type: string + description: The description of the incident for Jira, ServiceNow ITSM, ServiceNow SecOps, and Swimlane connectors. + dest_ip: + description: | + A list of destination IP addresses related to the security incident for ServiceNow SecOps connectors. The IPs are added as observables to the security incident. + oneOf: + - type: string + - type: array + items: + type: string + externalId: + type: string + description: | + The Jira, ServiceNow ITSM, or ServiceNow SecOps issue identifier. If present, the incident is updated. Otherwise, a new incident is created. + impact: + type: string + description: The impact of the incident for ServiceNow ITSM connectors. + issueType: + type: integer + description: The type of incident for Jira connectors. For example, 10006. To obtain the list of valid values, set `subAction` to `issueTypes`. + labels: + type: array + items: + type: string + description: | + The labels for the incident for Jira connectors. NOTE: Labels cannot contain spaces. + malware_hash: + description: A list of malware hashes related to the security incident for ServiceNow SecOps connectors. The hashes are added as observables to the security incident. + oneOf: + - type: string + - type: array + items: + type: string + malware_url: + type: string + description: A list of malware URLs related to the security incident for ServiceNow SecOps connectors. The URLs are added as observables to the security incident. + oneOf: + - type: string + - type: array + items: + type: string + parent: + type: string + description: The ID or key of the parent issue for Jira connectors. Applies only to `Sub-task` types of issues. + priority: + type: string + description: The priority of the incident in Jira and ServiceNow SecOps connectors. + ruleName: + type: string + description: The rule name for Swimlane connectors. + severity: + type: string + description: The severity of the incident for ServiceNow ITSM and Swimlane connectors. + short_description: + type: string + description: | + A short description of the incident for ServiceNow ITSM and ServiceNow SecOps connectors. It is used for searching the contents of the knowledge base. + source_ip: + description: A list of source IP addresses related to the security incident for ServiceNow SecOps connectors. The IPs are added as observables to the security incident. + oneOf: + - type: string + - type: array + items: + type: string + subcategory: + type: string + description: The subcategory of the incident for ServiceNow ITSM and ServiceNow SecOps connectors. + summary: + type: string + description: A summary of the incident for Jira connectors. + title: + type: string + description: | + A title for the incident for Jira connectors. It is used for searching the contents of the knowledge base. + urgency: + type: string + description: The urgency of the incident for ServiceNow ITSM connectors. + action_response_properties: + title: Action response properties + description: The properties vary depending on the action type. + type: object + properties: + actionTypeId: + type: string + config: + type: object + id: + type: string + isDeprecated: + type: boolean + description: Indicates whether the action type is deprecated. + isMissingSecrets: + type: boolean + description: Indicates whether secrets are missing for the action. + isPreconfigured: + type: boolean + description: Indicates whether it is a preconfigured action. + name: + type: string + run_connector_general_response: + title: Response from running a connector. + type: object + required: + - connector_id + - status + properties: + connector_id: + type: string + description: The identifier for the connector. + data: + oneOf: + - type: object + description: Information returned from the action. + additionalProperties: true + - type: array + description: An array of information returned from the action. + items: + type: object + status: + type: string + description: The status of the action. + enum: + - error + - ok + legacy_run_connector_general_response: + title: Response from legacy endpoint for running a connector. + type: object + properties: + actionId: + type: string + data: + oneOf: + - type: object + description: Information returned from the action. + additionalProperties: true + - type: array + description: An array of information returned from the action. + items: + type: object + status: + type: string + description: The status of the action. + bad_request_error: + title: Bad request + type: object + properties: + error: + type: string + example: Bad Request + enum: + - Bad Request + message: + type: string + example: 'error validating action type config: [index]: expected value of type [string] but got [undefined]' + statusCode: + type: integer + example: 400 + enum: + - 400 + authorization_error: + type: object + title: Unauthorized response + properties: + error: + type: string + example: Unauthorized + enum: + - Unauthorized + message: + type: string + statusCode: + type: integer + example: 401 + enum: + - 401 + object_not_found_error: + type: object + title: Not found response + properties: + error: + type: string + example: Not Found + enum: + - Not Found + message: + type: string + example: Saved object [action/baf33fc0-920c-11ed-b36a-874bd1548a00] not found + statusCode: + type: integer + example: 404 + enum: + - 404 + examples: + create_index_connector_request: + summary: Create an index connector. + value: + name: my-connector + connector_type_id: .index + config: + index: test-index + create_index_connector_response: + summary: A new index connector. + value: + id: c55b6eb0-6bad-11eb-9f3b-611eebc6c3ad + connector_type_id: .index + name: my-connector + config: + index: test-index + refresh: false + executionTimeField: null + is_preconfigured: false + is_deprecated: false + is_missing_secrets: false + get_connector_response: + summary: A list of connector types + value: + id: df770e30-8b8b-11ed-a780-3b746c987a81 + name: my_server_log_connector + config: {} + connector_type_id: .server-log + is_preconfigured: false + is_deprecated: false + is_missing_secrets: false + update_index_connector_request: + summary: Update an index connector. + value: + name: updated-connector + config: + index: updated-index + get_connectors_response: + summary: A list of connectors + value: + - id: preconfigured-email-connector + name: my-preconfigured-email-notification + connector_type_id: .email + is_preconfigured: true + is_deprecated: false + referenced_by_count: 0 + - id: e07d0c80-8b8b-11ed-a780-3b746c987a81 + name: my-index-connector + config: + index: test-index + refresh: false + executionTimeField: null + connector_type_id: .index + is_preconfigured: false + is_deprecated: false + referenced_by_count: 2 + is_missing_secrets: false + get_connector_types_response: + summary: A list of connector types + value: + - id: .swimlane + name: Swimlane + enabled: true + enabled_in_config: true + enabled_in_license: true + minimum_license_required: gold + supported_feature_ids: + - alerting + - cases + - siem + - id: .index + name: Index + enabled: true + enabled_in_config: true + enabled_in_license: true + minimum_license_required: basic + supported_feature_ids: + - alerting + - uptime + - siem + - id: .server-log + name: Server log + enabled: true + enabled_in_config: true + enabled_in_license: true + minimum_license_required: basic + supported_feature_ids: + - alerting + - uptime + run_index_connector_request: + summary: Run an index connector. + value: + params: + documents: + - id: my_doc_id + name: my_doc_name + message: hello, world + run_jira_connector_request: + summary: Run a Jira connector to retrieve the list of issue types. + value: + params: + subAction: issueTypes + run_server_log_connector_request: + summary: Run a server log connector. + value: + params: + level: warn + message: Test warning message. + run_servicenow_itom_connector_request: + summary: Run a ServiceNow ITOM connector to retrieve the list of choices. + value: + params: + subAction: getChoices + subActionParams: + fields: + - severity + - urgency + run_swimlane_connector_request: + summary: Run a Swimlane connector to create an incident. + value: + params: + subAction: pushToService + subActionParams: + comments: + - commentId: 1 + comment: A comment about the incident. + incident: + caseId: '1000' + caseName: Case name + description: Description of the incident. + run_index_connector_response: + summary: Response from running an index connector. + value: + connector_id: fd38c600-96a5-11ed-bb79-353b74189cba + data: + errors: false + items: + - create: + _id: 4JtvwYUBrcyxt2NnfW3y + _index: my-index + _primary_term: 1 + _seq_no: 0 + _shards: + failed: 0 + successful: 1 + total: 2 + _version: 1 + result: created + status: 201 + took: 135 + status: ok + run_jira_connector_response: + summary: Response from retrieving the list of issue types for a Jira connector. + value: + connector_id: b3aad810-edbe-11ec-82d1-11348ecbf4a6 + data: + - id: 10024 + name: Improvement + - id: 10006 + name: Task + - id: 10007 + name: Sub-task + - id: 10025 + name: New Feature + - id: 10023 + name: Bug + - id: 10000 + name: Epic + status: ok + run_server_log_connector_response: + summary: Response from running a server log connector. + value: + connector_id: 7fc7b9a0-ecc9-11ec-8736-e7d63118c907 + status: ok + run_servicenow_itom_connector_response: + summary: Response from retrieving the list of choices for a ServiceNow ITOM connector. + value: + connector_id: 9d9be270-2fd2-11ed-b0e0-87533c532698 + data: + - dependent_value: '' + element: severity + label: Critical + value: 1 + - dependent_value: '' + element: severity + label: Major + value: 2 + - dependent_value: '' + element: severity + label: Minor + value: 3 + - dependent_value: '' + element: severity + label: Warning + value: 4 + - dependent_value: '' + element: severity + label: OK + value: 5 + - dependent_value: '' + element: severity + label: Clear + value: 0 + - dependent_value: '' + element: urgency + label: 1 - High + value: 1 + - dependent_value: '' + element: urgency + label: 2 - Medium + value: 2 + - dependent_value: '' + element: urgency + label: 3 - Low + value: 3 + status: ok + run_swimlane_connector_response: + summary: Response from creating a Swimlane incident. + value: + connector_id: a4746470-2f94-11ed-b0e0-87533c532698 + data: + id: aKPmBHWzmdRQtx6Mx + title: TEST-457 + url: https://elastic.swimlane.url.us/record/aNcL2xniGHGpa2AHb/aKPmBHWzmdRQtx6Mx + pushedDate: '2022-09-08T16:52:27.866Z' + comments: + - commentId: 1 + pushedDate: '2022-09-08T16:52:27.865Z' + status: ok + responses: + 200_actions: + description: Indicates a successful call. + content: + application/json: + schema: + $ref: '#/components/schemas/action_response_properties' +security: + - basicAuth: [] + - apiKeyAuth: [] diff --git a/generated/connectors/connectors.gen.go b/generated/connectors/connectors.gen.go new file mode 100644 index 000000000..5e81e8c35 --- /dev/null +++ b/generated/connectors/connectors.gen.go @@ -0,0 +1,5472 @@ +// Package connectors provides primitives to interact with the openapi HTTP API. +// +// Code generated by github.com/deepmap/oapi-codegen version v1.12.4 DO NOT EDIT. +package connectors + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "io" + "net/http" + "net/url" + "strings" + + "github.com/deepmap/oapi-codegen/pkg/runtime" +) + +const ( + ApiKeyAuthScopes = "apiKeyAuth.Scopes" + BasicAuthScopes = "basicAuth.Scopes" +) + +// Defines values for AuthorizationErrorError. +const ( + Unauthorized AuthorizationErrorError = "Unauthorized" +) + +// Defines values for AuthorizationErrorStatusCode. +const ( + N401 AuthorizationErrorStatusCode = 401 +) + +// Defines values for BadRequestErrorError. +const ( + BadRequest BadRequestErrorError = "Bad Request" +) + +// Defines values for BadRequestErrorStatusCode. +const ( + N400 BadRequestErrorStatusCode = 400 +) + +// Defines values for ConfigPropertiesCasesWebhookCreateCommentMethod. +const ( + ConfigPropertiesCasesWebhookCreateCommentMethodPatch ConfigPropertiesCasesWebhookCreateCommentMethod = "patch" + ConfigPropertiesCasesWebhookCreateCommentMethodPost ConfigPropertiesCasesWebhookCreateCommentMethod = "post" + ConfigPropertiesCasesWebhookCreateCommentMethodPut ConfigPropertiesCasesWebhookCreateCommentMethod = "put" +) + +// Defines values for ConfigPropertiesCasesWebhookCreateIncidentMethod. +const ( + ConfigPropertiesCasesWebhookCreateIncidentMethodPatch ConfigPropertiesCasesWebhookCreateIncidentMethod = "patch" + ConfigPropertiesCasesWebhookCreateIncidentMethodPost ConfigPropertiesCasesWebhookCreateIncidentMethod = "post" + ConfigPropertiesCasesWebhookCreateIncidentMethodPut ConfigPropertiesCasesWebhookCreateIncidentMethod = "put" +) + +// Defines values for ConfigPropertiesCasesWebhookUpdateIncidentMethod. +const ( + ConfigPropertiesCasesWebhookUpdateIncidentMethodPatch ConfigPropertiesCasesWebhookUpdateIncidentMethod = "patch" + ConfigPropertiesCasesWebhookUpdateIncidentMethodPost ConfigPropertiesCasesWebhookUpdateIncidentMethod = "post" + ConfigPropertiesCasesWebhookUpdateIncidentMethodPut ConfigPropertiesCasesWebhookUpdateIncidentMethod = "put" +) + +// Defines values for ConfigPropertiesSwimlaneConnectorType. +const ( + ConfigPropertiesSwimlaneConnectorTypeAlerts ConfigPropertiesSwimlaneConnectorType = "alerts" + ConfigPropertiesSwimlaneConnectorTypeAll ConfigPropertiesSwimlaneConnectorType = "all" + ConfigPropertiesSwimlaneConnectorTypeCases ConfigPropertiesSwimlaneConnectorType = "cases" +) + +// Defines values for ConfigPropertiesWebhookMethod. +const ( + ConfigPropertiesWebhookMethodPatch ConfigPropertiesWebhookMethod = "patch" + ConfigPropertiesWebhookMethodPost ConfigPropertiesWebhookMethod = "post" + ConfigPropertiesWebhookMethodPut ConfigPropertiesWebhookMethod = "put" +) + +// Defines values for ConnectorResponsePropertiesCasesWebhookConnectorTypeId. +const ( + ConnectorResponsePropertiesCasesWebhookConnectorTypeIdDotCasesWebhook ConnectorResponsePropertiesCasesWebhookConnectorTypeId = ".cases-webhook" +) + +// Defines values for ConnectorResponsePropertiesEmailConnectorTypeId. +const ( + ConnectorResponsePropertiesEmailConnectorTypeIdDotEmail ConnectorResponsePropertiesEmailConnectorTypeId = ".email" +) + +// Defines values for ConnectorResponsePropertiesIndexConnectorTypeId. +const ( + ConnectorResponsePropertiesIndexConnectorTypeIdDotIndex ConnectorResponsePropertiesIndexConnectorTypeId = ".index" +) + +// Defines values for ConnectorResponsePropertiesJiraConnectorTypeId. +const ( + ConnectorResponsePropertiesJiraConnectorTypeIdDotJira ConnectorResponsePropertiesJiraConnectorTypeId = ".jira" +) + +// Defines values for ConnectorResponsePropertiesOpsgenieConnectorTypeId. +const ( + ConnectorResponsePropertiesOpsgenieConnectorTypeIdDotOpsgenie ConnectorResponsePropertiesOpsgenieConnectorTypeId = ".opsgenie" +) + +// Defines values for ConnectorResponsePropertiesPagerdutyConnectorTypeId. +const ( + ConnectorResponsePropertiesPagerdutyConnectorTypeIdDotPagerduty ConnectorResponsePropertiesPagerdutyConnectorTypeId = ".pagerduty" +) + +// Defines values for ConnectorResponsePropertiesResilientConnectorTypeId. +const ( + ConnectorResponsePropertiesResilientConnectorTypeIdDotResilient ConnectorResponsePropertiesResilientConnectorTypeId = ".resilient" +) + +// Defines values for ConnectorResponsePropertiesServerlogConnectorTypeId. +const ( + ConnectorResponsePropertiesServerlogConnectorTypeIdDotServerLog ConnectorResponsePropertiesServerlogConnectorTypeId = ".server-log" +) + +// Defines values for ConnectorResponsePropertiesServicenowConnectorTypeId. +const ( + ConnectorResponsePropertiesServicenowConnectorTypeIdDotServicenow ConnectorResponsePropertiesServicenowConnectorTypeId = ".servicenow" +) + +// Defines values for ConnectorResponsePropertiesServicenowItomConnectorTypeId. +const ( + ConnectorResponsePropertiesServicenowItomConnectorTypeIdDotServicenowItom ConnectorResponsePropertiesServicenowItomConnectorTypeId = ".servicenow-itom" +) + +// Defines values for ConnectorResponsePropertiesServicenowSirConnectorTypeId. +const ( + ConnectorResponsePropertiesServicenowSirConnectorTypeIdDotServicenowSir ConnectorResponsePropertiesServicenowSirConnectorTypeId = ".servicenow-sir" +) + +// Defines values for ConnectorResponsePropertiesSlackConnectorTypeId. +const ( + ConnectorResponsePropertiesSlackConnectorTypeIdDotSlack ConnectorResponsePropertiesSlackConnectorTypeId = ".slack" +) + +// Defines values for ConnectorResponsePropertiesSwimlaneConnectorTypeId. +const ( + ConnectorResponsePropertiesSwimlaneConnectorTypeIdDotSwimlane ConnectorResponsePropertiesSwimlaneConnectorTypeId = ".swimlane" +) + +// Defines values for ConnectorResponsePropertiesTeamsConnectorTypeId. +const ( + ConnectorResponsePropertiesTeamsConnectorTypeIdDotTeams ConnectorResponsePropertiesTeamsConnectorTypeId = ".teams" +) + +// Defines values for ConnectorResponsePropertiesTinesConnectorTypeId. +const ( + ConnectorResponsePropertiesTinesConnectorTypeIdDotTines ConnectorResponsePropertiesTinesConnectorTypeId = ".tines" +) + +// Defines values for ConnectorResponsePropertiesWebhookConnectorTypeId. +const ( + ConnectorResponsePropertiesWebhookConnectorTypeIdDotWebhook ConnectorResponsePropertiesWebhookConnectorTypeId = ".webhook" +) + +// Defines values for ConnectorResponsePropertiesXmattersConnectorTypeId. +const ( + ConnectorResponsePropertiesXmattersConnectorTypeIdDotXmatters ConnectorResponsePropertiesXmattersConnectorTypeId = ".xmatters" +) + +// Defines values for ConnectorTypes. +const ( + ConnectorTypesDotCasesWebhook ConnectorTypes = ".cases-webhook" + ConnectorTypesDotEmail ConnectorTypes = ".email" + ConnectorTypesDotIndex ConnectorTypes = ".index" + ConnectorTypesDotJira ConnectorTypes = ".jira" + ConnectorTypesDotOpsgenie ConnectorTypes = ".opsgenie" + ConnectorTypesDotPagerduty ConnectorTypes = ".pagerduty" + ConnectorTypesDotResilient ConnectorTypes = ".resilient" + ConnectorTypesDotServerLog ConnectorTypes = ".server-log" + ConnectorTypesDotServicenow ConnectorTypes = ".servicenow" + ConnectorTypesDotServicenowItom ConnectorTypes = ".servicenow-itom" + ConnectorTypesDotServicenowSir ConnectorTypes = ".servicenow-sir" + ConnectorTypesDotSlack ConnectorTypes = ".slack" + ConnectorTypesDotSwimlane ConnectorTypes = ".swimlane" + ConnectorTypesDotTeams ConnectorTypes = ".teams" + ConnectorTypesDotTines ConnectorTypes = ".tines" + ConnectorTypesDotWebhook ConnectorTypes = ".webhook" + ConnectorTypesDotXmatters ConnectorTypes = ".xmatters" +) + +// Defines values for CreateConnectorRequestCasesWebhookConnectorTypeId. +const ( + DotCasesWebhook CreateConnectorRequestCasesWebhookConnectorTypeId = ".cases-webhook" +) + +// Defines values for CreateConnectorRequestEmailConnectorTypeId. +const ( + CreateConnectorRequestEmailConnectorTypeIdDotEmail CreateConnectorRequestEmailConnectorTypeId = ".email" +) + +// Defines values for CreateConnectorRequestIndexConnectorTypeId. +const ( + CreateConnectorRequestIndexConnectorTypeIdDotIndex CreateConnectorRequestIndexConnectorTypeId = ".index" +) + +// Defines values for CreateConnectorRequestJiraConnectorTypeId. +const ( + CreateConnectorRequestJiraConnectorTypeIdDotJira CreateConnectorRequestJiraConnectorTypeId = ".jira" +) + +// Defines values for CreateConnectorRequestOpsgenieConnectorTypeId. +const ( + CreateConnectorRequestOpsgenieConnectorTypeIdDotOpsgenie CreateConnectorRequestOpsgenieConnectorTypeId = ".opsgenie" +) + +// Defines values for CreateConnectorRequestPagerdutyConnectorTypeId. +const ( + CreateConnectorRequestPagerdutyConnectorTypeIdDotPagerduty CreateConnectorRequestPagerdutyConnectorTypeId = ".pagerduty" +) + +// Defines values for CreateConnectorRequestResilientConnectorTypeId. +const ( + CreateConnectorRequestResilientConnectorTypeIdDotResilient CreateConnectorRequestResilientConnectorTypeId = ".resilient" +) + +// Defines values for CreateConnectorRequestServerlogConnectorTypeId. +const ( + CreateConnectorRequestServerlogConnectorTypeIdDotServerLog CreateConnectorRequestServerlogConnectorTypeId = ".server-log" +) + +// Defines values for CreateConnectorRequestServicenowConnectorTypeId. +const ( + CreateConnectorRequestServicenowConnectorTypeIdDotServicenow CreateConnectorRequestServicenowConnectorTypeId = ".servicenow" +) + +// Defines values for CreateConnectorRequestServicenowItomConnectorTypeId. +const ( + CreateConnectorRequestServicenowItomConnectorTypeIdDotServicenowItom CreateConnectorRequestServicenowItomConnectorTypeId = ".servicenow-itom" +) + +// Defines values for CreateConnectorRequestServicenowSirConnectorTypeId. +const ( + CreateConnectorRequestServicenowSirConnectorTypeIdDotServicenowSir CreateConnectorRequestServicenowSirConnectorTypeId = ".servicenow-sir" +) + +// Defines values for CreateConnectorRequestSlackConnectorTypeId. +const ( + CreateConnectorRequestSlackConnectorTypeIdDotSlack CreateConnectorRequestSlackConnectorTypeId = ".slack" +) + +// Defines values for CreateConnectorRequestSwimlaneConnectorTypeId. +const ( + CreateConnectorRequestSwimlaneConnectorTypeIdDotSwimlane CreateConnectorRequestSwimlaneConnectorTypeId = ".swimlane" +) + +// Defines values for CreateConnectorRequestTeamsConnectorTypeId. +const ( + CreateConnectorRequestTeamsConnectorTypeIdDotTeams CreateConnectorRequestTeamsConnectorTypeId = ".teams" +) + +// Defines values for CreateConnectorRequestTinesConnectorTypeId. +const ( + CreateConnectorRequestTinesConnectorTypeIdDotTines CreateConnectorRequestTinesConnectorTypeId = ".tines" +) + +// Defines values for CreateConnectorRequestWebhookConnectorTypeId. +const ( + CreateConnectorRequestWebhookConnectorTypeIdDotWebhook CreateConnectorRequestWebhookConnectorTypeId = ".webhook" +) + +// Defines values for CreateConnectorRequestXmattersConnectorTypeId. +const ( + CreateConnectorRequestXmattersConnectorTypeIdDotXmatters CreateConnectorRequestXmattersConnectorTypeId = ".xmatters" +) + +// Defines values for Features. +const ( + FeaturesAlerting Features = "alerting" + FeaturesCases Features = "cases" + FeaturesSiem Features = "siem" + FeaturesUptime Features = "uptime" +) + +// Defines values for ObjectNotFoundErrorError. +const ( + NotFound ObjectNotFoundErrorError = "Not Found" +) + +// Defines values for ObjectNotFoundErrorStatusCode. +const ( + N404 ObjectNotFoundErrorStatusCode = 404 +) + +// Defines values for RunConnectorGeneralResponseStatus. +const ( + RunConnectorGeneralResponseStatusError RunConnectorGeneralResponseStatus = "error" + RunConnectorGeneralResponseStatusOk RunConnectorGeneralResponseStatus = "ok" +) + +// Defines values for RunConnectorParamsLevelMessageLevel. +const ( + RunConnectorParamsLevelMessageLevelDebug RunConnectorParamsLevelMessageLevel = "debug" + RunConnectorParamsLevelMessageLevelError RunConnectorParamsLevelMessageLevel = "error" + RunConnectorParamsLevelMessageLevelFatal RunConnectorParamsLevelMessageLevel = "fatal" + RunConnectorParamsLevelMessageLevelInfo RunConnectorParamsLevelMessageLevel = "info" + RunConnectorParamsLevelMessageLevelTrace RunConnectorParamsLevelMessageLevel = "trace" + RunConnectorParamsLevelMessageLevelWarn RunConnectorParamsLevelMessageLevel = "warn" +) + +// Defines values for RunConnectorSubactionAddeventSubAction. +const ( + AddEvent RunConnectorSubactionAddeventSubAction = "addEvent" +) + +// Defines values for RunConnectorSubactionClosealertSubAction. +const ( + CloseAlert RunConnectorSubactionClosealertSubAction = "closeAlert" +) + +// Defines values for RunConnectorSubactionCreatealertSubAction. +const ( + CreateAlert RunConnectorSubactionCreatealertSubAction = "createAlert" +) + +// Defines values for RunConnectorSubactionCreatealertSubActionParamsPriority. +const ( + P1 RunConnectorSubactionCreatealertSubActionParamsPriority = "P1" + P2 RunConnectorSubactionCreatealertSubActionParamsPriority = "P2" + P3 RunConnectorSubactionCreatealertSubActionParamsPriority = "P3" + P4 RunConnectorSubactionCreatealertSubActionParamsPriority = "P4" + P5 RunConnectorSubactionCreatealertSubActionParamsPriority = "P5" +) + +// Defines values for RunConnectorSubactionCreatealertSubActionParamsRespondersType. +const ( + RunConnectorSubactionCreatealertSubActionParamsRespondersTypeEscalation RunConnectorSubactionCreatealertSubActionParamsRespondersType = "escalation" + RunConnectorSubactionCreatealertSubActionParamsRespondersTypeSchedule RunConnectorSubactionCreatealertSubActionParamsRespondersType = "schedule" + RunConnectorSubactionCreatealertSubActionParamsRespondersTypeTeam RunConnectorSubactionCreatealertSubActionParamsRespondersType = "team" + RunConnectorSubactionCreatealertSubActionParamsRespondersTypeUser RunConnectorSubactionCreatealertSubActionParamsRespondersType = "user" +) + +// Defines values for RunConnectorSubactionCreatealertSubActionParamsVisibleToType. +const ( + RunConnectorSubactionCreatealertSubActionParamsVisibleToTypeTeam RunConnectorSubactionCreatealertSubActionParamsVisibleToType = "team" + RunConnectorSubactionCreatealertSubActionParamsVisibleToTypeUser RunConnectorSubactionCreatealertSubActionParamsVisibleToType = "user" +) + +// Defines values for RunConnectorSubactionFieldsbyissuetypeSubAction. +const ( + FieldsByIssueType RunConnectorSubactionFieldsbyissuetypeSubAction = "fieldsByIssueType" +) + +// Defines values for RunConnectorSubactionGetchoicesSubAction. +const ( + GetChoices RunConnectorSubactionGetchoicesSubAction = "getChoices" +) + +// Defines values for RunConnectorSubactionGetfieldsSubAction. +const ( + GetFields RunConnectorSubactionGetfieldsSubAction = "getFields" +) + +// Defines values for RunConnectorSubactionGetincidentSubAction. +const ( + GetIncident RunConnectorSubactionGetincidentSubAction = "getIncident" +) + +// Defines values for RunConnectorSubactionIssueSubAction. +const ( + Issue RunConnectorSubactionIssueSubAction = "issue" +) + +// Defines values for RunConnectorSubactionIssuesSubAction. +const ( + Issues RunConnectorSubactionIssuesSubAction = "issues" +) + +// Defines values for RunConnectorSubactionIssuetypesSubAction. +const ( + IssueTypes RunConnectorSubactionIssuetypesSubAction = "issueTypes" +) + +// Defines values for RunConnectorSubactionPushtoserviceSubAction. +const ( + PushToService RunConnectorSubactionPushtoserviceSubAction = "pushToService" +) + +// ActionResponseProperties The properties vary depending on the action type. +type ActionResponseProperties struct { + ActionTypeId *string `json:"actionTypeId,omitempty"` + Config *map[string]interface{} `json:"config,omitempty"` + Id *string `json:"id,omitempty"` + + // IsDeprecated Indicates whether the action type is deprecated. + IsDeprecated *bool `json:"isDeprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the action. + IsMissingSecrets *bool `json:"isMissingSecrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured action. + IsPreconfigured *bool `json:"isPreconfigured,omitempty"` + Name *string `json:"name,omitempty"` +} + +// AuthorizationError defines model for authorization_error. +type AuthorizationError struct { + Error *AuthorizationErrorError `json:"error,omitempty"` + Message *string `json:"message,omitempty"` + StatusCode *AuthorizationErrorStatusCode `json:"statusCode,omitempty"` +} + +// AuthorizationErrorError defines model for AuthorizationError.Error. +type AuthorizationErrorError string + +// AuthorizationErrorStatusCode defines model for AuthorizationError.StatusCode. +type AuthorizationErrorStatusCode int + +// BadRequestError defines model for bad_request_error. +type BadRequestError struct { + Error *BadRequestErrorError `json:"error,omitempty"` + Message *string `json:"message,omitempty"` + StatusCode *BadRequestErrorStatusCode `json:"statusCode,omitempty"` +} + +// BadRequestErrorError defines model for BadRequestError.Error. +type BadRequestErrorError string + +// BadRequestErrorStatusCode defines model for BadRequestError.StatusCode. +type BadRequestErrorStatusCode int + +// ConfigPropertiesCasesWebhook Defines properties for connectors when type is `.cases-webhook`. +type ConfigPropertiesCasesWebhook struct { + // CreateCommentJson A JSON payload sent to the create comment URL to create a case comment. You can use variables to add Kibana Cases data to the payload. The required variable is `case.comment`. Due to Mustache template variables (the text enclosed in triple braces, for example, `{{{case.title}}}`), the JSON is not validated when you create the connector. The JSON is validated once the Mustache variables have been placed when the REST method runs. Manually ensure that the JSON is valid, disregarding the Mustache variables, so the later validation will pass. + CreateCommentJson *string `json:"createCommentJson,omitempty"` + + // CreateCommentMethod The REST API HTTP request method to create a case comment in the third-party system. Valid values are `patch`, `post`, and `put`. + CreateCommentMethod *ConfigPropertiesCasesWebhookCreateCommentMethod `json:"createCommentMethod,omitempty"` + + // CreateCommentUrl The REST API URL to create a case comment by ID in the third-party system. You can use a variable to add the external system ID to the URL. If you are using the `xpack.actions.allowedHosts setting`, add the hostname to the allowed hosts. + CreateCommentUrl *string `json:"createCommentUrl,omitempty"` + + // CreateIncidentJson A JSON payload sent to the create case URL to create a case. You can use variables to add case data to the payload. Required variables are `case.title` and `case.description`. Due to Mustache template variables (which is the text enclosed in triple braces, for example, `{{{case.title}}}`), the JSON is not validated when you create the connector. The JSON is validated after the Mustache variables have been placed when REST method runs. Manually ensure that the JSON is valid to avoid future validation errors; disregard Mustache variables during your review. + CreateIncidentJson string `json:"createIncidentJson"` + + // CreateIncidentMethod The REST API HTTP request method to create a case in the third-party system. Valid values are `patch`, `post`, and `put`. + CreateIncidentMethod *ConfigPropertiesCasesWebhookCreateIncidentMethod `json:"createIncidentMethod,omitempty"` + + // CreateIncidentResponseKey The JSON key in the create case response that contains the external case ID. + CreateIncidentResponseKey string `json:"createIncidentResponseKey"` + + // CreateIncidentUrl The REST API URL to create a case in the third-party system. If you are using the `xpack.actions.allowedHosts` setting, add the hostname to the allowed hosts. + CreateIncidentUrl string `json:"createIncidentUrl"` + + // GetIncidentResponseExternalTitleKey The JSON key in get case response that contains the external case title. + GetIncidentResponseExternalTitleKey string `json:"getIncidentResponseExternalTitleKey"` + + // GetIncidentUrl The REST API URL to get the case by ID from the third-party system. If you are using the `xpack.actions.allowedHosts` setting, add the hostname to the allowed hosts. You can use a variable to add the external system ID to the URL. Due to Mustache template variables (the text enclosed in triple braces, for example, `{{{case.title}}}`), the JSON is not validated when you create the connector. The JSON is validated after the Mustache variables have been placed when REST method runs. Manually ensure that the JSON is valid, disregarding the Mustache variables, so the later validation will pass. + GetIncidentUrl string `json:"getIncidentUrl"` + + // HasAuth If true, a username and password for login type authentication must be provided. + HasAuth *bool `json:"hasAuth,omitempty"` + + // Headers A set of key-value pairs sent as headers with the request URLs for the create case, update case, get case, and create comment methods. + Headers *string `json:"headers,omitempty"` + + // UpdateIncidentJson The JSON payload sent to the update case URL to update the case. You can use variables to add Kibana Cases data to the payload. Required variables are `case.title` and `case.description`. Due to Mustache template variables (which is the text enclosed in triple braces, for example, `{{{case.title}}}`), the JSON is not validated when you create the connector. The JSON is validated after the Mustache variables have been placed when REST method runs. Manually ensure that the JSON is valid to avoid future validation errors; disregard Mustache variables during your review. + UpdateIncidentJson string `json:"updateIncidentJson"` + + // UpdateIncidentMethod The REST API HTTP request method to update the case in the third-party system. Valid values are `patch`, `post`, and `put`. + UpdateIncidentMethod *ConfigPropertiesCasesWebhookUpdateIncidentMethod `json:"updateIncidentMethod,omitempty"` + + // UpdateIncidentUrl The REST API URL to update the case by ID in the third-party system. You can use a variable to add the external system ID to the URL. If you are using the `xpack.actions.allowedHosts` setting, add the hostname to the allowed hosts. + UpdateIncidentUrl string `json:"updateIncidentUrl"` + + // ViewIncidentUrl The URL to view the case in the external system. You can use variables to add the external system ID or external system title to the URL. + ViewIncidentUrl string `json:"viewIncidentUrl"` +} + +// ConfigPropertiesCasesWebhookCreateCommentMethod The REST API HTTP request method to create a case comment in the third-party system. Valid values are `patch`, `post`, and `put`. +type ConfigPropertiesCasesWebhookCreateCommentMethod string + +// ConfigPropertiesCasesWebhookCreateIncidentMethod The REST API HTTP request method to create a case in the third-party system. Valid values are `patch`, `post`, and `put`. +type ConfigPropertiesCasesWebhookCreateIncidentMethod string + +// ConfigPropertiesCasesWebhookUpdateIncidentMethod The REST API HTTP request method to update the case in the third-party system. Valid values are `patch`, `post`, and `put`. +type ConfigPropertiesCasesWebhookUpdateIncidentMethod string + +// ConfigPropertiesEmail Defines properties for connectors when type is `.email`. +type ConfigPropertiesEmail struct { + ClientId *string `json:"clientId"` + From *string `json:"from,omitempty"` + HasAuth *bool `json:"hasAuth,omitempty"` + Host *string `json:"host,omitempty"` + OauthTokenUrl *string `json:"oauthTokenUrl"` + Port *int `json:"port,omitempty"` + Secure *bool `json:"secure"` + Service *string `json:"service,omitempty"` + TenantId *string `json:"tenantId"` +} + +// ConfigPropertiesIndex Defines properties for connectors when type is `.index`. +type ConfigPropertiesIndex struct { + // ExecutionTimeField Specifies a field that will contain the time the alert condition was detected. + ExecutionTimeField *string `json:"executionTimeField"` + + // Index The Elasticsearch index to be written to. + Index string `json:"index"` + + // Refresh The refresh policy for the write request, which affects when changes are made visible to search. Refer to the refresh setting for Elasticsearch document APIs. + Refresh *bool `json:"refresh,omitempty"` +} + +// ConfigPropertiesJira Defines properties for connectors when type is `.jira`. +type ConfigPropertiesJira struct { + // ApiUrl The Jira instance URL. + ApiUrl string `json:"apiUrl"` + + // ProjectKey The Jira project key. + ProjectKey string `json:"projectKey"` +} + +// ConfigPropertiesOpsgenie Defines properties for connectors when type is `.opsgenie`. +type ConfigPropertiesOpsgenie struct { + // ApiUrl The Opsgenie URL. For example, `https://api.opsgenie.com` or `https://api.eu.opsgenie.com`. If you are using the `xpack.actions.allowedHosts` setting, add the hostname to the allowed hosts. + ApiUrl string `json:"apiUrl"` +} + +// ConfigPropertiesPagerduty Defines properties for connectors when type is `.pagerduty`. +type ConfigPropertiesPagerduty struct { + ApiUrl *string `json:"apiUrl"` +} + +// ConfigPropertiesResilient Defines properties for connectors when type is `.resilient`. +type ConfigPropertiesResilient struct { + // ApiUrl The IBM Resilient instance URL. + ApiUrl string `json:"apiUrl"` + + // OrgId The IBM Resilient organization ID. + OrgId string `json:"orgId"` +} + +// ConfigPropertiesServicenow Defines properties for connectors when type is `.servicenow`. +type ConfigPropertiesServicenow struct { + // ApiUrl The ServiceNow instance URL. + ApiUrl string `json:"apiUrl"` + + // ClientId The client ID assigned to your OAuth application. This property is required when `isOAuth` is `true`. + ClientId *string `json:"clientId,omitempty"` + + // IsOAuth The type of authentication to use. The default value is false, which means basic authentication is used instead of open authorization (OAuth). + IsOAuth *bool `json:"isOAuth,omitempty"` + + // JwtKeyId The key identifier assigned to the JWT verifier map of your OAuth application. This property is required when `isOAuth` is `true`. + JwtKeyId *string `json:"jwtKeyId,omitempty"` + + // UserIdentifierValue The identifier to use for OAuth authentication. This identifier should be the user field you selected when you created an OAuth JWT API endpoint for external clients in your ServiceNow instance. For example, if the selected user field is `Email`, the user identifier should be the user's email address. This property is required when `isOAuth` is `true`. + UserIdentifierValue *string `json:"userIdentifierValue,omitempty"` + + // UsesTableApi Determines whether the connector uses the Table API or the Import Set API. This property is supported only for ServiceNow ITSM and ServiceNow SecOps connectors. NOTE: If this property is set to `false`, the Elastic application should be installed in ServiceNow. + UsesTableApi *bool `json:"usesTableApi,omitempty"` +} + +// ConfigPropertiesServicenowItom Defines properties for connectors when type is `.servicenow`. +type ConfigPropertiesServicenowItom struct { + // ApiUrl The ServiceNow instance URL. + ApiUrl string `json:"apiUrl"` + + // ClientId The client ID assigned to your OAuth application. This property is required when `isOAuth` is `true`. + ClientId *string `json:"clientId,omitempty"` + + // IsOAuth The type of authentication to use. The default value is false, which means basic authentication is used instead of open authorization (OAuth). + IsOAuth *bool `json:"isOAuth,omitempty"` + + // JwtKeyId The key identifier assigned to the JWT verifier map of your OAuth application. This property is required when `isOAuth` is `true`. + JwtKeyId *string `json:"jwtKeyId,omitempty"` + + // UserIdentifierValue The identifier to use for OAuth authentication. This identifier should be the user field you selected when you created an OAuth JWT API endpoint for external clients in your ServiceNow instance. For example, if the selected user field is `Email`, the user identifier should be the user's email address. This property is required when `isOAuth` is `true`. + UserIdentifierValue *string `json:"userIdentifierValue,omitempty"` +} + +// ConfigPropertiesSwimlane Defines properties for connectors when type is `.swimlane`. +type ConfigPropertiesSwimlane struct { + // ApiUrl The Swimlane instance URL. + ApiUrl string `json:"apiUrl"` + + // AppId The Swimlane application ID. + AppId string `json:"appId"` + + // ConnectorType The type of connector. Valid values are `all`, `alerts`, and `cases`. + ConnectorType ConfigPropertiesSwimlaneConnectorType `json:"connectorType"` + + // Mappings The field mapping. + Mappings *ConfigPropertiesSwimlaneMappings `json:"mappings,omitempty"` +} + +// ConfigPropertiesSwimlaneConnectorType The type of connector. Valid values are `all`, `alerts`, and `cases`. +type ConfigPropertiesSwimlaneConnectorType string + +// ConfigPropertiesSwimlaneMappings The field mapping. +type ConfigPropertiesSwimlaneMappings struct { + // AlertIdConfig Mapping for the alert ID. + AlertIdConfig *struct { + // FieldType The type of field in Swimlane. + FieldType string `json:"fieldType"` + + // Id The identifier for the field in Swimlane. + Id string `json:"id"` + + // Key The key for the field in Swimlane. + Key string `json:"key"` + + // Name The name of the field in Swimlane. + Name string `json:"name"` + } `json:"alertIdConfig,omitempty"` + + // CaseIdConfig Mapping for the case ID. + CaseIdConfig *struct { + // FieldType The type of field in Swimlane. + FieldType string `json:"fieldType"` + + // Id The identifier for the field in Swimlane. + Id string `json:"id"` + + // Key The key for the field in Swimlane. + Key string `json:"key"` + + // Name The name of the field in Swimlane. + Name string `json:"name"` + } `json:"caseIdConfig,omitempty"` + + // CaseNameConfig Mapping for the case name. + CaseNameConfig *struct { + // FieldType The type of field in Swimlane. + FieldType string `json:"fieldType"` + + // Id The identifier for the field in Swimlane. + Id string `json:"id"` + + // Key The key for the field in Swimlane. + Key string `json:"key"` + + // Name The name of the field in Swimlane. + Name string `json:"name"` + } `json:"caseNameConfig,omitempty"` + + // CommentsConfig Mapping for the case comments. + CommentsConfig *struct { + // FieldType The type of field in Swimlane. + FieldType string `json:"fieldType"` + + // Id The identifier for the field in Swimlane. + Id string `json:"id"` + + // Key The key for the field in Swimlane. + Key string `json:"key"` + + // Name The name of the field in Swimlane. + Name string `json:"name"` + } `json:"commentsConfig,omitempty"` + + // DescriptionConfig Mapping for the case description. + DescriptionConfig *struct { + // FieldType The type of field in Swimlane. + FieldType string `json:"fieldType"` + + // Id The identifier for the field in Swimlane. + Id string `json:"id"` + + // Key The key for the field in Swimlane. + Key string `json:"key"` + + // Name The name of the field in Swimlane. + Name string `json:"name"` + } `json:"descriptionConfig,omitempty"` + + // RuleNameConfig Mapping for the name of the alert's rule. + RuleNameConfig *struct { + // FieldType The type of field in Swimlane. + FieldType string `json:"fieldType"` + + // Id The identifier for the field in Swimlane. + Id string `json:"id"` + + // Key The key for the field in Swimlane. + Key string `json:"key"` + + // Name The name of the field in Swimlane. + Name string `json:"name"` + } `json:"ruleNameConfig,omitempty"` + + // SeverityConfig Mapping for the severity. + SeverityConfig *struct { + // FieldType The type of field in Swimlane. + FieldType string `json:"fieldType"` + + // Id The identifier for the field in Swimlane. + Id string `json:"id"` + + // Key The key for the field in Swimlane. + Key string `json:"key"` + + // Name The name of the field in Swimlane. + Name string `json:"name"` + } `json:"severityConfig,omitempty"` +} + +// ConfigPropertiesTines Defines properties for connectors when type is `.tines`. +type ConfigPropertiesTines struct { + Url string `json:"url"` +} + +// ConfigPropertiesWebhook Defines properties for connectors when type is `.webhook`. +type ConfigPropertiesWebhook struct { + HasAuth *bool `json:"hasAuth,omitempty"` + Headers *map[string]interface{} `json:"headers,omitempty"` + Method *ConfigPropertiesWebhookMethod `json:"method,omitempty"` + Url string `json:"url"` +} + +// ConfigPropertiesWebhookMethod defines model for ConfigPropertiesWebhook.Method. +type ConfigPropertiesWebhookMethod string + +// ConfigPropertiesXmatters Defines properties for connectors when type is `.xmatters`. +type ConfigPropertiesXmatters struct { + ConfigUrl *string `json:"configUrl"` + UsesBasic *bool `json:"usesBasic,omitempty"` +} + +// ConnectorResponseProperties The properties vary depending on the connector type. +type ConnectorResponseProperties struct { + union json.RawMessage +} + +// ConnectorResponsePropertiesCasesWebhook defines model for connector_response_properties_cases_webhook. +type ConnectorResponsePropertiesCasesWebhook struct { + // Config Defines properties for connectors when type is `.cases-webhook`. + Config ConfigPropertiesCasesWebhook `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId ConnectorResponsePropertiesCasesWebhookConnectorTypeId `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// ConnectorResponsePropertiesCasesWebhookConnectorTypeId The type of connector. +type ConnectorResponsePropertiesCasesWebhookConnectorTypeId string + +// ConnectorResponsePropertiesEmail defines model for connector_response_properties_email. +type ConnectorResponsePropertiesEmail struct { + // Config Defines properties for connectors when type is `.email`. + Config ConfigPropertiesEmail `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId ConnectorResponsePropertiesEmailConnectorTypeId `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// ConnectorResponsePropertiesEmailConnectorTypeId The type of connector. +type ConnectorResponsePropertiesEmailConnectorTypeId string + +// ConnectorResponsePropertiesIndex defines model for connector_response_properties_index. +type ConnectorResponsePropertiesIndex struct { + // Config Defines properties for connectors when type is `.index`. + Config ConfigPropertiesIndex `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId ConnectorResponsePropertiesIndexConnectorTypeId `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// ConnectorResponsePropertiesIndexConnectorTypeId The type of connector. +type ConnectorResponsePropertiesIndexConnectorTypeId string + +// ConnectorResponsePropertiesJira defines model for connector_response_properties_jira. +type ConnectorResponsePropertiesJira struct { + // Config Defines properties for connectors when type is `.jira`. + Config ConfigPropertiesJira `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId ConnectorResponsePropertiesJiraConnectorTypeId `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// ConnectorResponsePropertiesJiraConnectorTypeId The type of connector. +type ConnectorResponsePropertiesJiraConnectorTypeId string + +// ConnectorResponsePropertiesOpsgenie defines model for connector_response_properties_opsgenie. +type ConnectorResponsePropertiesOpsgenie struct { + // Config Defines properties for connectors when type is `.opsgenie`. + Config ConfigPropertiesOpsgenie `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId ConnectorResponsePropertiesOpsgenieConnectorTypeId `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// ConnectorResponsePropertiesOpsgenieConnectorTypeId The type of connector. +type ConnectorResponsePropertiesOpsgenieConnectorTypeId string + +// ConnectorResponsePropertiesPagerduty defines model for connector_response_properties_pagerduty. +type ConnectorResponsePropertiesPagerduty struct { + // Config Defines properties for connectors when type is `.pagerduty`. + Config ConfigPropertiesPagerduty `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId ConnectorResponsePropertiesPagerdutyConnectorTypeId `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// ConnectorResponsePropertiesPagerdutyConnectorTypeId The type of connector. +type ConnectorResponsePropertiesPagerdutyConnectorTypeId string + +// ConnectorResponsePropertiesResilient defines model for connector_response_properties_resilient. +type ConnectorResponsePropertiesResilient struct { + // Config Defines properties for connectors when type is `.resilient`. + Config ConfigPropertiesResilient `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId ConnectorResponsePropertiesResilientConnectorTypeId `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// ConnectorResponsePropertiesResilientConnectorTypeId The type of connector. +type ConnectorResponsePropertiesResilientConnectorTypeId string + +// ConnectorResponsePropertiesServerlog defines model for connector_response_properties_serverlog. +type ConnectorResponsePropertiesServerlog struct { + Config *map[string]interface{} `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId ConnectorResponsePropertiesServerlogConnectorTypeId `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// ConnectorResponsePropertiesServerlogConnectorTypeId The type of connector. +type ConnectorResponsePropertiesServerlogConnectorTypeId string + +// ConnectorResponsePropertiesServicenow defines model for connector_response_properties_servicenow. +type ConnectorResponsePropertiesServicenow struct { + // Config Defines properties for connectors when type is `.servicenow`. + Config ConfigPropertiesServicenow `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId ConnectorResponsePropertiesServicenowConnectorTypeId `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// ConnectorResponsePropertiesServicenowConnectorTypeId The type of connector. +type ConnectorResponsePropertiesServicenowConnectorTypeId string + +// ConnectorResponsePropertiesServicenowItom defines model for connector_response_properties_servicenow_itom. +type ConnectorResponsePropertiesServicenowItom struct { + // Config Defines properties for connectors when type is `.servicenow`. + Config ConfigPropertiesServicenowItom `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId ConnectorResponsePropertiesServicenowItomConnectorTypeId `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// ConnectorResponsePropertiesServicenowItomConnectorTypeId The type of connector. +type ConnectorResponsePropertiesServicenowItomConnectorTypeId string + +// ConnectorResponsePropertiesServicenowSir defines model for connector_response_properties_servicenow_sir. +type ConnectorResponsePropertiesServicenowSir struct { + // Config Defines properties for connectors when type is `.servicenow`. + Config ConfigPropertiesServicenow `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId ConnectorResponsePropertiesServicenowSirConnectorTypeId `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// ConnectorResponsePropertiesServicenowSirConnectorTypeId The type of connector. +type ConnectorResponsePropertiesServicenowSirConnectorTypeId string + +// ConnectorResponsePropertiesSlack defines model for connector_response_properties_slack. +type ConnectorResponsePropertiesSlack struct { + // ConnectorTypeId The type of connector. + ConnectorTypeId ConnectorResponsePropertiesSlackConnectorTypeId `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// ConnectorResponsePropertiesSlackConnectorTypeId The type of connector. +type ConnectorResponsePropertiesSlackConnectorTypeId string + +// ConnectorResponsePropertiesSwimlane defines model for connector_response_properties_swimlane. +type ConnectorResponsePropertiesSwimlane struct { + // Config Defines properties for connectors when type is `.swimlane`. + Config ConfigPropertiesSwimlane `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId ConnectorResponsePropertiesSwimlaneConnectorTypeId `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// ConnectorResponsePropertiesSwimlaneConnectorTypeId The type of connector. +type ConnectorResponsePropertiesSwimlaneConnectorTypeId string + +// ConnectorResponsePropertiesTeams defines model for connector_response_properties_teams. +type ConnectorResponsePropertiesTeams struct { + // ConnectorTypeId The type of connector. + ConnectorTypeId ConnectorResponsePropertiesTeamsConnectorTypeId `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// ConnectorResponsePropertiesTeamsConnectorTypeId The type of connector. +type ConnectorResponsePropertiesTeamsConnectorTypeId string + +// ConnectorResponsePropertiesTines defines model for connector_response_properties_tines. +type ConnectorResponsePropertiesTines struct { + // Config Defines properties for connectors when type is `.tines`. + Config ConfigPropertiesTines `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId ConnectorResponsePropertiesTinesConnectorTypeId `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// ConnectorResponsePropertiesTinesConnectorTypeId The type of connector. +type ConnectorResponsePropertiesTinesConnectorTypeId string + +// ConnectorResponsePropertiesWebhook defines model for connector_response_properties_webhook. +type ConnectorResponsePropertiesWebhook struct { + // Config Defines properties for connectors when type is `.webhook`. + Config ConfigPropertiesWebhook `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId ConnectorResponsePropertiesWebhookConnectorTypeId `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// ConnectorResponsePropertiesWebhookConnectorTypeId The type of connector. +type ConnectorResponsePropertiesWebhookConnectorTypeId string + +// ConnectorResponsePropertiesXmatters defines model for connector_response_properties_xmatters. +type ConnectorResponsePropertiesXmatters struct { + // Config Defines properties for connectors when type is `.xmatters`. + Config ConfigPropertiesXmatters `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId ConnectorResponsePropertiesXmattersConnectorTypeId `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// ConnectorResponsePropertiesXmattersConnectorTypeId The type of connector. +type ConnectorResponsePropertiesXmattersConnectorTypeId string + +// ConnectorTypes The type of connector. For example, `.email`, `.index`, `.jira`, `.opsgenie`, or `.server-log`. +type ConnectorTypes string + +// CreateConnectorRequestCasesWebhook The Webhook - Case Management connector uses axios to send POST, PUT, and GET requests to a case management RESTful API web service. +type CreateConnectorRequestCasesWebhook struct { + // Config Defines properties for connectors when type is `.cases-webhook`. + Config ConfigPropertiesCasesWebhook `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId CreateConnectorRequestCasesWebhookConnectorTypeId `json:"connector_type_id"` + + // Name The display name for the connector. + Name string `json:"name"` + Secrets *SecretsPropertiesCasesWebhook `json:"secrets,omitempty"` +} + +// CreateConnectorRequestCasesWebhookConnectorTypeId The type of connector. +type CreateConnectorRequestCasesWebhookConnectorTypeId string + +// CreateConnectorRequestEmail The email connector uses the SMTP protocol to send mail messages, using an integration of Nodemailer. An exception is Microsoft Exchange, which uses HTTP protocol for sending emails, Send mail. Email message text is sent as both plain text and html text. +type CreateConnectorRequestEmail struct { + // Config Defines properties for connectors when type is `.email`. + Config ConfigPropertiesEmail `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId CreateConnectorRequestEmailConnectorTypeId `json:"connector_type_id"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.email`. + Secrets SecretsPropertiesEmail `json:"secrets"` +} + +// CreateConnectorRequestEmailConnectorTypeId The type of connector. +type CreateConnectorRequestEmailConnectorTypeId string + +// CreateConnectorRequestIndex The index connector indexes a document into Elasticsearch. +type CreateConnectorRequestIndex struct { + // Config Defines properties for connectors when type is `.index`. + Config ConfigPropertiesIndex `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId CreateConnectorRequestIndexConnectorTypeId `json:"connector_type_id"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// CreateConnectorRequestIndexConnectorTypeId The type of connector. +type CreateConnectorRequestIndexConnectorTypeId string + +// CreateConnectorRequestJira The Jira connector uses the REST API v2 to create Jira issues. +type CreateConnectorRequestJira struct { + // Config Defines properties for connectors when type is `.jira`. + Config ConfigPropertiesJira `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId CreateConnectorRequestJiraConnectorTypeId `json:"connector_type_id"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.jira`. + Secrets SecretsPropertiesJira `json:"secrets"` +} + +// CreateConnectorRequestJiraConnectorTypeId The type of connector. +type CreateConnectorRequestJiraConnectorTypeId string + +// CreateConnectorRequestOpsgenie The Opsgenie connector uses the Opsgenie alert API. +type CreateConnectorRequestOpsgenie struct { + // Config Defines properties for connectors when type is `.opsgenie`. + Config ConfigPropertiesOpsgenie `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId CreateConnectorRequestOpsgenieConnectorTypeId `json:"connector_type_id"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.opsgenie`. + Secrets SecretsPropertiesOpsgenie `json:"secrets"` +} + +// CreateConnectorRequestOpsgenieConnectorTypeId The type of connector. +type CreateConnectorRequestOpsgenieConnectorTypeId string + +// CreateConnectorRequestPagerduty The PagerDuty connector uses the v2 Events API to trigger, acknowledge, and resolve PagerDuty alerts. +type CreateConnectorRequestPagerduty struct { + // Config Defines properties for connectors when type is `.pagerduty`. + Config ConfigPropertiesPagerduty `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId CreateConnectorRequestPagerdutyConnectorTypeId `json:"connector_type_id"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.pagerduty`. + Secrets SecretsPropertiesPagerduty `json:"secrets"` +} + +// CreateConnectorRequestPagerdutyConnectorTypeId The type of connector. +type CreateConnectorRequestPagerdutyConnectorTypeId string + +// CreateConnectorRequestResilient The IBM Resilient connector uses the RESILIENT REST v2 to create IBM Resilient incidents. +type CreateConnectorRequestResilient struct { + // Config Defines properties for connectors when type is `.resilient`. + Config ConfigPropertiesResilient `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId CreateConnectorRequestResilientConnectorTypeId `json:"connector_type_id"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.resilient`. + Secrets SecretsPropertiesResilient `json:"secrets"` +} + +// CreateConnectorRequestResilientConnectorTypeId The type of connector. +type CreateConnectorRequestResilientConnectorTypeId string + +// CreateConnectorRequestServerlog This connector writes an entry to the Kibana server log. +type CreateConnectorRequestServerlog struct { + // ConnectorTypeId The type of connector. + ConnectorTypeId CreateConnectorRequestServerlogConnectorTypeId `json:"connector_type_id"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// CreateConnectorRequestServerlogConnectorTypeId The type of connector. +type CreateConnectorRequestServerlogConnectorTypeId string + +// CreateConnectorRequestServicenow The ServiceNow ITSM connector uses the import set API to create ServiceNow incidents. You can use the connector for rule actions and cases. +type CreateConnectorRequestServicenow struct { + // Config Defines properties for connectors when type is `.servicenow`. + Config ConfigPropertiesServicenow `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId CreateConnectorRequestServicenowConnectorTypeId `json:"connector_type_id"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.servicenow`, `.servicenow-sir`, or `.servicenow-itom`. + Secrets SecretsPropertiesServicenow `json:"secrets"` +} + +// CreateConnectorRequestServicenowConnectorTypeId The type of connector. +type CreateConnectorRequestServicenowConnectorTypeId string + +// CreateConnectorRequestServicenowItom The ServiceNow ITOM connector uses the event API to create ServiceNow events. You can use the connector for rule actions. +type CreateConnectorRequestServicenowItom struct { + // Config Defines properties for connectors when type is `.servicenow`. + Config ConfigPropertiesServicenowItom `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId CreateConnectorRequestServicenowItomConnectorTypeId `json:"connector_type_id"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.servicenow`, `.servicenow-sir`, or `.servicenow-itom`. + Secrets SecretsPropertiesServicenow `json:"secrets"` +} + +// CreateConnectorRequestServicenowItomConnectorTypeId The type of connector. +type CreateConnectorRequestServicenowItomConnectorTypeId string + +// CreateConnectorRequestServicenowSir The ServiceNow SecOps connector uses the import set API to create ServiceNow security incidents. You can use the connector for rule actions and cases. +type CreateConnectorRequestServicenowSir struct { + // Config Defines properties for connectors when type is `.servicenow`. + Config ConfigPropertiesServicenow `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId CreateConnectorRequestServicenowSirConnectorTypeId `json:"connector_type_id"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.servicenow`, `.servicenow-sir`, or `.servicenow-itom`. + Secrets SecretsPropertiesServicenow `json:"secrets"` +} + +// CreateConnectorRequestServicenowSirConnectorTypeId The type of connector. +type CreateConnectorRequestServicenowSirConnectorTypeId string + +// CreateConnectorRequestSlack The Slack connector uses Slack Incoming Webhooks. +type CreateConnectorRequestSlack struct { + // ConnectorTypeId The type of connector. + ConnectorTypeId CreateConnectorRequestSlackConnectorTypeId `json:"connector_type_id"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.slack`. + Secrets SecretsPropertiesSlack `json:"secrets"` +} + +// CreateConnectorRequestSlackConnectorTypeId The type of connector. +type CreateConnectorRequestSlackConnectorTypeId string + +// CreateConnectorRequestSwimlane The Swimlane connector uses the Swimlane REST API to create Swimlane records. +type CreateConnectorRequestSwimlane struct { + // Config Defines properties for connectors when type is `.swimlane`. + Config ConfigPropertiesSwimlane `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId CreateConnectorRequestSwimlaneConnectorTypeId `json:"connector_type_id"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.swimlane`. + Secrets SecretsPropertiesSwimlane `json:"secrets"` +} + +// CreateConnectorRequestSwimlaneConnectorTypeId The type of connector. +type CreateConnectorRequestSwimlaneConnectorTypeId string + +// CreateConnectorRequestTeams The Microsoft Teams connector uses Incoming Webhooks. +type CreateConnectorRequestTeams struct { + // ConnectorTypeId The type of connector. + ConnectorTypeId CreateConnectorRequestTeamsConnectorTypeId `json:"connector_type_id"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.teams`. + Secrets SecretsPropertiesTeams `json:"secrets"` +} + +// CreateConnectorRequestTeamsConnectorTypeId The type of connector. +type CreateConnectorRequestTeamsConnectorTypeId string + +// CreateConnectorRequestTines The Tines connector uses Tines Webhook actions to send events via POST request. +type CreateConnectorRequestTines struct { + // Config Defines properties for connectors when type is `.tines`. + Config ConfigPropertiesTines `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId CreateConnectorRequestTinesConnectorTypeId `json:"connector_type_id"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.tines`. + Secrets SecretsPropertiesTines `json:"secrets"` +} + +// CreateConnectorRequestTinesConnectorTypeId The type of connector. +type CreateConnectorRequestTinesConnectorTypeId string + +// CreateConnectorRequestWebhook The Webhook connector uses axios to send a POST or PUT request to a web service. +type CreateConnectorRequestWebhook struct { + // Config Defines properties for connectors when type is `.webhook`. + Config ConfigPropertiesWebhook `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId CreateConnectorRequestWebhookConnectorTypeId `json:"connector_type_id"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.webhook`. + Secrets SecretsPropertiesWebhook `json:"secrets"` +} + +// CreateConnectorRequestWebhookConnectorTypeId The type of connector. +type CreateConnectorRequestWebhookConnectorTypeId string + +// CreateConnectorRequestXmatters The xMatters connector uses the xMatters Workflow for Elastic to send actionable alerts to on-call xMatters resources. +type CreateConnectorRequestXmatters struct { + // Config Defines properties for connectors when type is `.xmatters`. + Config ConfigPropertiesXmatters `json:"config"` + + // ConnectorTypeId The type of connector. + ConnectorTypeId CreateConnectorRequestXmattersConnectorTypeId `json:"connector_type_id"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.xmatters`. + Secrets SecretsPropertiesXmatters `json:"secrets"` +} + +// CreateConnectorRequestXmattersConnectorTypeId The type of connector. +type CreateConnectorRequestXmattersConnectorTypeId string + +// Features The feature that uses the connector. Valid values are `alerting`, `cases`, `uptime`, and `siem`. +type Features string + +// IsDeprecated Indicates whether the connector type is deprecated. +type IsDeprecated = bool + +// IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. +type IsMissingSecrets = bool + +// IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. +type IsPreconfigured = bool + +// LegacyRunConnectorGeneralResponse defines model for legacy_run_connector_general_response. +type LegacyRunConnectorGeneralResponse struct { + ActionId *string `json:"actionId,omitempty"` + Data *LegacyRunConnectorGeneralResponse_Data `json:"data,omitempty"` + + // Status The status of the action. + Status *string `json:"status,omitempty"` +} + +// LegacyRunConnectorGeneralResponseData0 Information returned from the action. +type LegacyRunConnectorGeneralResponseData0 map[string]interface{} + +// LegacyRunConnectorGeneralResponseData1 An array of information returned from the action. +type LegacyRunConnectorGeneralResponseData1 = []map[string]interface{} + +// LegacyRunConnectorGeneralResponse_Data defines model for LegacyRunConnectorGeneralResponse.Data. +type LegacyRunConnectorGeneralResponse_Data struct { + union json.RawMessage +} + +// ObjectNotFoundError defines model for object_not_found_error. +type ObjectNotFoundError struct { + Error *ObjectNotFoundErrorError `json:"error,omitempty"` + Message *string `json:"message,omitempty"` + StatusCode *ObjectNotFoundErrorStatusCode `json:"statusCode,omitempty"` +} + +// ObjectNotFoundErrorError defines model for ObjectNotFoundError.Error. +type ObjectNotFoundErrorError string + +// ObjectNotFoundErrorStatusCode defines model for ObjectNotFoundError.StatusCode. +type ObjectNotFoundErrorStatusCode int + +// RunConnectorGeneralResponse defines model for run_connector_general_response. +type RunConnectorGeneralResponse struct { + // ConnectorId The identifier for the connector. + ConnectorId string `json:"connector_id"` + Data *RunConnectorGeneralResponse_Data `json:"data,omitempty"` + + // Status The status of the action. + Status RunConnectorGeneralResponseStatus `json:"status"` +} + +// RunConnectorGeneralResponseData0 Information returned from the action. +type RunConnectorGeneralResponseData0 map[string]interface{} + +// RunConnectorGeneralResponseData1 An array of information returned from the action. +type RunConnectorGeneralResponseData1 = []map[string]interface{} + +// RunConnectorGeneralResponse_Data defines model for RunConnectorGeneralResponse.Data. +type RunConnectorGeneralResponse_Data struct { + union json.RawMessage +} + +// RunConnectorGeneralResponseStatus The status of the action. +type RunConnectorGeneralResponseStatus string + +// RunConnectorParamsDocuments Test an action that indexes a document into Elasticsearch. +type RunConnectorParamsDocuments struct { + // Documents The documents in JSON format for index connectors. + Documents []map[string]interface{} `json:"documents"` +} + +// RunConnectorParamsLevelMessage Test an action that writes an entry to the Kibana server log. +type RunConnectorParamsLevelMessage struct { + // Level The log level of the message for server log connectors. + Level *RunConnectorParamsLevelMessageLevel `json:"level,omitempty"` + + // Message The message for server log connectors. + Message string `json:"message"` +} + +// RunConnectorParamsLevelMessageLevel The log level of the message for server log connectors. +type RunConnectorParamsLevelMessageLevel string + +// RunConnectorSubactionAddevent The `addEvent` subaction for ServiceNow ITOM connectors. +type RunConnectorSubactionAddevent struct { + // SubAction The action to test. + SubAction RunConnectorSubactionAddeventSubAction `json:"subAction"` + + // SubActionParams The set of configuration properties for the action. + SubActionParams *struct { + // AdditionalInfo Additional information about the event. + AdditionalInfo *string `json:"additional_info,omitempty"` + + // Description The details about the event. + Description *string `json:"description,omitempty"` + + // EventClass A specific instance of the source. + EventClass *string `json:"event_class,omitempty"` + + // MessageKey All actions sharing this key are associated with the same ServiceNow alert. The default value is `:`. + MessageKey *string `json:"message_key,omitempty"` + + // MetricName The name of the metric. + MetricName *string `json:"metric_name,omitempty"` + + // Node The host that the event was triggered for. + Node *string `json:"node,omitempty"` + + // Resource The name of the resource. + Resource *string `json:"resource,omitempty"` + + // Severity The severity of the event. + Severity *string `json:"severity,omitempty"` + + // Source The name of the event source type. + Source *string `json:"source,omitempty"` + + // TimeOfEvent The time of the event. + TimeOfEvent *string `json:"time_of_event,omitempty"` + + // Type The type of event. + Type *string `json:"type,omitempty"` + } `json:"subActionParams,omitempty"` +} + +// RunConnectorSubactionAddeventSubAction The action to test. +type RunConnectorSubactionAddeventSubAction string + +// RunConnectorSubactionClosealert The `closeAlert` subaction for Opsgenie connectors. +type RunConnectorSubactionClosealert struct { + // SubAction The action to test. + SubAction RunConnectorSubactionClosealertSubAction `json:"subAction"` + SubActionParams struct { + // Alias The unique identifier used for alert deduplication in Opsgenie. The alias must match the value used when creating the alert. + Alias string `json:"alias"` + + // Note Additional information for the alert. + Note *string `json:"note,omitempty"` + + // Source The display name for the source of the alert. + Source *string `json:"source,omitempty"` + + // User The display name for the owner. + User *string `json:"user,omitempty"` + } `json:"subActionParams"` +} + +// RunConnectorSubactionClosealertSubAction The action to test. +type RunConnectorSubactionClosealertSubAction string + +// RunConnectorSubactionCreatealert The `createAlert` subaction for Opsgenie connectors. +type RunConnectorSubactionCreatealert struct { + // SubAction The action to test. + SubAction RunConnectorSubactionCreatealertSubAction `json:"subAction"` + SubActionParams struct { + // Actions The custom actions available to the alert. + Actions *[]string `json:"actions,omitempty"` + + // Alias The unique identifier used for alert deduplication in Opsgenie. + Alias *string `json:"alias,omitempty"` + + // Description A description that provides detailed information about the alert. + Description *string `json:"description,omitempty"` + + // Details The custom properties of the alert. + Details *map[string]interface{} `json:"details,omitempty"` + + // Entity The domain of the alert. For example, the application or server name. + Entity *string `json:"entity,omitempty"` + + // Message The alert message. + Message string `json:"message"` + + // Note Additional information for the alert. + Note *string `json:"note,omitempty"` + + // Priority The priority level for the alert. + Priority *RunConnectorSubactionCreatealertSubActionParamsPriority `json:"priority,omitempty"` + + // Responders The entities to receive notifications about the alert. If `type` is `user`, either `id` or `username` is required. If `type` is `team`, either `id` or `name` is required. + Responders *[]struct { + // Id The identifier for the entity. + Id *string `json:"id,omitempty"` + + // Name The name of the entity. + Name *string `json:"name,omitempty"` + + // Type The type of responders, in this case `escalation`. + Type *RunConnectorSubactionCreatealertSubActionParamsRespondersType `json:"type,omitempty"` + + // Username A valid email address for the user. + Username *string `json:"username,omitempty"` + } `json:"responders,omitempty"` + + // Source The display name for the source of the alert. + Source *string `json:"source,omitempty"` + + // Tags The tags for the alert. + Tags *[]string `json:"tags,omitempty"` + + // User The display name for the owner. + User *string `json:"user,omitempty"` + + // VisibleTo The teams and users that the alert will be visible to without sending a notification. Only one of `id`, `name`, or `username` is required. + VisibleTo *[]struct { + // Id The identifier for the entity. + Id *string `json:"id,omitempty"` + + // Name The name of the entity. + Name *string `json:"name,omitempty"` + + // Type Valid values are `team` and `user`. + Type RunConnectorSubactionCreatealertSubActionParamsVisibleToType `json:"type"` + + // Username The user name. This property is required only when the `type` is `user`. + Username *string `json:"username,omitempty"` + } `json:"visibleTo,omitempty"` + } `json:"subActionParams"` +} + +// RunConnectorSubactionCreatealertSubAction The action to test. +type RunConnectorSubactionCreatealertSubAction string + +// RunConnectorSubactionCreatealertSubActionParamsPriority The priority level for the alert. +type RunConnectorSubactionCreatealertSubActionParamsPriority string + +// RunConnectorSubactionCreatealertSubActionParamsRespondersType The type of responders, in this case `escalation`. +type RunConnectorSubactionCreatealertSubActionParamsRespondersType string + +// RunConnectorSubactionCreatealertSubActionParamsVisibleToType Valid values are `team` and `user`. +type RunConnectorSubactionCreatealertSubActionParamsVisibleToType string + +// RunConnectorSubactionFieldsbyissuetype The `fieldsByIssueType` subaction for Jira connectors. +type RunConnectorSubactionFieldsbyissuetype struct { + // SubAction The action to test. + SubAction RunConnectorSubactionFieldsbyissuetypeSubAction `json:"subAction"` + SubActionParams struct { + // Id The Jira issue type identifier. + Id string `json:"id"` + } `json:"subActionParams"` +} + +// RunConnectorSubactionFieldsbyissuetypeSubAction The action to test. +type RunConnectorSubactionFieldsbyissuetypeSubAction string + +// RunConnectorSubactionGetchoices The `getChoices` subaction for ServiceNow ITOM, ServiceNow ITSM, and ServiceNow SecOps connectors. +type RunConnectorSubactionGetchoices struct { + // SubAction The action to test. + SubAction RunConnectorSubactionGetchoicesSubAction `json:"subAction"` + + // SubActionParams The set of configuration properties for the action. + SubActionParams struct { + // Fields An array of fields. + Fields []string `json:"fields"` + } `json:"subActionParams"` +} + +// RunConnectorSubactionGetchoicesSubAction The action to test. +type RunConnectorSubactionGetchoicesSubAction string + +// RunConnectorSubactionGetfields The `getFields` subaction for Jira, ServiceNow ITSM, and ServiceNow SecOps connectors. +type RunConnectorSubactionGetfields struct { + // SubAction The action to test. + SubAction RunConnectorSubactionGetfieldsSubAction `json:"subAction"` +} + +// RunConnectorSubactionGetfieldsSubAction The action to test. +type RunConnectorSubactionGetfieldsSubAction string + +// RunConnectorSubactionGetincident The `getIncident` subaction for Jira, ServiceNow ITSM, and ServiceNow SecOps connectors. +type RunConnectorSubactionGetincident struct { + // SubAction The action to test. + SubAction RunConnectorSubactionGetincidentSubAction `json:"subAction"` + SubActionParams struct { + // ExternalId The Jira, ServiceNow ITSM, or ServiceNow SecOps issue identifier. + ExternalId string `json:"externalId"` + } `json:"subActionParams"` +} + +// RunConnectorSubactionGetincidentSubAction The action to test. +type RunConnectorSubactionGetincidentSubAction string + +// RunConnectorSubactionIssue The `issue` subaction for Jira connectors. +type RunConnectorSubactionIssue struct { + // SubAction The action to test. + SubAction RunConnectorSubactionIssueSubAction `json:"subAction"` + SubActionParams *struct { + // Id The Jira issue identifier. + Id string `json:"id"` + } `json:"subActionParams,omitempty"` +} + +// RunConnectorSubactionIssueSubAction The action to test. +type RunConnectorSubactionIssueSubAction string + +// RunConnectorSubactionIssues The `issues` subaction for Jira connectors. +type RunConnectorSubactionIssues struct { + // SubAction The action to test. + SubAction RunConnectorSubactionIssuesSubAction `json:"subAction"` + SubActionParams struct { + // Title The title of the Jira issue. + Title string `json:"title"` + } `json:"subActionParams"` +} + +// RunConnectorSubactionIssuesSubAction The action to test. +type RunConnectorSubactionIssuesSubAction string + +// RunConnectorSubactionIssuetypes The `issueTypes` subaction for Jira connectors. +type RunConnectorSubactionIssuetypes struct { + // SubAction The action to test. + SubAction RunConnectorSubactionIssuetypesSubAction `json:"subAction"` +} + +// RunConnectorSubactionIssuetypesSubAction The action to test. +type RunConnectorSubactionIssuetypesSubAction string + +// RunConnectorSubactionPushtoservice The `pushToService` subaction for Jira, ServiceNow ITSM, ServiceNow SecOps, and Swimlane connectors. +type RunConnectorSubactionPushtoservice struct { + // SubAction The action to test. + SubAction RunConnectorSubactionPushtoserviceSubAction `json:"subAction"` + + // SubActionParams The set of configuration properties for the action. + SubActionParams struct { + // Comments Additional information that is sent to Jira, ServiceNow ITSM, ServiceNow SecOps, or Swimlane. + Comments *[]struct { + // Comment A comment related to the incident. For example, describe how to troubleshoot the issue. + Comment *string `json:"comment,omitempty"` + + // CommentId A unique identifier for the comment. + CommentId *int `json:"commentId,omitempty"` + } `json:"comments,omitempty"` + + // Incident Information necessary to create or update a Jira, ServiceNow ITSM, ServiveNow SecOps, or Swimlane incident. + Incident *struct { + // AlertId The alert identifier for Swimlane connectors. + AlertId *string `json:"alertId,omitempty"` + + // CaseId The case identifier for the incident for Swimlane connectors. + CaseId *string `json:"caseId,omitempty"` + + // CaseName The case name for the incident for Swimlane connectors. + CaseName *string `json:"caseName,omitempty"` + + // Category The category of the incident for ServiceNow ITSM and ServiceNow SecOps connectors. + Category *string `json:"category,omitempty"` + + // CorrelationDisplay A descriptive label of the alert for correlation purposes for ServiceNow ITSM and ServiceNow SecOps connectors. + CorrelationDisplay *string `json:"correlation_display,omitempty"` + + // CorrelationId The correlation identifier for the security incident for ServiceNow ITSM and ServiveNow SecOps connectors. Connectors using the same correlation ID are associated with the same ServiceNow incident. This value determines whether a new ServiceNow incident is created or an existing one is updated. Modifying this value is optional; if not modified, the rule ID and alert ID are combined as `{{ruleID}}:{{alert ID}}` to form the correlation ID value in ServiceNow. The maximum character length for this value is 100 characters. NOTE: Using the default configuration of `{{ruleID}}:{{alert ID}}` ensures that ServiceNow creates a separate incident record for every generated alert that uses a unique alert ID. If the rule generates multiple alerts that use the same alert IDs, ServiceNow creates and continually updates a single incident record for the alert. + CorrelationId *string `json:"correlation_id,omitempty"` + + // Description The description of the incident for Jira, ServiceNow ITSM, ServiceNow SecOps, and Swimlane connectors. + Description *string `json:"description,omitempty"` + + // DestIp A list of destination IP addresses related to the security incident for ServiceNow SecOps connectors. The IPs are added as observables to the security incident. + DestIp *RunConnectorSubactionPushtoservice_SubActionParams_Incident_DestIp `json:"dest_ip,omitempty"` + + // ExternalId The Jira, ServiceNow ITSM, or ServiceNow SecOps issue identifier. If present, the incident is updated. Otherwise, a new incident is created. + ExternalId *string `json:"externalId,omitempty"` + + // Impact The impact of the incident for ServiceNow ITSM connectors. + Impact *string `json:"impact,omitempty"` + + // IssueType The type of incident for Jira connectors. For example, 10006. To obtain the list of valid values, set `subAction` to `issueTypes`. + IssueType *int `json:"issueType,omitempty"` + + // Labels The labels for the incident for Jira connectors. NOTE: Labels cannot contain spaces. + Labels *[]string `json:"labels,omitempty"` + + // MalwareHash A list of malware hashes related to the security incident for ServiceNow SecOps connectors. The hashes are added as observables to the security incident. + MalwareHash *RunConnectorSubactionPushtoservice_SubActionParams_Incident_MalwareHash `json:"malware_hash,omitempty"` + + // MalwareUrl A list of malware URLs related to the security incident for ServiceNow SecOps connectors. The URLs are added as observables to the security incident. + MalwareUrl *string `json:"malware_url,omitempty"` + + // Parent The ID or key of the parent issue for Jira connectors. Applies only to `Sub-task` types of issues. + Parent *string `json:"parent,omitempty"` + + // Priority The priority of the incident in Jira and ServiceNow SecOps connectors. + Priority *string `json:"priority,omitempty"` + + // RuleName The rule name for Swimlane connectors. + RuleName *string `json:"ruleName,omitempty"` + + // Severity The severity of the incident for ServiceNow ITSM and Swimlane connectors. + Severity *string `json:"severity,omitempty"` + + // ShortDescription A short description of the incident for ServiceNow ITSM and ServiceNow SecOps connectors. It is used for searching the contents of the knowledge base. + ShortDescription *string `json:"short_description,omitempty"` + + // SourceIp A list of source IP addresses related to the security incident for ServiceNow SecOps connectors. The IPs are added as observables to the security incident. + SourceIp *RunConnectorSubactionPushtoservice_SubActionParams_Incident_SourceIp `json:"source_ip,omitempty"` + + // Subcategory The subcategory of the incident for ServiceNow ITSM and ServiceNow SecOps connectors. + Subcategory *string `json:"subcategory,omitempty"` + + // Summary A summary of the incident for Jira connectors. + Summary *string `json:"summary,omitempty"` + + // Title A title for the incident for Jira connectors. It is used for searching the contents of the knowledge base. + Title *string `json:"title,omitempty"` + + // Urgency The urgency of the incident for ServiceNow ITSM connectors. + Urgency *string `json:"urgency,omitempty"` + } `json:"incident,omitempty"` + } `json:"subActionParams"` +} + +// RunConnectorSubactionPushtoserviceSubAction The action to test. +type RunConnectorSubactionPushtoserviceSubAction string + +// RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp0 defines model for . +type RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp0 = string + +// RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp1 defines model for . +type RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp1 = []string + +// RunConnectorSubactionPushtoservice_SubActionParams_Incident_DestIp A list of destination IP addresses related to the security incident for ServiceNow SecOps connectors. The IPs are added as observables to the security incident. +type RunConnectorSubactionPushtoservice_SubActionParams_Incident_DestIp struct { + union json.RawMessage +} + +// RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash0 defines model for . +type RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash0 = string + +// RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash1 defines model for . +type RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash1 = []string + +// RunConnectorSubactionPushtoservice_SubActionParams_Incident_MalwareHash A list of malware hashes related to the security incident for ServiceNow SecOps connectors. The hashes are added as observables to the security incident. +type RunConnectorSubactionPushtoservice_SubActionParams_Incident_MalwareHash struct { + union json.RawMessage +} + +// RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp0 defines model for . +type RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp0 = string + +// RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp1 defines model for . +type RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp1 = []string + +// RunConnectorSubactionPushtoservice_SubActionParams_Incident_SourceIp A list of source IP addresses related to the security incident for ServiceNow SecOps connectors. The IPs are added as observables to the security incident. +type RunConnectorSubactionPushtoservice_SubActionParams_Incident_SourceIp struct { + union json.RawMessage +} + +// SecretsPropertiesCasesWebhook defines model for secrets_properties_cases_webhook. +type SecretsPropertiesCasesWebhook struct { + // Password The password for HTTP basic authentication. If `hasAuth` is set to `true`, this property is required. + Password *string `json:"password,omitempty"` + + // User The username for HTTP basic authentication. If `hasAuth` is set to `true`, this property is required. + User *string `json:"user,omitempty"` +} + +// SecretsPropertiesEmail Defines secrets for connectors when type is `.email`. +type SecretsPropertiesEmail map[string]interface{} + +// SecretsPropertiesJira Defines secrets for connectors when type is `.jira`. +type SecretsPropertiesJira struct { + // ApiToken The Jira API authentication token for HTTP basic authentication. + ApiToken string `json:"apiToken"` + + // Email The account email for HTTP Basic authentication. + Email string `json:"email"` +} + +// SecretsPropertiesOpsgenie Defines secrets for connectors when type is `.opsgenie`. +type SecretsPropertiesOpsgenie struct { + // ApiKey The Opsgenie API authentication key for HTTP Basic authentication. + ApiKey string `json:"apiKey"` +} + +// SecretsPropertiesPagerduty Defines secrets for connectors when type is `.pagerduty`. +type SecretsPropertiesPagerduty map[string]interface{} + +// SecretsPropertiesResilient Defines secrets for connectors when type is `.resilient`. +type SecretsPropertiesResilient struct { + // ApiKeyId The authentication key ID for HTTP Basic authentication. + ApiKeyId string `json:"apiKeyId"` + + // ApiKeySecret The authentication key secret for HTTP Basic authentication. + ApiKeySecret string `json:"apiKeySecret"` +} + +// SecretsPropertiesServicenow Defines secrets for connectors when type is `.servicenow`, `.servicenow-sir`, or `.servicenow-itom`. +type SecretsPropertiesServicenow struct { + // ClientSecret The client secret assigned to your OAuth application. This property is required when `isOAuth` is `true`. + ClientSecret *string `json:"clientSecret,omitempty"` + + // Password The password for HTTP basic authentication. This property is required when `isOAuth` is `false`. + Password *string `json:"password,omitempty"` + + // PrivateKey The RSA private key that you created for use in ServiceNow. This property is required when `isOAuth` is `true`. + PrivateKey *string `json:"privateKey,omitempty"` + + // PrivateKeyPassword The password for the RSA private key. This property is required when `isOAuth` is `true` and you set a password on your private key. + PrivateKeyPassword *string `json:"privateKeyPassword,omitempty"` + + // Username The username for HTTP basic authentication. This property is required when `isOAuth` is `false`. + Username *string `json:"username,omitempty"` +} + +// SecretsPropertiesSlack Defines secrets for connectors when type is `.slack`. +type SecretsPropertiesSlack map[string]interface{} + +// SecretsPropertiesSwimlane Defines secrets for connectors when type is `.swimlane`. +type SecretsPropertiesSwimlane struct { + // ApiToken Swimlane API authentication token. + ApiToken *string `json:"apiToken,omitempty"` +} + +// SecretsPropertiesTeams Defines secrets for connectors when type is `.teams`. +type SecretsPropertiesTeams map[string]interface{} + +// SecretsPropertiesTines Defines secrets for connectors when type is `.tines`. +type SecretsPropertiesTines map[string]interface{} + +// SecretsPropertiesWebhook Defines secrets for connectors when type is `.webhook`. +type SecretsPropertiesWebhook map[string]interface{} + +// SecretsPropertiesXmatters Defines secrets for connectors when type is `.xmatters`. +type SecretsPropertiesXmatters map[string]interface{} + +// UpdateConnectorRequestCasesWebhook defines model for update_connector_request_cases_webhook. +type UpdateConnectorRequestCasesWebhook struct { + // Config Defines properties for connectors when type is `.cases-webhook`. + Config ConfigPropertiesCasesWebhook `json:"config"` + + // Name The display name for the connector. + Name string `json:"name"` + Secrets *SecretsPropertiesCasesWebhook `json:"secrets,omitempty"` +} + +// UpdateConnectorRequestEmail defines model for update_connector_request_email. +type UpdateConnectorRequestEmail struct { + // Config Defines properties for connectors when type is `.email`. + Config ConfigPropertiesEmail `json:"config"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.email`. + Secrets SecretsPropertiesEmail `json:"secrets"` +} + +// UpdateConnectorRequestIndex defines model for update_connector_request_index. +type UpdateConnectorRequestIndex struct { + // Config Defines properties for connectors when type is `.index`. + Config ConfigPropertiesIndex `json:"config"` + + // Name The display name for the connector. + Name string `json:"name"` +} + +// UpdateConnectorRequestJira defines model for update_connector_request_jira. +type UpdateConnectorRequestJira struct { + // Config Defines properties for connectors when type is `.jira`. + Config ConfigPropertiesJira `json:"config"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.jira`. + Secrets SecretsPropertiesJira `json:"secrets"` +} + +// UpdateConnectorRequestOpsgenie defines model for update_connector_request_opsgenie. +type UpdateConnectorRequestOpsgenie struct { + // Config Defines properties for connectors when type is `.opsgenie`. + Config ConfigPropertiesOpsgenie `json:"config"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.opsgenie`. + Secrets SecretsPropertiesOpsgenie `json:"secrets"` +} + +// UpdateConnectorRequestPagerduty The PagerDuty connector uses the v2 Events API to trigger, acknowledge, and resolve PagerDuty alerts. +type UpdateConnectorRequestPagerduty struct { + // Config Defines properties for connectors when type is `.pagerduty`. + Config ConfigPropertiesPagerduty `json:"config"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.pagerduty`. + Secrets SecretsPropertiesPagerduty `json:"secrets"` +} + +// UpdateConnectorRequestResilient defines model for update_connector_request_resilient. +type UpdateConnectorRequestResilient struct { + // Config Defines properties for connectors when type is `.resilient`. + Config ConfigPropertiesResilient `json:"config"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.resilient`. + Secrets SecretsPropertiesResilient `json:"secrets"` +} + +// UpdateConnectorRequestServerlog defines model for update_connector_request_serverlog. +type UpdateConnectorRequestServerlog struct { + // Name The display name for the connector. + Name string `json:"name"` +} + +// UpdateConnectorRequestServicenow defines model for update_connector_request_servicenow. +type UpdateConnectorRequestServicenow struct { + // Config Defines properties for connectors when type is `.servicenow`. + Config ConfigPropertiesServicenow `json:"config"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.servicenow`, `.servicenow-sir`, or `.servicenow-itom`. + Secrets SecretsPropertiesServicenow `json:"secrets"` +} + +// UpdateConnectorRequestServicenowItom defines model for update_connector_request_servicenow_itom. +type UpdateConnectorRequestServicenowItom struct { + // Config Defines properties for connectors when type is `.servicenow`. + Config ConfigPropertiesServicenowItom `json:"config"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.servicenow`, `.servicenow-sir`, or `.servicenow-itom`. + Secrets SecretsPropertiesServicenow `json:"secrets"` +} + +// UpdateConnectorRequestServicenowSir The ServiceNow SecOps connector uses the import set API to create ServiceNow security incidents. You can use the connector for rule actions and cases. +type UpdateConnectorRequestServicenowSir struct { + // Config Defines properties for connectors when type is `.servicenow`. + Config ConfigPropertiesServicenow `json:"config"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.servicenow`, `.servicenow-sir`, or `.servicenow-itom`. + Secrets SecretsPropertiesServicenow `json:"secrets"` +} + +// UpdateConnectorRequestSlack The Slack connector uses Slack Incoming Webhooks. +type UpdateConnectorRequestSlack struct { + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.slack`. + Secrets SecretsPropertiesSlack `json:"secrets"` +} + +// UpdateConnectorRequestSwimlane defines model for update_connector_request_swimlane. +type UpdateConnectorRequestSwimlane struct { + // Config Defines properties for connectors when type is `.swimlane`. + Config ConfigPropertiesSwimlane `json:"config"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.swimlane`. + Secrets SecretsPropertiesSwimlane `json:"secrets"` +} + +// UpdateConnectorRequestTeams The Microsoft Teams connector uses Incoming Webhooks. +type UpdateConnectorRequestTeams struct { + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.teams`. + Secrets SecretsPropertiesTeams `json:"secrets"` +} + +// UpdateConnectorRequestTines The Tines connector uses Tines Webhook actions to send events via POST request. +type UpdateConnectorRequestTines struct { + // Config Defines properties for connectors when type is `.tines`. + Config ConfigPropertiesTines `json:"config"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.tines`. + Secrets SecretsPropertiesTines `json:"secrets"` +} + +// UpdateConnectorRequestWebhook The Webhook connector uses axios to send a POST or PUT request to a web service. +type UpdateConnectorRequestWebhook struct { + // Config Defines properties for connectors when type is `.webhook`. + Config ConfigPropertiesWebhook `json:"config"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.webhook`. + Secrets SecretsPropertiesWebhook `json:"secrets"` +} + +// UpdateConnectorRequestXmatters The xMatters connector uses the xMatters Workflow for Elastic to send actionable alerts to on-call xMatters resources. +type UpdateConnectorRequestXmatters struct { + // Config Defines properties for connectors when type is `.xmatters`. + Config ConfigPropertiesXmatters `json:"config"` + + // Name The display name for the connector. + Name string `json:"name"` + + // Secrets Defines secrets for connectors when type is `.xmatters`. + Secrets SecretsPropertiesXmatters `json:"secrets"` +} + +// ActionId defines model for action_id. +type ActionId = string + +// ConnectorId defines model for connector_id. +type ConnectorId = string + +// KbnXsrf defines model for kbn_xsrf. +type KbnXsrf = string + +// SpaceId defines model for space_id. +type SpaceId = string + +// N200Actions The properties vary depending on the action type. +type N200Actions = ActionResponseProperties + +// LegacyCreateConnectorJSONBody defines parameters for LegacyCreateConnector. +type LegacyCreateConnectorJSONBody struct { + // ActionTypeId The connector type identifier. + ActionTypeId *string `json:"actionTypeId,omitempty"` + + // Config The configuration for the connector. Configuration properties vary depending on the connector type. + Config *map[string]interface{} `json:"config,omitempty"` + + // Name The display name for the connector. + Name *string `json:"name,omitempty"` + + // Secrets The secrets configuration for the connector. Secrets configuration properties vary depending on the connector type. NOTE: Remember these values. You must provide them each time you update the connector. + Secrets *map[string]interface{} `json:"secrets,omitempty"` +} + +// LegacyCreateConnectorParams defines parameters for LegacyCreateConnector. +type LegacyCreateConnectorParams struct { + // KbnXsrf Cross-site request forgery protection + KbnXsrf KbnXsrf `json:"kbn-xsrf"` +} + +// LegacyDeleteConnectorParams defines parameters for LegacyDeleteConnector. +type LegacyDeleteConnectorParams struct { + // KbnXsrf Cross-site request forgery protection + KbnXsrf KbnXsrf `json:"kbn-xsrf"` +} + +// LegacyUpdateConnectorJSONBody defines parameters for LegacyUpdateConnector. +type LegacyUpdateConnectorJSONBody struct { + // Config The new connector configuration. Configuration properties vary depending on the connector type. + Config *map[string]interface{} `json:"config,omitempty"` + + // Name The new name for the connector. + Name *string `json:"name,omitempty"` + + // Secrets The updated secrets configuration for the connector. Secrets properties vary depending on the connector type. + Secrets *map[string]interface{} `json:"secrets,omitempty"` +} + +// LegacyUpdateConnectorParams defines parameters for LegacyUpdateConnector. +type LegacyUpdateConnectorParams struct { + // KbnXsrf Cross-site request forgery protection + KbnXsrf KbnXsrf `json:"kbn-xsrf"` +} + +// LegacyRunConnectorJSONBody defines parameters for LegacyRunConnector. +type LegacyRunConnectorJSONBody struct { + // Params The parameters of the connector. Parameter properties vary depending on the connector type. + Params map[string]interface{} `json:"params"` +} + +// LegacyRunConnectorParams defines parameters for LegacyRunConnector. +type LegacyRunConnectorParams struct { + // KbnXsrf Cross-site request forgery protection + KbnXsrf KbnXsrf `json:"kbn-xsrf"` +} + +// CreateConnectorJSONBody defines parameters for CreateConnector. +type CreateConnectorJSONBody struct { + union json.RawMessage +} + +// CreateConnectorParams defines parameters for CreateConnector. +type CreateConnectorParams struct { + // KbnXsrf Cross-site request forgery protection + KbnXsrf KbnXsrf `json:"kbn-xsrf"` +} + +// DeleteConnectorParams defines parameters for DeleteConnector. +type DeleteConnectorParams struct { + // KbnXsrf Cross-site request forgery protection + KbnXsrf KbnXsrf `json:"kbn-xsrf"` +} + +// UpdateConnectorJSONBody defines parameters for UpdateConnector. +type UpdateConnectorJSONBody struct { + union json.RawMessage +} + +// UpdateConnectorParams defines parameters for UpdateConnector. +type UpdateConnectorParams struct { + // KbnXsrf Cross-site request forgery protection + KbnXsrf KbnXsrf `json:"kbn-xsrf"` +} + +// RunConnectorJSONBody defines parameters for RunConnector. +type RunConnectorJSONBody struct { + Params RunConnectorJSONBody_Params `json:"params"` +} + +// RunConnectorParams defines parameters for RunConnector. +type RunConnectorParams struct { + // KbnXsrf Cross-site request forgery protection + KbnXsrf KbnXsrf `json:"kbn-xsrf"` +} + +// RunConnectorJSONBodyParams2 defines parameters for RunConnector. +type RunConnectorJSONBodyParams2 struct { + union json.RawMessage +} + +// RunConnectorJSONBody_Params defines parameters for RunConnector. +type RunConnectorJSONBody_Params struct { + union json.RawMessage +} + +// GetConnectorTypesParams defines parameters for GetConnectorTypes. +type GetConnectorTypesParams struct { + // FeatureId A filter to limit the retrieved connector types to those that support a specific feature (such as alerting or cases). + FeatureId *Features `form:"feature_id,omitempty" json:"feature_id,omitempty"` +} + +// LegacyCreateConnectorJSONRequestBody defines body for LegacyCreateConnector for application/json ContentType. +type LegacyCreateConnectorJSONRequestBody LegacyCreateConnectorJSONBody + +// LegacyUpdateConnectorJSONRequestBody defines body for LegacyUpdateConnector for application/json ContentType. +type LegacyUpdateConnectorJSONRequestBody LegacyUpdateConnectorJSONBody + +// LegacyRunConnectorJSONRequestBody defines body for LegacyRunConnector for application/json ContentType. +type LegacyRunConnectorJSONRequestBody LegacyRunConnectorJSONBody + +// CreateConnectorJSONRequestBody defines body for CreateConnector for application/json ContentType. +type CreateConnectorJSONRequestBody CreateConnectorJSONBody + +// UpdateConnectorJSONRequestBody defines body for UpdateConnector for application/json ContentType. +type UpdateConnectorJSONRequestBody UpdateConnectorJSONBody + +// RunConnectorJSONRequestBody defines body for RunConnector for application/json ContentType. +type RunConnectorJSONRequestBody RunConnectorJSONBody + +// AsConnectorResponsePropertiesCasesWebhook returns the union data inside the ConnectorResponseProperties as a ConnectorResponsePropertiesCasesWebhook +func (t ConnectorResponseProperties) AsConnectorResponsePropertiesCasesWebhook() (ConnectorResponsePropertiesCasesWebhook, error) { + var body ConnectorResponsePropertiesCasesWebhook + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromConnectorResponsePropertiesCasesWebhook overwrites any union data inside the ConnectorResponseProperties as the provided ConnectorResponsePropertiesCasesWebhook +func (t *ConnectorResponseProperties) FromConnectorResponsePropertiesCasesWebhook(v ConnectorResponsePropertiesCasesWebhook) error { + v.ConnectorTypeId = ".cases-webhook" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeConnectorResponsePropertiesCasesWebhook performs a merge with any union data inside the ConnectorResponseProperties, using the provided ConnectorResponsePropertiesCasesWebhook +func (t *ConnectorResponseProperties) MergeConnectorResponsePropertiesCasesWebhook(v ConnectorResponsePropertiesCasesWebhook) error { + v.ConnectorTypeId = ".cases-webhook" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsConnectorResponsePropertiesEmail returns the union data inside the ConnectorResponseProperties as a ConnectorResponsePropertiesEmail +func (t ConnectorResponseProperties) AsConnectorResponsePropertiesEmail() (ConnectorResponsePropertiesEmail, error) { + var body ConnectorResponsePropertiesEmail + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromConnectorResponsePropertiesEmail overwrites any union data inside the ConnectorResponseProperties as the provided ConnectorResponsePropertiesEmail +func (t *ConnectorResponseProperties) FromConnectorResponsePropertiesEmail(v ConnectorResponsePropertiesEmail) error { + v.ConnectorTypeId = ".email" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeConnectorResponsePropertiesEmail performs a merge with any union data inside the ConnectorResponseProperties, using the provided ConnectorResponsePropertiesEmail +func (t *ConnectorResponseProperties) MergeConnectorResponsePropertiesEmail(v ConnectorResponsePropertiesEmail) error { + v.ConnectorTypeId = ".email" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsConnectorResponsePropertiesIndex returns the union data inside the ConnectorResponseProperties as a ConnectorResponsePropertiesIndex +func (t ConnectorResponseProperties) AsConnectorResponsePropertiesIndex() (ConnectorResponsePropertiesIndex, error) { + var body ConnectorResponsePropertiesIndex + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromConnectorResponsePropertiesIndex overwrites any union data inside the ConnectorResponseProperties as the provided ConnectorResponsePropertiesIndex +func (t *ConnectorResponseProperties) FromConnectorResponsePropertiesIndex(v ConnectorResponsePropertiesIndex) error { + v.ConnectorTypeId = ".index" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeConnectorResponsePropertiesIndex performs a merge with any union data inside the ConnectorResponseProperties, using the provided ConnectorResponsePropertiesIndex +func (t *ConnectorResponseProperties) MergeConnectorResponsePropertiesIndex(v ConnectorResponsePropertiesIndex) error { + v.ConnectorTypeId = ".index" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsConnectorResponsePropertiesJira returns the union data inside the ConnectorResponseProperties as a ConnectorResponsePropertiesJira +func (t ConnectorResponseProperties) AsConnectorResponsePropertiesJira() (ConnectorResponsePropertiesJira, error) { + var body ConnectorResponsePropertiesJira + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromConnectorResponsePropertiesJira overwrites any union data inside the ConnectorResponseProperties as the provided ConnectorResponsePropertiesJira +func (t *ConnectorResponseProperties) FromConnectorResponsePropertiesJira(v ConnectorResponsePropertiesJira) error { + v.ConnectorTypeId = ".jira" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeConnectorResponsePropertiesJira performs a merge with any union data inside the ConnectorResponseProperties, using the provided ConnectorResponsePropertiesJira +func (t *ConnectorResponseProperties) MergeConnectorResponsePropertiesJira(v ConnectorResponsePropertiesJira) error { + v.ConnectorTypeId = ".jira" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsConnectorResponsePropertiesOpsgenie returns the union data inside the ConnectorResponseProperties as a ConnectorResponsePropertiesOpsgenie +func (t ConnectorResponseProperties) AsConnectorResponsePropertiesOpsgenie() (ConnectorResponsePropertiesOpsgenie, error) { + var body ConnectorResponsePropertiesOpsgenie + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromConnectorResponsePropertiesOpsgenie overwrites any union data inside the ConnectorResponseProperties as the provided ConnectorResponsePropertiesOpsgenie +func (t *ConnectorResponseProperties) FromConnectorResponsePropertiesOpsgenie(v ConnectorResponsePropertiesOpsgenie) error { + v.ConnectorTypeId = ".opsgenie" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeConnectorResponsePropertiesOpsgenie performs a merge with any union data inside the ConnectorResponseProperties, using the provided ConnectorResponsePropertiesOpsgenie +func (t *ConnectorResponseProperties) MergeConnectorResponsePropertiesOpsgenie(v ConnectorResponsePropertiesOpsgenie) error { + v.ConnectorTypeId = ".opsgenie" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsConnectorResponsePropertiesPagerduty returns the union data inside the ConnectorResponseProperties as a ConnectorResponsePropertiesPagerduty +func (t ConnectorResponseProperties) AsConnectorResponsePropertiesPagerduty() (ConnectorResponsePropertiesPagerduty, error) { + var body ConnectorResponsePropertiesPagerduty + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromConnectorResponsePropertiesPagerduty overwrites any union data inside the ConnectorResponseProperties as the provided ConnectorResponsePropertiesPagerduty +func (t *ConnectorResponseProperties) FromConnectorResponsePropertiesPagerduty(v ConnectorResponsePropertiesPagerduty) error { + v.ConnectorTypeId = ".pagerduty" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeConnectorResponsePropertiesPagerduty performs a merge with any union data inside the ConnectorResponseProperties, using the provided ConnectorResponsePropertiesPagerduty +func (t *ConnectorResponseProperties) MergeConnectorResponsePropertiesPagerduty(v ConnectorResponsePropertiesPagerduty) error { + v.ConnectorTypeId = ".pagerduty" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsConnectorResponsePropertiesResilient returns the union data inside the ConnectorResponseProperties as a ConnectorResponsePropertiesResilient +func (t ConnectorResponseProperties) AsConnectorResponsePropertiesResilient() (ConnectorResponsePropertiesResilient, error) { + var body ConnectorResponsePropertiesResilient + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromConnectorResponsePropertiesResilient overwrites any union data inside the ConnectorResponseProperties as the provided ConnectorResponsePropertiesResilient +func (t *ConnectorResponseProperties) FromConnectorResponsePropertiesResilient(v ConnectorResponsePropertiesResilient) error { + v.ConnectorTypeId = ".resilient" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeConnectorResponsePropertiesResilient performs a merge with any union data inside the ConnectorResponseProperties, using the provided ConnectorResponsePropertiesResilient +func (t *ConnectorResponseProperties) MergeConnectorResponsePropertiesResilient(v ConnectorResponsePropertiesResilient) error { + v.ConnectorTypeId = ".resilient" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsConnectorResponsePropertiesServerlog returns the union data inside the ConnectorResponseProperties as a ConnectorResponsePropertiesServerlog +func (t ConnectorResponseProperties) AsConnectorResponsePropertiesServerlog() (ConnectorResponsePropertiesServerlog, error) { + var body ConnectorResponsePropertiesServerlog + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromConnectorResponsePropertiesServerlog overwrites any union data inside the ConnectorResponseProperties as the provided ConnectorResponsePropertiesServerlog +func (t *ConnectorResponseProperties) FromConnectorResponsePropertiesServerlog(v ConnectorResponsePropertiesServerlog) error { + v.ConnectorTypeId = ".server-log" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeConnectorResponsePropertiesServerlog performs a merge with any union data inside the ConnectorResponseProperties, using the provided ConnectorResponsePropertiesServerlog +func (t *ConnectorResponseProperties) MergeConnectorResponsePropertiesServerlog(v ConnectorResponsePropertiesServerlog) error { + v.ConnectorTypeId = ".server-log" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsConnectorResponsePropertiesServicenow returns the union data inside the ConnectorResponseProperties as a ConnectorResponsePropertiesServicenow +func (t ConnectorResponseProperties) AsConnectorResponsePropertiesServicenow() (ConnectorResponsePropertiesServicenow, error) { + var body ConnectorResponsePropertiesServicenow + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromConnectorResponsePropertiesServicenow overwrites any union data inside the ConnectorResponseProperties as the provided ConnectorResponsePropertiesServicenow +func (t *ConnectorResponseProperties) FromConnectorResponsePropertiesServicenow(v ConnectorResponsePropertiesServicenow) error { + v.ConnectorTypeId = ".servicenow" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeConnectorResponsePropertiesServicenow performs a merge with any union data inside the ConnectorResponseProperties, using the provided ConnectorResponsePropertiesServicenow +func (t *ConnectorResponseProperties) MergeConnectorResponsePropertiesServicenow(v ConnectorResponsePropertiesServicenow) error { + v.ConnectorTypeId = ".servicenow" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsConnectorResponsePropertiesServicenowItom returns the union data inside the ConnectorResponseProperties as a ConnectorResponsePropertiesServicenowItom +func (t ConnectorResponseProperties) AsConnectorResponsePropertiesServicenowItom() (ConnectorResponsePropertiesServicenowItom, error) { + var body ConnectorResponsePropertiesServicenowItom + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromConnectorResponsePropertiesServicenowItom overwrites any union data inside the ConnectorResponseProperties as the provided ConnectorResponsePropertiesServicenowItom +func (t *ConnectorResponseProperties) FromConnectorResponsePropertiesServicenowItom(v ConnectorResponsePropertiesServicenowItom) error { + v.ConnectorTypeId = ".servicenow-itom" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeConnectorResponsePropertiesServicenowItom performs a merge with any union data inside the ConnectorResponseProperties, using the provided ConnectorResponsePropertiesServicenowItom +func (t *ConnectorResponseProperties) MergeConnectorResponsePropertiesServicenowItom(v ConnectorResponsePropertiesServicenowItom) error { + v.ConnectorTypeId = ".servicenow-itom" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsConnectorResponsePropertiesServicenowSir returns the union data inside the ConnectorResponseProperties as a ConnectorResponsePropertiesServicenowSir +func (t ConnectorResponseProperties) AsConnectorResponsePropertiesServicenowSir() (ConnectorResponsePropertiesServicenowSir, error) { + var body ConnectorResponsePropertiesServicenowSir + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromConnectorResponsePropertiesServicenowSir overwrites any union data inside the ConnectorResponseProperties as the provided ConnectorResponsePropertiesServicenowSir +func (t *ConnectorResponseProperties) FromConnectorResponsePropertiesServicenowSir(v ConnectorResponsePropertiesServicenowSir) error { + v.ConnectorTypeId = ".servicenow-sir" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeConnectorResponsePropertiesServicenowSir performs a merge with any union data inside the ConnectorResponseProperties, using the provided ConnectorResponsePropertiesServicenowSir +func (t *ConnectorResponseProperties) MergeConnectorResponsePropertiesServicenowSir(v ConnectorResponsePropertiesServicenowSir) error { + v.ConnectorTypeId = ".servicenow-sir" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsConnectorResponsePropertiesSlack returns the union data inside the ConnectorResponseProperties as a ConnectorResponsePropertiesSlack +func (t ConnectorResponseProperties) AsConnectorResponsePropertiesSlack() (ConnectorResponsePropertiesSlack, error) { + var body ConnectorResponsePropertiesSlack + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromConnectorResponsePropertiesSlack overwrites any union data inside the ConnectorResponseProperties as the provided ConnectorResponsePropertiesSlack +func (t *ConnectorResponseProperties) FromConnectorResponsePropertiesSlack(v ConnectorResponsePropertiesSlack) error { + v.ConnectorTypeId = ".slack" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeConnectorResponsePropertiesSlack performs a merge with any union data inside the ConnectorResponseProperties, using the provided ConnectorResponsePropertiesSlack +func (t *ConnectorResponseProperties) MergeConnectorResponsePropertiesSlack(v ConnectorResponsePropertiesSlack) error { + v.ConnectorTypeId = ".slack" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsConnectorResponsePropertiesSwimlane returns the union data inside the ConnectorResponseProperties as a ConnectorResponsePropertiesSwimlane +func (t ConnectorResponseProperties) AsConnectorResponsePropertiesSwimlane() (ConnectorResponsePropertiesSwimlane, error) { + var body ConnectorResponsePropertiesSwimlane + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromConnectorResponsePropertiesSwimlane overwrites any union data inside the ConnectorResponseProperties as the provided ConnectorResponsePropertiesSwimlane +func (t *ConnectorResponseProperties) FromConnectorResponsePropertiesSwimlane(v ConnectorResponsePropertiesSwimlane) error { + v.ConnectorTypeId = ".swimlane" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeConnectorResponsePropertiesSwimlane performs a merge with any union data inside the ConnectorResponseProperties, using the provided ConnectorResponsePropertiesSwimlane +func (t *ConnectorResponseProperties) MergeConnectorResponsePropertiesSwimlane(v ConnectorResponsePropertiesSwimlane) error { + v.ConnectorTypeId = ".swimlane" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsConnectorResponsePropertiesTeams returns the union data inside the ConnectorResponseProperties as a ConnectorResponsePropertiesTeams +func (t ConnectorResponseProperties) AsConnectorResponsePropertiesTeams() (ConnectorResponsePropertiesTeams, error) { + var body ConnectorResponsePropertiesTeams + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromConnectorResponsePropertiesTeams overwrites any union data inside the ConnectorResponseProperties as the provided ConnectorResponsePropertiesTeams +func (t *ConnectorResponseProperties) FromConnectorResponsePropertiesTeams(v ConnectorResponsePropertiesTeams) error { + v.ConnectorTypeId = ".teams" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeConnectorResponsePropertiesTeams performs a merge with any union data inside the ConnectorResponseProperties, using the provided ConnectorResponsePropertiesTeams +func (t *ConnectorResponseProperties) MergeConnectorResponsePropertiesTeams(v ConnectorResponsePropertiesTeams) error { + v.ConnectorTypeId = ".teams" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsConnectorResponsePropertiesTines returns the union data inside the ConnectorResponseProperties as a ConnectorResponsePropertiesTines +func (t ConnectorResponseProperties) AsConnectorResponsePropertiesTines() (ConnectorResponsePropertiesTines, error) { + var body ConnectorResponsePropertiesTines + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromConnectorResponsePropertiesTines overwrites any union data inside the ConnectorResponseProperties as the provided ConnectorResponsePropertiesTines +func (t *ConnectorResponseProperties) FromConnectorResponsePropertiesTines(v ConnectorResponsePropertiesTines) error { + v.ConnectorTypeId = ".tines" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeConnectorResponsePropertiesTines performs a merge with any union data inside the ConnectorResponseProperties, using the provided ConnectorResponsePropertiesTines +func (t *ConnectorResponseProperties) MergeConnectorResponsePropertiesTines(v ConnectorResponsePropertiesTines) error { + v.ConnectorTypeId = ".tines" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsConnectorResponsePropertiesWebhook returns the union data inside the ConnectorResponseProperties as a ConnectorResponsePropertiesWebhook +func (t ConnectorResponseProperties) AsConnectorResponsePropertiesWebhook() (ConnectorResponsePropertiesWebhook, error) { + var body ConnectorResponsePropertiesWebhook + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromConnectorResponsePropertiesWebhook overwrites any union data inside the ConnectorResponseProperties as the provided ConnectorResponsePropertiesWebhook +func (t *ConnectorResponseProperties) FromConnectorResponsePropertiesWebhook(v ConnectorResponsePropertiesWebhook) error { + v.ConnectorTypeId = ".webhook" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeConnectorResponsePropertiesWebhook performs a merge with any union data inside the ConnectorResponseProperties, using the provided ConnectorResponsePropertiesWebhook +func (t *ConnectorResponseProperties) MergeConnectorResponsePropertiesWebhook(v ConnectorResponsePropertiesWebhook) error { + v.ConnectorTypeId = ".webhook" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsConnectorResponsePropertiesXmatters returns the union data inside the ConnectorResponseProperties as a ConnectorResponsePropertiesXmatters +func (t ConnectorResponseProperties) AsConnectorResponsePropertiesXmatters() (ConnectorResponsePropertiesXmatters, error) { + var body ConnectorResponsePropertiesXmatters + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromConnectorResponsePropertiesXmatters overwrites any union data inside the ConnectorResponseProperties as the provided ConnectorResponsePropertiesXmatters +func (t *ConnectorResponseProperties) FromConnectorResponsePropertiesXmatters(v ConnectorResponsePropertiesXmatters) error { + v.ConnectorTypeId = ".xmatters" + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeConnectorResponsePropertiesXmatters performs a merge with any union data inside the ConnectorResponseProperties, using the provided ConnectorResponsePropertiesXmatters +func (t *ConnectorResponseProperties) MergeConnectorResponsePropertiesXmatters(v ConnectorResponsePropertiesXmatters) error { + v.ConnectorTypeId = ".xmatters" + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +func (t ConnectorResponseProperties) Discriminator() (string, error) { + var discriminator struct { + Discriminator string `json:"connector_type_id"` + } + err := json.Unmarshal(t.union, &discriminator) + return discriminator.Discriminator, err +} + +func (t ConnectorResponseProperties) ValueByDiscriminator() (interface{}, error) { + discriminator, err := t.Discriminator() + if err != nil { + return nil, err + } + switch discriminator { + case ".cases-webhook": + return t.AsConnectorResponsePropertiesCasesWebhook() + case ".email": + return t.AsConnectorResponsePropertiesEmail() + case ".index": + return t.AsConnectorResponsePropertiesIndex() + case ".jira": + return t.AsConnectorResponsePropertiesJira() + case ".opsgenie": + return t.AsConnectorResponsePropertiesOpsgenie() + case ".pagerduty": + return t.AsConnectorResponsePropertiesPagerduty() + case ".resilient": + return t.AsConnectorResponsePropertiesResilient() + case ".server-log": + return t.AsConnectorResponsePropertiesServerlog() + case ".servicenow": + return t.AsConnectorResponsePropertiesServicenow() + case ".servicenow-itom": + return t.AsConnectorResponsePropertiesServicenowItom() + case ".servicenow-sir": + return t.AsConnectorResponsePropertiesServicenowSir() + case ".slack": + return t.AsConnectorResponsePropertiesSlack() + case ".swimlane": + return t.AsConnectorResponsePropertiesSwimlane() + case ".teams": + return t.AsConnectorResponsePropertiesTeams() + case ".tines": + return t.AsConnectorResponsePropertiesTines() + case ".webhook": + return t.AsConnectorResponsePropertiesWebhook() + case ".xmatters": + return t.AsConnectorResponsePropertiesXmatters() + default: + return nil, errors.New("unknown discriminator value: " + discriminator) + } +} + +func (t ConnectorResponseProperties) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *ConnectorResponseProperties) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// AsLegacyRunConnectorGeneralResponseData0 returns the union data inside the LegacyRunConnectorGeneralResponse_Data as a LegacyRunConnectorGeneralResponseData0 +func (t LegacyRunConnectorGeneralResponse_Data) AsLegacyRunConnectorGeneralResponseData0() (LegacyRunConnectorGeneralResponseData0, error) { + var body LegacyRunConnectorGeneralResponseData0 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromLegacyRunConnectorGeneralResponseData0 overwrites any union data inside the LegacyRunConnectorGeneralResponse_Data as the provided LegacyRunConnectorGeneralResponseData0 +func (t *LegacyRunConnectorGeneralResponse_Data) FromLegacyRunConnectorGeneralResponseData0(v LegacyRunConnectorGeneralResponseData0) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeLegacyRunConnectorGeneralResponseData0 performs a merge with any union data inside the LegacyRunConnectorGeneralResponse_Data, using the provided LegacyRunConnectorGeneralResponseData0 +func (t *LegacyRunConnectorGeneralResponse_Data) MergeLegacyRunConnectorGeneralResponseData0(v LegacyRunConnectorGeneralResponseData0) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsLegacyRunConnectorGeneralResponseData1 returns the union data inside the LegacyRunConnectorGeneralResponse_Data as a LegacyRunConnectorGeneralResponseData1 +func (t LegacyRunConnectorGeneralResponse_Data) AsLegacyRunConnectorGeneralResponseData1() (LegacyRunConnectorGeneralResponseData1, error) { + var body LegacyRunConnectorGeneralResponseData1 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromLegacyRunConnectorGeneralResponseData1 overwrites any union data inside the LegacyRunConnectorGeneralResponse_Data as the provided LegacyRunConnectorGeneralResponseData1 +func (t *LegacyRunConnectorGeneralResponse_Data) FromLegacyRunConnectorGeneralResponseData1(v LegacyRunConnectorGeneralResponseData1) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeLegacyRunConnectorGeneralResponseData1 performs a merge with any union data inside the LegacyRunConnectorGeneralResponse_Data, using the provided LegacyRunConnectorGeneralResponseData1 +func (t *LegacyRunConnectorGeneralResponse_Data) MergeLegacyRunConnectorGeneralResponseData1(v LegacyRunConnectorGeneralResponseData1) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +func (t LegacyRunConnectorGeneralResponse_Data) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *LegacyRunConnectorGeneralResponse_Data) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// AsRunConnectorGeneralResponseData0 returns the union data inside the RunConnectorGeneralResponse_Data as a RunConnectorGeneralResponseData0 +func (t RunConnectorGeneralResponse_Data) AsRunConnectorGeneralResponseData0() (RunConnectorGeneralResponseData0, error) { + var body RunConnectorGeneralResponseData0 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromRunConnectorGeneralResponseData0 overwrites any union data inside the RunConnectorGeneralResponse_Data as the provided RunConnectorGeneralResponseData0 +func (t *RunConnectorGeneralResponse_Data) FromRunConnectorGeneralResponseData0(v RunConnectorGeneralResponseData0) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeRunConnectorGeneralResponseData0 performs a merge with any union data inside the RunConnectorGeneralResponse_Data, using the provided RunConnectorGeneralResponseData0 +func (t *RunConnectorGeneralResponse_Data) MergeRunConnectorGeneralResponseData0(v RunConnectorGeneralResponseData0) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsRunConnectorGeneralResponseData1 returns the union data inside the RunConnectorGeneralResponse_Data as a RunConnectorGeneralResponseData1 +func (t RunConnectorGeneralResponse_Data) AsRunConnectorGeneralResponseData1() (RunConnectorGeneralResponseData1, error) { + var body RunConnectorGeneralResponseData1 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromRunConnectorGeneralResponseData1 overwrites any union data inside the RunConnectorGeneralResponse_Data as the provided RunConnectorGeneralResponseData1 +func (t *RunConnectorGeneralResponse_Data) FromRunConnectorGeneralResponseData1(v RunConnectorGeneralResponseData1) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeRunConnectorGeneralResponseData1 performs a merge with any union data inside the RunConnectorGeneralResponse_Data, using the provided RunConnectorGeneralResponseData1 +func (t *RunConnectorGeneralResponse_Data) MergeRunConnectorGeneralResponseData1(v RunConnectorGeneralResponseData1) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +func (t RunConnectorGeneralResponse_Data) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *RunConnectorGeneralResponse_Data) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// AsRunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp0 returns the union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_DestIp as a RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp0 +func (t RunConnectorSubactionPushtoservice_SubActionParams_Incident_DestIp) AsRunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp0() (RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp0, error) { + var body RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp0 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromRunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp0 overwrites any union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_DestIp as the provided RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp0 +func (t *RunConnectorSubactionPushtoservice_SubActionParams_Incident_DestIp) FromRunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp0(v RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp0) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeRunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp0 performs a merge with any union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_DestIp, using the provided RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp0 +func (t *RunConnectorSubactionPushtoservice_SubActionParams_Incident_DestIp) MergeRunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp0(v RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp0) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsRunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp1 returns the union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_DestIp as a RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp1 +func (t RunConnectorSubactionPushtoservice_SubActionParams_Incident_DestIp) AsRunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp1() (RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp1, error) { + var body RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp1 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromRunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp1 overwrites any union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_DestIp as the provided RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp1 +func (t *RunConnectorSubactionPushtoservice_SubActionParams_Incident_DestIp) FromRunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp1(v RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp1) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeRunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp1 performs a merge with any union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_DestIp, using the provided RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp1 +func (t *RunConnectorSubactionPushtoservice_SubActionParams_Incident_DestIp) MergeRunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp1(v RunConnectorSubactionPushtoserviceSubActionParamsIncidentDestIp1) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +func (t RunConnectorSubactionPushtoservice_SubActionParams_Incident_DestIp) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *RunConnectorSubactionPushtoservice_SubActionParams_Incident_DestIp) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// AsRunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash0 returns the union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_MalwareHash as a RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash0 +func (t RunConnectorSubactionPushtoservice_SubActionParams_Incident_MalwareHash) AsRunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash0() (RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash0, error) { + var body RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash0 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromRunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash0 overwrites any union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_MalwareHash as the provided RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash0 +func (t *RunConnectorSubactionPushtoservice_SubActionParams_Incident_MalwareHash) FromRunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash0(v RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash0) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeRunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash0 performs a merge with any union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_MalwareHash, using the provided RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash0 +func (t *RunConnectorSubactionPushtoservice_SubActionParams_Incident_MalwareHash) MergeRunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash0(v RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash0) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsRunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash1 returns the union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_MalwareHash as a RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash1 +func (t RunConnectorSubactionPushtoservice_SubActionParams_Incident_MalwareHash) AsRunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash1() (RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash1, error) { + var body RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash1 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromRunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash1 overwrites any union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_MalwareHash as the provided RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash1 +func (t *RunConnectorSubactionPushtoservice_SubActionParams_Incident_MalwareHash) FromRunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash1(v RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash1) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeRunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash1 performs a merge with any union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_MalwareHash, using the provided RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash1 +func (t *RunConnectorSubactionPushtoservice_SubActionParams_Incident_MalwareHash) MergeRunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash1(v RunConnectorSubactionPushtoserviceSubActionParamsIncidentMalwareHash1) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +func (t RunConnectorSubactionPushtoservice_SubActionParams_Incident_MalwareHash) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *RunConnectorSubactionPushtoservice_SubActionParams_Incident_MalwareHash) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// AsRunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp0 returns the union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_SourceIp as a RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp0 +func (t RunConnectorSubactionPushtoservice_SubActionParams_Incident_SourceIp) AsRunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp0() (RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp0, error) { + var body RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp0 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromRunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp0 overwrites any union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_SourceIp as the provided RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp0 +func (t *RunConnectorSubactionPushtoservice_SubActionParams_Incident_SourceIp) FromRunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp0(v RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp0) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeRunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp0 performs a merge with any union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_SourceIp, using the provided RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp0 +func (t *RunConnectorSubactionPushtoservice_SubActionParams_Incident_SourceIp) MergeRunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp0(v RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp0) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +// AsRunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp1 returns the union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_SourceIp as a RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp1 +func (t RunConnectorSubactionPushtoservice_SubActionParams_Incident_SourceIp) AsRunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp1() (RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp1, error) { + var body RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp1 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromRunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp1 overwrites any union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_SourceIp as the provided RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp1 +func (t *RunConnectorSubactionPushtoservice_SubActionParams_Incident_SourceIp) FromRunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp1(v RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp1) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeRunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp1 performs a merge with any union data inside the RunConnectorSubactionPushtoservice_SubActionParams_Incident_SourceIp, using the provided RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp1 +func (t *RunConnectorSubactionPushtoservice_SubActionParams_Incident_SourceIp) MergeRunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp1(v RunConnectorSubactionPushtoserviceSubActionParamsIncidentSourceIp1) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JsonMerge(b, t.union) + t.union = merged + return err +} + +func (t RunConnectorSubactionPushtoservice_SubActionParams_Incident_SourceIp) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *RunConnectorSubactionPushtoservice_SubActionParams_Incident_SourceIp) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + +// RequestEditorFn is the function signature for the RequestEditor callback function +type RequestEditorFn func(ctx context.Context, req *http.Request) error + +// Doer performs HTTP requests. +// +// The standard http.Client implements this interface. +type HttpRequestDoer interface { + Do(req *http.Request) (*http.Response, error) +} + +// Client which conforms to the OpenAPI3 specification for this service. +type Client struct { + // The endpoint of the server conforming to this interface, with scheme, + // https://api.deepmap.com for example. This can contain a path relative + // to the server, such as https://api.deepmap.com/dev-test, and all the + // paths in the swagger spec will be appended to the server. + Server string + + // Doer for performing requests, typically a *http.Client with any + // customized settings, such as certificate chains. + Client HttpRequestDoer + + // A list of callbacks for modifying requests which are generated before sending over + // the network. + RequestEditors []RequestEditorFn +} + +// ClientOption allows setting custom parameters during construction +type ClientOption func(*Client) error + +// Creates a new Client, with reasonable defaults +func NewClient(server string, opts ...ClientOption) (*Client, error) { + // create a client with sane default values + client := Client{ + Server: server, + } + // mutate client and add all optional params + for _, o := range opts { + if err := o(&client); err != nil { + return nil, err + } + } + // ensure the server URL always has a trailing slash + if !strings.HasSuffix(client.Server, "/") { + client.Server += "/" + } + // create httpClient, if not already present + if client.Client == nil { + client.Client = &http.Client{} + } + return &client, nil +} + +// WithHTTPClient allows overriding the default Doer, which is +// automatically created using http.Client. This is useful for tests. +func WithHTTPClient(doer HttpRequestDoer) ClientOption { + return func(c *Client) error { + c.Client = doer + return nil + } +} + +// WithRequestEditorFn allows setting up a callback function, which will be +// called right before sending the request. This can be used to mutate the request. +func WithRequestEditorFn(fn RequestEditorFn) ClientOption { + return func(c *Client) error { + c.RequestEditors = append(c.RequestEditors, fn) + return nil + } +} + +// The interface specification for the client above. +type ClientInterface interface { + // LegacyGetConnectors request + LegacyGetConnectors(ctx context.Context, spaceId SpaceId, reqEditors ...RequestEditorFn) (*http.Response, error) + + // LegacyCreateConnector request with any body + LegacyCreateConnectorWithBody(ctx context.Context, spaceId SpaceId, params *LegacyCreateConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + LegacyCreateConnector(ctx context.Context, spaceId SpaceId, params *LegacyCreateConnectorParams, body LegacyCreateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // LegacyDeleteConnector request + LegacyDeleteConnector(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyDeleteConnectorParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // LegacyGetConnector request + LegacyGetConnector(ctx context.Context, spaceId SpaceId, actionId ActionId, reqEditors ...RequestEditorFn) (*http.Response, error) + + // LegacyUpdateConnector request with any body + LegacyUpdateConnectorWithBody(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyUpdateConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + LegacyUpdateConnector(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyUpdateConnectorParams, body LegacyUpdateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // LegacyRunConnector request with any body + LegacyRunConnectorWithBody(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyRunConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + LegacyRunConnector(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyRunConnectorParams, body LegacyRunConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateConnector request with any body + CreateConnectorWithBody(ctx context.Context, spaceId SpaceId, params *CreateConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + CreateConnector(ctx context.Context, spaceId SpaceId, params *CreateConnectorParams, body CreateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteConnector request + DeleteConnector(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *DeleteConnectorParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetConnector request + GetConnector(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateConnector request with any body + UpdateConnectorWithBody(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *UpdateConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + UpdateConnector(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *UpdateConnectorParams, body UpdateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RunConnector request with any body + RunConnectorWithBody(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *RunConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + RunConnector(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *RunConnectorParams, body RunConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetConnectorTypes request + GetConnectorTypes(ctx context.Context, spaceId SpaceId, params *GetConnectorTypesParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetConnectors request + GetConnectors(ctx context.Context, spaceId SpaceId, reqEditors ...RequestEditorFn) (*http.Response, error) + + // LegacyGetConnectorTypes request + LegacyGetConnectorTypes(ctx context.Context, spaceId SpaceId, reqEditors ...RequestEditorFn) (*http.Response, error) +} + +func (c *Client) LegacyGetConnectors(ctx context.Context, spaceId SpaceId, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLegacyGetConnectorsRequest(c.Server, spaceId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) LegacyCreateConnectorWithBody(ctx context.Context, spaceId SpaceId, params *LegacyCreateConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLegacyCreateConnectorRequestWithBody(c.Server, spaceId, params, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) LegacyCreateConnector(ctx context.Context, spaceId SpaceId, params *LegacyCreateConnectorParams, body LegacyCreateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLegacyCreateConnectorRequest(c.Server, spaceId, params, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) LegacyDeleteConnector(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyDeleteConnectorParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLegacyDeleteConnectorRequest(c.Server, spaceId, actionId, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) LegacyGetConnector(ctx context.Context, spaceId SpaceId, actionId ActionId, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLegacyGetConnectorRequest(c.Server, spaceId, actionId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) LegacyUpdateConnectorWithBody(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyUpdateConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLegacyUpdateConnectorRequestWithBody(c.Server, spaceId, actionId, params, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) LegacyUpdateConnector(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyUpdateConnectorParams, body LegacyUpdateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLegacyUpdateConnectorRequest(c.Server, spaceId, actionId, params, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) LegacyRunConnectorWithBody(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyRunConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLegacyRunConnectorRequestWithBody(c.Server, spaceId, actionId, params, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) LegacyRunConnector(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyRunConnectorParams, body LegacyRunConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLegacyRunConnectorRequest(c.Server, spaceId, actionId, params, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CreateConnectorWithBody(ctx context.Context, spaceId SpaceId, params *CreateConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateConnectorRequestWithBody(c.Server, spaceId, params, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CreateConnector(ctx context.Context, spaceId SpaceId, params *CreateConnectorParams, body CreateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateConnectorRequest(c.Server, spaceId, params, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) DeleteConnector(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *DeleteConnectorParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteConnectorRequest(c.Server, spaceId, connectorId, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetConnector(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetConnectorRequest(c.Server, spaceId, connectorId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateConnectorWithBody(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *UpdateConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateConnectorRequestWithBody(c.Server, spaceId, connectorId, params, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateConnector(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *UpdateConnectorParams, body UpdateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateConnectorRequest(c.Server, spaceId, connectorId, params, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) RunConnectorWithBody(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *RunConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRunConnectorRequestWithBody(c.Server, spaceId, connectorId, params, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) RunConnector(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *RunConnectorParams, body RunConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRunConnectorRequest(c.Server, spaceId, connectorId, params, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetConnectorTypes(ctx context.Context, spaceId SpaceId, params *GetConnectorTypesParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetConnectorTypesRequest(c.Server, spaceId, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) GetConnectors(ctx context.Context, spaceId SpaceId, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetConnectorsRequest(c.Server, spaceId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) LegacyGetConnectorTypes(ctx context.Context, spaceId SpaceId, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewLegacyGetConnectorTypesRequest(c.Server, spaceId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +// NewLegacyGetConnectorsRequest generates requests for LegacyGetConnectors +func NewLegacyGetConnectorsRequest(server string, spaceId SpaceId) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/actions", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewLegacyCreateConnectorRequest calls the generic LegacyCreateConnector builder with application/json body +func NewLegacyCreateConnectorRequest(server string, spaceId SpaceId, params *LegacyCreateConnectorParams, body LegacyCreateConnectorJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewLegacyCreateConnectorRequestWithBody(server, spaceId, params, "application/json", bodyReader) +} + +// NewLegacyCreateConnectorRequestWithBody generates requests for LegacyCreateConnector with any type of body +func NewLegacyCreateConnectorRequestWithBody(server string, spaceId SpaceId, params *LegacyCreateConnectorParams, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/actions", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "kbn-xsrf", runtime.ParamLocationHeader, params.KbnXsrf) + if err != nil { + return nil, err + } + + req.Header.Set("kbn-xsrf", headerParam0) + + return req, nil +} + +// NewLegacyDeleteConnectorRequest generates requests for LegacyDeleteConnector +func NewLegacyDeleteConnectorRequest(server string, spaceId SpaceId, actionId ActionId, params *LegacyDeleteConnectorParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "actionId", runtime.ParamLocationPath, actionId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/actions/action/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "kbn-xsrf", runtime.ParamLocationHeader, params.KbnXsrf) + if err != nil { + return nil, err + } + + req.Header.Set("kbn-xsrf", headerParam0) + + return req, nil +} + +// NewLegacyGetConnectorRequest generates requests for LegacyGetConnector +func NewLegacyGetConnectorRequest(server string, spaceId SpaceId, actionId ActionId) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "actionId", runtime.ParamLocationPath, actionId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/actions/action/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewLegacyUpdateConnectorRequest calls the generic LegacyUpdateConnector builder with application/json body +func NewLegacyUpdateConnectorRequest(server string, spaceId SpaceId, actionId ActionId, params *LegacyUpdateConnectorParams, body LegacyUpdateConnectorJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewLegacyUpdateConnectorRequestWithBody(server, spaceId, actionId, params, "application/json", bodyReader) +} + +// NewLegacyUpdateConnectorRequestWithBody generates requests for LegacyUpdateConnector with any type of body +func NewLegacyUpdateConnectorRequestWithBody(server string, spaceId SpaceId, actionId ActionId, params *LegacyUpdateConnectorParams, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "actionId", runtime.ParamLocationPath, actionId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/actions/action/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "kbn-xsrf", runtime.ParamLocationHeader, params.KbnXsrf) + if err != nil { + return nil, err + } + + req.Header.Set("kbn-xsrf", headerParam0) + + return req, nil +} + +// NewLegacyRunConnectorRequest calls the generic LegacyRunConnector builder with application/json body +func NewLegacyRunConnectorRequest(server string, spaceId SpaceId, actionId ActionId, params *LegacyRunConnectorParams, body LegacyRunConnectorJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewLegacyRunConnectorRequestWithBody(server, spaceId, actionId, params, "application/json", bodyReader) +} + +// NewLegacyRunConnectorRequestWithBody generates requests for LegacyRunConnector with any type of body +func NewLegacyRunConnectorRequestWithBody(server string, spaceId SpaceId, actionId ActionId, params *LegacyRunConnectorParams, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "actionId", runtime.ParamLocationPath, actionId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/actions/action/%s/_execute", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "kbn-xsrf", runtime.ParamLocationHeader, params.KbnXsrf) + if err != nil { + return nil, err + } + + req.Header.Set("kbn-xsrf", headerParam0) + + return req, nil +} + +// NewCreateConnectorRequest calls the generic CreateConnector builder with application/json body +func NewCreateConnectorRequest(server string, spaceId SpaceId, params *CreateConnectorParams, body CreateConnectorJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateConnectorRequestWithBody(server, spaceId, params, "application/json", bodyReader) +} + +// NewCreateConnectorRequestWithBody generates requests for CreateConnector with any type of body +func NewCreateConnectorRequestWithBody(server string, spaceId SpaceId, params *CreateConnectorParams, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/actions/connector", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "kbn-xsrf", runtime.ParamLocationHeader, params.KbnXsrf) + if err != nil { + return nil, err + } + + req.Header.Set("kbn-xsrf", headerParam0) + + return req, nil +} + +// NewDeleteConnectorRequest generates requests for DeleteConnector +func NewDeleteConnectorRequest(server string, spaceId SpaceId, connectorId ConnectorId, params *DeleteConnectorParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "connectorId", runtime.ParamLocationPath, connectorId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/actions/connector/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "kbn-xsrf", runtime.ParamLocationHeader, params.KbnXsrf) + if err != nil { + return nil, err + } + + req.Header.Set("kbn-xsrf", headerParam0) + + return req, nil +} + +// NewGetConnectorRequest generates requests for GetConnector +func NewGetConnectorRequest(server string, spaceId SpaceId, connectorId ConnectorId) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "connectorId", runtime.ParamLocationPath, connectorId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/actions/connector/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateConnectorRequest calls the generic UpdateConnector builder with application/json body +func NewUpdateConnectorRequest(server string, spaceId SpaceId, connectorId ConnectorId, params *UpdateConnectorParams, body UpdateConnectorJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateConnectorRequestWithBody(server, spaceId, connectorId, params, "application/json", bodyReader) +} + +// NewUpdateConnectorRequestWithBody generates requests for UpdateConnector with any type of body +func NewUpdateConnectorRequestWithBody(server string, spaceId SpaceId, connectorId ConnectorId, params *UpdateConnectorParams, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "connectorId", runtime.ParamLocationPath, connectorId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/actions/connector/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PUT", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "kbn-xsrf", runtime.ParamLocationHeader, params.KbnXsrf) + if err != nil { + return nil, err + } + + req.Header.Set("kbn-xsrf", headerParam0) + + return req, nil +} + +// NewRunConnectorRequest calls the generic RunConnector builder with application/json body +func NewRunConnectorRequest(server string, spaceId SpaceId, connectorId ConnectorId, params *RunConnectorParams, body RunConnectorJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewRunConnectorRequestWithBody(server, spaceId, connectorId, params, "application/json", bodyReader) +} + +// NewRunConnectorRequestWithBody generates requests for RunConnector with any type of body +func NewRunConnectorRequestWithBody(server string, spaceId SpaceId, connectorId ConnectorId, params *RunConnectorParams, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "connectorId", runtime.ParamLocationPath, connectorId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/actions/connector/%s/_execute", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + var headerParam0 string + + headerParam0, err = runtime.StyleParamWithLocation("simple", false, "kbn-xsrf", runtime.ParamLocationHeader, params.KbnXsrf) + if err != nil { + return nil, err + } + + req.Header.Set("kbn-xsrf", headerParam0) + + return req, nil +} + +// NewGetConnectorTypesRequest generates requests for GetConnectorTypes +func NewGetConnectorTypesRequest(server string, spaceId SpaceId, params *GetConnectorTypesParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/actions/connector_types", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + queryValues := queryURL.Query() + + if params.FeatureId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "feature_id", runtime.ParamLocationQuery, *params.FeatureId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewGetConnectorsRequest generates requests for GetConnectors +func NewGetConnectorsRequest(server string, spaceId SpaceId) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/actions/connectors", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewLegacyGetConnectorTypesRequest generates requests for LegacyGetConnectorTypes +func NewLegacyGetConnectorTypesRequest(server string, spaceId SpaceId) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "spaceId", runtime.ParamLocationPath, spaceId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/s/%s/api/actions/list_action_types", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { + for _, r := range c.RequestEditors { + if err := r(ctx, req); err != nil { + return err + } + } + for _, r := range additionalEditors { + if err := r(ctx, req); err != nil { + return err + } + } + return nil +} + +// ClientWithResponses builds on ClientInterface to offer response payloads +type ClientWithResponses struct { + ClientInterface +} + +// NewClientWithResponses creates a new ClientWithResponses, which wraps +// Client with return type handling +func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { + client, err := NewClient(server, opts...) + if err != nil { + return nil, err + } + return &ClientWithResponses{client}, nil +} + +// WithBaseURL overrides the baseURL. +func WithBaseURL(baseURL string) ClientOption { + return func(c *Client) error { + newBaseURL, err := url.Parse(baseURL) + if err != nil { + return err + } + c.Server = newBaseURL.String() + return nil + } +} + +// ClientWithResponsesInterface is the interface specification for the client with responses above. +type ClientWithResponsesInterface interface { + // LegacyGetConnectors request + LegacyGetConnectorsWithResponse(ctx context.Context, spaceId SpaceId, reqEditors ...RequestEditorFn) (*LegacyGetConnectorsResponse, error) + + // LegacyCreateConnector request with any body + LegacyCreateConnectorWithBodyWithResponse(ctx context.Context, spaceId SpaceId, params *LegacyCreateConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LegacyCreateConnectorResponse, error) + + LegacyCreateConnectorWithResponse(ctx context.Context, spaceId SpaceId, params *LegacyCreateConnectorParams, body LegacyCreateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*LegacyCreateConnectorResponse, error) + + // LegacyDeleteConnector request + LegacyDeleteConnectorWithResponse(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyDeleteConnectorParams, reqEditors ...RequestEditorFn) (*LegacyDeleteConnectorResponse, error) + + // LegacyGetConnector request + LegacyGetConnectorWithResponse(ctx context.Context, spaceId SpaceId, actionId ActionId, reqEditors ...RequestEditorFn) (*LegacyGetConnectorResponse, error) + + // LegacyUpdateConnector request with any body + LegacyUpdateConnectorWithBodyWithResponse(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyUpdateConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LegacyUpdateConnectorResponse, error) + + LegacyUpdateConnectorWithResponse(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyUpdateConnectorParams, body LegacyUpdateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*LegacyUpdateConnectorResponse, error) + + // LegacyRunConnector request with any body + LegacyRunConnectorWithBodyWithResponse(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyRunConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LegacyRunConnectorResponse, error) + + LegacyRunConnectorWithResponse(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyRunConnectorParams, body LegacyRunConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*LegacyRunConnectorResponse, error) + + // CreateConnector request with any body + CreateConnectorWithBodyWithResponse(ctx context.Context, spaceId SpaceId, params *CreateConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateConnectorResponse, error) + + CreateConnectorWithResponse(ctx context.Context, spaceId SpaceId, params *CreateConnectorParams, body CreateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateConnectorResponse, error) + + // DeleteConnector request + DeleteConnectorWithResponse(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *DeleteConnectorParams, reqEditors ...RequestEditorFn) (*DeleteConnectorResponse, error) + + // GetConnector request + GetConnectorWithResponse(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, reqEditors ...RequestEditorFn) (*GetConnectorResponse, error) + + // UpdateConnector request with any body + UpdateConnectorWithBodyWithResponse(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *UpdateConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateConnectorResponse, error) + + UpdateConnectorWithResponse(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *UpdateConnectorParams, body UpdateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateConnectorResponse, error) + + // RunConnector request with any body + RunConnectorWithBodyWithResponse(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *RunConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RunConnectorResponse, error) + + RunConnectorWithResponse(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *RunConnectorParams, body RunConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*RunConnectorResponse, error) + + // GetConnectorTypes request + GetConnectorTypesWithResponse(ctx context.Context, spaceId SpaceId, params *GetConnectorTypesParams, reqEditors ...RequestEditorFn) (*GetConnectorTypesResponse, error) + + // GetConnectors request + GetConnectorsWithResponse(ctx context.Context, spaceId SpaceId, reqEditors ...RequestEditorFn) (*GetConnectorsResponse, error) + + // LegacyGetConnectorTypes request + LegacyGetConnectorTypesWithResponse(ctx context.Context, spaceId SpaceId, reqEditors ...RequestEditorFn) (*LegacyGetConnectorTypesResponse, error) +} + +type LegacyGetConnectorsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]ActionResponseProperties + JSON401 *AuthorizationError +} + +// Status returns HTTPResponse.Status +func (r LegacyGetConnectorsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r LegacyGetConnectorsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type LegacyCreateConnectorResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ActionResponseProperties + JSON401 *AuthorizationError +} + +// Status returns HTTPResponse.Status +func (r LegacyCreateConnectorResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r LegacyCreateConnectorResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type LegacyDeleteConnectorResponse struct { + Body []byte + HTTPResponse *http.Response + JSON401 *AuthorizationError +} + +// Status returns HTTPResponse.Status +func (r LegacyDeleteConnectorResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r LegacyDeleteConnectorResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type LegacyGetConnectorResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ActionResponseProperties + JSON401 *AuthorizationError +} + +// Status returns HTTPResponse.Status +func (r LegacyGetConnectorResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r LegacyGetConnectorResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type LegacyUpdateConnectorResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ActionResponseProperties + JSON404 *ObjectNotFoundError +} + +// Status returns HTTPResponse.Status +func (r LegacyUpdateConnectorResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r LegacyUpdateConnectorResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type LegacyRunConnectorResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *LegacyRunConnectorGeneralResponse + JSON401 *AuthorizationError +} + +// Status returns HTTPResponse.Status +func (r LegacyRunConnectorResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r LegacyRunConnectorResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type CreateConnectorResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ConnectorResponseProperties + JSON400 *BadRequestError + JSON401 *AuthorizationError +} + +// Status returns HTTPResponse.Status +func (r CreateConnectorResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateConnectorResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DeleteConnectorResponse struct { + Body []byte + HTTPResponse *http.Response + JSON401 *AuthorizationError + JSON404 *struct { + Error *string `json:"error,omitempty"` + Message *string `json:"message,omitempty"` + StatusCode *int `json:"statusCode,omitempty"` + } +} + +// Status returns HTTPResponse.Status +func (r DeleteConnectorResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteConnectorResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetConnectorResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ConnectorResponseProperties + JSON401 *AuthorizationError + JSON404 *struct { + Error *string `json:"error,omitempty"` + Message *string `json:"message,omitempty"` + StatusCode *int `json:"statusCode,omitempty"` + } +} + +// Status returns HTTPResponse.Status +func (r GetConnectorResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetConnectorResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type UpdateConnectorResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ConnectorResponseProperties + JSON400 *BadRequestError + JSON401 *AuthorizationError + JSON404 *ObjectNotFoundError +} + +// Status returns HTTPResponse.Status +func (r UpdateConnectorResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateConnectorResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type RunConnectorResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *RunConnectorGeneralResponse + JSON401 *AuthorizationError +} + +// Status returns HTTPResponse.Status +func (r RunConnectorResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RunConnectorResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetConnectorTypesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]struct { + // Enabled Indicates whether the connector type is enabled in Kibana. + Enabled *bool `json:"enabled,omitempty"` + + // EnabledInConfig Indicates whether the connector type is enabled in the Kibana `.yml` file. + EnabledInConfig *bool `json:"enabled_in_config,omitempty"` + + // EnabledInLicense Indicates whether the connector is enabled in the license. + EnabledInLicense *bool `json:"enabled_in_license,omitempty"` + + // Id The type of connector. For example, `.email`, `.index`, `.jira`, `.opsgenie`, or `.server-log`. + Id *ConnectorTypes `json:"id,omitempty"` + + // MinimumLicenseRequired The license that is required to use the connector type. + MinimumLicenseRequired *string `json:"minimum_license_required,omitempty"` + + // Name The name of the connector type. + Name *string `json:"name,omitempty"` + + // SupportedFeatureIds The Kibana features that are supported by the connector type. + SupportedFeatureIds *[]Features `json:"supported_feature_ids,omitempty"` + } + JSON401 *AuthorizationError +} + +// Status returns HTTPResponse.Status +func (r GetConnectorTypesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetConnectorTypesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type GetConnectorsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]struct { + // Config The configuration for the connector. Configuration properties vary depending on the connector type. + Config *map[string]interface{} `json:"config"` + + // ConnectorTypeId The type of connector. For example, `.email`, `.index`, `.jira`, `.opsgenie`, or `.server-log`. + ConnectorTypeId ConnectorTypes `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` + + // ReferencedByCount Indicates the number of saved objects that reference the connector. If `is_preconfigured` is true, this value is not calculated. + ReferencedByCount int `json:"referenced_by_count"` + } + JSON401 *AuthorizationError +} + +// Status returns HTTPResponse.Status +func (r GetConnectorsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetConnectorsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type LegacyGetConnectorTypesResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]struct { + // Enabled Indicates whether the connector type is enabled in Kibana. + Enabled *bool `json:"enabled,omitempty"` + + // EnabledInConfig Indicates whether the connector type is enabled in the Kibana `.yml` file. + EnabledInConfig *bool `json:"enabledInConfig,omitempty"` + + // EnabledInLicense Indicates whether the connector is enabled in the license. + EnabledInLicense *bool `json:"enabledInLicense,omitempty"` + + // Id The unique identifier for the connector type. + Id *string `json:"id,omitempty"` + + // MinimumLicenseRequired The license that is required to use the connector type. + MinimumLicenseRequired *string `json:"minimumLicenseRequired,omitempty"` + + // Name The name of the connector type. + Name *string `json:"name,omitempty"` + } + JSON401 *AuthorizationError +} + +// Status returns HTTPResponse.Status +func (r LegacyGetConnectorTypesResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r LegacyGetConnectorTypesResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +// LegacyGetConnectorsWithResponse request returning *LegacyGetConnectorsResponse +func (c *ClientWithResponses) LegacyGetConnectorsWithResponse(ctx context.Context, spaceId SpaceId, reqEditors ...RequestEditorFn) (*LegacyGetConnectorsResponse, error) { + rsp, err := c.LegacyGetConnectors(ctx, spaceId, reqEditors...) + if err != nil { + return nil, err + } + return ParseLegacyGetConnectorsResponse(rsp) +} + +// LegacyCreateConnectorWithBodyWithResponse request with arbitrary body returning *LegacyCreateConnectorResponse +func (c *ClientWithResponses) LegacyCreateConnectorWithBodyWithResponse(ctx context.Context, spaceId SpaceId, params *LegacyCreateConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LegacyCreateConnectorResponse, error) { + rsp, err := c.LegacyCreateConnectorWithBody(ctx, spaceId, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseLegacyCreateConnectorResponse(rsp) +} + +func (c *ClientWithResponses) LegacyCreateConnectorWithResponse(ctx context.Context, spaceId SpaceId, params *LegacyCreateConnectorParams, body LegacyCreateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*LegacyCreateConnectorResponse, error) { + rsp, err := c.LegacyCreateConnector(ctx, spaceId, params, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseLegacyCreateConnectorResponse(rsp) +} + +// LegacyDeleteConnectorWithResponse request returning *LegacyDeleteConnectorResponse +func (c *ClientWithResponses) LegacyDeleteConnectorWithResponse(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyDeleteConnectorParams, reqEditors ...RequestEditorFn) (*LegacyDeleteConnectorResponse, error) { + rsp, err := c.LegacyDeleteConnector(ctx, spaceId, actionId, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseLegacyDeleteConnectorResponse(rsp) +} + +// LegacyGetConnectorWithResponse request returning *LegacyGetConnectorResponse +func (c *ClientWithResponses) LegacyGetConnectorWithResponse(ctx context.Context, spaceId SpaceId, actionId ActionId, reqEditors ...RequestEditorFn) (*LegacyGetConnectorResponse, error) { + rsp, err := c.LegacyGetConnector(ctx, spaceId, actionId, reqEditors...) + if err != nil { + return nil, err + } + return ParseLegacyGetConnectorResponse(rsp) +} + +// LegacyUpdateConnectorWithBodyWithResponse request with arbitrary body returning *LegacyUpdateConnectorResponse +func (c *ClientWithResponses) LegacyUpdateConnectorWithBodyWithResponse(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyUpdateConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LegacyUpdateConnectorResponse, error) { + rsp, err := c.LegacyUpdateConnectorWithBody(ctx, spaceId, actionId, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseLegacyUpdateConnectorResponse(rsp) +} + +func (c *ClientWithResponses) LegacyUpdateConnectorWithResponse(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyUpdateConnectorParams, body LegacyUpdateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*LegacyUpdateConnectorResponse, error) { + rsp, err := c.LegacyUpdateConnector(ctx, spaceId, actionId, params, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseLegacyUpdateConnectorResponse(rsp) +} + +// LegacyRunConnectorWithBodyWithResponse request with arbitrary body returning *LegacyRunConnectorResponse +func (c *ClientWithResponses) LegacyRunConnectorWithBodyWithResponse(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyRunConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*LegacyRunConnectorResponse, error) { + rsp, err := c.LegacyRunConnectorWithBody(ctx, spaceId, actionId, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseLegacyRunConnectorResponse(rsp) +} + +func (c *ClientWithResponses) LegacyRunConnectorWithResponse(ctx context.Context, spaceId SpaceId, actionId ActionId, params *LegacyRunConnectorParams, body LegacyRunConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*LegacyRunConnectorResponse, error) { + rsp, err := c.LegacyRunConnector(ctx, spaceId, actionId, params, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseLegacyRunConnectorResponse(rsp) +} + +// CreateConnectorWithBodyWithResponse request with arbitrary body returning *CreateConnectorResponse +func (c *ClientWithResponses) CreateConnectorWithBodyWithResponse(ctx context.Context, spaceId SpaceId, params *CreateConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateConnectorResponse, error) { + rsp, err := c.CreateConnectorWithBody(ctx, spaceId, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateConnectorResponse(rsp) +} + +func (c *ClientWithResponses) CreateConnectorWithResponse(ctx context.Context, spaceId SpaceId, params *CreateConnectorParams, body CreateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateConnectorResponse, error) { + rsp, err := c.CreateConnector(ctx, spaceId, params, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateConnectorResponse(rsp) +} + +// DeleteConnectorWithResponse request returning *DeleteConnectorResponse +func (c *ClientWithResponses) DeleteConnectorWithResponse(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *DeleteConnectorParams, reqEditors ...RequestEditorFn) (*DeleteConnectorResponse, error) { + rsp, err := c.DeleteConnector(ctx, spaceId, connectorId, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteConnectorResponse(rsp) +} + +// GetConnectorWithResponse request returning *GetConnectorResponse +func (c *ClientWithResponses) GetConnectorWithResponse(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, reqEditors ...RequestEditorFn) (*GetConnectorResponse, error) { + rsp, err := c.GetConnector(ctx, spaceId, connectorId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetConnectorResponse(rsp) +} + +// UpdateConnectorWithBodyWithResponse request with arbitrary body returning *UpdateConnectorResponse +func (c *ClientWithResponses) UpdateConnectorWithBodyWithResponse(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *UpdateConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateConnectorResponse, error) { + rsp, err := c.UpdateConnectorWithBody(ctx, spaceId, connectorId, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateConnectorResponse(rsp) +} + +func (c *ClientWithResponses) UpdateConnectorWithResponse(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *UpdateConnectorParams, body UpdateConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateConnectorResponse, error) { + rsp, err := c.UpdateConnector(ctx, spaceId, connectorId, params, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateConnectorResponse(rsp) +} + +// RunConnectorWithBodyWithResponse request with arbitrary body returning *RunConnectorResponse +func (c *ClientWithResponses) RunConnectorWithBodyWithResponse(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *RunConnectorParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RunConnectorResponse, error) { + rsp, err := c.RunConnectorWithBody(ctx, spaceId, connectorId, params, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRunConnectorResponse(rsp) +} + +func (c *ClientWithResponses) RunConnectorWithResponse(ctx context.Context, spaceId SpaceId, connectorId ConnectorId, params *RunConnectorParams, body RunConnectorJSONRequestBody, reqEditors ...RequestEditorFn) (*RunConnectorResponse, error) { + rsp, err := c.RunConnector(ctx, spaceId, connectorId, params, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRunConnectorResponse(rsp) +} + +// GetConnectorTypesWithResponse request returning *GetConnectorTypesResponse +func (c *ClientWithResponses) GetConnectorTypesWithResponse(ctx context.Context, spaceId SpaceId, params *GetConnectorTypesParams, reqEditors ...RequestEditorFn) (*GetConnectorTypesResponse, error) { + rsp, err := c.GetConnectorTypes(ctx, spaceId, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetConnectorTypesResponse(rsp) +} + +// GetConnectorsWithResponse request returning *GetConnectorsResponse +func (c *ClientWithResponses) GetConnectorsWithResponse(ctx context.Context, spaceId SpaceId, reqEditors ...RequestEditorFn) (*GetConnectorsResponse, error) { + rsp, err := c.GetConnectors(ctx, spaceId, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetConnectorsResponse(rsp) +} + +// LegacyGetConnectorTypesWithResponse request returning *LegacyGetConnectorTypesResponse +func (c *ClientWithResponses) LegacyGetConnectorTypesWithResponse(ctx context.Context, spaceId SpaceId, reqEditors ...RequestEditorFn) (*LegacyGetConnectorTypesResponse, error) { + rsp, err := c.LegacyGetConnectorTypes(ctx, spaceId, reqEditors...) + if err != nil { + return nil, err + } + return ParseLegacyGetConnectorTypesResponse(rsp) +} + +// ParseLegacyGetConnectorsResponse parses an HTTP response from a LegacyGetConnectorsWithResponse call +func ParseLegacyGetConnectorsResponse(rsp *http.Response) (*LegacyGetConnectorsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &LegacyGetConnectorsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []ActionResponseProperties + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest AuthorizationError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + } + + return response, nil +} + +// ParseLegacyCreateConnectorResponse parses an HTTP response from a LegacyCreateConnectorWithResponse call +func ParseLegacyCreateConnectorResponse(rsp *http.Response) (*LegacyCreateConnectorResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &LegacyCreateConnectorResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ActionResponseProperties + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest AuthorizationError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + } + + return response, nil +} + +// ParseLegacyDeleteConnectorResponse parses an HTTP response from a LegacyDeleteConnectorWithResponse call +func ParseLegacyDeleteConnectorResponse(rsp *http.Response) (*LegacyDeleteConnectorResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &LegacyDeleteConnectorResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest AuthorizationError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + } + + return response, nil +} + +// ParseLegacyGetConnectorResponse parses an HTTP response from a LegacyGetConnectorWithResponse call +func ParseLegacyGetConnectorResponse(rsp *http.Response) (*LegacyGetConnectorResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &LegacyGetConnectorResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ActionResponseProperties + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest AuthorizationError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + } + + return response, nil +} + +// ParseLegacyUpdateConnectorResponse parses an HTTP response from a LegacyUpdateConnectorWithResponse call +func ParseLegacyUpdateConnectorResponse(rsp *http.Response) (*LegacyUpdateConnectorResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &LegacyUpdateConnectorResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ActionResponseProperties + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest ObjectNotFoundError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + } + + return response, nil +} + +// ParseLegacyRunConnectorResponse parses an HTTP response from a LegacyRunConnectorWithResponse call +func ParseLegacyRunConnectorResponse(rsp *http.Response) (*LegacyRunConnectorResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &LegacyRunConnectorResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest LegacyRunConnectorGeneralResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest AuthorizationError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + } + + return response, nil +} + +// ParseCreateConnectorResponse parses an HTTP response from a CreateConnectorWithResponse call +func ParseCreateConnectorResponse(rsp *http.Response) (*CreateConnectorResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateConnectorResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ConnectorResponseProperties + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequestError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest AuthorizationError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + } + + return response, nil +} + +// ParseDeleteConnectorResponse parses an HTTP response from a DeleteConnectorWithResponse call +func ParseDeleteConnectorResponse(rsp *http.Response) (*DeleteConnectorResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteConnectorResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest AuthorizationError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest struct { + Error *string `json:"error,omitempty"` + Message *string `json:"message,omitempty"` + StatusCode *int `json:"statusCode,omitempty"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + } + + return response, nil +} + +// ParseGetConnectorResponse parses an HTTP response from a GetConnectorWithResponse call +func ParseGetConnectorResponse(rsp *http.Response) (*GetConnectorResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetConnectorResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ConnectorResponseProperties + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest AuthorizationError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest struct { + Error *string `json:"error,omitempty"` + Message *string `json:"message,omitempty"` + StatusCode *int `json:"statusCode,omitempty"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + } + + return response, nil +} + +// ParseUpdateConnectorResponse parses an HTTP response from a UpdateConnectorWithResponse call +func ParseUpdateConnectorResponse(rsp *http.Response) (*UpdateConnectorResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateConnectorResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ConnectorResponseProperties + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400: + var dest BadRequestError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON400 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest AuthorizationError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 404: + var dest ObjectNotFoundError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON404 = &dest + + } + + return response, nil +} + +// ParseRunConnectorResponse parses an HTTP response from a RunConnectorWithResponse call +func ParseRunConnectorResponse(rsp *http.Response) (*RunConnectorResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RunConnectorResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest RunConnectorGeneralResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest AuthorizationError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + } + + return response, nil +} + +// ParseGetConnectorTypesResponse parses an HTTP response from a GetConnectorTypesWithResponse call +func ParseGetConnectorTypesResponse(rsp *http.Response) (*GetConnectorTypesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetConnectorTypesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []struct { + // Enabled Indicates whether the connector type is enabled in Kibana. + Enabled *bool `json:"enabled,omitempty"` + + // EnabledInConfig Indicates whether the connector type is enabled in the Kibana `.yml` file. + EnabledInConfig *bool `json:"enabled_in_config,omitempty"` + + // EnabledInLicense Indicates whether the connector is enabled in the license. + EnabledInLicense *bool `json:"enabled_in_license,omitempty"` + + // Id The type of connector. For example, `.email`, `.index`, `.jira`, `.opsgenie`, or `.server-log`. + Id *ConnectorTypes `json:"id,omitempty"` + + // MinimumLicenseRequired The license that is required to use the connector type. + MinimumLicenseRequired *string `json:"minimum_license_required,omitempty"` + + // Name The name of the connector type. + Name *string `json:"name,omitempty"` + + // SupportedFeatureIds The Kibana features that are supported by the connector type. + SupportedFeatureIds *[]Features `json:"supported_feature_ids,omitempty"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest AuthorizationError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + } + + return response, nil +} + +// ParseGetConnectorsResponse parses an HTTP response from a GetConnectorsWithResponse call +func ParseGetConnectorsResponse(rsp *http.Response) (*GetConnectorsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetConnectorsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []struct { + // Config The configuration for the connector. Configuration properties vary depending on the connector type. + Config *map[string]interface{} `json:"config"` + + // ConnectorTypeId The type of connector. For example, `.email`, `.index`, `.jira`, `.opsgenie`, or `.server-log`. + ConnectorTypeId ConnectorTypes `json:"connector_type_id"` + + // Id The identifier for the connector. + Id string `json:"id"` + + // IsDeprecated Indicates whether the connector type is deprecated. + IsDeprecated *IsDeprecated `json:"is_deprecated,omitempty"` + + // IsMissingSecrets Indicates whether secrets are missing for the connector. Secrets configuration properties vary depending on the connector type. + IsMissingSecrets *IsMissingSecrets `json:"is_missing_secrets,omitempty"` + + // IsPreconfigured Indicates whether it is a preconfigured connector. If true, the `config` and `is_missing_secrets` properties are omitted from the response. + IsPreconfigured IsPreconfigured `json:"is_preconfigured"` + + // Name The display name for the connector. + Name string `json:"name"` + + // ReferencedByCount Indicates the number of saved objects that reference the connector. If `is_preconfigured` is true, this value is not calculated. + ReferencedByCount int `json:"referenced_by_count"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest AuthorizationError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + } + + return response, nil +} + +// ParseLegacyGetConnectorTypesResponse parses an HTTP response from a LegacyGetConnectorTypesWithResponse call +func ParseLegacyGetConnectorTypesResponse(rsp *http.Response) (*LegacyGetConnectorTypesResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &LegacyGetConnectorTypesResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []struct { + // Enabled Indicates whether the connector type is enabled in Kibana. + Enabled *bool `json:"enabled,omitempty"` + + // EnabledInConfig Indicates whether the connector type is enabled in the Kibana `.yml` file. + EnabledInConfig *bool `json:"enabledInConfig,omitempty"` + + // EnabledInLicense Indicates whether the connector is enabled in the license. + EnabledInLicense *bool `json:"enabledInLicense,omitempty"` + + // Id The unique identifier for the connector type. + Id *string `json:"id,omitempty"` + + // MinimumLicenseRequired The license that is required to use the connector type. + MinimumLicenseRequired *string `json:"minimumLicenseRequired,omitempty"` + + // Name The name of the connector type. + Name *string `json:"name,omitempty"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 401: + var dest AuthorizationError + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON401 = &dest + + } + + return response, nil +} diff --git a/go.mod b/go.mod index 96002a77b..ff14bf605 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/fatih/color v1.13.0 // indirect + github.com/fatih/color v1.15.0 // indirect github.com/go-resty/resty/v2 v2.7.0 // indirect github.com/golang/protobuf v1.5.2 // indirect github.com/google/go-cmp v0.5.9 // indirect @@ -40,8 +40,9 @@ require ( github.com/hashicorp/terraform-registry-address v0.2.0 // indirect github.com/hashicorp/terraform-svchost v0.0.1 // indirect github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect + github.com/kr/pretty v0.3.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.16 // indirect + github.com/mattn/go-isatty v0.0.18 // indirect github.com/mitchellh/copystructure v1.2.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect github.com/mitchellh/go-wordwrap v1.0.1 // indirect @@ -49,16 +50,17 @@ require ( github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/oklog/run v1.1.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/rogpeppe/go-internal v1.8.0 // indirect github.com/sirupsen/logrus v1.9.0 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/zclconf/go-cty v1.13.1 // indirect golang.org/x/crypto v0.7.0 // indirect - golang.org/x/mod v0.8.0 // indirect - golang.org/x/net v0.8.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect + golang.org/x/mod v0.10.0 // indirect + golang.org/x/net v0.9.0 // indirect + golang.org/x/sys v0.7.0 // indirect + golang.org/x/text v0.9.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect google.golang.org/grpc v1.54.0 // indirect diff --git a/go.sum b/go.sum index b1affb457..e3bacdb43 100644 --- a/go.sum +++ b/go.sum @@ -34,8 +34,9 @@ github.com/elastic/go-elasticsearch/v7 v7.17.7/go.mod h1:OJ4wdbtDNk5g503kvlHLyEr github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg= github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= +github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= @@ -123,8 +124,9 @@ github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 h1:DowS9hvgy github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -139,8 +141,9 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98= +github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= github.com/mitchellh/cli v1.1.5/go.mod h1:v8+iFts2sPIKUV1ltktPXMCC8fumSKFItNcD2cLtRR4= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= @@ -160,11 +163,15 @@ github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= @@ -213,8 +220,8 @@ golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= +golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -223,8 +230,8 @@ golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5o golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= +golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -250,20 +257,21 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= -golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw= +golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= @@ -286,6 +294,7 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/internal/clients/api_client.go b/internal/clients/api_client.go index eefeacaa0..c9ddf994e 100644 --- a/internal/clients/api_client.go +++ b/internal/clients/api_client.go @@ -11,9 +11,11 @@ import ( "strconv" "strings" + "github.com/deepmap/oapi-codegen/pkg/securityprovider" "github.com/disaster37/go-kibana-rest/v8" "github.com/elastic/go-elasticsearch/v7" "github.com/elastic/terraform-provider-elasticstack/generated/alerting" + "github.com/elastic/terraform-provider-elasticstack/generated/connectors" "github.com/elastic/terraform-provider-elasticstack/internal/clients/fleet" "github.com/elastic/terraform-provider-elasticstack/internal/models" "github.com/elastic/terraform-provider-elasticstack/internal/utils" @@ -64,6 +66,7 @@ type ApiClient struct { elasticsearchClusterInfo *models.ClusterInfo kibana *kibana.Client alerting alerting.AlertingApi + connectors *connectors.Client kibanaConfig kibana.Config fleet *fleet.Client version string @@ -135,6 +138,10 @@ func NewAcceptanceTestingClient() (*ApiClient, error) { return nil, err } + actionConnectors, err := buildConnectorsClient(baseConfig, kibanaConfig) + if err != nil { + return nil, fmt.Errorf("cannot create Kibana action connectors client: [%w]", err) + } fleetCfg := fleet.Config{ URL: kibanaConfig.Address, Username: kibanaConfig.Username, @@ -155,6 +162,7 @@ func NewAcceptanceTestingClient() (*ApiClient, error) { elasticsearch: es, kibana: kib, alerting: buildAlertingClient(baseConfig, kibanaConfig).AlertingApi, + connectors: actionConnectors, kibanaConfig: kibanaConfig, fleet: fleetClient, version: "acceptance-testing", @@ -222,6 +230,14 @@ func (a *ApiClient) GetAlertingClient() (alerting.AlertingApi, error) { return a.alerting, nil } +func (a *ApiClient) GetKibanaConnectorsClient(ctx context.Context) (*connectors.Client, error) { + if a.connectors == nil { + return nil, errors.New("kibana action connector client not found") + } + + return a.connectors, nil +} + func (a *ApiClient) GetFleetClient() (*fleet.Client, error) { if a.fleet == nil { return nil, errors.New("fleet client not found") @@ -549,6 +565,17 @@ func buildAlertingClient(baseConfig BaseConfig, config kibana.Config) *alerting. return alerting.NewAPIClient(&alertingConfig) } +func buildConnectorsClient(baseConfig BaseConfig, config kibana.Config) (*connectors.Client, error) { + basicAuthProvider, err := securityprovider.NewSecurityProviderBasicAuth(config.Username, config.Password) + if err != nil { + return nil, fmt.Errorf("unable to create basic auth provider: %w", err) + } + return connectors.NewClient( + config.Address, + connectors.WithRequestEditorFn(basicAuthProvider.Intercept), + ) +} + func buildFleetClient(d *schema.ResourceData, kibanaCfg kibana.Config) (*fleet.Client, diag.Diagnostics) { var diags diag.Diagnostics @@ -623,7 +650,6 @@ func buildFleetClient(d *schema.ResourceData, kibanaCfg kibana.Config) (*fleet.C const esKey string = "elasticsearch" func newApiClient(d *schema.ResourceData, version string) (*ApiClient, diag.Diagnostics) { - var diags diag.Diagnostics baseConfig := buildBaseConfig(d, version, esKey) kibanaConfig, diags := buildKibanaConfig(d, baseConfig) if diags.HasError() { @@ -642,6 +668,11 @@ func newApiClient(d *schema.ResourceData, version string) (*ApiClient, diag.Diag alertingClient := buildAlertingClient(baseConfig, kibanaConfig) + connectorsClient, err := buildConnectorsClient(baseConfig, kibanaConfig) + if err != nil { + return nil, diag.FromErr(fmt.Errorf("cannot create Kibana connectors client: [%w]", err)) + } + fleetClient, diags := buildFleetClient(d, kibanaConfig) if diags.HasError() { return nil, diags @@ -653,7 +684,8 @@ func newApiClient(d *schema.ResourceData, version string) (*ApiClient, diag.Diag kibana: kibanaClient, kibanaConfig: kibanaConfig, alerting: alertingClient.AlertingApi, + connectors: connectorsClient, fleet: fleetClient, version: version, - }, diags + }, nil } diff --git a/internal/clients/kibana/alerting.go b/internal/clients/kibana/alerting.go index a4a262d20..8f03306fe 100644 --- a/internal/clients/kibana/alerting.go +++ b/internal/clients/kibana/alerting.go @@ -130,7 +130,7 @@ func UpdateAlertingRule(ctx context.Context, apiClient *clients.ApiClient, rule defer res.Body.Close() if diags := utils.CheckHttpError(res, "Unable to update alerting rule"); diags.HasError() { - return nil, diag.FromErr(err) + return nil, diags } shouldBeEnabled := rule.Enabled != nil && *rule.Enabled diff --git a/internal/clients/kibana/alerting_test.go b/internal/clients/kibana/alerting_test.go index df64a9f0d..707ccaff8 100644 --- a/internal/clients/kibana/alerting_test.go +++ b/internal/clients/kibana/alerting_test.go @@ -103,12 +103,12 @@ func Test_ruleResponseToModel(t *testing.T) { Status: makePtr("firing"), }, Actions: []models.AlertingRuleAction{ - models.AlertingRuleAction{ + { Group: "group-1", ID: "id", Params: map[string]interface{}{}, }, - models.AlertingRuleAction{ + { Group: "group-2", ID: "id", Params: map[string]interface{}{}, diff --git a/internal/clients/kibana/connector.go b/internal/clients/kibana/connector.go new file mode 100644 index 000000000..25e5b8e2f --- /dev/null +++ b/internal/clients/kibana/connector.go @@ -0,0 +1,1481 @@ +package kibana + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + + "github.com/elastic/terraform-provider-elasticstack/generated/connectors" + "github.com/elastic/terraform-provider-elasticstack/internal/clients" + "github.com/elastic/terraform-provider-elasticstack/internal/models" + "github.com/elastic/terraform-provider-elasticstack/internal/utils" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" +) + +func CreateConnector(ctx context.Context, apiClient *clients.ApiClient, connectorOld models.KibanaActionConnector) (string, diag.Diagnostics) { + client, err := apiClient.GetKibanaConnectorsClient(ctx) + if err != nil { + return "", diag.FromErr(err) + } + + body, err := createConnectorRequestBody(connectorOld) + if err != nil { + return "", diag.FromErr(err) + } + + httpResp, err := client.CreateConnectorWithBody(ctx, connectorOld.SpaceID, &connectors.CreateConnectorParams{KbnXsrf: connectors.KbnXsrf("true")}, "application/json", body) + + if err != nil { + return "", diag.Errorf("unable to create connector: [%v]", err) + } + + defer httpResp.Body.Close() + + resp, err := connectors.ParseCreateConnectorResponse(httpResp) + if err != nil { + return "", diag.Errorf("unable to parse connector create response: [%v]", err) + } + + if resp.JSON400 != nil { + return "", diag.Errorf("%s: %s", *resp.JSON400.Error, *resp.JSON400.Message) + } + + if resp.JSON401 != nil { + return "", diag.Errorf("%s: %s", *resp.JSON401.Error, *resp.JSON401.Message) + } + + if resp.JSON200 == nil { + return "", diag.Errorf("%s: %s", resp.Status(), string(resp.Body)) + } + + connectorNew, err := connectorResponseToModel(connectorOld.SpaceID, *resp.JSON200) + if err != nil { + return "", diag.FromErr(err) + } + + return connectorNew.ConnectorID, nil +} + +func UpdateConnector(ctx context.Context, apiClient *clients.ApiClient, connectorOld models.KibanaActionConnector) (string, diag.Diagnostics) { + client, err := apiClient.GetKibanaConnectorsClient(ctx) + if err != nil { + return "", diag.FromErr(err) + } + + body, err := updateConnectorRequestBody(connectorOld) + if err != nil { + return "", diag.FromErr(err) + } + + httpResp, err := client.UpdateConnectorWithBody(ctx, connectorOld.SpaceID, connectorOld.ConnectorID, &connectors.UpdateConnectorParams{KbnXsrf: connectors.KbnXsrf("true")}, "application/json", body) + + if err != nil { + return "", diag.Errorf("unable to update connector: [%v]", err) + } + + defer httpResp.Body.Close() + + resp, err := connectors.ParseCreateConnectorResponse(httpResp) + if err != nil { + return "", diag.Errorf("unable to parse connector update response: [%v]", err) + } + + if resp.JSON400 != nil { + return "", diag.Errorf("%s: %s", *resp.JSON400.Error, *resp.JSON400.Message) + } + + if resp.JSON401 != nil { + return "", diag.Errorf("%s: %s", *resp.JSON401.Error, *resp.JSON401.Message) + } + + if resp.JSON200 == nil { + return "", diag.Errorf("%s: %s", resp.Status(), string(resp.Body)) + } + + connectorNew, err := connectorResponseToModel(connectorOld.SpaceID, *resp.JSON200) + if err != nil { + return "", diag.FromErr(err) + } + + return connectorNew.ConnectorID, nil +} + +func GetConnector(ctx context.Context, apiClient *clients.ApiClient, connectorID, spaceID string) (*models.KibanaActionConnector, diag.Diagnostics) { + client, err := apiClient.GetKibanaConnectorsClient(ctx) + if err != nil { + return nil, diag.FromErr(err) + } + + httpResp, err := client.GetConnector(ctx, spaceID, connectorID) + + if err != nil { + return nil, diag.Errorf("unable to get connector: [%v]", err) + } + + defer httpResp.Body.Close() + + resp, err := connectors.ParseGetConnectorResponse(httpResp) + if err != nil { + return nil, diag.Errorf("unable to parse connector get response: [%v]", err) + } + + if resp.JSON401 != nil { + return nil, diag.Errorf("%s: %s", *resp.JSON401.Error, *resp.JSON401.Message) + } + + if resp.JSON404 != nil { + return nil, nil + } + + if resp.JSON200 == nil { + return nil, diag.Errorf("%s: %s", resp.Status(), string(resp.Body)) + } + + connector, err := connectorResponseToModel(spaceID, *resp.JSON200) + if err != nil { + return nil, diag.Errorf("unable to convert response to model: %v", err) + } + + return connector, nil +} + +func DeleteConnector(ctx context.Context, apiClient *clients.ApiClient, connectorID string, spaceID string) diag.Diagnostics { + client, err := apiClient.GetKibanaConnectorsClient(ctx) + if err != nil { + return diag.FromErr(err) + } + + httpResp, err := client.DeleteConnector(ctx, spaceID, connectorID, &connectors.DeleteConnectorParams{KbnXsrf: "true"}) + + if err != nil { + return diag.Errorf("unable to delete connector: [%v]", err) + } + + defer httpResp.Body.Close() + + resp, err := connectors.ParseDeleteConnectorResponse(httpResp) + if err != nil { + return diag.Errorf("unable to parse connector get response: [%v]", err) + } + + if resp.JSON404 != nil { + return diag.Errorf("%s: %s", *resp.JSON404.Error, *resp.JSON404.Message) + } + + if resp.JSON401 != nil { + return diag.Errorf("%s: %s", *resp.JSON401.Error, *resp.JSON401.Message) + } + + if resp.StatusCode() != 200 && resp.StatusCode() != 204 { + return diag.Errorf("failed to delete connector: got status [%v] [%s]", resp.StatusCode(), resp.Status()) + } + + return nil +} + +func ConnectorConfigWithDefaults(connectorTypeID, plan, backend, state string) (string, error) { + switch connectors.ConnectorTypes(connectorTypeID) { + + case connectors.ConnectorTypesDotCasesWebhook: + return connectorConfigWithDefaultsCasesWebhook(plan) + + case connectors.ConnectorTypesDotEmail: + return connectorConfigWithDefaultsEmail(plan) + + case connectors.ConnectorTypesDotIndex: + return connectorConfigWithDefaultsIndex(plan) + + case connectors.ConnectorTypesDotJira: + return connectorConfigWithDefaultsJira(plan) + + case connectors.ConnectorTypesDotOpsgenie: + return connectorConfigWithDefaultsOpsgenie(plan) + + case connectors.ConnectorTypesDotPagerduty: + return connectorConfigWithDefaultsPagerduty(plan) + + case connectors.ConnectorTypesDotResilient: + return connectorConfigWithDefaultsResilient(plan) + + case connectors.ConnectorTypesDotServicenow: + return connectorConfigWithDefaultsServicenow(plan, backend) + + case connectors.ConnectorTypesDotServicenowItom: + return connectorConfigWithDefaultsServicenowItom(plan) + + case connectors.ConnectorTypesDotServicenowSir: + return connectorConfigWithDefaultsServicenowSir(plan, backend) + + case connectors.ConnectorTypesDotSwimlane: + return connectorConfigWithDefaultsSwimlane(plan) + + case connectors.ConnectorTypesDotTines: + return connectorConfigWithDefaultsTines(plan) + + case connectors.ConnectorTypesDotWebhook: + return connectorConfigWithDefaultsWebhook(plan) + + case connectors.ConnectorTypesDotXmatters: + return connectorConfigWithDefaultsXmatters(plan) + } + return plan, nil +} + +// User can omit optonal fields in config JSON. +// The func adds empty optional fields to the diff. +// Otherwise plan command shows omitted fields as the diff, +// because backend returns all fields. +func connectorConfigWithDefaults[T any](plan string) (string, error) { + var config T + if err := json.Unmarshal([]byte(plan), &config); err != nil { + return "", err + } + customJSON, err := json.Marshal(config) + if err != nil { + return "", err + } + return string(customJSON), nil +} + +func connectorConfigWithDefaultsCasesWebhook(plan string) (string, error) { + var custom connectors.ConfigPropertiesCasesWebhook + if err := json.Unmarshal([]byte(plan), &custom); err != nil { + return "", err + } + if custom.CreateIncidentMethod == nil { + custom.CreateIncidentMethod = new(connectors.ConfigPropertiesCasesWebhookCreateIncidentMethod) + *custom.CreateIncidentMethod = connectors.ConfigPropertiesCasesWebhookCreateIncidentMethodPost + } + if custom.HasAuth == nil { + custom.HasAuth = utils.Pointer(true) + } + if custom.UpdateIncidentMethod == nil { + custom.UpdateIncidentMethod = new(connectors.ConfigPropertiesCasesWebhookUpdateIncidentMethod) + *custom.UpdateIncidentMethod = connectors.ConfigPropertiesCasesWebhookUpdateIncidentMethodPut + } + customJSON, err := json.Marshal(custom) + if err != nil { + return "", err + } + return string(customJSON), nil +} + +func connectorConfigWithDefaultsEmail(plan string) (string, error) { + var custom connectors.ConfigPropertiesEmail + if err := json.Unmarshal([]byte(plan), &custom); err != nil { + return "", err + } + if custom.HasAuth == nil { + custom.HasAuth = utils.Pointer(true) + } + if custom.Service == nil { + custom.Service = new(string) + *custom.Service = "other" + } + customJSON, err := json.Marshal(custom) + if err != nil { + return "", err + } + return string(customJSON), nil +} + +func connectorConfigWithDefaultsIndex(plan string) (string, error) { + var custom connectors.ConfigPropertiesIndex + if err := json.Unmarshal([]byte(plan), &custom); err != nil { + return "", err + } + if custom.Refresh == nil { + custom.Refresh = utils.Pointer(false) + } + customJSON, err := json.Marshal(custom) + if err != nil { + return "", err + } + return string(customJSON), nil +} + +func connectorConfigWithDefaultsJira(plan string) (string, error) { + return connectorConfigWithDefaults[connectors.ConfigPropertiesJira](plan) +} + +func connectorConfigWithDefaultsOpsgenie(plan string) (string, error) { + return plan, nil +} + +func connectorConfigWithDefaultsPagerduty(plan string) (string, error) { + return connectorConfigWithDefaults[connectors.ConfigPropertiesPagerduty](plan) +} + +func connectorConfigWithDefaultsResilient(plan string) (string, error) { + return plan, nil +} + +func connectorConfigWithDefaultsServicenow(plan, backend string) (string, error) { + var planConfig connectors.ConfigPropertiesServicenow + if err := json.Unmarshal([]byte(plan), &planConfig); err != nil { + return "", err + } + var backendConfig connectors.ConfigPropertiesServicenow + if err := json.Unmarshal([]byte(backend), &backendConfig); err != nil { + return "", err + } + if planConfig.IsOAuth == nil && backendConfig.IsOAuth != nil && !*backendConfig.IsOAuth { + planConfig.IsOAuth = utils.Pointer(false) + } + if planConfig.UsesTableApi == nil { + planConfig.UsesTableApi = utils.Pointer(true) + } + customJSON, err := json.Marshal(planConfig) + if err != nil { + return "", err + } + return string(customJSON), nil +} + +func connectorConfigWithDefaultsServicenowItom(plan string) (string, error) { + var custom connectors.ConfigPropertiesServicenowItom + if err := json.Unmarshal([]byte(plan), &custom); err != nil { + return "", err + } + if custom.IsOAuth == nil { + custom.IsOAuth = utils.Pointer(false) + } + customJSON, err := json.Marshal(custom) + if err != nil { + return "", err + } + return string(customJSON), nil +} + +func connectorConfigWithDefaultsServicenowSir(plan, backend string) (string, error) { + return connectorConfigWithDefaultsServicenow(plan, backend) +} + +func connectorConfigWithDefaultsSwimlane(plan string) (string, error) { + var custom connectors.ConfigPropertiesSwimlane + if err := json.Unmarshal([]byte(plan), &custom); err != nil { + return "", err + } + if custom.Mappings == nil { + custom.Mappings = &connectors.ConfigPropertiesSwimlaneMappings{} + } + customJSON, err := json.Marshal(custom) + if err != nil { + return "", err + } + return string(customJSON), nil +} + +func connectorConfigWithDefaultsTines(plan string) (string, error) { + return plan, nil +} + +func connectorConfigWithDefaultsWebhook(plan string) (string, error) { + return plan, nil +} + +func connectorConfigWithDefaultsXmatters(plan string) (string, error) { + var custom connectors.ConfigPropertiesXmatters + if err := json.Unmarshal([]byte(plan), &custom); err != nil { + return "", err + } + if custom.UsesBasic == nil { + custom.UsesBasic = utils.Pointer(true) + } + customJSON, err := json.Marshal(custom) + if err != nil { + return "", err + } + return string(customJSON), nil +} + +func createConnectorRequestBody(connector models.KibanaActionConnector) (io.Reader, error) { + switch connectors.ConnectorTypes(connector.ConnectorTypeID) { + + case connectors.ConnectorTypesDotCasesWebhook: + return createConnectorRequestCasesWebhook(connector) + + case connectors.ConnectorTypesDotEmail: + return createConnectorRequestEmail(connector) + + case connectors.ConnectorTypesDotIndex: + return createConnectorRequestIndex(connector) + + case connectors.ConnectorTypesDotJira: + return createConnectorRequestJira(connector) + + case connectors.ConnectorTypesDotOpsgenie: + return createConnectorRequestOpsgenie(connector) + + case connectors.ConnectorTypesDotPagerduty: + return createConnectorRequestPagerduty(connector) + + case connectors.ConnectorTypesDotResilient: + return createConnectorRequestResilient(connector) + + case connectors.ConnectorTypesDotServicenow: + return createConnectorRequestServicenow(connector) + + case connectors.ConnectorTypesDotServicenowItom: + return createConnectorRequestServicenowItom(connector) + + case connectors.ConnectorTypesDotServicenowSir: + return createConnectorRequestServicenowSir(connector) + + case connectors.ConnectorTypesDotServerLog: + return createConnectorRequestServerLog(connector) + + case connectors.ConnectorTypesDotSlack: + return createConnectorRequestSlack(connector) + + case connectors.ConnectorTypesDotSwimlane: + return createConnectorRequestSwimlane(connector) + + case connectors.ConnectorTypesDotTeams: + return createConnectorRequestTeams(connector) + + case connectors.ConnectorTypesDotTines: + return createConnectorRequestTines(connector) + + case connectors.ConnectorTypesDotWebhook: + return createConnectorRequestWebhook(connector) + + case connectors.ConnectorTypesDotXmatters: + return createConnectorRequestXmatters(connector) + } + + return nil, fmt.Errorf("unknown connector type [%s]", connector.ConnectorTypeID) +} + +func updateConnectorRequestBody(connector models.KibanaActionConnector) (io.Reader, error) { + switch connectors.ConnectorTypes(connector.ConnectorTypeID) { + + case connectors.ConnectorTypesDotCasesWebhook: + return updateConnectorRequestCasesWebhook(connector) + + case connectors.ConnectorTypesDotEmail: + return updateConnectorRequestEmail(connector) + + case connectors.ConnectorTypesDotIndex: + return updateConnectorRequestIndex(connector) + + case connectors.ConnectorTypesDotJira: + return updateConnectorRequestJira(connector) + + case connectors.ConnectorTypesDotOpsgenie: + return updateConnectorRequestOpsgenie(connector) + + case connectors.ConnectorTypesDotPagerduty: + return updateConnectorRequestPagerduty(connector) + + case connectors.ConnectorTypesDotResilient: + return updateConnectorRequestResilient(connector) + + case connectors.ConnectorTypesDotServicenow: + return updateConnectorRequestServicenow(connector) + + case connectors.ConnectorTypesDotServicenowItom: + return updateConnectorRequestServicenowItom(connector) + + case connectors.ConnectorTypesDotServicenowSir: + return updateConnectorRequestServicenowSir(connector) + + case connectors.ConnectorTypesDotServerLog: + return updateConnectorRequestServerlog(connector) + + case connectors.ConnectorTypesDotSlack: + return updateConnectorRequestSlack(connector) + + case connectors.ConnectorTypesDotSwimlane: + return updateConnectorRequestSwimlane(connector) + + case connectors.ConnectorTypesDotTeams: + return updateConnectorRequestTeams(connector) + + case connectors.ConnectorTypesDotTines: + return updateConnectorRequestTines(connector) + + case connectors.ConnectorTypesDotWebhook: + return updateConnectorRequestWebhook(connector) + + case connectors.ConnectorTypesDotXmatters: + return updateConnectorRequestXmatters(connector) + } + + return nil, fmt.Errorf("unknown connector type [%s]", connector.ConnectorTypeID) +} + +func marshalConnectorRequest[C, S, R any](connector models.KibanaActionConnector, config *C, secrets *S, request *R) (io.Reader, error) { + if config != nil && len(connector.ConfigJSON) > 0 { + if err := json.Unmarshal([]byte(connector.ConfigJSON), config); err != nil { + return nil, fmt.Errorf("failed to unmarshal [config] attribute: %w", err) + } + } + + if secrets != nil && len(connector.SecretsJSON) > 0 { + if err := json.Unmarshal([]byte(connector.SecretsJSON), secrets); err != nil { + return nil, fmt.Errorf("failed to unmarshal [secrets] attribute: %w", err) + } + } + + bt, err := json.Marshal(request) + if err != nil { + return nil, fmt.Errorf("failed to marshal request: %w", err) + } + + return bytes.NewReader(bt), nil +} + +func createConnectorRequestCasesWebhook(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.CreateConnectorRequestCasesWebhook{ + ConnectorTypeId: connectors.DotCasesWebhook, + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func createConnectorRequestEmail(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.CreateConnectorRequestEmail{ + ConnectorTypeId: connectors.CreateConnectorRequestEmailConnectorTypeIdDotEmail, + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func createConnectorRequestIndex(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.CreateConnectorRequestIndex{ + ConnectorTypeId: connectors.CreateConnectorRequestIndexConnectorTypeIdDotIndex, + Name: connector.Name, + } + + return marshalConnectorRequest[connectors.ConfigPropertiesIndex, any](connector, &request.Config, nil, &request) +} + +func createConnectorRequestJira(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.CreateConnectorRequestJira{ + ConnectorTypeId: connectors.CreateConnectorRequestJiraConnectorTypeIdDotJira, + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func createConnectorRequestOpsgenie(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.CreateConnectorRequestOpsgenie{ + ConnectorTypeId: connectors.CreateConnectorRequestOpsgenieConnectorTypeIdDotOpsgenie, + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func createConnectorRequestPagerduty(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.CreateConnectorRequestPagerduty{ + ConnectorTypeId: connectors.CreateConnectorRequestPagerdutyConnectorTypeIdDotPagerduty, + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func createConnectorRequestResilient(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.CreateConnectorRequestResilient{ + ConnectorTypeId: connectors.CreateConnectorRequestResilientConnectorTypeIdDotResilient, + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func createConnectorRequestServicenow(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.CreateConnectorRequestServicenow{ + ConnectorTypeId: connectors.CreateConnectorRequestServicenowConnectorTypeIdDotServicenow, + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func createConnectorRequestServicenowItom(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.CreateConnectorRequestServicenowItom{ + ConnectorTypeId: connectors.CreateConnectorRequestServicenowItomConnectorTypeIdDotServicenowItom, + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func createConnectorRequestServicenowSir(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.CreateConnectorRequestServicenowSir{ + ConnectorTypeId: connectors.CreateConnectorRequestServicenowSirConnectorTypeIdDotServicenowSir, + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func createConnectorRequestServerLog(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.CreateConnectorRequestServerlog{ + ConnectorTypeId: connectors.CreateConnectorRequestServerlogConnectorTypeIdDotServerLog, + Name: connector.Name, + } + + return marshalConnectorRequest[any, any](connector, nil, nil, &request) +} + +func createConnectorRequestSlack(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.CreateConnectorRequestSlack{ + ConnectorTypeId: connectors.CreateConnectorRequestSlackConnectorTypeIdDotSlack, + Name: connector.Name, + } + + return marshalConnectorRequest[any](connector, nil, &request.Secrets, &request) +} + +func createConnectorRequestSwimlane(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.CreateConnectorRequestSwimlane{ + ConnectorTypeId: connectors.CreateConnectorRequestSwimlaneConnectorTypeIdDotSwimlane, + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func createConnectorRequestTeams(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.CreateConnectorRequestTeams{ + ConnectorTypeId: connectors.CreateConnectorRequestTeamsConnectorTypeIdDotTeams, + Name: connector.Name, + } + + return marshalConnectorRequest[any](connector, nil, &request.Secrets, &request) +} + +func createConnectorRequestTines(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.CreateConnectorRequestTines{ + ConnectorTypeId: connectors.CreateConnectorRequestTinesConnectorTypeIdDotTines, + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func createConnectorRequestWebhook(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.CreateConnectorRequestWebhook{ + ConnectorTypeId: connectors.CreateConnectorRequestWebhookConnectorTypeIdDotWebhook, + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func createConnectorRequestXmatters(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.CreateConnectorRequestXmatters{ + ConnectorTypeId: connectors.CreateConnectorRequestXmattersConnectorTypeIdDotXmatters, + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func updateConnectorRequestCasesWebhook(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.UpdateConnectorRequestCasesWebhook{ + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func updateConnectorRequestEmail(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.UpdateConnectorRequestEmail{ + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func updateConnectorRequestIndex(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.UpdateConnectorRequestIndex{ + Name: connector.Name, + } + + return marshalConnectorRequest[connectors.ConfigPropertiesIndex, any](connector, &request.Config, nil, &request) +} + +func updateConnectorRequestJira(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.UpdateConnectorRequestJira{ + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func updateConnectorRequestOpsgenie(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.UpdateConnectorRequestOpsgenie{ + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func updateConnectorRequestPagerduty(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.UpdateConnectorRequestPagerduty{ + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func updateConnectorRequestResilient(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.UpdateConnectorRequestResilient{ + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func updateConnectorRequestServicenow(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.UpdateConnectorRequestServicenow{ + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func updateConnectorRequestServicenowItom(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.UpdateConnectorRequestServicenowItom{ + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func updateConnectorRequestServicenowSir(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.UpdateConnectorRequestServicenowSir{ + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func updateConnectorRequestServerlog(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.UpdateConnectorRequestServerlog{ + Name: connector.Name, + } + + return marshalConnectorRequest[any, any](connector, nil, nil, &request) +} + +func updateConnectorRequestSlack(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.UpdateConnectorRequestSlack{ + Name: connector.Name, + } + + return marshalConnectorRequest[any](connector, nil, &request.Secrets, &request) +} + +func updateConnectorRequestSwimlane(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.UpdateConnectorRequestSwimlane{ + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func updateConnectorRequestTeams(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.UpdateConnectorRequestTeams{ + Name: connector.Name, + } + + return marshalConnectorRequest[any](connector, nil, &request.Secrets, &request) +} + +func updateConnectorRequestTines(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.UpdateConnectorRequestTines{ + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func updateConnectorRequestWebhook(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.UpdateConnectorRequestWebhook{ + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func updateConnectorRequestXmatters(connector models.KibanaActionConnector) (io.Reader, error) { + request := connectors.UpdateConnectorRequestXmatters{ + Name: connector.Name, + } + + return marshalConnectorRequest(connector, &request.Config, &request.Secrets, &request) +} + +func connectorResponseToModel(spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + discriminator, err := properties.Discriminator() + if err != nil { + return nil, err + } + + switch connectors.ConnectorTypes(discriminator) { + + case connectors.ConnectorTypesDotCasesWebhook: + return connectorResponseToModelCasesWebhook(discriminator, spaceID, properties) + + case connectors.ConnectorTypesDotEmail: + return connectorResponseToModelEmail(discriminator, spaceID, properties) + + case connectors.ConnectorTypesDotIndex: + return connectorResponseToModelIndex(discriminator, spaceID, properties) + + case connectors.ConnectorTypesDotJira: + return connectorResponseToModelJira(discriminator, spaceID, properties) + + case connectors.ConnectorTypesDotOpsgenie: + return connectorResponseToModelOpsgenie(discriminator, spaceID, properties) + + case connectors.ConnectorTypesDotPagerduty: + return connectorResponseToModelPagerduty(discriminator, spaceID, properties) + + case connectors.ConnectorTypesDotResilient: + return connectorResponseToModelResilient(discriminator, spaceID, properties) + + case connectors.ConnectorTypesDotServerLog: + return connectorResponseToModelServerlog(discriminator, spaceID, properties) + + case connectors.ConnectorTypesDotServicenow: + return connectorResponseToModelServicenow(discriminator, spaceID, properties) + + case connectors.ConnectorTypesDotServicenowItom: + return connectorResponseToModelServicenowItom(discriminator, spaceID, properties) + + case connectors.ConnectorTypesDotServicenowSir: + return connectorResponseToModelServicenowSir(discriminator, spaceID, properties) + + case connectors.ConnectorTypesDotSlack: + return connectorResponseToModelSlack(discriminator, spaceID, properties) + + case connectors.ConnectorTypesDotSwimlane: + return connectorResponseToModelSwimlane(discriminator, spaceID, properties) + + case connectors.ConnectorTypesDotTeams: + return connectorResponseToModelTeams(discriminator, spaceID, properties) + + case connectors.ConnectorTypesDotTines: + return connectorResponseToModelTines(discriminator, spaceID, properties) + + case connectors.ConnectorTypesDotWebhook: + return connectorResponseToModelWebhook(discriminator, spaceID, properties) + + case connectors.ConnectorTypesDotXmatters: + return connectorResponseToModelXmatters(discriminator, spaceID, properties) + } + + return nil, fmt.Errorf("unknown connector type [%s]", discriminator) +} + +func connectorResponseToModelCasesWebhook(discriminator, spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + resp, err := properties.AsConnectorResponsePropertiesCasesWebhook() + if err != nil { + return nil, err + } + + config, err := json.Marshal(resp.Config) + if err != nil { + return nil, fmt.Errorf("unable to marshal config: %w", err) + } + + isDeprecated := false + isMissingSecrets := false + + if resp.IsDeprecated != nil { + isDeprecated = *resp.IsDeprecated + } + + if resp.IsMissingSecrets != nil { + isMissingSecrets = *resp.IsMissingSecrets + } + + connector := models.KibanaActionConnector{ + ConnectorID: resp.Id, + SpaceID: spaceID, + Name: resp.Name, + ConnectorTypeID: discriminator, + IsDeprecated: isDeprecated, + IsMissingSecrets: isMissingSecrets, + IsPreconfigured: bool(resp.IsPreconfigured), + ConfigJSON: string(config), + } + + return &connector, nil +} + +func connectorResponseToModelEmail(discriminator, spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + resp, err := properties.AsConnectorResponsePropertiesEmail() + if err != nil { + return nil, err + } + + config, err := json.Marshal(resp.Config) + if err != nil { + return nil, fmt.Errorf("unable to marshal config: %w", err) + } + + isDeprecated := false + isMissingSecrets := false + + if resp.IsDeprecated != nil { + isDeprecated = *resp.IsDeprecated + } + + if resp.IsMissingSecrets != nil { + isMissingSecrets = *resp.IsMissingSecrets + } + + connector := models.KibanaActionConnector{ + ConnectorID: resp.Id, + SpaceID: spaceID, + Name: resp.Name, + ConnectorTypeID: discriminator, + IsDeprecated: isDeprecated, + IsMissingSecrets: isMissingSecrets, + IsPreconfigured: bool(resp.IsPreconfigured), + ConfigJSON: string(config), + } + + return &connector, nil +} + +func connectorResponseToModelIndex(discriminator, spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + resp, err := properties.AsConnectorResponsePropertiesIndex() + if err != nil { + return nil, err + } + + config, err := json.Marshal(resp.Config) + if err != nil { + return nil, fmt.Errorf("unable to marshal config: %w", err) + } + + isDeprecated := false + isMissingSecrets := false + + if resp.IsDeprecated != nil { + isDeprecated = *resp.IsDeprecated + } + + if resp.IsMissingSecrets != nil { + isMissingSecrets = *resp.IsMissingSecrets + } + + connector := models.KibanaActionConnector{ + ConnectorID: resp.Id, + SpaceID: spaceID, + Name: resp.Name, + ConnectorTypeID: discriminator, + IsDeprecated: isDeprecated, + IsMissingSecrets: isMissingSecrets, + IsPreconfigured: bool(resp.IsPreconfigured), + ConfigJSON: string(config), + } + + return &connector, nil +} + +func connectorResponseToModelJira(discriminator, spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + resp, err := properties.AsConnectorResponsePropertiesJira() + if err != nil { + return nil, err + } + + config, err := json.Marshal(resp.Config) + if err != nil { + return nil, fmt.Errorf("unable to marshal config: %w", err) + } + + isDeprecated := false + isMissingSecrets := false + + if resp.IsDeprecated != nil { + isDeprecated = *resp.IsDeprecated + } + + if resp.IsMissingSecrets != nil { + isMissingSecrets = *resp.IsMissingSecrets + } + + connector := models.KibanaActionConnector{ + ConnectorID: resp.Id, + SpaceID: spaceID, + Name: resp.Name, + ConnectorTypeID: discriminator, + IsDeprecated: isDeprecated, + IsMissingSecrets: isMissingSecrets, + IsPreconfigured: bool(resp.IsPreconfigured), + ConfigJSON: string(config), + } + + return &connector, nil +} + +func connectorResponseToModelOpsgenie(discriminator, spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + resp, err := properties.AsConnectorResponsePropertiesOpsgenie() + if err != nil { + return nil, err + } + + config, err := json.Marshal(resp.Config) + if err != nil { + return nil, fmt.Errorf("unable to marshal config: %w", err) + } + + isDeprecated := false + isMissingSecrets := false + + if resp.IsDeprecated != nil { + isDeprecated = *resp.IsDeprecated + } + + if resp.IsMissingSecrets != nil { + isMissingSecrets = *resp.IsMissingSecrets + } + + connector := models.KibanaActionConnector{ + ConnectorID: resp.Id, + SpaceID: spaceID, + Name: resp.Name, + ConnectorTypeID: discriminator, + IsDeprecated: isDeprecated, + IsMissingSecrets: isMissingSecrets, + IsPreconfigured: bool(resp.IsPreconfigured), + ConfigJSON: string(config), + } + + return &connector, nil +} + +func connectorResponseToModelPagerduty(discriminator, spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + resp, err := properties.AsConnectorResponsePropertiesPagerduty() + if err != nil { + return nil, err + } + + config, err := json.Marshal(resp.Config) + if err != nil { + return nil, fmt.Errorf("unable to marshal config: %w", err) + } + + isDeprecated := false + isMissingSecrets := false + + if resp.IsDeprecated != nil { + isDeprecated = *resp.IsDeprecated + } + + if resp.IsMissingSecrets != nil { + isMissingSecrets = *resp.IsMissingSecrets + } + + connector := models.KibanaActionConnector{ + ConnectorID: resp.Id, + SpaceID: spaceID, + Name: resp.Name, + ConnectorTypeID: discriminator, + IsDeprecated: isDeprecated, + IsMissingSecrets: isMissingSecrets, + IsPreconfigured: bool(resp.IsPreconfigured), + ConfigJSON: string(config), + } + + return &connector, nil +} + +func connectorResponseToModelResilient(discriminator, spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + resp, err := properties.AsConnectorResponsePropertiesResilient() + if err != nil { + return nil, err + } + + config, err := json.Marshal(resp.Config) + if err != nil { + return nil, fmt.Errorf("unable to marshal config: %w", err) + } + + isDeprecated := false + isMissingSecrets := false + + if resp.IsDeprecated != nil { + isDeprecated = *resp.IsDeprecated + } + + if resp.IsMissingSecrets != nil { + isMissingSecrets = *resp.IsMissingSecrets + } + + connector := models.KibanaActionConnector{ + ConnectorID: resp.Id, + SpaceID: spaceID, + Name: resp.Name, + ConnectorTypeID: discriminator, + IsDeprecated: isDeprecated, + IsMissingSecrets: isMissingSecrets, + IsPreconfigured: bool(resp.IsPreconfigured), + ConfigJSON: string(config), + } + + return &connector, nil +} + +func connectorResponseToModelServerlog(discriminator, spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + resp, err := properties.AsConnectorResponsePropertiesServerlog() + if err != nil { + return nil, err + } + + config, err := json.Marshal(resp.Config) + if err != nil { + return nil, fmt.Errorf("unable to marshal config: %w", err) + } + + isDeprecated := false + isMissingSecrets := false + + if resp.IsDeprecated != nil { + isDeprecated = *resp.IsDeprecated + } + + if resp.IsMissingSecrets != nil { + isMissingSecrets = *resp.IsMissingSecrets + } + + connector := models.KibanaActionConnector{ + ConnectorID: resp.Id, + SpaceID: spaceID, + Name: resp.Name, + ConnectorTypeID: discriminator, + IsDeprecated: isDeprecated, + IsMissingSecrets: isMissingSecrets, + IsPreconfigured: bool(resp.IsPreconfigured), + ConfigJSON: string(config), + } + + return &connector, nil +} + +func connectorResponseToModelServicenow(discriminator, spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + resp, err := properties.AsConnectorResponsePropertiesServicenow() + if err != nil { + return nil, err + } + + config, err := json.Marshal(resp.Config) + if err != nil { + return nil, fmt.Errorf("unable to marshal config: %w", err) + } + + isDeprecated := false + isMissingSecrets := false + + if resp.IsDeprecated != nil { + isDeprecated = *resp.IsDeprecated + } + + if resp.IsMissingSecrets != nil { + isMissingSecrets = *resp.IsMissingSecrets + } + + connector := models.KibanaActionConnector{ + ConnectorID: resp.Id, + SpaceID: spaceID, + Name: resp.Name, + ConnectorTypeID: discriminator, + IsDeprecated: isDeprecated, + IsMissingSecrets: isMissingSecrets, + IsPreconfigured: bool(resp.IsPreconfigured), + ConfigJSON: string(config), + } + + return &connector, nil +} + +func connectorResponseToModelServicenowItom(discriminator, spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + resp, err := properties.AsConnectorResponsePropertiesServicenowItom() + if err != nil { + return nil, err + } + + config, err := json.Marshal(resp.Config) + if err != nil { + return nil, fmt.Errorf("unable to marshal config: %w", err) + } + + isDeprecated := false + isMissingSecrets := false + + if resp.IsDeprecated != nil { + isDeprecated = *resp.IsDeprecated + } + + if resp.IsMissingSecrets != nil { + isMissingSecrets = *resp.IsMissingSecrets + } + + connector := models.KibanaActionConnector{ + ConnectorID: resp.Id, + SpaceID: spaceID, + Name: resp.Name, + ConnectorTypeID: discriminator, + IsDeprecated: isDeprecated, + IsMissingSecrets: isMissingSecrets, + IsPreconfigured: bool(resp.IsPreconfigured), + ConfigJSON: string(config), + } + + return &connector, nil +} + +func connectorResponseToModelServicenowSir(discriminator, spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + resp, err := properties.AsConnectorResponsePropertiesServicenowSir() + if err != nil { + return nil, err + } + + config, err := json.Marshal(resp.Config) + if err != nil { + return nil, fmt.Errorf("unable to marshal config: %w", err) + } + + isDeprecated := false + isMissingSecrets := false + + if resp.IsDeprecated != nil { + isDeprecated = *resp.IsDeprecated + } + + if resp.IsMissingSecrets != nil { + isMissingSecrets = *resp.IsMissingSecrets + } + + connector := models.KibanaActionConnector{ + ConnectorID: resp.Id, + SpaceID: spaceID, + Name: resp.Name, + ConnectorTypeID: discriminator, + IsDeprecated: isDeprecated, + IsMissingSecrets: isMissingSecrets, + IsPreconfigured: bool(resp.IsPreconfigured), + ConfigJSON: string(config), + } + + return &connector, nil +} + +func connectorResponseToModelSlack(discriminator, spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + resp, err := properties.AsConnectorResponsePropertiesSlack() + if err != nil { + return nil, err + } + + isDeprecated := false + isMissingSecrets := false + + if resp.IsDeprecated != nil { + isDeprecated = *resp.IsDeprecated + } + + if resp.IsMissingSecrets != nil { + isMissingSecrets = *resp.IsMissingSecrets + } + + connector := models.KibanaActionConnector{ + ConnectorID: resp.Id, + SpaceID: spaceID, + Name: resp.Name, + ConnectorTypeID: discriminator, + IsDeprecated: isDeprecated, + IsMissingSecrets: isMissingSecrets, + IsPreconfigured: bool(resp.IsPreconfigured), + } + + return &connector, nil +} + +func connectorResponseToModelSwimlane(discriminator, spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + resp, err := properties.AsConnectorResponsePropertiesSwimlane() + if err != nil { + return nil, err + } + + config, err := json.Marshal(resp.Config) + if err != nil { + return nil, fmt.Errorf("unable to marshal config: %w", err) + } + + isDeprecated := false + isMissingSecrets := false + + if resp.IsDeprecated != nil { + isDeprecated = *resp.IsDeprecated + } + + if resp.IsMissingSecrets != nil { + isMissingSecrets = *resp.IsMissingSecrets + } + + connector := models.KibanaActionConnector{ + ConnectorID: resp.Id, + SpaceID: spaceID, + Name: resp.Name, + ConnectorTypeID: discriminator, + IsDeprecated: isDeprecated, + IsMissingSecrets: isMissingSecrets, + IsPreconfigured: bool(resp.IsPreconfigured), + ConfigJSON: string(config), + } + + return &connector, nil +} + +func connectorResponseToModelTeams(discriminator, spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + resp, err := properties.AsConnectorResponsePropertiesTeams() + if err != nil { + return nil, err + } + + isDeprecated := false + isMissingSecrets := false + + if resp.IsDeprecated != nil { + isDeprecated = *resp.IsDeprecated + } + + if resp.IsMissingSecrets != nil { + isMissingSecrets = *resp.IsMissingSecrets + } + + connector := models.KibanaActionConnector{ + ConnectorID: resp.Id, + SpaceID: spaceID, + Name: resp.Name, + ConnectorTypeID: discriminator, + IsDeprecated: isDeprecated, + IsMissingSecrets: isMissingSecrets, + IsPreconfigured: bool(resp.IsPreconfigured), + } + + return &connector, nil +} + +func connectorResponseToModelTines(discriminator, spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + resp, err := properties.AsConnectorResponsePropertiesTines() + if err != nil { + return nil, err + } + + config, err := json.Marshal(resp.Config) + if err != nil { + return nil, fmt.Errorf("unable to marshal config: %w", err) + } + + isDeprecated := false + isMissingSecrets := false + + if resp.IsDeprecated != nil { + isDeprecated = *resp.IsDeprecated + } + + if resp.IsMissingSecrets != nil { + isMissingSecrets = *resp.IsMissingSecrets + } + + connector := models.KibanaActionConnector{ + ConnectorID: resp.Id, + SpaceID: spaceID, + Name: resp.Name, + ConnectorTypeID: discriminator, + IsDeprecated: isDeprecated, + IsMissingSecrets: isMissingSecrets, + IsPreconfigured: bool(resp.IsPreconfigured), + ConfigJSON: string(config), + } + + return &connector, nil +} + +func connectorResponseToModelWebhook(discriminator, spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + resp, err := properties.AsConnectorResponsePropertiesTines() + if err != nil { + return nil, err + } + + config, err := json.Marshal(resp.Config) + if err != nil { + return nil, fmt.Errorf("unable to marshal config: %w", err) + } + + isDeprecated := false + isMissingSecrets := false + + if resp.IsDeprecated != nil { + isDeprecated = *resp.IsDeprecated + } + + if resp.IsMissingSecrets != nil { + isMissingSecrets = *resp.IsMissingSecrets + } + + connector := models.KibanaActionConnector{ + ConnectorID: resp.Id, + SpaceID: spaceID, + Name: resp.Name, + ConnectorTypeID: discriminator, + IsDeprecated: isDeprecated, + IsMissingSecrets: isMissingSecrets, + IsPreconfigured: bool(resp.IsPreconfigured), + ConfigJSON: string(config), + } + + return &connector, nil +} + +func connectorResponseToModelXmatters(discriminator, spaceID string, properties connectors.ConnectorResponseProperties) (*models.KibanaActionConnector, error) { + resp, err := properties.AsConnectorResponsePropertiesXmatters() + if err != nil { + return nil, err + } + + config, err := json.Marshal(resp.Config) + if err != nil { + return nil, fmt.Errorf("unable to marshal config: %w", err) + } + + isDeprecated := false + isMissingSecrets := false + + if resp.IsDeprecated != nil { + isDeprecated = *resp.IsDeprecated + } + + if resp.IsMissingSecrets != nil { + isMissingSecrets = *resp.IsMissingSecrets + } + + connector := models.KibanaActionConnector{ + ConnectorID: resp.Id, + SpaceID: spaceID, + Name: resp.Name, + ConnectorTypeID: discriminator, + IsDeprecated: isDeprecated, + IsMissingSecrets: isMissingSecrets, + IsPreconfigured: bool(resp.IsPreconfigured), + ConfigJSON: string(config), + } + + return &connector, nil +} diff --git a/internal/clients/kibana/connector_test.go b/internal/clients/kibana/connector_test.go new file mode 100644 index 000000000..3be85481b --- /dev/null +++ b/internal/clients/kibana/connector_test.go @@ -0,0 +1,129 @@ +package kibana + +import ( + "encoding/json" + "fmt" + "testing" + + "github.com/elastic/terraform-provider-elasticstack/generated/connectors" + "github.com/elastic/terraform-provider-elasticstack/internal/models" + "github.com/stretchr/testify/require" +) + +func Test_connectorResponseToModel(t *testing.T) { + type testCase struct { + name string + spaceId string + response connectors.ConnectorResponseProperties + expectedModel *models.KibanaActionConnector + expectedError error + } + + generator := func(connectorTypeID string, config any, propertiesGenerator func(*connectors.ConnectorResponseProperties) error) testCase { + return testCase{ + name: fmt.Sprintf("it should parse empty [%s] connector", connectorTypeID), + spaceId: "test", + response: func() connectors.ConnectorResponseProperties { + var properties connectors.ConnectorResponseProperties + err := propertiesGenerator(&properties) + require.Nil(t, err) + return properties + }(), + expectedModel: &models.KibanaActionConnector{ + SpaceID: "test", + ConnectorTypeID: connectorTypeID, + ConfigJSON: func() string { + if config == nil { + return "" + } + byt, err := json.Marshal(config) + require.Nil(t, err) + return string(byt) + }(), + }, + } + } + tests := []testCase{ + { + name: "it should fail if discriminator is unknown", + response: func() connectors.ConnectorResponseProperties { + discriminator := struct { + Discriminator string `json:"connector_type_id"` + }{"unknown-value"} + byt, err := json.Marshal(discriminator) + require.Nil(t, err) + var resp connectors.ConnectorResponseProperties + err = resp.UnmarshalJSON(byt) + require.Nil(t, err) + return resp + }(), + expectedError: func() error { return fmt.Errorf("unknown connector type [unknown-value]") }(), + }, + generator(".cases-webhook", connectors.ConfigPropertiesCasesWebhook{}, func(props *connectors.ConnectorResponseProperties) error { + return props.FromConnectorResponsePropertiesCasesWebhook(connectors.ConnectorResponsePropertiesCasesWebhook{}) + }), + generator(".email", connectors.ConfigPropertiesEmail{}, func(props *connectors.ConnectorResponseProperties) error { + return props.FromConnectorResponsePropertiesEmail(connectors.ConnectorResponsePropertiesEmail{}) + }), + generator(".index", connectors.ConfigPropertiesIndex{}, func(props *connectors.ConnectorResponseProperties) error { + return props.FromConnectorResponsePropertiesIndex(connectors.ConnectorResponsePropertiesIndex{}) + }), + generator(".jira", connectors.ConfigPropertiesJira{}, func(props *connectors.ConnectorResponseProperties) error { + return props.FromConnectorResponsePropertiesJira(connectors.ConnectorResponsePropertiesJira{}) + }), + generator(".opsgenie", connectors.ConfigPropertiesOpsgenie{}, func(props *connectors.ConnectorResponseProperties) error { + return props.FromConnectorResponsePropertiesOpsgenie(connectors.ConnectorResponsePropertiesOpsgenie{}) + }), + generator(".pagerduty", connectors.ConfigPropertiesPagerduty{}, func(props *connectors.ConnectorResponseProperties) error { + return props.FromConnectorResponsePropertiesPagerduty(connectors.ConnectorResponsePropertiesPagerduty{}) + }), + generator(".resilient", connectors.ConfigPropertiesResilient{}, func(props *connectors.ConnectorResponseProperties) error { + return props.FromConnectorResponsePropertiesResilient(connectors.ConnectorResponsePropertiesResilient{}) + }), + generator(".server-log", map[string]interface{}{}, func(props *connectors.ConnectorResponseProperties) error { + return props.FromConnectorResponsePropertiesServerlog(connectors.ConnectorResponsePropertiesServerlog{ + Config: &map[string]interface{}{}, + }) + }), + generator(".servicenow", connectors.ConfigPropertiesServicenow{}, func(props *connectors.ConnectorResponseProperties) error { + return props.FromConnectorResponsePropertiesServicenow(connectors.ConnectorResponsePropertiesServicenow{}) + }), + generator(".servicenow-itom", connectors.ConfigPropertiesServicenowItom{}, func(props *connectors.ConnectorResponseProperties) error { + return props.FromConnectorResponsePropertiesServicenowItom(connectors.ConnectorResponsePropertiesServicenowItom{}) + }), + generator(".servicenow-sir", connectors.ConfigPropertiesServicenow{}, func(props *connectors.ConnectorResponseProperties) error { + return props.FromConnectorResponsePropertiesServicenowSir(connectors.ConnectorResponsePropertiesServicenowSir{}) + }), + generator(".slack", nil, func(props *connectors.ConnectorResponseProperties) error { + return props.FromConnectorResponsePropertiesSlack(connectors.ConnectorResponsePropertiesSlack{}) + }), + generator(".swimlane", connectors.ConfigPropertiesSwimlane{}, func(props *connectors.ConnectorResponseProperties) error { + return props.FromConnectorResponsePropertiesSwimlane(connectors.ConnectorResponsePropertiesSwimlane{}) + }), + generator(".teams", nil, func(props *connectors.ConnectorResponseProperties) error { + return props.FromConnectorResponsePropertiesTeams(connectors.ConnectorResponsePropertiesTeams{}) + }), + generator(".tines", connectors.ConfigPropertiesTines{}, func(props *connectors.ConnectorResponseProperties) error { + return props.FromConnectorResponsePropertiesTines(connectors.ConnectorResponsePropertiesTines{}) + }), + generator(".webhook", connectors.ConfigPropertiesWebhook{}, func(props *connectors.ConnectorResponseProperties) error { + return props.FromConnectorResponsePropertiesWebhook(connectors.ConnectorResponsePropertiesWebhook{}) + }), + generator(".xmatters", connectors.ConfigPropertiesXmatters{}, func(props *connectors.ConnectorResponseProperties) error { + return props.FromConnectorResponsePropertiesXmatters(connectors.ConnectorResponsePropertiesXmatters{}) + }), + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + model, err := connectorResponseToModel(tt.spaceId, tt.response) + + if tt.expectedError == nil { + require.Nil(t, err) + require.Equal(t, tt.expectedModel, model) + } else { + require.Equal(t, tt.expectedError, err) + } + }) + } +} diff --git a/internal/kibana/alerting_test.go b/internal/kibana/alerting_test.go index 73ad31b2a..12f2e790e 100644 --- a/internal/kibana/alerting_test.go +++ b/internal/kibana/alerting_test.go @@ -15,9 +15,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) -var minSupportedVersion = version.Must(version.NewSemver("7.14.0")) - func TestAccResourceAlertingRule(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("7.14.0")) + ruleName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) resource.Test(t, resource.TestCase{ diff --git a/internal/kibana/connector.go b/internal/kibana/connector.go new file mode 100644 index 000000000..5b3dee5af --- /dev/null +++ b/internal/kibana/connector.go @@ -0,0 +1,264 @@ +package kibana + +import ( + "context" + + "github.com/elastic/terraform-provider-elasticstack/internal/clients" + "github.com/elastic/terraform-provider-elasticstack/internal/clients/kibana" + "github.com/elastic/terraform-provider-elasticstack/internal/models" + "github.com/elastic/terraform-provider-elasticstack/internal/utils" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" +) + +func ResourceActionConnector() *schema.Resource { + apikeySchema := map[string]*schema.Schema{ + "connector_id": { + Description: "A UUID v1 or v4 to use instead of a randomly generated ID.", + Type: schema.TypeString, + Computed: true, + Optional: true, + ForceNew: true, + }, + "space_id": { + Description: "An identifier for the space. If space_id is not provided, the default space is used.", + Type: schema.TypeString, + Optional: true, + Default: "default", + ForceNew: true, + }, + "name": { + Description: "The name of the connector. While this name does not have to be unique, a distinctive name can help you identify a connector.", + Type: schema.TypeString, + Required: true, + }, + "connector_type_id": { + Description: "The ID of the connector type, e.g. `.index`.", + Type: schema.TypeString, + Required: true, + ForceNew: true, + }, + "config": { + Description: "The configuration for the connector. Configuration properties vary depending on the connector type.", + Type: schema.TypeString, + Optional: true, + Computed: true, + ValidateFunc: validation.StringIsJSON, + }, + "secrets": { + Description: "The secrets configuration for the connector. Secrets configuration properties vary depending on the connector type.", + Type: schema.TypeString, + Optional: true, + DiffSuppressFunc: utils.DiffJsonSuppress, + ValidateFunc: validation.StringIsJSON, + }, + "is_deprecated": { + Description: "Indicates whether the connector type is deprecated.", + Type: schema.TypeBool, + Computed: true, + }, + "is_missing_secrets": { + Description: "Indicates whether secrets are missing for the connector.", + Type: schema.TypeBool, + Computed: true, + }, + "is_preconfigured": { + Description: "Indicates whether it is a preconfigured connector.", + Type: schema.TypeBool, + Computed: true, + }, + } + + return &schema.Resource{ + Description: "Creates a Kibana action connector. See https://www.elastic.co/guide/en/kibana/8.7/action-types.html", + + CreateContext: resourceConnectorCreate, + UpdateContext: resourceConnectorUpdate, + ReadContext: resourceConnectorRead, + DeleteContext: resourceConnectorDelete, + CustomizeDiff: connectorCustomizeDiff, + + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + + Schema: apikeySchema, + } +} + +func connectorCustomizeDiff(ctx context.Context, rd *schema.ResourceDiff, in interface{}) error { + if !rd.HasChange("config") { + return nil + } + oldVal, newVal := rd.GetChange("config") + oldJSON := oldVal.(string) + newJSON := newVal.(string) + if oldJSON == newJSON { + return nil + } + oldVal, newVal = rd.GetChange("connector_type_id") + oldTypeID := oldVal.(string) + newTypeID := newVal.(string) + if oldTypeID != newTypeID { + return nil + } + + rawState := rd.GetRawState() + if !rawState.IsKnown() || rawState.IsNull() { + return nil + } + + state := rawState.GetAttr("config") + if !state.IsKnown() || state.IsNull() { + return nil + } + + stateJSON := state.AsString() + + customJSON, err := kibana.ConnectorConfigWithDefaults(oldTypeID, newJSON, oldJSON, stateJSON) + if err != nil { + return err + } + return rd.SetNew("config", string(customJSON)) +} + +func resourceConnectorCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client, diags := clients.NewApiClient(d, meta) + if diags.HasError() { + return diags + } + + connectorOld, diags := expandActionConnector(d) + if diags.HasError() { + return diags + } + + connectorID, diags := kibana.CreateConnector(ctx, client, connectorOld) + + if diags.HasError() { + return diags + } + + compositeID := &clients.CompositeId{ClusterId: connectorOld.SpaceID, ResourceId: connectorID} + d.SetId(compositeID.String()) + + return resourceConnectorRead(ctx, d, meta) +} + +func resourceConnectorUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client, diags := clients.NewApiClient(d, meta) + if diags.HasError() { + return diags + } + + connectorOld, diags := expandActionConnector(d) + if diags.HasError() { + return diags + } + + compositeIDold, diags := clients.CompositeIdFromStr(d.Id()) + if diags.HasError() { + return diags + } + connectorOld.ConnectorID = compositeIDold.ResourceId + + connectorID, diags := kibana.UpdateConnector(ctx, client, connectorOld) + + if diags.HasError() { + return diags + } + + compositeIDnew := &clients.CompositeId{ClusterId: connectorOld.SpaceID, ResourceId: connectorID} + d.SetId(compositeIDnew.String()) + + return resourceConnectorRead(ctx, d, meta) +} + +func resourceConnectorRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client, diags := clients.NewApiClient(d, meta) + if diags.HasError() { + return diags + } + + compositeID, diags := clients.CompositeIdFromStr(d.Id()) + if diags.HasError() { + return diags + } + + connector, diags := kibana.GetConnector(ctx, client, compositeID.ResourceId, compositeID.ClusterId) + if connector == nil && diags == nil { + d.SetId("") + return diags + } + if diags.HasError() { + return diags + } + + return flattenActionConnector(connector, d) +} + +func resourceConnectorDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { + client, diags := clients.NewApiClient(d, meta) + if diags.HasError() { + return diags + } + + compositeID, diags := clients.CompositeIdFromStr(d.Id()) + if diags.HasError() { + return diags + } + + spaceId := d.Get("space_id").(string) + + if diags := kibana.DeleteConnector(ctx, client, compositeID.ResourceId, spaceId); diags.HasError() { + return diags + } + + d.SetId("") + return nil +} + +func expandActionConnector(d *schema.ResourceData) (models.KibanaActionConnector, diag.Diagnostics) { + var diags diag.Diagnostics + + connector := models.KibanaActionConnector{ + SpaceID: d.Get("space_id").(string), + Name: d.Get("name").(string), + ConnectorTypeID: d.Get("connector_type_id").(string), + } + + connector.ConfigJSON = d.Get("config").(string) + connector.SecretsJSON = d.Get("secrets").(string) + + return connector, diags +} + +func flattenActionConnector(connector *models.KibanaActionConnector, d *schema.ResourceData) diag.Diagnostics { + if err := d.Set("connector_id", connector.ConnectorID); err != nil { + return diag.FromErr(err) + } + if err := d.Set("space_id", connector.SpaceID); err != nil { + return diag.FromErr(err) + } + if err := d.Set("name", connector.Name); err != nil { + return diag.FromErr(err) + } + if err := d.Set("connector_type_id", connector.ConnectorTypeID); err != nil { + return diag.FromErr(err) + } + if err := d.Set("config", connector.ConfigJSON); err != nil { + return diag.FromErr(err) + } + if err := d.Set("is_deprecated", connector.IsDeprecated); err != nil { + return diag.FromErr(err) + } + if err := d.Set("is_missing_secrets", connector.IsMissingSecrets); err != nil { + return diag.FromErr(err) + } + if err := d.Set("is_preconfigured", connector.IsPreconfigured); err != nil { + return diag.FromErr(err) + } + + return nil +} diff --git a/internal/kibana/connector_test.go b/internal/kibana/connector_test.go new file mode 100644 index 000000000..140d17357 --- /dev/null +++ b/internal/kibana/connector_test.go @@ -0,0 +1,1406 @@ +package kibana_test + +import ( + "context" + "fmt" + "regexp" + "testing" + + "github.com/elastic/terraform-provider-elasticstack/internal/acctest" + "github.com/elastic/terraform-provider-elasticstack/internal/clients" + "github.com/elastic/terraform-provider-elasticstack/internal/clients/kibana" + "github.com/elastic/terraform-provider-elasticstack/internal/versionutils" + "github.com/hashicorp/go-version" + sdkacctest "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccResourceKibanaConnectorCasesWebhook(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("8.4.0")) + + connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + create := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "%s" + config = jsonencode({ + createIncidentJson = "{}" + createIncidentResponseKey = "key" + createIncidentUrl = "https://www.elastic.co/" + getIncidentResponseExternalTitleKey = "title" + getIncidentUrl = "https://www.elastic.co/" + updateIncidentJson = "{}" + updateIncidentUrl = "https://www.elastic.co/" + viewIncidentUrl = "https://www.elastic.co/" + }) + secrets = jsonencode({ + user = "user1" + password = "password1" + }) + connector_type_id = ".cases-webhook" + }`, + name) + } + + update := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "Updated %s" + config = jsonencode({ + createIncidentJson = "{}" + createIncidentResponseKey = "key" + createIncidentUrl = "https://www.elastic.co/" + getIncidentResponseExternalTitleKey = "title" + getIncidentUrl = "https://www.elastic.co/" + updateIncidentJson = "{}" + updateIncidentUrl = "https://elasticsearch.com/" + viewIncidentUrl = "https://www.elastic.co/" + createIncidentMethod = "put" + }) + secrets = jsonencode({ + user = "user2" + password = "password2" + }) + connector_type_id = ".cases-webhook" + }`, + name) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceKibanaConnectorDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: create(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(connectorName, ".cases-webhook"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"createIncidentJson\":\"{}\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"createIncidentResponseKey\":\"key\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"createIncidentUrl\":\"https://www\.elastic\.co/\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"getIncidentResponseExternalTitleKey\":\"title\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"getIncidentUrl\":\"https://www\.elastic\.co/\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"updateIncidentJson\":\"{}\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"updateIncidentUrl\":\"https://www.elastic\.co/\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"viewIncidentUrl\":\"https://www\.elastic\.co/\"`)), + // `post` is the default value that is returned by backend + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`"createIncidentMethod\":\"post\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"user\":\"user1\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"password\":\"password1\"`)), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: update(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(fmt.Sprintf("Updated %s", connectorName), ".cases-webhook"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"createIncidentJson\":\"{}\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"createIncidentResponseKey\":\"key\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"createIncidentUrl\":\"https://www\.elastic\.co/\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"getIncidentResponseExternalTitleKey\":\"title\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"getIncidentUrl\":\"https://www\.elastic\.co/\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"updateIncidentJson\":\"{}\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"updateIncidentUrl\":\"https://elasticsearch\.com/\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"viewIncidentUrl\":\"https://www\.elastic\.co/\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`createIncidentMethod\":\"put\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"user\":\"user2\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"password\":\"password2\"`)), + ), + }, + }, + }) +} + +func TestAccResourceKibanaConnectorEmail(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("7.14.0")) + + connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + create := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "%s" + config = jsonencode({ + from = "test@elastic.co" + port = 111 + host = "localhost" + }) + secrets = jsonencode({}) + connector_type_id = ".email" + }`, + name) + } + + update := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "Updated %s" + config = jsonencode({ + from = "test2@elastic.co" + port = 222 + host = "localhost" + }) + secrets = jsonencode({ + user = "user1" + password = "password1" + }) + connector_type_id = ".email" + }`, + name) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceKibanaConnectorDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: create(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(connectorName, ".email"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"from\":\"test@elastic\.co\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"port\":111`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"host\":\"localhost\"`)), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: update(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(fmt.Sprintf("Updated %s", connectorName), ".email"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"from\":\"test2@elastic\.co\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"port\":222`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"host\":\"localhost\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"user\":\"user1\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"password\":\"password1\"`)), + ), + }, + }, + }) +} + +func TestAccResourceKibanaConnectorIndex(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("7.14.0")) + + connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + create := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "%s" + config = jsonencode({ + index = ".kibana" + refresh = true + }) + connector_type_id = ".index" + }`, + name) + } + + update := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "Updated %s" + config = jsonencode({ + index = ".kibana" + refresh = false + }) + connector_type_id = ".index" + }`, + name) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceKibanaConnectorDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: create(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(connectorName, ".index"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"index\":\"\.kibana\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"refresh\":true`)), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: update(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(fmt.Sprintf("Updated %s", connectorName), ".index"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"index\":\"\.kibana\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"refresh\":false`)), + ), + }, + }, + }) +} + +func TestAccResourceKibanaConnectorJira(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("7.14.0")) + + connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + create := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "%s" + config = jsonencode({ + apiUrl = "url1" + projectKey = "project1" + }) + secrets = jsonencode({ + apiToken = "secret1" + email = "email1" + }) + connector_type_id = ".jira" + }`, + name) + } + + update := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "Updated %s" + config = jsonencode({ + apiUrl = "url2" + projectKey = "project2" + }) + secrets = jsonencode({ + apiToken = "secret2" + email = "email2" + }) + connector_type_id = ".jira" + }`, + name) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceKibanaConnectorDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: create(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(connectorName, ".jira"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"apiUrl\":\"url1\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"projectKey\":\"project1\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"apiToken\":\"secret1\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"email\":\"email1\"`)), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: update(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(fmt.Sprintf("Updated %s", connectorName), ".jira"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"apiUrl\":\"url2\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"projectKey\":\"project2\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"apiToken\":\"secret2\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"email\":\"email2\"`)), + ), + }, + }, + }) +} + +func TestAccResourceKibanaConnectorOpsgenie(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("8.6.0")) + + connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + create := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "%s" + config = jsonencode({ + apiUrl = "https://elastic.co" + }) + secrets = jsonencode({ + apiKey = "key1" + }) + connector_type_id = ".opsgenie" + }`, + name) + } + + update := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "Updated %s" + config = jsonencode({ + apiUrl = "https://elasticsearch.com" + }) + secrets = jsonencode({ + apiKey = "key2" + }) + connector_type_id = ".opsgenie" + }`, + name) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceKibanaConnectorDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: create(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(connectorName, ".opsgenie"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"apiUrl\":\"https://elastic\.co\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"apiKey\":\"key1\"`)), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: update(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(fmt.Sprintf("Updated %s", connectorName), ".opsgenie"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"apiUrl\":\"https://elasticsearch\.com\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"apiKey\":\"key2\"`)), + ), + }, + }, + }) +} + +func TestAccResourceKibanaConnectorPagerduty(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("7.14.0")) + + connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + create := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "%s" + config = jsonencode({ + }) + secrets = jsonencode({ + routingKey = "test1" + }) + connector_type_id = ".pagerduty" + }`, + name) + } + + update := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "Updated %s" + config = jsonencode({ + }) + secrets = jsonencode({ + routingKey = "test2" + }) + connector_type_id = ".pagerduty" + }`, + name) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceKibanaConnectorDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: create(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(connectorName, ".pagerduty"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"routingKey\":\"test1\"`)), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: update(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(fmt.Sprintf("Updated %s", connectorName), ".pagerduty"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"routingKey\":\"test2\"`)), + ), + }, + }, + }) +} + +func TestAccResourceKibanaConnectorResilient(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("7.14.0")) + + connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + create := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "%s" + config = jsonencode({ + apiUrl = "https://elastic.co" + orgId = "id1" + }) + secrets = jsonencode({ + apiKeyId = "key1" + apiKeySecret = "secret1" + }) + connector_type_id = ".resilient" + }`, + name) + } + + update := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "Updated %s" + config = jsonencode({ + apiUrl = "https://elasticsearch.com" + orgId = "id2" + }) + secrets = jsonencode({ + apiKeyId = "key2" + apiKeySecret = "secret2" + }) + connector_type_id = ".resilient" + }`, + name) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceKibanaConnectorDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: create(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(connectorName, ".resilient"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"apiUrl\":\"https://elastic\.co\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"orgId\":\"id1\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"apiKeyId\":\"key1\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"apiKeySecret\":\"secret1\"`)), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: update(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(fmt.Sprintf("Updated %s", connectorName), ".resilient"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"apiUrl\":\"https://elasticsearch\.com\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"orgId\":\"id2\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"apiKeyId\":\"key2\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"apiKeySecret\":\"secret2\"`)), + ), + }, + }, + }) +} + +func TestAccResourceKibanaConnectorServerLog(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("7.14.0")) + + connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + create := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "%s" + connector_type_id = ".server-log" + }`, + name) + } + + update := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "Updated %s" + connector_type_id = ".server-log" + }`, + name) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceKibanaConnectorDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: create(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(connectorName, ".server-log"), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: update(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(fmt.Sprintf("Updated %s", connectorName), ".server-log"), + ), + }, + }, + }) +} + +func TestAccResourceKibanaConnectorServicenow(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("7.14.0")) + + connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + create := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "%s" + config = jsonencode({ + apiUrl = "https://elastic.co" + }) + secrets = jsonencode({ + username = "user1" + password = "password1" + }) + connector_type_id = ".servicenow" + }`, + name) + } + + update := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "Updated %s" + config = jsonencode({ + apiUrl = "https://elasticsearch.com" + + }) + secrets = jsonencode({ + username = "user2" + password = "password2" + }) + connector_type_id = ".servicenow" + }`, + name) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceKibanaConnectorDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: create(connectorName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "name", connectorName), + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "connector_type_id", ".servicenow"), + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "is_missing_secrets", "false"), + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "is_preconfigured", "false"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"apiUrl\":\"https://elastic\.co\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"username\":\"user1\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"password\":\"password1\"`)), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: update(connectorName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "name", fmt.Sprintf("Updated %s", connectorName)), + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "connector_type_id", ".servicenow"), + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "is_missing_secrets", "false"), + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "is_preconfigured", "false"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"apiUrl\":\"https://elasticsearch\.com\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"username\":\"user2\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"password\":\"password2\"`)), + ), + }, + }, + }) +} + +func TestAccResourceKibanaConnectorServicenowItom(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("8.3.0")) + + connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + create := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "%s" + config = jsonencode({ + apiUrl = "https://elastic.co" + }) + secrets = jsonencode({ + username = "user1" + password = "password1" + }) + connector_type_id = ".servicenow-itom" + }`, + name) + } + + update := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "Updated %s" + config = jsonencode({ + apiUrl = "https://elasticsearch.com" + }) + secrets = jsonencode({ + username = "user2" + password = "password2" + }) + connector_type_id = ".servicenow-itom" + }`, + name) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceKibanaConnectorDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: create(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(connectorName, ".servicenow-itom"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"apiUrl\":\"https://elastic\.co\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"username\":\"user1\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"password\":\"password1\"`)), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: update(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(fmt.Sprintf("Updated %s", connectorName), ".servicenow-itom"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"apiUrl\":\"https://elasticsearch\.com\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"username\":\"user2\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"password\":\"password2\"`)), + ), + }, + }, + }) +} + +func TestAccResourceKibanaConnectorServicenowSir(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("7.14.0")) + + connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + create := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "%s" + config = jsonencode({ + apiUrl = "https://elastic.co" + }) + secrets = jsonencode({ + username = "user1" + password = "password1" + }) + connector_type_id = ".servicenow-sir" + }`, + name) + } + + update := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "Updated %s" + config = jsonencode({ + apiUrl = "https://elasticsearch.com" + }) + secrets = jsonencode({ + username = "user2" + password = "password2" + }) + connector_type_id = ".servicenow-sir" + }`, + name) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceKibanaConnectorDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: create(connectorName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "name", connectorName), + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "connector_type_id", ".servicenow-sir"), + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "is_missing_secrets", "false"), + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "is_preconfigured", "false"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"apiUrl\":\"https://elastic\.co\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"username\":\"user1\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"password\":\"password1\"`)), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: update(connectorName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "name", fmt.Sprintf("Updated %s", connectorName)), + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "connector_type_id", ".servicenow-sir"), + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "is_missing_secrets", "false"), + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "is_preconfigured", "false"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"apiUrl\":\"https://elasticsearch\.com\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"username\":\"user2\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"password\":\"password2\"`)), + ), + }, + }, + }) +} + +func TestAccResourceKibanaConnectorSlack(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("7.14.0")) + + connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + create := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "%s" + secrets = jsonencode({ + webhookUrl = "https://elastic.co" + }) + connector_type_id = ".slack" + }`, + name) + } + + update := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "Updated %s" + secrets = jsonencode({ + webhookUrl = "https://elasticsearch.com" + }) + connector_type_id = ".slack" + }`, + name) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceKibanaConnectorDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: create(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(connectorName, ".slack"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"webhookUrl\":\"https://elastic\.co\"`)), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: update(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(fmt.Sprintf("Updated %s", connectorName), ".slack"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"webhookUrl\":\"https://elasticsearch\.com\"`)), + ), + }, + }, + }) +} + +func TestAccResourceKibanaConnectorSwimlane(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("7.14.0")) + + connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + create := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "%s" + config = jsonencode({ + apiUrl = "https://elastic.co" + appId = "test1" + connectorType = "all" + mappings = { + alertIdConfig = { + fieldType = "type1" + id = "id1" + key = "key1" + name = "name1" + } + } + }) + secrets = jsonencode({ + apiToken = "token1" + }) + connector_type_id = ".swimlane" + }`, + name) + } + + update := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "Updated %s" + config = jsonencode({ + apiUrl = "https://elasticsearch.com" + appId = "test2" + connectorType = "all" + mappings = { + alertIdConfig = { + fieldType = "type2" + id = "id2" + key = "key2" + name = "name2" + } + } + }) + secrets = jsonencode({ + apiToken = "token2" + }) + connector_type_id = ".swimlane" + }`, + name) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceKibanaConnectorDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: create(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(connectorName, ".swimlane"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"apiUrl\":\"https://elastic\.co\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"appId\":\"test1\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"connectorType\":\"all\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"fieldType\":\"type1\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"id\":\"id1\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"key\":\"key1\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"name\":\"name1\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"apiToken\":\"token1\"`)), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: update(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(fmt.Sprintf("Updated %s", connectorName), ".swimlane"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"apiUrl\":\"https://elasticsearch\.com\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"appId\":\"test2\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"connectorType\":\"all\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"fieldType\":\"type2\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"id\":\"id2\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"key\":\"key2\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"name\":\"name2\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"apiToken\":\"token2\"`)), + ), + }, + }, + }) +} + +func TestAccResourceKibanaConnectorTeams(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("7.14.0")) + + connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + create := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "%s" + secrets = jsonencode({ + webhookUrl = "https://elastic.co" + }) + connector_type_id = ".teams" + }`, + name) + } + + update := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "Updated %s" + secrets = jsonencode({ + webhookUrl = "https://elasticsearch.com" + }) + connector_type_id = ".teams" + }`, + name) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceKibanaConnectorDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: create(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(connectorName, ".teams"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"webhookUrl\":\"https://elastic\.co\"`)), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: update(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(fmt.Sprintf("Updated %s", connectorName), ".teams"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"webhookUrl\":\"https://elasticsearch\.com\"`)), + ), + }, + }, + }) +} + +func TestAccResourceKibanaConnectorTines(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("8.6.0")) + + connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + create := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "%s" + config = jsonencode({ + url = "https://elastic.co" + }) + secrets = jsonencode({ + email = "test@elastic.co" + token = "token1" + }) + connector_type_id = ".tines" + }`, + name) + } + + update := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "Updated %s" + config = jsonencode({ + url = "https://elasticsearch.com" + }) + secrets = jsonencode({ + email = "test@elasticsearch.com" + token = "token2" + }) + connector_type_id = ".tines" + }`, + name) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceKibanaConnectorDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: create(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(connectorName, ".tines"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"url\":\"https://elastic\.co\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"email\":\"test@elastic\.co\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"token\":\"token1"`)), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: update(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(fmt.Sprintf("Updated %s", connectorName), ".tines"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"url\":\"https://elasticsearch\.com\"`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"email\":\"test@elasticsearch\.com\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"token\":\"token2"`)), + ), + }, + }, + }) +} + +func TestAccResourceKibanaConnectorWebhook(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("7.14.0")) + + connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + create := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "%s" + config = jsonencode({ + url = "https://elastic.co" + }) + secrets = jsonencode({}) + connector_type_id = ".webhook" + }`, + name) + } + + update := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "Updated %s" + config = jsonencode({ + url = "https://elasticsearch.com" + }) + secrets = jsonencode({}) + connector_type_id = ".webhook" + }`, + name) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceKibanaConnectorDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: create(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(connectorName, ".webhook"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"url\":\"https://elastic\.co\"`)), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: update(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(fmt.Sprintf("Updated %s", connectorName), ".webhook"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"url\":\"https://elasticsearch\.com\"`)), + ), + }, + }, + }) +} + +func TestAccResourceKibanaConnectorXmatters(t *testing.T) { + minSupportedVersion := version.Must(version.NewSemver("8.2.0")) + + connectorName := sdkacctest.RandStringFromCharSet(22, sdkacctest.CharSetAlphaNum) + + create := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "%s" + config = jsonencode({ + configUrl = "https://elastic.co" + usesBasic = true + }) + secrets = jsonencode({ + user = "user1" + password = "password1" + }) + connector_type_id = ".xmatters" + }`, + name) + } + + update := func(name string) string { + return fmt.Sprintf(` + provider "elasticstack" { + elasticsearch {} + kibana {} + } + + resource "elasticstack_kibana_action_connector" "test" { + name = "Updated %s" + config = jsonencode({ + usesBasic = false + }) + secrets = jsonencode({ + secretsUrl = "https://elasticsearch.com" + }) + connector_type_id = ".xmatters" + }`, + name) + } + + resource.Test(t, resource.TestCase{ + PreCheck: func() { acctest.PreCheck(t) }, + CheckDestroy: checkResourceKibanaConnectorDestroy, + ProtoV5ProviderFactories: acctest.Providers, + Steps: []resource.TestStep{ + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: create(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(connectorName, ".xmatters"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"configUrl\":\"https://elastic\.co\"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"usesBasic\":true`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"user\":\"user1"`)), + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"password\":\"password1"`)), + ), + }, + { + SkipFunc: versionutils.CheckIfVersionIsUnsupported(minSupportedVersion), + Config: update(connectorName), + Check: resource.ComposeTestCheckFunc( + testCommonAttributes(fmt.Sprintf("Updated %s", connectorName), ".xmatters"), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "config", regexp.MustCompile(`\"usesBasic\":false`)), + + resource.TestMatchResourceAttr("elasticstack_kibana_action_connector.test", "secrets", regexp.MustCompile(`\"secretsUrl\":\"https://elasticsearch\.com\"`)), + ), + }, + }, + }) +} + +func testCommonAttributes(connectorName, connectorTypeID string) resource.TestCheckFunc { + return resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "name", connectorName), + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "connector_type_id", connectorTypeID), + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "is_deprecated", "false"), + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "is_missing_secrets", "false"), + resource.TestCheckResourceAttr("elasticstack_kibana_action_connector.test", "is_preconfigured", "false"), + ) +} + +func checkResourceKibanaConnectorDestroy(s *terraform.State) error { + client, err := clients.NewAcceptanceTestingClient() + if err != nil { + return err + } + + for _, rs := range s.RootModule().Resources { + if rs.Type != "elasticstack_kibana_action_connector" { + continue + } + compId, _ := clients.CompositeIdFromStr(rs.Primary.ID) + + connector, diags := kibana.GetConnector(context.Background(), client, compId.ResourceId, compId.ClusterId) + if diags.HasError() { + return fmt.Errorf("Failed to get connector: %v", diags) + } + + if connector != nil { + return fmt.Errorf("Action connector (%s) still exists", compId.ResourceId) + } + } + return nil +} diff --git a/internal/models/action_connector.go b/internal/models/action_connector.go new file mode 100644 index 000000000..031e83a4d --- /dev/null +++ b/internal/models/action_connector.go @@ -0,0 +1,13 @@ +package models + +type KibanaActionConnector struct { + ConnectorID string + SpaceID string + Name string + ConnectorTypeID string + ConfigJSON string + SecretsJSON string + IsDeprecated bool + IsMissingSecrets bool + IsPreconfigured bool +} diff --git a/internal/utils/diffs.go b/internal/utils/diffs.go index 58493c9df..06340f219 100644 --- a/internal/utils/diffs.go +++ b/internal/utils/diffs.go @@ -35,3 +35,21 @@ func NormalizeIndexSettings(m map[string]interface{}) map[string]interface{} { } return out } + +func DiffNullMapEntriesSuppress(key, old, new string, d *schema.ResourceData) bool { + var oldMap, newMap map[string]interface{} + if err := json.Unmarshal([]byte(old), &oldMap); err != nil { + return false + } + if err := json.Unmarshal([]byte(new), &newMap); err != nil { + return false + } + for _, m := range [...]map[string]interface{}{oldMap, newMap} { + for k, v := range m { + if v == nil { + delete(m, k) + } + } + } + return MapsEqual(oldMap, newMap) +} diff --git a/internal/utils/utils.go b/internal/utils/utils.go index b3e8351f4..57c86912d 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -184,3 +184,7 @@ func ExpandIndividuallyDefinedSettings(ctx context.Context, d *schema.ResourceDa func ConvertSettingsKeyToTFFieldKey(settingKey string) string { return strings.Replace(settingKey, ".", "_", -1) } + +func Pointer[T any](value T) *T { + return &value +} diff --git a/provider/provider.go b/provider/provider.go index e70798a38..d51f3fb7b 100644 --- a/provider/provider.go +++ b/provider/provider.go @@ -99,8 +99,9 @@ func New(version string) *schema.Provider { "elasticstack_elasticsearch_transform": transform.ResourceTransform(), "elasticstack_elasticsearch_watch": watcher.ResourceWatch(), - "elasticstack_kibana_alerting_rule": kibana.ResourceAlertingRule(), - "elasticstack_kibana_space": kibana.ResourceSpace(), + "elasticstack_kibana_alerting_rule": kibana.ResourceAlertingRule(), + "elasticstack_kibana_space": kibana.ResourceSpace(), + "elasticstack_kibana_action_connector": kibana.ResourceActionConnector(), "elasticstack_fleet_agent_policy": fleet.ResourceAgentPolicy(), "elasticstack_fleet_output": fleet.ResourceOutput(), diff --git a/tools/connectors_gen.go b/tools/connectors_gen.go new file mode 100644 index 000000000..3f2b610e6 --- /dev/null +++ b/tools/connectors_gen.go @@ -0,0 +1,3 @@ +//go:generate go run github.com/deepmap/oapi-codegen/cmd/oapi-codegen -package connectors -o ../generated/connectors/connectors.gen.go -generate "types,client" ../generated/connectors/bundled.yaml + +package tools