Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions apps/docs/content/docs/cli/organizations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,14 @@ sim organizations members remove <userId> [options]

API request and response schemas: [removeOrganizationMember](/api-reference/organizations/removeOrganizationMember).

## GitLab Search permissions
## Search source permissions

### Get GitLab search permission revision
### Get search source permission revision

OAuth login or personal API key required.

```bash
sim organizations gitlab-permissions get <sourceId> [options]
sim organizations search sources permissions get <sourceId> [options]
```

**Arguments**
Expand All @@ -245,7 +245,7 @@ sim organizations gitlab-permissions get <sourceId> [options]

| Argument | Required | Description |
| --- | --- | --- |
| `sourceId` | Yes | Identifier of the configured GitLab Search source. |
| `sourceId` | Yes | Identifier of the configured Search source. |

</CommandTable>

Expand All @@ -259,16 +259,16 @@ sim organizations gitlab-permissions get <sourceId> [options]

</CommandTable>

API request and response schemas: [getGitLabSearchPermissions](/api-reference/organizations/getGitLabSearchPermissions).
API request and response schemas: [getSearchSourcePermissions](/api-reference/organizations/getSearchSourcePermissions).

### Replace GitLab search permission CSVs
### Replace search source permissions

OAuth login or personal API key required.

This replaces both GitLab permission files. Readers omitted from the new grants lose access.
This replaces the source’s permission grants. Readers omitted from the new grants lose access.

```bash
sim organizations gitlab-permissions replace <sourceId> [options]
sim organizations search sources permissions replace <sourceId> [options]
```

**Arguments**
Expand All @@ -277,7 +277,7 @@ sim organizations gitlab-permissions replace <sourceId> [options]

| Argument | Required | Description |
| --- | --- | --- |
| `sourceId` | Yes | Identifier of the configured GitLab Search source. |
| `sourceId` | Yes | Identifier of the configured Search source. |

</CommandTable>

Expand All @@ -288,14 +288,13 @@ sim organizations gitlab-permissions replace <sourceId> [options]
| Option | Required | Description |
| --- | --- | --- |
| `--organization <value>` | Yes | Organization identifier. |
| `--expected-revision <value>` | Yes | Current permission revision obtained before generating this snapshot. |
| `--user-mapping <json\|@file>` | Yes | GitLab user IDs and their verified Sim email addresses. (JSON, or @path / @- to read a file or stdin). |
| `--project-permissions <json\|@file>` | Yes | GitLab project paths and the IDs of users granted access. (JSON, or @path / @- to read a file or stdin). |
| `--expected-revision <value>` | Yes | Permission revision read before exporting the grants. |
| `--permissions <json\|@file>` | Yes | Complete permission grants in the source provider’s format. (JSON, or @path / @- to read a file or stdin). |
| `-y, --yes` | Yes | Confirm this operation. |

</CommandTable>

API request and response schemas: [replaceGitLabSearchPermissions](/api-reference/organizations/replaceGitLabSearchPermissions).
API request and response schemas: [replaceSearchSourcePermissions](/api-reference/organizations/replaceSearchSourcePermissions).

## Invitations

Expand Down
131 changes: 65 additions & 66 deletions apps/docs/content/docs/cli/reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4288,72 +4288,6 @@ sim organizations sso policy update [options]

API request and response schemas: [updateSsoPolicy](/api-reference/organizations/updateSsoPolicy).

### sim organizations gitlab-permissions get

Get GitLab search permission revision (OAuth login or personal API key required)

```bash
sim organizations gitlab-permissions get <sourceId> [options]
```

**Arguments**

<CommandTable>

| Argument | Required | Description |
| --- | --- | --- |
| `sourceId` | Yes | Identifier of the configured GitLab Search source. |

</CommandTable>

**Options**

<CommandTable>

| Option | Required | Description |
| --- | --- | --- |
| `--organization <value>` | Yes | Organization identifier. |

</CommandTable>

API request and response schemas: [getGitLabSearchPermissions](/api-reference/organizations/getGitLabSearchPermissions).

### sim organizations gitlab-permissions replace

Replace GitLab search permission CSVs (OAuth login or personal API key required)

This replaces both GitLab permission files. Readers omitted from the new grants lose access.

```bash
sim organizations gitlab-permissions replace <sourceId> [options]
```

**Arguments**

<CommandTable>

| Argument | Required | Description |
| --- | --- | --- |
| `sourceId` | Yes | Identifier of the configured GitLab Search source. |

</CommandTable>

**Options**

<CommandTable>

| Option | Required | Description |
| --- | --- | --- |
| `--organization <value>` | Yes | Organization identifier. |
| `--expected-revision <value>` | Yes | Current permission revision obtained before generating this snapshot. |
| `--user-mapping <json\|@file>` | Yes | GitLab user IDs and their verified Sim email addresses. (JSON, or @path / @- to read a file or stdin). |
| `--project-permissions <json\|@file>` | Yes | GitLab project paths and the IDs of users granted access. (JSON, or @path / @- to read a file or stdin). |
| `-y, --yes` | Yes | Confirm this operation. |

