---
sidebar:
  hidden: true
title: roboto.domain.orgs.s3_integration
---
## Module Contents

### RegisterS3IntegrationRequest

```python
class roboto.domain.orgs.s3_integration.RegisterS3IntegrationRequest(/, **data: Any)
```

`from roboto.domain.orgs.s3_integration import RegisterS3IntegrationRequest`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/orgs/s3_integration.py#L97-L120)

Bases: `pydantic.BaseModel`

Request body for `S3IntegrationService.register_bucket`.

**Parameters**

- **data** (`Any`)

**Attributes**

- **RegisterS3IntegrationRequest.account_id** (`str`): ID of the AWS account that owns the bucket.

- **RegisterS3IntegrationRequest.aws_region** (`str`): AWS region the bucket is in, such as `us-west-2`.

- **RegisterS3IntegrationRequest.bucket_name** (`str`): Name of the S3 bucket to register.

- **RegisterS3IntegrationRequest.org_id** (`str`): ID of the organization to register the bucket with.

- **RegisterS3IntegrationRequest.readonly** (`bool`) = `False`: Whether to grant Roboto read-only access to the bucket.

  `False` grants read-write access and makes the bucket the organization's default bucket for new datasets' files. Only a Roboto administrator can register a read-only bucket.

- **RegisterS3IntegrationRequest.transfer_accelerated** (`bool`) = `False`: Whether the bucket uses S3 Transfer Acceleration. Roboto records the value; it does not turn acceleration on.

### RegisterS3IntegrationResponse

```python
class roboto.domain.orgs.s3_integration.RegisterS3IntegrationResponse(/, **data: Any)
```

`from roboto.domain.orgs.s3_integration import RegisterS3IntegrationResponse`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/orgs/s3_integration.py#L123-L143)

Bases: `pydantic.BaseModel`

Response body of `S3IntegrationService.register_bucket`.

Holds the IAM role and CORS rules that the bucket's AWS account needs before Roboto can reach the bucket; `register_bucket` creates them.

**Parameters**

- **data** (`Any`)

**Attributes**

- **RegisterS3IntegrationResponse.iam_role_name** (`str`): Name of the IAM role to create in the bucket's AWS account, which Roboto assumes to reach the bucket.

- **RegisterS3IntegrationResponse.iam_role_policy** (`dict[str, Any]`): Inline policy document to attach to the role, granting the S3 actions Roboto needs on the bucket.

- **RegisterS3IntegrationResponse.iam_role_trust_relationship** (`dict[str, Any]`): Trust policy document for the role, which lets Roboto's AWS account assume it.

  Roboto's account must present an external ID unique to this registration to assume the role.

- **RegisterS3IntegrationResponse.s3_bucket_cors_policy** (`list[dict[str, Any]]`): CORS rules to set on the bucket, so that the Roboto web app can read and write the bucket's objects.

### S3BucketHealthCheck

```python
class roboto.domain.orgs.s3_integration.S3BucketHealthCheck(/, **data: Any)
```

`from roboto.domain.orgs.s3_integration import S3BucketHealthCheck`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/orgs/s3_integration.py#L24-L51)

Bases: `pydantic.BaseModel`

Result of a health check, in which Roboto tests that it can reach an organization's S3 bucket.

Holds no bucket name, role Amazon Resource Name (ARN), AWS account ID, secret, or AWS error message, so it is safe to display; the record that carries it holds the bucket's identifiers. Carried in `S3BucketIntegrationRecord.last_health_check`.

**Parameters**

- **data** (`Any`)

**Attributes**

- **S3BucketHealthCheck.aws_error_code** (`str | None`) = `None`: AWS error code behind the result, such as `AccessDenied`, or `None` if no AWS error caused it.

- **S3BucketHealthCheck.message** (`str`): Human-readable explanation of the result, safe to display.

- **S3BucketHealthCheck.probes** (`dict[str, str]`) = `None`: Outcome of each request Roboto tried, keyed by request.

  The keys are `assume_role`, `location`, `list`, `put`, `get` and `delete`. Each outcome is `ok`, `denied`, `error` or `skipped`. Roboto stops at the first request that fails and skips the rest, and on a read-only bucket it skips `put`, `get` and `delete`.

- **S3BucketHealthCheck.reason_code** (`str`): Classification of the result.

  One of `ok`, `role_not_assumable`, `permission_denied`, `bucket_not_found`, `region_mismatch`, `encryption_denied`, `throttled` or `roboto_error`.

### S3BucketIntegrationRecord

```python
class roboto.domain.orgs.s3_integration.S3BucketIntegrationRecord(/, **data: Any)
```

`from roboto.domain.orgs.s3_integration import S3BucketIntegrationRecord`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/orgs/s3_integration.py#L54-L94)

Bases: `pydantic.BaseModel`

Data record of an S3 bucket integration, as `GET /v1/integrations/storage/s3/buckets` returns it.

`POST /v1/integrations/storage/s3/buckets/{bucket}/healthcheck` also returns it, after checking the bucket. An S3 bucket integration is an S3 bucket in a customer's own AWS account that an organization has registered with Roboto, so that Roboto reads and stores the organization's files there.

**Parameters**

- **data** (`Any`)

**Attributes**

