Elastic Box connector reference
editElastic Box connector reference
editTh Box connector is written in Python using the Elastic connector framework.
View the source code for this connector (branch 8.x, compatible with Elastic 8.17).
Elastic managed connector reference
editView Elastic managed connector reference
Availability and prerequisites
editThis connector is available as a managed connector as of Elastic version 8.14.0.
To use this connector natively in Elastic Cloud, satisfy all managed connector requirements.
This connector is in technical preview and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Technical preview features are not subject to the support SLA of official GA features.
Create a Box connector
editUse the UI
editTo create a new Box connector:
- In the Kibana UI, navigate to the Search → Content → Connectors page from the main menu, or use the global search field.
- Follow the instructions to create a new native Box connector.
For additional operations, see Connectors UI in Kibana.
Use the API
editYou can use the Elasticsearch Create connector API to create a new native Box connector.
For example:
resp = client.connector.put( connector_id="my-{service-name-stub}-connector", index_name="my-elasticsearch-index", name="Content synced from {service-name}", service_type="{service-name-stub}", is_native=True, ) print(resp)
const response = await client.connector.put({ connector_id: "my-{service-name-stub}-connector", index_name: "my-elasticsearch-index", name: "Content synced from {service-name}", service_type: "{service-name-stub}", is_native: true, }); console.log(response);
PUT _connector/my-box-connector { "index_name": "my-elasticsearch-index", "name": "Content synced from Box", "service_type": "box", "is_native": true }
You’ll also need to create an API key for the connector to use.
The user needs the cluster privileges manage_api_key
, manage_connector
and write_connector_secrets
to generate API keys programmatically.
To create an API key for the connector:
-
Run the following command, replacing values where indicated. Note the
id
andencoded
return values from the response:resp = client.security.create_api_key( name="my-connector-api-key", role_descriptors={ "my-connector-connector-role": { "cluster": [ "monitor", "manage_connector" ], "indices": [ { "names": [ "my-index_name", ".search-acl-filter-my-index_name", ".elastic-connectors*" ], "privileges": [ "all" ], "allow_restricted_indices": False } ] } }, ) print(resp)
const response = await client.security.createApiKey({ name: "my-connector-api-key", role_descriptors: { "my-connector-connector-role": { cluster: ["monitor", "manage_connector"], indices: [ { names: [ "my-index_name", ".search-acl-filter-my-index_name", ".elastic-connectors*", ], privileges: ["all"], allow_restricted_indices: false, }, ], }, }, }); console.log(response);
POST /_security/api_key { "name": "my-connector-api-key", "role_descriptors": { "my-connector-connector-role": { "cluster": [ "monitor", "manage_connector" ], "indices": [ { "names": [ "my-index_name", ".search-acl-filter-my-index_name", ".elastic-connectors*" ], "privileges": [ "all" ], "allow_restricted_indices": false } ] } } }
-
Use the
encoded
value to store a connector secret, and note theid
return value from this response:resp = client.connector.secret_post( body={ "value": "encoded_api_key" }, ) print(resp)
const response = await client.transport.request({ method: "POST", path: "/_connector/_secret", body: { value: "encoded_api_key", }, }); console.log(response);
POST _connector/_secret { "value": "encoded_api_key" }
-
Use the API key
id
and the connector secretid
to update the connector:resp = client.connector.update_api_key_id( connector_id="my_connector_id>", api_key_id="API key_id", api_key_secret_id="secret_id", ) print(resp)
const response = await client.connector.updateApiKeyId({ connector_id: "my_connector_id>", api_key_id: "API key_id", api_key_secret_id: "secret_id", }); console.log(response);
PUT /_connector/my_connector_id>/_api_key_id { "api_key_id": "API key_id", "api_key_secret_id": "secret_id" }
Refer to the Elasticsearch API documentation for details of all available Connector APIs.
Usage
editTo use this connector as a self-managed connector, use the Box tile from the connectors list OR Customized connector workflow.
For additional operations, see Connectors UI in Kibana.
Box API Authorization
editBox Free Account
editCreate Box User Authentication (OAuth 2.0) Custom App
You’ll need to create an OAuth app in the Box developer console by following these steps:
- Register a new app in the Box dev console with custom App and select User authentication (OAuth 2.0).
- Add the URL of the web page in Redirect URIs, which is accessible by you.
- Check "Write all files and folders stored in Box" in Application Scopes.
- Once the app is created, Client ID and Client secret values are available in the configuration tab. Keep these handy.
To generate a refresh token, follow these steps:
-
Go to the following URL, replacing
<CLIENT_ID>
with the Client ID value saved earlier. For example:https://account.box.com/api/oauth2/authorize?response_type=code&client_id=<CLIENT_ID>
- Grant access to your application.
- You will now be redirected to the web page that you configured in Redirect URIs, and the HTTP response should contain an authorization code that you’ll use to generate a refresh token. Note: Authorization codes to generate refresh tokens can only be used once and are only valid for 30 seconds.
-
In your terminal, run the following
curl
command, replacing<AUTHORIZATION_CODE>
,<CLIENT_ID> and <CLIENT_SECRET>
with the values you saved earlier:curl -i -X POST "https://api.box.com/oauth2/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "client_id=<CLIENT_ID>" \ -d "client_secret=<CLIENT_SECRET>" \ -d "code=<AUTHORIZATION_CODE>" \ -d "grant_type=authorization_code"
Save the refresh token from the response. You’ll need this for the connector configuration.
Box Enterprise Account
editCreate Box Server Authentication (Client Credentials Grant) Custom App
- Register a new app in the Box dev console with custom App and select Server Authentication (Client Credentials Grant).
-
Check following permissions:
- "Write all files and folders stored in Box" in Application Scopes
- "Make API calls using the as-user header" in Advanced Features
-
Select
App + Enterprise Access
in App Access Level. - Authorize your application from the admin console. Save the Client Credentials and Enterprise ID. You’ll need these to configure the connector.
Configuration
edit-
Box Account
(required) -
Dropdown to determine Box Account type:
Box Free Account
orBox Enterprise Account
. Default value isBox Free Account
. -
Client ID
(required) - The Client ID to authenticate with Box instance.
-
Client Secret
(required) - The Client Secret to authenticate with Box instance.
-
Refresh Token
(required if Box Account is Box Free) - The Refresh Token to generate Access Token. NOTE: If the process terminates, you’ll need to generate a new refresh token.
-
Enterprise ID
(required if Box Account is Box Enterprise) - The Enterprise ID to authenticate with Box instance.
Content Extraction
editRefer to Content extraction.
Documents and syncs
editThe connector syncs the following objects and entities:
- Files
- Folders
- Files bigger than 10 MB won’t be extracted.
- Permissions are not synced. All documents indexed to an Elastic deployment will be visible to all users with access to that Elastic Deployment.
Sync types
editFull syncs are supported by default for all connectors.
This connector also supports incremental syncs.
Sync rules
editBasic sync rules are identical for all connectors and are available by default.
Advanced Sync Rules
editAdvanced sync rules are not available for this connector in the present version.
Known issues
editThere are no known issues for this connector. Refer to Known issues for a list of known issues for all connectors.
Troubleshooting
editSee Troubleshooting.
Security
editSee Security.
Self-managed connector reference
editView self-managed connector reference
Availability and prerequisites
editThis connector is available as a self-managed self-managed connector. To use this connector, satisfy all self-managed connector prerequisites.
This connector is in technical preview and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Technical preview features are not subject to the support SLA of official GA features.
Create a Box connector
editUse the UI
editTo create a new Box connector:
- In the Kibana UI, navigate to the Search → Content → Connectors page from the main menu, or use the global search field.
- Follow the instructions to create a new Box self-managed connector.
Use the API
editYou can use the Elasticsearch Create connector API to create a new self-managed Box self-managed connector.
For example:
resp = client.connector.put( connector_id="my-{service-name-stub}-connector", index_name="my-elasticsearch-index", name="Content synced from {service-name}", service_type="{service-name-stub}", ) print(resp)
const response = await client.connector.put({ connector_id: "my-{service-name-stub}-connector", index_name: "my-elasticsearch-index", name: "Content synced from {service-name}", service_type: "{service-name-stub}", }); console.log(response);
PUT _connector/my-box-connector { "index_name": "my-elasticsearch-index", "name": "Content synced from Box", "service_type": "box" }
You’ll also need to create an API key for the connector to use.
The user needs the cluster privileges manage_api_key
, manage_connector
and write_connector_secrets
to generate API keys programmatically.
To create an API key for the connector:
-
Run the following command, replacing values where indicated. Note the
encoded
return values from the response:resp = client.security.create_api_key( name="connector_name-connector-api-key", role_descriptors={ "connector_name-connector-role": { "cluster": [ "monitor", "manage_connector" ], "indices": [ { "names": [ "index_name", ".search-acl-filter-index_name", ".elastic-connectors*" ], "privileges": [ "all" ], "allow_restricted_indices": False } ] } }, ) print(resp)
const response = await client.security.createApiKey({ name: "connector_name-connector-api-key", role_descriptors: { "connector_name-connector-role": { cluster: ["monitor", "manage_connector"], indices: [ { names: [ "index_name", ".search-acl-filter-index_name", ".elastic-connectors*", ], privileges: ["all"], allow_restricted_indices: false, }, ], }, }, }); console.log(response);
POST /_security/api_key { "name": "connector_name-connector-api-key", "role_descriptors": { "connector_name-connector-role": { "cluster": [ "monitor", "manage_connector" ], "indices": [ { "names": [ "index_name", ".search-acl-filter-index_name", ".elastic-connectors*" ], "privileges": [ "all" ], "allow_restricted_indices": false } ] } } }
-
Update your
config.yml
file with the API keyencoded
value.
Refer to the Elasticsearch API documentation for details of all available Connector APIs.
Usage
editTo use this connector as a self-managed connector, use the Box tile from the connectors list OR Customized connector workflow.
For additional operations, see Connectors UI in Kibana.
Box API Authorization
editBox Free Account
editCreate Box User Authentication (OAuth 2.0) Custom App
You’ll need to create an OAuth app in the Box developer console by following these steps:
- Register a new app in the Box dev console with custom App and select User authentication (OAuth 2.0).
- Add the URL of the web page in Redirect URIs, which is accessible by you.
- Check "Write all files and folders stored in Box" in Application Scopes.
- Once the app is created, Client ID and Client secret values are available in the configuration tab. Keep these handy.
To generate a refresh token, follow these steps:
-
Go to the following URL, replacing
<CLIENT_ID>
with the Client ID value saved earlier. For example:https://account.box.com/api/oauth2/authorize?response_type=code&client_id=<CLIENT_ID>
- Grant access to your application.
- You will now be redirected to the web page that you configured in Redirect URIs, and the HTTP response should contain an authorization code that you’ll use to generate a refresh token. Note: Authorization codes to generate refresh tokens can only be used once and are only valid for 30 seconds.
-
In your terminal, run the following
curl
command, replacing<AUTHORIZATION_CODE>
,<CLIENT_ID> and <CLIENT_SECRET>
with the values you saved earlier:curl -i -X POST "https://api.box.com/oauth2/token" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "client_id=<CLIENT_ID>" \ -d "client_secret=<CLIENT_SECRET>" \ -d "code=<AUTHORIZATION_CODE>" \ -d "grant_type=authorization_code"
Save the refresh token from the response. You’ll need this for the connector configuration.
Box Enterprise Account
editCreate Box Server Authentication (Client Credentials Grant) Custom App
- Register a new app in the Box dev console with custom App and select Server Authentication (Client Credentials Grant).
-
Check following permissions:
- "Write all files and folders stored in Box" in Application Scopes
- "Make API calls using the as-user header" in Advanced Features
-
Select
App + Enterprise Access
in App Access Level. - Authorize your application from the admin console. Save the Client Credentials and Enterprise ID. You’ll need these to configure the connector.
Configuration
edit-
Box Account
(required) -
Dropdown to determine Box Account type:
Box Free Account
orBox Enterprise Account
. Default value isBox Free Account
. -
Client ID
(required) - The Client ID to authenticate with Box instance.
-
Client Secret
(required) - The Client Secret to authenticate with Box instance.
-
Refresh Token
(required if Box Account is Box Free) - The Refresh Token to generate Access Token. NOTE: If the process terminates, you’ll need to generate a new refresh token.
-
Enterprise ID
(required if Box Account is Box Enterprise) - The Enterprise ID to authenticate with Box instance.
Deployment using Docker
editYou can deploy the Box connector as a self-managed connector using Docker. Follow these instructions.
Step 1: Download sample configuration file
Download the sample configuration file. You can either download it manually or run the following command:
curl https://raw.githubusercontent.com/elastic/connectors/main/config.yml.example --output ~/connectors-config/config.yml
Remember to update the --output
argument value if your directory name is different, or you want to use a different config file name.
Step 2: Update the configuration file for your self-managed connector
Update the configuration file with the following settings to match your environment:
-
elasticsearch.host
-
elasticsearch.api_key
-
connectors
If you’re running the connector service against a Dockerized version of Elasticsearch and Kibana, your config file will look like this:
# When connecting to your cloud deployment you should edit the host value elasticsearch.host: http://host.docker.internal:9200 elasticsearch.api_key: <ELASTICSEARCH_API_KEY> connectors: - connector_id: <CONNECTOR_ID_FROM_KIBANA> service_type: box api_key: <CONNECTOR_API_KEY_FROM_KIBANA> # Optional. If not provided, the connector will use the elasticsearch.api_key instead
Using the elasticsearch.api_key
is the recommended authentication method. However, you can also use elasticsearch.username
and elasticsearch.password
to authenticate with your Elasticsearch instance.
Note: You can change other default configurations by simply uncommenting specific settings in the configuration file and modifying their values.
Step 3: Run the Docker image
Run the Docker image with the Connector Service using the following command:
docker run \ -v ~/connectors-config:/config \ --network "elastic" \ --tty \ --rm \ docker.elastic.co/enterprise-search/elastic-connectors:8.17.0.0 \ /app/bin/elastic-ingest \ -c /config/config.yml
Refer to DOCKER.md
in the elastic/connectors
repo for more details.
Find all available Docker images in the official registry.
We also have a quickstart self-managed option using Docker Compose, so you can spin up all required services at once: Elasticsearch, Kibana, and the connectors service.
Refer to this README in the elastic/connectors
repo for more information.
Content Extraction
editRefer to Content extraction.
Documents and syncs
editThe connector syncs the following objects and entities:
- Files
- Folders
- Files bigger than 10 MB won’t be extracted.
- Permissions are not synced. All documents indexed to an Elastic deployment will be visible to all users with access to that Elastic Deployment.
Sync types
editFull syncs are supported by default for all connectors.
This connector also supports incremental syncs.
Sync rules
editBasic sync rules are identical for all connectors and are available by default.
Advanced Sync Rules
editAdvanced sync rules are not available for this connector in the present version.
End-to-end Testing
editThe connector framework enables operators to run functional tests against a real data source. Refer to Connector testing for more details.
To perform E2E testing for the Box connector, run the following command:
$ make ftest NAME=box
For faster tests, add the DATA_SIZE=small
flag:
make ftest NAME=box DATA_SIZE=small
Known issues
editThere are no known issues for this connector. Refer to Known issues for a list of known issues for all connectors.
Troubleshooting
editSee Troubleshooting.
Security
editSee Security.