</CommandTable>

API request and response schemas: [replaceGitLabSearchPermissions](/api-reference/organizations/replaceGitLabSearchPermissions).

### sim organizations get

Get organization (OAuth login or personal API key required)
Expand Down Expand Up @@ -4602,6 +4536,71 @@ sim organizations usage events [options]

API request and response schemas: [listOrganizationUsageEvents](/api-reference/organizations/listOrganizationUsageEvents).

### sim organizations search sources permissions get

Get search source permission revision (OAuth login or personal API key required)

```bash
sim organizations search sources permissions get <sourceId> [options]
```

**Arguments**

<CommandTable>

| Argument | Required | Description |
| --- | --- | --- |
| `sourceId` | Yes | Identifier of the configured Search source. |

</CommandTable>

**Options**

<CommandTable>

| Option | Required | Description |
| --- | --- | --- |
| `--organization <value>` | Yes | Organization identifier. |

</CommandTable>

API request and response schemas: [getSearchSourcePermissions](/api-reference/organizations/getSearchSourcePermissions).

### sim organizations search sources permissions replace

Replace search source permissions (OAuth login or personal API key required)

This replaces the source’s permission grants. Readers omitted from the new grants lose access.

```bash
sim organizations search sources permissions replace <sourceId> [options]
```

**Arguments**

<CommandTable>

| Argument | Required | Description |
| --- | --- | --- |
| `sourceId` | Yes | Identifier of the configured Search source. |

</CommandTable>

**Options**

<CommandTable>

| Option | Required | Description |
| --- | --- | --- |
| `--organization <value>` | Yes | Organization identifier. |
| `--expected-revision <value>` | Yes | Permission revision read before exporting the grants. |
| `--permissions <json\|@file>` | Yes | Complete permission grants in the source provider’s format. (JSON, or @path / @- to read a file or stdin). |
| `-y, --yes` | Yes | Confirm this operation. |

</CommandTable>

API request and response schemas: [replaceSearchSourcePermissions](/api-reference/organizations/replaceSearchSourcePermissions).

### sim organizations list

List organizations (OAuth login or personal API key required)
Expand Down
9 changes: 5 additions & 4 deletions apps/docs/content/docs/search/gitlab.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ To rotate the PAT, supply its replacement in source settings. A blank token reta

### Automate updates with GitLab CI

After an admin configures a source in **Non-admin token** mode, a job can [read its revision](/api-reference/organizations/getGitLabSearchPermissions) and [replace both CSVs](/api-reference/organizations/replaceGitLabSearchPermissions). Copy `SIM_ORG_ID` and `SIM_SOURCE_ID` from the source settings URL: `/o/<organizationId>/settings/integrations/sources/<sourceId>`. Set `SIM_BASE_URL` to your Sim origin (for hosted Sim, `https://www.sim.ai`).
After an admin configures a source in **Non-admin token** mode, a job can [read its revision](/api-reference/organizations/getSearchSourcePermissions) and [replace both CSVs](/api-reference/organizations/replaceSearchSourcePermissions). Copy `SIM_ORG_ID` and `SIM_SOURCE_ID` from the source settings URL: `/o/<organizationId>/settings/integrations/sources/<sourceId>`. Set `SIM_BASE_URL` to your Sim origin (for hosted Sim, `https://www.sim.ai`).

Store an organization admin's [personal Sim API key](/api-reference/authentication) as a [masked, protected GitLab CI variable](https://docs.gitlab.com/ci/variables/) named `SIM_API_KEY`. A personal key inherits its owner's access. This endpoint can only read the revision or replace both CSVs; it cannot change the GitLab PAT, host, or project.

Expand All @@ -106,15 +106,16 @@ sync_gitlab_permissions:
script:
- |
set -eu
url="${SIM_BASE_URL%/}/api/v2/organizations/$SIM_ORG_ID/search/sources/$SIM_SOURCE_ID/gitlab-permissions"
url="${SIM_BASE_URL%/}/api/v2/organizations/$SIM_ORG_ID/search/sources/$SIM_SOURCE_ID/permissions"
auth="X-API-Key: $SIM_API_KEY"
current=$(curl --fail --silent --show-error -H "$auth" "$url")
revision=$(printf '%s' "$current" | jq -er '.data.revision')
./ci/export-gitlab-permissions
jq -n --argjson rev "$revision" \
--rawfile users users.csv --rawfile grants project-permissions.csv \
'{expectedRevision: $rev, userMapping: {filename: "users.csv", content: $users},
projectPermissions: {filename: "project-permissions.csv", content: $grants}}' > update.json
'{expectedRevision: $rev, permissions: {provider: "gitlab",
userMapping: {filename: "users.csv", content: $users},
projectPermissions: {filename: "project-permissions.csv", content: $grants}}}' > update.json
curl --fail --silent --show-error --request PUT -H "$auth" \
-H 'Content-Type: application/json' --data-binary @update.json "$url"
```
Expand Down
Loading
Loading