- **S3BucketIntegrationRecord.aws_region** (`str`): AWS region the bucket is in, such as `us-west-2`.

- **S3BucketIntegrationRecord.bucket_name** (`str`): Name of the S3 bucket.

- **S3BucketIntegrationRecord.created** (`datetime.datetime`): Time the bucket was registered.

- **S3BucketIntegrationRecord.last_health_check** (`S3BucketHealthCheck | None`) = `None`: Result of the most recent health check, or `None` if the bucket has never been checked.

- **S3BucketIntegrationRecord.modified** (`datetime.datetime`): Time the integration's configuration was last modified. Health checks do not change it.

- **S3BucketIntegrationRecord.org_id** (`str`): ID of the organization that registered the bucket.

- **S3BucketIntegrationRecord.readonly** (`bool`): Whether Roboto has read-only access to the bucket.

- **S3BucketIntegrationRecord.status** (`str`): Result of the most recent health check.

  One of `healthy`, `unhealthy` when the check found a problem to fix, `unknown` when it reached no verdict, such as when AWS throttled it, or `unverified` if the bucket has never been checked.

- **S3BucketIntegrationRecord.status_last_updated** (`datetime.datetime | None`) = `None`: Time `status` was last set.

  This is when the most recent health check ran, or when the bucket was registered if it has never been checked.

### S3IntegrationService

```python
class roboto.domain.orgs.s3_integration.S3IntegrationService(
    roboto_client: roboto.http.RobotoClient,
    sts_client: Optional[Any] = None,
    s3_client: Optional[Any] = None,
    iam_client: Optional[Any] = None,
)
```

`from roboto.domain.orgs.s3_integration import S3IntegrationService`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/orgs/s3_integration.py#L146-L284)

Client that registers an S3 bucket in the caller's own AWS account with a Roboto organization.

Calls AWS with the caller's AWS credentials to grant Roboto access to the bucket. To register a bucket from the command line, use `roboto orgs register-bucket`.

**Parameters**

- **roboto_client** (`roboto.http.RobotoClient`): Client to make requests to Roboto with.
- **sts_client** (`Optional[Any]`): boto3 STS client to make AWS requests with. `None` creates one from the environment's AWS credentials and configuration.
- **s3_client** (`Optional[Any]`): boto3 S3 client to make AWS requests with. `None` creates one the same way.
- **iam_client** (`Optional[Any]`): boto3 IAM client to make AWS requests with. `None` creates one the same way.

#### S3IntegrationService.register_bucket()

```python
def register_bucket(
    org_id: str,
    account_id: str,
    bucket_name: str,
    transfer_accelerated: bool = False,
    readonly: bool = False,
)
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/orgs/s3_integration.py#L177-L284)

Register an S3 bucket with an organization and grant Roboto access to it.

Uses the environment's AWS credentials, which must belong to `account_id` and be allowed to create IAM roles and set the bucket's CORS configuration. In order, it:

1. Checks that the credentials belong to `account_id` and that the account owns the bucket.
2. Registers the bucket with Roboto, which returns the IAM role and CORS rules Roboto needs.
3. Creates the IAM role in the account and attaches its inline policy.
4. Sets the bucket's CORS rules.

Only a member of the organization can call it, and only a Roboto administrator can register a read-only bucket.

**Parameters**

- **org_id** (`str`): ID of the organization to register the bucket with.
- **account_id** (`str`): ID of the AWS account that owns the bucket.
- **bucket_name** (`str`): Name of the S3 bucket to register.
- **transfer_accelerated** (`bool`): Whether the bucket uses S3 Transfer Acceleration. Roboto records the value; this method does not turn acceleration on.
- **readonly** (`bool`): Whether to grant Roboto read-only access to the bucket. `False` grants read-write access and makes the bucket the organization's default bucket for new datasets' files.

**Raises**

- [`RobotoInvalidRequestException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoInvalidRequestException): AWS cannot identify the credentials, or they belong to an account other than `account_id`.
- `ValueError`: The account does not own a bucket named `bucket_name`.
- [`RobotoUnauthorizedException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoUnauthorizedException): The organization is not on the premium tier, or the caller is not allowed to register the bucket.
- [`RobotoConflictException`](/docs/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoConflictException): The organization has already registered the bucket.
- `botocore.exceptions.ClientError`: An AWS request fails, such as when the credentials cannot create IAM roles or a role with the same name already exists.

> **Note**
>
> Step 4 replaces any CORS rules the bucket already has. If step 3 or 4 fails, the bucket stays registered with Roboto, so calling this method again raises `RobotoConflictException`.

**Usage**

Register a bucket for read-write access:

```python
from roboto import RobotoClient
from roboto.domain.orgs.s3_integration import S3IntegrationService
service = S3IntegrationService(RobotoClient.from_env())
service.register_bucket(org_id="og_12345", account_id="123456789012", bucket_name="my-data-bucket")
```

Register a bucket with read-only access:

```python
service.register_bucket(
    org_id="og_12345", account_id="123456789012", bucket_name="my-readonly-bucket", readonly=True
)
```

### logger

```python
roboto.domain.orgs.s3_integration.logger
```

`from roboto.domain.orgs.s3_integration import logger`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/orgs/s3_integration.py#L21-L21)
