From 245d175cc896dba0959a3f01eab1764ac3eb0696 Mon Sep 17 00:00:00 2001 From: Barak Amar Date: Wed, 15 Nov 2023 10:11:02 +0200 Subject: [PATCH] Long running dump and restore capability (#6975) --- api/swagger.yml | 166 +++ clients/java-legacy/.openapi-generator/FILES | 9 + clients/java-legacy/README.md | 7 + clients/java-legacy/api/openapi.yaml | 268 ++++ clients/java-legacy/docs/RepositoriesApi.md | 380 ++++++ .../java-legacy/docs/RepositoryDumpStatus.md | 17 + .../docs/RepositoryRestoreStatus.md | 16 + clients/java-legacy/docs/TaskInfo.md | 13 + .../lakefs/clients/api/RepositoriesApi.java | 559 ++++++++ .../api/model/RepositoryDumpStatus.java | 216 +++ .../api/model/RepositoryRestoreStatus.java | 186 +++ .../io/lakefs/clients/api/model/TaskInfo.java | 98 ++ .../clients/api/RepositoriesApiTest.java | 67 + .../api/model/RepositoryDumpStatusTest.java | 85 ++ .../model/RepositoryRestoreStatusTest.java | 76 ++ .../clients/api/model/TaskInfoTest.java | 51 + clients/java/README.md | 7 + clients/java/api/openapi.yaml | 268 ++++ clients/java/docs/RepositoriesApi.md | 384 ++++++ clients/java/docs/RepositoryDumpStatus.md | 17 + clients/java/docs/RepositoryRestoreStatus.md | 16 + clients/java/docs/TaskInfo.md | 13 + .../main/java/io/lakefs/clients/sdk/JSON.java | 3 + .../lakefs/clients/sdk/RepositoriesApi.java | 1163 ++++++++++++++--- .../sdk/model/RepositoryDumpStatus.java | 416 ++++++ .../sdk/model/RepositoryRestoreStatus.java | 383 ++++++ .../io/lakefs/clients/sdk/model/TaskInfo.java | 293 +++++ .../clients/sdk/RepositoriesApiTest.java | 59 + .../sdk/model/RepositoryDumpStatusTest.java | 82 ++ .../model/RepositoryRestoreStatusTest.java | 73 ++ .../clients/sdk/model/TaskInfoTest.java | 48 + .../python-legacy/.openapi-generator/FILES | 9 + clients/python-legacy/README.md | 7 + clients/python-legacy/docs/RepositoriesApi.md | 449 +++++++ .../docs/RepositoryDumpStatus.md | 16 + .../docs/RepositoryRestoreStatus.md | 15 + clients/python-legacy/docs/TaskInfo.md | 12 + .../lakefs_client/api/repositories_api.py | 515 ++++++++ .../model/repository_dump_status.py | 288 ++++ .../model/repository_restore_status.py | 278 ++++ .../lakefs_client/model/task_info.py | 262 ++++ .../lakefs_client/models/__init__.py | 3 + .../test/test_repositories_api.py | 28 + .../test/test_repository_dump_status.py | 38 + .../test/test_repository_restore_status.py | 36 + clients/python-legacy/test/test_task_info.py | 36 + clients/python/.openapi-generator/FILES | 9 + clients/python/README.md | 7 + clients/python/docs/RepositoriesApi.md | 453 +++++++ clients/python/docs/RepositoryDumpStatus.md | 33 + .../python/docs/RepositoryRestoreStatus.md | 32 + clients/python/docs/TaskInfo.md | 29 + clients/python/lakefs_sdk/__init__.py | 3 + .../python/lakefs_sdk/api/repositories_api.py | 597 +++++++++ clients/python/lakefs_sdk/models/__init__.py | 3 + .../models/repository_dump_status.py | 84 ++ .../models/repository_restore_status.py | 78 ++ clients/python/lakefs_sdk/models/task_info.py | 72 + clients/python/test/test_repositories_api.py | 28 + .../test/test_repository_dump_status.py | 65 + .../test/test_repository_restore_status.py | 61 + clients/python/test/test_task_info.py | 56 + cmd/lakectl/cmd/common_helpers.go | 8 +- cmd/lakectl/cmd/refs_dump.go | 99 +- cmd/lakectl/cmd/refs_restore.go | 56 +- cmd/lakefs/cmd/run.go | 58 +- docs/assets/js/swagger.yml | 166 +++ docs/reference/cli.md | 11 +- pkg/api/controller.go | 191 ++- pkg/api/controller_test.go | 152 +++ pkg/catalog/catalog.go | 233 ++++ pkg/catalog/catalog.pb.go | 435 +++++- pkg/catalog/catalog.proto | 35 + pkg/catalog/errors.go | 2 + pkg/catalog/task.go | 53 + 75 files changed, 10269 insertions(+), 271 deletions(-) create mode 100644 clients/java-legacy/docs/RepositoryDumpStatus.md create mode 100644 clients/java-legacy/docs/RepositoryRestoreStatus.md create mode 100644 clients/java-legacy/docs/TaskInfo.md create mode 100644 clients/java-legacy/src/main/java/io/lakefs/clients/api/model/RepositoryDumpStatus.java create mode 100644 clients/java-legacy/src/main/java/io/lakefs/clients/api/model/RepositoryRestoreStatus.java create mode 100644 clients/java-legacy/src/main/java/io/lakefs/clients/api/model/TaskInfo.java create mode 100644 clients/java-legacy/src/test/java/io/lakefs/clients/api/model/RepositoryDumpStatusTest.java create mode 100644 clients/java-legacy/src/test/java/io/lakefs/clients/api/model/RepositoryRestoreStatusTest.java create mode 100644 clients/java-legacy/src/test/java/io/lakefs/clients/api/model/TaskInfoTest.java create mode 100644 clients/java/docs/RepositoryDumpStatus.md create mode 100644 clients/java/docs/RepositoryRestoreStatus.md create mode 100644 clients/java/docs/TaskInfo.md create mode 100644 clients/java/src/main/java/io/lakefs/clients/sdk/model/RepositoryDumpStatus.java create mode 100644 clients/java/src/main/java/io/lakefs/clients/sdk/model/RepositoryRestoreStatus.java create mode 100644 clients/java/src/main/java/io/lakefs/clients/sdk/model/TaskInfo.java create mode 100644 clients/java/src/test/java/io/lakefs/clients/sdk/model/RepositoryDumpStatusTest.java create mode 100644 clients/java/src/test/java/io/lakefs/clients/sdk/model/RepositoryRestoreStatusTest.java create mode 100644 clients/java/src/test/java/io/lakefs/clients/sdk/model/TaskInfoTest.java create mode 100644 clients/python-legacy/docs/RepositoryDumpStatus.md create mode 100644 clients/python-legacy/docs/RepositoryRestoreStatus.md create mode 100644 clients/python-legacy/docs/TaskInfo.md create mode 100644 clients/python-legacy/lakefs_client/model/repository_dump_status.py create mode 100644 clients/python-legacy/lakefs_client/model/repository_restore_status.py create mode 100644 clients/python-legacy/lakefs_client/model/task_info.py create mode 100644 clients/python-legacy/test/test_repository_dump_status.py create mode 100644 clients/python-legacy/test/test_repository_restore_status.py create mode 100644 clients/python-legacy/test/test_task_info.py create mode 100644 clients/python/docs/RepositoryDumpStatus.md create mode 100644 clients/python/docs/RepositoryRestoreStatus.md create mode 100644 clients/python/docs/TaskInfo.md create mode 100644 clients/python/lakefs_sdk/models/repository_dump_status.py create mode 100644 clients/python/lakefs_sdk/models/repository_restore_status.py create mode 100644 clients/python/lakefs_sdk/models/task_info.py create mode 100644 clients/python/test/test_repository_dump_status.py create mode 100644 clients/python/test/test_repository_restore_status.py create mode 100644 clients/python/test/test_task_info.py create mode 100644 pkg/catalog/task.go diff --git a/api/swagger.yml b/api/swagger.yml index 04cd69a5398..b12b2f39508 100644 --- a/api/swagger.yml +++ b/api/swagger.yml @@ -594,6 +594,53 @@ components: ref: type: string + TaskInfo: + type: object + required: + - id + properties: + id: + type: string + description: ID of the task + + RepositoryDumpStatus: + type: object + required: + - id + - done + - update_time + properties: + id: + type: string + description: ID of the task + done: + type: boolean + update_time: + type: string + format: date-time + error: + type: string + refs: + $ref: "#/components/schemas/RefsDump" + + RepositoryRestoreStatus: + type: object + required: + - id + - done + - update_time + properties: + id: + type: string + description: ID of the task + done: + type: boolean + update_time: + type: string + format: date-time + error: + type: string + RefsDump: type: object required: @@ -2686,6 +2733,125 @@ paths: default: $ref: "#/components/responses/ServerError" + + /repositories/{repository}/dump: + parameters: + - in: path + name: repository + required: true + schema: + type: string + post: + tags: + - repositories + operationId: dumpSubmit + summary: Backup the repository metadata (tags, commits, branches) and save the backup to the object store. + responses: + 202: + description: dump task information + content: + application/json: + schema: + $ref: "#/components/schemas/TaskInfo" + 400: + $ref: "#/components/responses/ValidationError" + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + default: + $ref: "#/components/responses/ServerError" + get: + tags: + - repositories + operationId: dumpStatus + summary: Status of a repository dump task + parameters: + - in: query + name: task_id + required: true + schema: + type: string + responses: + 200: + description: dump task status + content: + application/json: + schema: + $ref: "#/components/schemas/RepositoryDumpStatus" + 400: + $ref: "#/components/responses/ValidationError" + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + 420: + description: too many requests + default: + $ref: "#/components/responses/ServerError" + + /repositories/{repository}/restore: + parameters: + - in: path + name: repository + required: true + schema: + type: string + post: + tags: + - repositories + operationId: restoreSubmit + summary: Restore repository from a dump in the object store + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/RefsDump" + responses: + 202: + description: restore task created + content: + application/json: + schema: + $ref: "#/components/schemas/TaskInfo" + 400: + $ref: "#/components/responses/ValidationError" + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + default: + $ref: "#/components/responses/ServerError" + get: + tags: + - repositories + operationId: restoreStatus + summary: Status of a restore request + parameters: + - in: query + name: task_id + required: true + schema: + type: string + responses: + 200: + description: restore task status + content: + application/json: + schema: + $ref: "#/components/schemas/RepositoryRestoreStatus" + 400: + $ref: "#/components/responses/ValidationError" + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + 420: + description: too many requests + default: + $ref: "#/components/responses/ServerError" + /repositories/{repository}/tags: parameters: - in: path diff --git a/clients/java-legacy/.openapi-generator/FILES b/clients/java-legacy/.openapi-generator/FILES index f4bb3d8dbb3..5d04c93464e 100644 --- a/clients/java-legacy/.openapi-generator/FILES +++ b/clients/java-legacy/.openapi-generator/FILES @@ -84,7 +84,9 @@ docs/RefsDump.md docs/RepositoriesApi.md docs/Repository.md docs/RepositoryCreation.md +docs/RepositoryDumpStatus.md docs/RepositoryList.md +docs/RepositoryRestoreStatus.md docs/ResetCreation.md docs/RevertCreation.md docs/Setup.md @@ -99,6 +101,7 @@ docs/StorageConfig.md docs/StorageURI.md docs/TagCreation.md docs/TagsApi.md +docs/TaskInfo.md docs/UnderlyingObjectProperties.md docs/UpdateToken.md docs/User.md @@ -212,7 +215,9 @@ src/main/java/io/lakefs/clients/api/model/RefList.java src/main/java/io/lakefs/clients/api/model/RefsDump.java src/main/java/io/lakefs/clients/api/model/Repository.java src/main/java/io/lakefs/clients/api/model/RepositoryCreation.java +src/main/java/io/lakefs/clients/api/model/RepositoryDumpStatus.java src/main/java/io/lakefs/clients/api/model/RepositoryList.java +src/main/java/io/lakefs/clients/api/model/RepositoryRestoreStatus.java src/main/java/io/lakefs/clients/api/model/ResetCreation.java src/main/java/io/lakefs/clients/api/model/RevertCreation.java src/main/java/io/lakefs/clients/api/model/Setup.java @@ -225,6 +230,7 @@ src/main/java/io/lakefs/clients/api/model/StatsEventsList.java src/main/java/io/lakefs/clients/api/model/StorageConfig.java src/main/java/io/lakefs/clients/api/model/StorageURI.java src/main/java/io/lakefs/clients/api/model/TagCreation.java +src/main/java/io/lakefs/clients/api/model/TaskInfo.java src/main/java/io/lakefs/clients/api/model/UnderlyingObjectProperties.java src/main/java/io/lakefs/clients/api/model/UpdateToken.java src/main/java/io/lakefs/clients/api/model/User.java @@ -311,7 +317,9 @@ src/test/java/io/lakefs/clients/api/model/RefListTest.java src/test/java/io/lakefs/clients/api/model/RefTest.java src/test/java/io/lakefs/clients/api/model/RefsDumpTest.java src/test/java/io/lakefs/clients/api/model/RepositoryCreationTest.java +src/test/java/io/lakefs/clients/api/model/RepositoryDumpStatusTest.java src/test/java/io/lakefs/clients/api/model/RepositoryListTest.java +src/test/java/io/lakefs/clients/api/model/RepositoryRestoreStatusTest.java src/test/java/io/lakefs/clients/api/model/RepositoryTest.java src/test/java/io/lakefs/clients/api/model/ResetCreationTest.java src/test/java/io/lakefs/clients/api/model/RevertCreationTest.java @@ -325,6 +333,7 @@ src/test/java/io/lakefs/clients/api/model/StatsEventsListTest.java src/test/java/io/lakefs/clients/api/model/StorageConfigTest.java src/test/java/io/lakefs/clients/api/model/StorageURITest.java src/test/java/io/lakefs/clients/api/model/TagCreationTest.java +src/test/java/io/lakefs/clients/api/model/TaskInfoTest.java src/test/java/io/lakefs/clients/api/model/UnderlyingObjectPropertiesTest.java src/test/java/io/lakefs/clients/api/model/UpdateTokenTest.java src/test/java/io/lakefs/clients/api/model/UserCreationTest.java diff --git a/clients/java-legacy/README.md b/clients/java-legacy/README.md index 4988fc95aa3..0100e5ec864 100644 --- a/clients/java-legacy/README.md +++ b/clients/java-legacy/README.md @@ -228,11 +228,15 @@ Class | Method | HTTP request | Description *RepositoriesApi* | [**createRepository**](docs/RepositoriesApi.md#createRepository) | **POST** /repositories | create repository *RepositoriesApi* | [**deleteGCRules**](docs/RepositoriesApi.md#deleteGCRules) | **DELETE** /repositories/{repository}/settings/gc_rules | *RepositoriesApi* | [**deleteRepository**](docs/RepositoriesApi.md#deleteRepository) | **DELETE** /repositories/{repository} | delete repository +*RepositoriesApi* | [**dumpStatus**](docs/RepositoriesApi.md#dumpStatus) | **GET** /repositories/{repository}/dump | Status of a repository dump task +*RepositoriesApi* | [**dumpSubmit**](docs/RepositoriesApi.md#dumpSubmit) | **POST** /repositories/{repository}/dump | Backup the repository metadata (tags, commits, branches) and save the backup to the object store. *RepositoriesApi* | [**getBranchProtectionRules**](docs/RepositoriesApi.md#getBranchProtectionRules) | **GET** /repositories/{repository}/settings/branch_protection | get branch protection rules *RepositoriesApi* | [**getGCRules**](docs/RepositoriesApi.md#getGCRules) | **GET** /repositories/{repository}/settings/gc_rules | get repository GC rules *RepositoriesApi* | [**getRepository**](docs/RepositoriesApi.md#getRepository) | **GET** /repositories/{repository} | get repository *RepositoriesApi* | [**getRepositoryMetadata**](docs/RepositoriesApi.md#getRepositoryMetadata) | **GET** /repositories/{repository}/metadata | get repository metadata *RepositoriesApi* | [**listRepositories**](docs/RepositoriesApi.md#listRepositories) | **GET** /repositories | list repositories +*RepositoriesApi* | [**restoreStatus**](docs/RepositoriesApi.md#restoreStatus) | **GET** /repositories/{repository}/restore | Status of a restore request +*RepositoriesApi* | [**restoreSubmit**](docs/RepositoriesApi.md#restoreSubmit) | **POST** /repositories/{repository}/restore | Restore repository from a dump in the object store *RepositoriesApi* | [**setBranchProtectionRules**](docs/RepositoriesApi.md#setBranchProtectionRules) | **PUT** /repositories/{repository}/settings/branch_protection | *RepositoriesApi* | [**setGCRules**](docs/RepositoriesApi.md#setGCRules) | **PUT** /repositories/{repository}/settings/gc_rules | *StagingApi* | [**getPhysicalAddress**](docs/StagingApi.md#getPhysicalAddress) | **GET** /repositories/{repository}/branches/{branch}/staging/backing | generate an address to which the client can upload an object @@ -311,7 +315,9 @@ Class | Method | HTTP request | Description - [RefsDump](docs/RefsDump.md) - [Repository](docs/Repository.md) - [RepositoryCreation](docs/RepositoryCreation.md) + - [RepositoryDumpStatus](docs/RepositoryDumpStatus.md) - [RepositoryList](docs/RepositoryList.md) + - [RepositoryRestoreStatus](docs/RepositoryRestoreStatus.md) - [ResetCreation](docs/ResetCreation.md) - [RevertCreation](docs/RevertCreation.md) - [Setup](docs/Setup.md) @@ -324,6 +330,7 @@ Class | Method | HTTP request | Description - [StorageConfig](docs/StorageConfig.md) - [StorageURI](docs/StorageURI.md) - [TagCreation](docs/TagCreation.md) + - [TaskInfo](docs/TaskInfo.md) - [UnderlyingObjectProperties](docs/UnderlyingObjectProperties.md) - [UpdateToken](docs/UpdateToken.md) - [User](docs/User.md) diff --git a/clients/java-legacy/api/openapi.yaml b/clients/java-legacy/api/openapi.yaml index 41b0a7d53dd..ef51906e752 100644 --- a/clients/java-legacy/api/openapi.yaml +++ b/clients/java-legacy/api/openapi.yaml @@ -2303,6 +2303,214 @@ paths: - internal x-contentType: application/json x-accepts: application/json + /repositories/{repository}/dump: + get: + operationId: dumpStatus + parameters: + - explode: false + in: path + name: repository + required: true + schema: + type: string + style: simple + - explode: true + in: query + name: task_id + required: true + schema: + type: string + style: form + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/RepositoryDumpStatus' + description: dump task status + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Validation Error + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Unauthorized + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Resource Not Found + "420": + description: too many requests + default: + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Internal Server Error + summary: Status of a repository dump task + tags: + - repositories + x-accepts: application/json + post: + operationId: dumpSubmit + parameters: + - explode: false + in: path + name: repository + required: true + schema: + type: string + style: simple + responses: + "202": + content: + application/json: + schema: + $ref: '#/components/schemas/TaskInfo' + description: dump task information + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Validation Error + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Unauthorized + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Resource Not Found + default: + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Internal Server Error + summary: Backup the repository metadata (tags, commits, branches) and save the + backup to the object store. + tags: + - repositories + x-accepts: application/json + /repositories/{repository}/restore: + get: + operationId: restoreStatus + parameters: + - explode: false + in: path + name: repository + required: true + schema: + type: string + style: simple + - explode: true + in: query + name: task_id + required: true + schema: + type: string + style: form + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/RepositoryRestoreStatus' + description: restore task status + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Validation Error + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Unauthorized + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Resource Not Found + "420": + description: too many requests + default: + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Internal Server Error + summary: Status of a restore request + tags: + - repositories + x-accepts: application/json + post: + operationId: restoreSubmit + parameters: + - explode: false + in: path + name: repository + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RefsDump' + required: true + responses: + "202": + content: + application/json: + schema: + $ref: '#/components/schemas/TaskInfo' + description: restore task created + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Validation Error + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Unauthorized + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Resource Not Found + default: + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Internal Server Error + summary: Restore repository from a dump in the object store + tags: + - repositories + x-contentType: application/json + x-accepts: application/json /repositories/{repository}/tags: get: operationId: listTags @@ -6546,6 +6754,66 @@ components: - id - ref type: object + TaskInfo: + example: + id: id + properties: + id: + description: ID of the task + type: string + required: + - id + type: object + RepositoryDumpStatus: + example: + update_time: 2000-01-23T04:56:07.000+00:00 + refs: + tags_meta_range_id: tags_meta_range_id + branches_meta_range_id: branches_meta_range_id + commits_meta_range_id: commits_meta_range_id + id: id + error: error + done: true + properties: + id: + description: ID of the task + type: string + done: + type: boolean + update_time: + format: date-time + type: string + error: + type: string + refs: + $ref: '#/components/schemas/RefsDump' + required: + - done + - id + - update_time + type: object + RepositoryRestoreStatus: + example: + update_time: 2000-01-23T04:56:07.000+00:00 + id: id + error: error + done: true + properties: + id: + description: ID of the task + type: string + done: + type: boolean + update_time: + format: date-time + type: string + error: + type: string + required: + - done + - id + - update_time + type: object RefsDump: example: tags_meta_range_id: tags_meta_range_id diff --git a/clients/java-legacy/docs/RepositoriesApi.md b/clients/java-legacy/docs/RepositoriesApi.md index abf8980ce6d..cc325763ab3 100644 --- a/clients/java-legacy/docs/RepositoriesApi.md +++ b/clients/java-legacy/docs/RepositoriesApi.md @@ -7,11 +7,15 @@ Method | HTTP request | Description [**createRepository**](RepositoriesApi.md#createRepository) | **POST** /repositories | create repository [**deleteGCRules**](RepositoriesApi.md#deleteGCRules) | **DELETE** /repositories/{repository}/settings/gc_rules | [**deleteRepository**](RepositoriesApi.md#deleteRepository) | **DELETE** /repositories/{repository} | delete repository +[**dumpStatus**](RepositoriesApi.md#dumpStatus) | **GET** /repositories/{repository}/dump | Status of a repository dump task +[**dumpSubmit**](RepositoriesApi.md#dumpSubmit) | **POST** /repositories/{repository}/dump | Backup the repository metadata (tags, commits, branches) and save the backup to the object store. [**getBranchProtectionRules**](RepositoriesApi.md#getBranchProtectionRules) | **GET** /repositories/{repository}/settings/branch_protection | get branch protection rules [**getGCRules**](RepositoriesApi.md#getGCRules) | **GET** /repositories/{repository}/settings/gc_rules | get repository GC rules [**getRepository**](RepositoriesApi.md#getRepository) | **GET** /repositories/{repository} | get repository [**getRepositoryMetadata**](RepositoriesApi.md#getRepositoryMetadata) | **GET** /repositories/{repository}/metadata | get repository metadata [**listRepositories**](RepositoriesApi.md#listRepositories) | **GET** /repositories | list repositories +[**restoreStatus**](RepositoriesApi.md#restoreStatus) | **GET** /repositories/{repository}/restore | Status of a restore request +[**restoreSubmit**](RepositoriesApi.md#restoreSubmit) | **POST** /repositories/{repository}/restore | Restore repository from a dump in the object store [**setBranchProtectionRules**](RepositoriesApi.md#setBranchProtectionRules) | **PUT** /repositories/{repository}/settings/branch_protection | [**setGCRules**](RepositoriesApi.md#setGCRules) | **PUT** /repositories/{repository}/settings/gc_rules | @@ -293,6 +297,193 @@ null (empty response body) **420** | too many requests | - | **0** | Internal Server Error | - | + +# **dumpStatus** +> RepositoryDumpStatus dumpStatus(repository, taskId) + +Status of a repository dump task + +### Example +```java +// Import classes: +import io.lakefs.clients.api.ApiClient; +import io.lakefs.clients.api.ApiException; +import io.lakefs.clients.api.Configuration; +import io.lakefs.clients.api.auth.*; +import io.lakefs.clients.api.models.*; +import io.lakefs.clients.api.RepositoriesApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost/api/v1"); + + // Configure HTTP basic authorization: basic_auth + HttpBasicAuth basic_auth = (HttpBasicAuth) defaultClient.getAuthentication("basic_auth"); + basic_auth.setUsername("YOUR USERNAME"); + basic_auth.setPassword("YOUR PASSWORD"); + + // Configure API key authorization: cookie_auth + ApiKeyAuth cookie_auth = (ApiKeyAuth) defaultClient.getAuthentication("cookie_auth"); + cookie_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //cookie_auth.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: jwt_token + HttpBearerAuth jwt_token = (HttpBearerAuth) defaultClient.getAuthentication("jwt_token"); + jwt_token.setBearerToken("BEARER TOKEN"); + + // Configure API key authorization: oidc_auth + ApiKeyAuth oidc_auth = (ApiKeyAuth) defaultClient.getAuthentication("oidc_auth"); + oidc_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //oidc_auth.setApiKeyPrefix("Token"); + + // Configure API key authorization: saml_auth + ApiKeyAuth saml_auth = (ApiKeyAuth) defaultClient.getAuthentication("saml_auth"); + saml_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //saml_auth.setApiKeyPrefix("Token"); + + RepositoriesApi apiInstance = new RepositoriesApi(defaultClient); + String repository = "repository_example"; // String | + String taskId = "taskId_example"; // String | + try { + RepositoryDumpStatus result = apiInstance.dumpStatus(repository, taskId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling RepositoriesApi#dumpStatus"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **String**| | + **taskId** | **String**| | + +### Return type + +[**RepositoryDumpStatus**](RepositoryDumpStatus.md) + +### Authorization + +[basic_auth](../README.md#basic_auth), [cookie_auth](../README.md#cookie_auth), [jwt_token](../README.md#jwt_token), [oidc_auth](../README.md#oidc_auth), [saml_auth](../README.md#saml_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | dump task status | - | +**400** | Validation Error | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**420** | too many requests | - | +**0** | Internal Server Error | - | + + +# **dumpSubmit** +> TaskInfo dumpSubmit(repository) + +Backup the repository metadata (tags, commits, branches) and save the backup to the object store. + +### Example +```java +// Import classes: +import io.lakefs.clients.api.ApiClient; +import io.lakefs.clients.api.ApiException; +import io.lakefs.clients.api.Configuration; +import io.lakefs.clients.api.auth.*; +import io.lakefs.clients.api.models.*; +import io.lakefs.clients.api.RepositoriesApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost/api/v1"); + + // Configure HTTP basic authorization: basic_auth + HttpBasicAuth basic_auth = (HttpBasicAuth) defaultClient.getAuthentication("basic_auth"); + basic_auth.setUsername("YOUR USERNAME"); + basic_auth.setPassword("YOUR PASSWORD"); + + // Configure API key authorization: cookie_auth + ApiKeyAuth cookie_auth = (ApiKeyAuth) defaultClient.getAuthentication("cookie_auth"); + cookie_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //cookie_auth.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: jwt_token + HttpBearerAuth jwt_token = (HttpBearerAuth) defaultClient.getAuthentication("jwt_token"); + jwt_token.setBearerToken("BEARER TOKEN"); + + // Configure API key authorization: oidc_auth + ApiKeyAuth oidc_auth = (ApiKeyAuth) defaultClient.getAuthentication("oidc_auth"); + oidc_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //oidc_auth.setApiKeyPrefix("Token"); + + // Configure API key authorization: saml_auth + ApiKeyAuth saml_auth = (ApiKeyAuth) defaultClient.getAuthentication("saml_auth"); + saml_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //saml_auth.setApiKeyPrefix("Token"); + + RepositoriesApi apiInstance = new RepositoriesApi(defaultClient); + String repository = "repository_example"; // String | + try { + TaskInfo result = apiInstance.dumpSubmit(repository); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling RepositoriesApi#dumpSubmit"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **String**| | + +### Return type + +[**TaskInfo**](TaskInfo.md) + +### Authorization + +[basic_auth](../README.md#basic_auth), [cookie_auth](../README.md#cookie_auth), [jwt_token](../README.md#jwt_token), [oidc_auth](../README.md#oidc_auth), [saml_auth](../README.md#saml_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**202** | dump task information | - | +**400** | Validation Error | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**0** | Internal Server Error | - | + # **getBranchProtectionRules** > List<BranchProtectionRule> getBranchProtectionRules(repository) @@ -756,6 +947,195 @@ Name | Type | Description | Notes **420** | too many requests | - | **0** | Internal Server Error | - | + +# **restoreStatus** +> RepositoryRestoreStatus restoreStatus(repository, taskId) + +Status of a restore request + +### Example +```java +// Import classes: +import io.lakefs.clients.api.ApiClient; +import io.lakefs.clients.api.ApiException; +import io.lakefs.clients.api.Configuration; +import io.lakefs.clients.api.auth.*; +import io.lakefs.clients.api.models.*; +import io.lakefs.clients.api.RepositoriesApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost/api/v1"); + + // Configure HTTP basic authorization: basic_auth + HttpBasicAuth basic_auth = (HttpBasicAuth) defaultClient.getAuthentication("basic_auth"); + basic_auth.setUsername("YOUR USERNAME"); + basic_auth.setPassword("YOUR PASSWORD"); + + // Configure API key authorization: cookie_auth + ApiKeyAuth cookie_auth = (ApiKeyAuth) defaultClient.getAuthentication("cookie_auth"); + cookie_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //cookie_auth.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: jwt_token + HttpBearerAuth jwt_token = (HttpBearerAuth) defaultClient.getAuthentication("jwt_token"); + jwt_token.setBearerToken("BEARER TOKEN"); + + // Configure API key authorization: oidc_auth + ApiKeyAuth oidc_auth = (ApiKeyAuth) defaultClient.getAuthentication("oidc_auth"); + oidc_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //oidc_auth.setApiKeyPrefix("Token"); + + // Configure API key authorization: saml_auth + ApiKeyAuth saml_auth = (ApiKeyAuth) defaultClient.getAuthentication("saml_auth"); + saml_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //saml_auth.setApiKeyPrefix("Token"); + + RepositoriesApi apiInstance = new RepositoriesApi(defaultClient); + String repository = "repository_example"; // String | + String taskId = "taskId_example"; // String | + try { + RepositoryRestoreStatus result = apiInstance.restoreStatus(repository, taskId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling RepositoriesApi#restoreStatus"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **String**| | + **taskId** | **String**| | + +### Return type + +[**RepositoryRestoreStatus**](RepositoryRestoreStatus.md) + +### Authorization + +[basic_auth](../README.md#basic_auth), [cookie_auth](../README.md#cookie_auth), [jwt_token](../README.md#jwt_token), [oidc_auth](../README.md#oidc_auth), [saml_auth](../README.md#saml_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | restore task status | - | +**400** | Validation Error | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**420** | too many requests | - | +**0** | Internal Server Error | - | + + +# **restoreSubmit** +> TaskInfo restoreSubmit(repository, refsDump) + +Restore repository from a dump in the object store + +### Example +```java +// Import classes: +import io.lakefs.clients.api.ApiClient; +import io.lakefs.clients.api.ApiException; +import io.lakefs.clients.api.Configuration; +import io.lakefs.clients.api.auth.*; +import io.lakefs.clients.api.models.*; +import io.lakefs.clients.api.RepositoriesApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost/api/v1"); + + // Configure HTTP basic authorization: basic_auth + HttpBasicAuth basic_auth = (HttpBasicAuth) defaultClient.getAuthentication("basic_auth"); + basic_auth.setUsername("YOUR USERNAME"); + basic_auth.setPassword("YOUR PASSWORD"); + + // Configure API key authorization: cookie_auth + ApiKeyAuth cookie_auth = (ApiKeyAuth) defaultClient.getAuthentication("cookie_auth"); + cookie_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //cookie_auth.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: jwt_token + HttpBearerAuth jwt_token = (HttpBearerAuth) defaultClient.getAuthentication("jwt_token"); + jwt_token.setBearerToken("BEARER TOKEN"); + + // Configure API key authorization: oidc_auth + ApiKeyAuth oidc_auth = (ApiKeyAuth) defaultClient.getAuthentication("oidc_auth"); + oidc_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //oidc_auth.setApiKeyPrefix("Token"); + + // Configure API key authorization: saml_auth + ApiKeyAuth saml_auth = (ApiKeyAuth) defaultClient.getAuthentication("saml_auth"); + saml_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //saml_auth.setApiKeyPrefix("Token"); + + RepositoriesApi apiInstance = new RepositoriesApi(defaultClient); + String repository = "repository_example"; // String | + RefsDump refsDump = new RefsDump(); // RefsDump | + try { + TaskInfo result = apiInstance.restoreSubmit(repository, refsDump); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling RepositoriesApi#restoreSubmit"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **String**| | + **refsDump** | [**RefsDump**](RefsDump.md)| | + +### Return type + +[**TaskInfo**](TaskInfo.md) + +### Authorization + +[basic_auth](../README.md#basic_auth), [cookie_auth](../README.md#cookie_auth), [jwt_token](../README.md#jwt_token), [oidc_auth](../README.md#oidc_auth), [saml_auth](../README.md#saml_auth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**202** | restore task created | - | +**400** | Validation Error | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**0** | Internal Server Error | - | + # **setBranchProtectionRules** > setBranchProtectionRules(repository, branchProtectionRule, ifMatch) diff --git a/clients/java-legacy/docs/RepositoryDumpStatus.md b/clients/java-legacy/docs/RepositoryDumpStatus.md new file mode 100644 index 00000000000..b01bc10a688 --- /dev/null +++ b/clients/java-legacy/docs/RepositoryDumpStatus.md @@ -0,0 +1,17 @@ + + +# RepositoryDumpStatus + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | ID of the task | +**done** | **Boolean** | | +**updateTime** | **OffsetDateTime** | | +**error** | **String** | | [optional] +**refs** | [**RefsDump**](RefsDump.md) | | [optional] + + + diff --git a/clients/java-legacy/docs/RepositoryRestoreStatus.md b/clients/java-legacy/docs/RepositoryRestoreStatus.md new file mode 100644 index 00000000000..d058b185eb4 --- /dev/null +++ b/clients/java-legacy/docs/RepositoryRestoreStatus.md @@ -0,0 +1,16 @@ + + +# RepositoryRestoreStatus + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | ID of the task | +**done** | **Boolean** | | +**updateTime** | **OffsetDateTime** | | +**error** | **String** | | [optional] + + + diff --git a/clients/java-legacy/docs/TaskInfo.md b/clients/java-legacy/docs/TaskInfo.md new file mode 100644 index 00000000000..2286cb19873 --- /dev/null +++ b/clients/java-legacy/docs/TaskInfo.md @@ -0,0 +1,13 @@ + + +# TaskInfo + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **String** | ID of the task | + + + diff --git a/clients/java-legacy/src/main/java/io/lakefs/clients/api/RepositoriesApi.java b/clients/java-legacy/src/main/java/io/lakefs/clients/api/RepositoriesApi.java index 080ff1c98a9..0eb71877e55 100644 --- a/clients/java-legacy/src/main/java/io/lakefs/clients/api/RepositoriesApi.java +++ b/clients/java-legacy/src/main/java/io/lakefs/clients/api/RepositoriesApi.java @@ -30,9 +30,13 @@ import io.lakefs.clients.api.model.BranchProtectionRule; import io.lakefs.clients.api.model.Error; import io.lakefs.clients.api.model.GarbageCollectionRules; +import io.lakefs.clients.api.model.RefsDump; import io.lakefs.clients.api.model.Repository; import io.lakefs.clients.api.model.RepositoryCreation; +import io.lakefs.clients.api.model.RepositoryDumpStatus; import io.lakefs.clients.api.model.RepositoryList; +import io.lakefs.clients.api.model.RepositoryRestoreStatus; +import io.lakefs.clients.api.model.TaskInfo; import java.lang.reflect.Type; import java.util.ArrayList; @@ -446,6 +450,279 @@ public okhttp3.Call deleteRepositoryAsync(String repository, final ApiCallback + Status Code Description Response Headers + 200 dump task status - + 400 Validation Error - + 401 Unauthorized - + 404 Resource Not Found - + 420 too many requests - + 0 Internal Server Error - + + */ + public okhttp3.Call dumpStatusCall(String repository, String taskId, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/repositories/{repository}/dump" + .replaceAll("\\{" + "repository" + "\\}", localVarApiClient.escapeString(repository.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (taskId != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("task_id", taskId)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "basic_auth", "cookie_auth", "jwt_token", "oidc_auth", "saml_auth" }; + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call dumpStatusValidateBeforeCall(String repository, String taskId, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'repository' is set + if (repository == null) { + throw new ApiException("Missing the required parameter 'repository' when calling dumpStatus(Async)"); + } + + // verify the required parameter 'taskId' is set + if (taskId == null) { + throw new ApiException("Missing the required parameter 'taskId' when calling dumpStatus(Async)"); + } + + + okhttp3.Call localVarCall = dumpStatusCall(repository, taskId, _callback); + return localVarCall; + + } + + /** + * Status of a repository dump task + * + * @param repository (required) + * @param taskId (required) + * @return RepositoryDumpStatus + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Status Code Description Response Headers
200 dump task status -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
+ */ + public RepositoryDumpStatus dumpStatus(String repository, String taskId) throws ApiException { + ApiResponse localVarResp = dumpStatusWithHttpInfo(repository, taskId); + return localVarResp.getData(); + } + + /** + * Status of a repository dump task + * + * @param repository (required) + * @param taskId (required) + * @return ApiResponse<RepositoryDumpStatus> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Status Code Description Response Headers
200 dump task status -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
+ */ + public ApiResponse dumpStatusWithHttpInfo(String repository, String taskId) throws ApiException { + okhttp3.Call localVarCall = dumpStatusValidateBeforeCall(repository, taskId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Status of a repository dump task (asynchronously) + * + * @param repository (required) + * @param taskId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Status Code Description Response Headers
200 dump task status -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
+ */ + public okhttp3.Call dumpStatusAsync(String repository, String taskId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = dumpStatusValidateBeforeCall(repository, taskId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for dumpSubmit + * @param repository (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + +
Status Code Description Response Headers
202 dump task information -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public okhttp3.Call dumpSubmitCall(String repository, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/repositories/{repository}/dump" + .replaceAll("\\{" + "repository" + "\\}", localVarApiClient.escapeString(repository.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "basic_auth", "cookie_auth", "jwt_token", "oidc_auth", "saml_auth" }; + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call dumpSubmitValidateBeforeCall(String repository, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'repository' is set + if (repository == null) { + throw new ApiException("Missing the required parameter 'repository' when calling dumpSubmit(Async)"); + } + + + okhttp3.Call localVarCall = dumpSubmitCall(repository, _callback); + return localVarCall; + + } + + /** + * Backup the repository metadata (tags, commits, branches) and save the backup to the object store. + * + * @param repository (required) + * @return TaskInfo + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
202 dump task information -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public TaskInfo dumpSubmit(String repository) throws ApiException { + ApiResponse localVarResp = dumpSubmitWithHttpInfo(repository); + return localVarResp.getData(); + } + + /** + * Backup the repository metadata (tags, commits, branches) and save the backup to the object store. + * + * @param repository (required) + * @return ApiResponse<TaskInfo> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
202 dump task information -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public ApiResponse dumpSubmitWithHttpInfo(String repository) throws ApiException { + okhttp3.Call localVarCall = dumpSubmitValidateBeforeCall(repository, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Backup the repository metadata (tags, commits, branches) and save the backup to the object store. (asynchronously) + * + * @param repository (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + +
Status Code Description Response Headers
202 dump task information -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public okhttp3.Call dumpSubmitAsync(String repository, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = dumpSubmitValidateBeforeCall(repository, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } /** * Build call for getBranchProtectionRules * @param repository (required) @@ -1096,6 +1373,288 @@ public okhttp3.Call listRepositoriesAsync(String prefix, String after, Integer a localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for restoreStatus + * @param repository (required) + * @param taskId (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Status Code Description Response Headers
200 restore task status -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
+ */ + public okhttp3.Call restoreStatusCall(String repository, String taskId, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/repositories/{repository}/restore" + .replaceAll("\\{" + "repository" + "\\}", localVarApiClient.escapeString(repository.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (taskId != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("task_id", taskId)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "basic_auth", "cookie_auth", "jwt_token", "oidc_auth", "saml_auth" }; + return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call restoreStatusValidateBeforeCall(String repository, String taskId, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'repository' is set + if (repository == null) { + throw new ApiException("Missing the required parameter 'repository' when calling restoreStatus(Async)"); + } + + // verify the required parameter 'taskId' is set + if (taskId == null) { + throw new ApiException("Missing the required parameter 'taskId' when calling restoreStatus(Async)"); + } + + + okhttp3.Call localVarCall = restoreStatusCall(repository, taskId, _callback); + return localVarCall; + + } + + /** + * Status of a restore request + * + * @param repository (required) + * @param taskId (required) + * @return RepositoryRestoreStatus + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Status Code Description Response Headers
200 restore task status -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
+ */ + public RepositoryRestoreStatus restoreStatus(String repository, String taskId) throws ApiException { + ApiResponse localVarResp = restoreStatusWithHttpInfo(repository, taskId); + return localVarResp.getData(); + } + + /** + * Status of a restore request + * + * @param repository (required) + * @param taskId (required) + * @return ApiResponse<RepositoryRestoreStatus> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Status Code Description Response Headers
200 restore task status -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
+ */ + public ApiResponse restoreStatusWithHttpInfo(String repository, String taskId) throws ApiException { + okhttp3.Call localVarCall = restoreStatusValidateBeforeCall(repository, taskId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Status of a restore request (asynchronously) + * + * @param repository (required) + * @param taskId (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Status Code Description Response Headers
200 restore task status -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
+ */ + public okhttp3.Call restoreStatusAsync(String repository, String taskId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = restoreStatusValidateBeforeCall(repository, taskId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for restoreSubmit + * @param repository (required) + * @param refsDump (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + +
Status Code Description Response Headers
202 restore task created -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public okhttp3.Call restoreSubmitCall(String repository, RefsDump refsDump, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = refsDump; + + // create path and map variables + String localVarPath = "/repositories/{repository}/restore" + .replaceAll("\\{" + "repository" + "\\}", localVarApiClient.escapeString(repository.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "basic_auth", "cookie_auth", "jwt_token", "oidc_auth", "saml_auth" }; + return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call restoreSubmitValidateBeforeCall(String repository, RefsDump refsDump, final ApiCallback _callback) throws ApiException { + + // verify the required parameter 'repository' is set + if (repository == null) { + throw new ApiException("Missing the required parameter 'repository' when calling restoreSubmit(Async)"); + } + + // verify the required parameter 'refsDump' is set + if (refsDump == null) { + throw new ApiException("Missing the required parameter 'refsDump' when calling restoreSubmit(Async)"); + } + + + okhttp3.Call localVarCall = restoreSubmitCall(repository, refsDump, _callback); + return localVarCall; + + } + + /** + * Restore repository from a dump in the object store + * + * @param repository (required) + * @param refsDump (required) + * @return TaskInfo + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
202 restore task created -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public TaskInfo restoreSubmit(String repository, RefsDump refsDump) throws ApiException { + ApiResponse localVarResp = restoreSubmitWithHttpInfo(repository, refsDump); + return localVarResp.getData(); + } + + /** + * Restore repository from a dump in the object store + * + * @param repository (required) + * @param refsDump (required) + * @return ApiResponse<TaskInfo> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
202 restore task created -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public ApiResponse restoreSubmitWithHttpInfo(String repository, RefsDump refsDump) throws ApiException { + okhttp3.Call localVarCall = restoreSubmitValidateBeforeCall(repository, refsDump, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Restore repository from a dump in the object store (asynchronously) + * + * @param repository (required) + * @param refsDump (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + +
Status Code Description Response Headers
202 restore task created -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public okhttp3.Call restoreSubmitAsync(String repository, RefsDump refsDump, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = restoreSubmitValidateBeforeCall(repository, refsDump, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } /** * Build call for setBranchProtectionRules * @param repository (required) diff --git a/clients/java-legacy/src/main/java/io/lakefs/clients/api/model/RepositoryDumpStatus.java b/clients/java-legacy/src/main/java/io/lakefs/clients/api/model/RepositoryDumpStatus.java new file mode 100644 index 00000000000..03fbeb1beb6 --- /dev/null +++ b/clients/java-legacy/src/main/java/io/lakefs/clients/api/model/RepositoryDumpStatus.java @@ -0,0 +1,216 @@ +/* + * lakeFS API + * lakeFS HTTP API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lakefs.clients.api.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.lakefs.clients.api.model.RefsDump; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import org.threeten.bp.OffsetDateTime; + +/** + * RepositoryDumpStatus + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class RepositoryDumpStatus { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + private Boolean done; + + public static final String SERIALIZED_NAME_UPDATE_TIME = "update_time"; + @SerializedName(SERIALIZED_NAME_UPDATE_TIME) + private OffsetDateTime updateTime; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + private String error; + + public static final String SERIALIZED_NAME_REFS = "refs"; + @SerializedName(SERIALIZED_NAME_REFS) + private RefsDump refs; + + + public RepositoryDumpStatus id(String id) { + + this.id = id; + return this; + } + + /** + * ID of the task + * @return id + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "ID of the task") + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public RepositoryDumpStatus done(Boolean done) { + + this.done = done; + return this; + } + + /** + * Get done + * @return done + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public Boolean getDone() { + return done; + } + + + public void setDone(Boolean done) { + this.done = done; + } + + + public RepositoryDumpStatus updateTime(OffsetDateTime updateTime) { + + this.updateTime = updateTime; + return this; + } + + /** + * Get updateTime + * @return updateTime + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public OffsetDateTime getUpdateTime() { + return updateTime; + } + + + public void setUpdateTime(OffsetDateTime updateTime) { + this.updateTime = updateTime; + } + + + public RepositoryDumpStatus error(String error) { + + this.error = error; + return this; + } + + /** + * Get error + * @return error + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getError() { + return error; + } + + + public void setError(String error) { + this.error = error; + } + + + public RepositoryDumpStatus refs(RefsDump refs) { + + this.refs = refs; + return this; + } + + /** + * Get refs + * @return refs + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public RefsDump getRefs() { + return refs; + } + + + public void setRefs(RefsDump refs) { + this.refs = refs; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RepositoryDumpStatus repositoryDumpStatus = (RepositoryDumpStatus) o; + return Objects.equals(this.id, repositoryDumpStatus.id) && + Objects.equals(this.done, repositoryDumpStatus.done) && + Objects.equals(this.updateTime, repositoryDumpStatus.updateTime) && + Objects.equals(this.error, repositoryDumpStatus.error) && + Objects.equals(this.refs, repositoryDumpStatus.refs); + } + + @Override + public int hashCode() { + return Objects.hash(id, done, updateTime, error, refs); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RepositoryDumpStatus {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" updateTime: ").append(toIndentedString(updateTime)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" refs: ").append(toIndentedString(refs)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/clients/java-legacy/src/main/java/io/lakefs/clients/api/model/RepositoryRestoreStatus.java b/clients/java-legacy/src/main/java/io/lakefs/clients/api/model/RepositoryRestoreStatus.java new file mode 100644 index 00000000000..b428d846070 --- /dev/null +++ b/clients/java-legacy/src/main/java/io/lakefs/clients/api/model/RepositoryRestoreStatus.java @@ -0,0 +1,186 @@ +/* + * lakeFS API + * lakeFS HTTP API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lakefs.clients.api.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import org.threeten.bp.OffsetDateTime; + +/** + * RepositoryRestoreStatus + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class RepositoryRestoreStatus { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + private Boolean done; + + public static final String SERIALIZED_NAME_UPDATE_TIME = "update_time"; + @SerializedName(SERIALIZED_NAME_UPDATE_TIME) + private OffsetDateTime updateTime; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + private String error; + + + public RepositoryRestoreStatus id(String id) { + + this.id = id; + return this; + } + + /** + * ID of the task + * @return id + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "ID of the task") + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public RepositoryRestoreStatus done(Boolean done) { + + this.done = done; + return this; + } + + /** + * Get done + * @return done + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public Boolean getDone() { + return done; + } + + + public void setDone(Boolean done) { + this.done = done; + } + + + public RepositoryRestoreStatus updateTime(OffsetDateTime updateTime) { + + this.updateTime = updateTime; + return this; + } + + /** + * Get updateTime + * @return updateTime + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + + public OffsetDateTime getUpdateTime() { + return updateTime; + } + + + public void setUpdateTime(OffsetDateTime updateTime) { + this.updateTime = updateTime; + } + + + public RepositoryRestoreStatus error(String error) { + + this.error = error; + return this; + } + + /** + * Get error + * @return error + **/ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + + public String getError() { + return error; + } + + + public void setError(String error) { + this.error = error; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RepositoryRestoreStatus repositoryRestoreStatus = (RepositoryRestoreStatus) o; + return Objects.equals(this.id, repositoryRestoreStatus.id) && + Objects.equals(this.done, repositoryRestoreStatus.done) && + Objects.equals(this.updateTime, repositoryRestoreStatus.updateTime) && + Objects.equals(this.error, repositoryRestoreStatus.error); + } + + @Override + public int hashCode() { + return Objects.hash(id, done, updateTime, error); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RepositoryRestoreStatus {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" updateTime: ").append(toIndentedString(updateTime)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/clients/java-legacy/src/main/java/io/lakefs/clients/api/model/TaskInfo.java b/clients/java-legacy/src/main/java/io/lakefs/clients/api/model/TaskInfo.java new file mode 100644 index 00000000000..2de8a4147f8 --- /dev/null +++ b/clients/java-legacy/src/main/java/io/lakefs/clients/api/model/TaskInfo.java @@ -0,0 +1,98 @@ +/* + * lakeFS API + * lakeFS HTTP API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lakefs.clients.api.model; + +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; + +/** + * TaskInfo + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TaskInfo { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + + public TaskInfo id(String id) { + + this.id = id; + return this; + } + + /** + * ID of the task + * @return id + **/ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "ID of the task") + + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TaskInfo taskInfo = (TaskInfo) o; + return Objects.equals(this.id, taskInfo.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TaskInfo {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +} + diff --git a/clients/java-legacy/src/test/java/io/lakefs/clients/api/RepositoriesApiTest.java b/clients/java-legacy/src/test/java/io/lakefs/clients/api/RepositoriesApiTest.java index 1a1ea47742e..7cea7adca81 100644 --- a/clients/java-legacy/src/test/java/io/lakefs/clients/api/RepositoriesApiTest.java +++ b/clients/java-legacy/src/test/java/io/lakefs/clients/api/RepositoriesApiTest.java @@ -17,9 +17,13 @@ import io.lakefs.clients.api.model.BranchProtectionRule; import io.lakefs.clients.api.model.Error; import io.lakefs.clients.api.model.GarbageCollectionRules; +import io.lakefs.clients.api.model.RefsDump; import io.lakefs.clients.api.model.Repository; import io.lakefs.clients.api.model.RepositoryCreation; +import io.lakefs.clients.api.model.RepositoryDumpStatus; import io.lakefs.clients.api.model.RepositoryList; +import io.lakefs.clients.api.model.RepositoryRestoreStatus; +import io.lakefs.clients.api.model.TaskInfo; import org.junit.Test; import org.junit.Ignore; @@ -83,6 +87,37 @@ public void deleteRepositoryTest() throws ApiException { // TODO: test validations } + /** + * Status of a repository dump task + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void dumpStatusTest() throws ApiException { + String repository = null; + String taskId = null; + RepositoryDumpStatus response = api.dumpStatus(repository, taskId); + // TODO: test validations + } + + /** + * Backup the repository metadata (tags, commits, branches) and save the backup to the object store. + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void dumpSubmitTest() throws ApiException { + String repository = null; + TaskInfo response = api.dumpSubmit(repository); + // TODO: test validations + } + /** * get branch protection rules * @@ -160,6 +195,38 @@ public void listRepositoriesTest() throws ApiException { // TODO: test validations } + /** + * Status of a restore request + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void restoreStatusTest() throws ApiException { + String repository = null; + String taskId = null; + RepositoryRestoreStatus response = api.restoreStatus(repository, taskId); + // TODO: test validations + } + + /** + * Restore repository from a dump in the object store + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void restoreSubmitTest() throws ApiException { + String repository = null; + RefsDump refsDump = null; + TaskInfo response = api.restoreSubmit(repository, refsDump); + // TODO: test validations + } + /** * * diff --git a/clients/java-legacy/src/test/java/io/lakefs/clients/api/model/RepositoryDumpStatusTest.java b/clients/java-legacy/src/test/java/io/lakefs/clients/api/model/RepositoryDumpStatusTest.java new file mode 100644 index 00000000000..1637b795b85 --- /dev/null +++ b/clients/java-legacy/src/test/java/io/lakefs/clients/api/model/RepositoryDumpStatusTest.java @@ -0,0 +1,85 @@ +/* + * lakeFS API + * lakeFS HTTP API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lakefs.clients.api.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.lakefs.clients.api.model.RefsDump; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import org.threeten.bp.OffsetDateTime; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for RepositoryDumpStatus + */ +public class RepositoryDumpStatusTest { + private final RepositoryDumpStatus model = new RepositoryDumpStatus(); + + /** + * Model tests for RepositoryDumpStatus + */ + @Test + public void testRepositoryDumpStatus() { + // TODO: test RepositoryDumpStatus + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'done' + */ + @Test + public void doneTest() { + // TODO: test done + } + + /** + * Test the property 'updateTime' + */ + @Test + public void updateTimeTest() { + // TODO: test updateTime + } + + /** + * Test the property 'error' + */ + @Test + public void errorTest() { + // TODO: test error + } + + /** + * Test the property 'refs' + */ + @Test + public void refsTest() { + // TODO: test refs + } + +} diff --git a/clients/java-legacy/src/test/java/io/lakefs/clients/api/model/RepositoryRestoreStatusTest.java b/clients/java-legacy/src/test/java/io/lakefs/clients/api/model/RepositoryRestoreStatusTest.java new file mode 100644 index 00000000000..64470afc820 --- /dev/null +++ b/clients/java-legacy/src/test/java/io/lakefs/clients/api/model/RepositoryRestoreStatusTest.java @@ -0,0 +1,76 @@ +/* + * lakeFS API + * lakeFS HTTP API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lakefs.clients.api.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import org.threeten.bp.OffsetDateTime; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for RepositoryRestoreStatus + */ +public class RepositoryRestoreStatusTest { + private final RepositoryRestoreStatus model = new RepositoryRestoreStatus(); + + /** + * Model tests for RepositoryRestoreStatus + */ + @Test + public void testRepositoryRestoreStatus() { + // TODO: test RepositoryRestoreStatus + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'done' + */ + @Test + public void doneTest() { + // TODO: test done + } + + /** + * Test the property 'updateTime' + */ + @Test + public void updateTimeTest() { + // TODO: test updateTime + } + + /** + * Test the property 'error' + */ + @Test + public void errorTest() { + // TODO: test error + } + +} diff --git a/clients/java-legacy/src/test/java/io/lakefs/clients/api/model/TaskInfoTest.java b/clients/java-legacy/src/test/java/io/lakefs/clients/api/model/TaskInfoTest.java new file mode 100644 index 00000000000..e73fc125db1 --- /dev/null +++ b/clients/java-legacy/src/test/java/io/lakefs/clients/api/model/TaskInfoTest.java @@ -0,0 +1,51 @@ +/* + * lakeFS API + * lakeFS HTTP API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lakefs.clients.api.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + + +/** + * Model tests for TaskInfo + */ +public class TaskInfoTest { + private final TaskInfo model = new TaskInfo(); + + /** + * Model tests for TaskInfo + */ + @Test + public void testTaskInfo() { + // TODO: test TaskInfo + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + +} diff --git a/clients/java/README.md b/clients/java/README.md index d7121fc919a..0ce0c937776 100644 --- a/clients/java/README.md +++ b/clients/java/README.md @@ -236,11 +236,15 @@ Class | Method | HTTP request | Description *RepositoriesApi* | [**createRepository**](docs/RepositoriesApi.md#createRepository) | **POST** /repositories | create repository *RepositoriesApi* | [**deleteGCRules**](docs/RepositoriesApi.md#deleteGCRules) | **DELETE** /repositories/{repository}/settings/gc_rules | *RepositoriesApi* | [**deleteRepository**](docs/RepositoriesApi.md#deleteRepository) | **DELETE** /repositories/{repository} | delete repository +*RepositoriesApi* | [**dumpStatus**](docs/RepositoriesApi.md#dumpStatus) | **GET** /repositories/{repository}/dump | Status of a repository dump task +*RepositoriesApi* | [**dumpSubmit**](docs/RepositoriesApi.md#dumpSubmit) | **POST** /repositories/{repository}/dump | Backup the repository metadata (tags, commits, branches) and save the backup to the object store. *RepositoriesApi* | [**getBranchProtectionRules**](docs/RepositoriesApi.md#getBranchProtectionRules) | **GET** /repositories/{repository}/settings/branch_protection | get branch protection rules *RepositoriesApi* | [**getGCRules**](docs/RepositoriesApi.md#getGCRules) | **GET** /repositories/{repository}/settings/gc_rules | get repository GC rules *RepositoriesApi* | [**getRepository**](docs/RepositoriesApi.md#getRepository) | **GET** /repositories/{repository} | get repository *RepositoriesApi* | [**getRepositoryMetadata**](docs/RepositoriesApi.md#getRepositoryMetadata) | **GET** /repositories/{repository}/metadata | get repository metadata *RepositoriesApi* | [**listRepositories**](docs/RepositoriesApi.md#listRepositories) | **GET** /repositories | list repositories +*RepositoriesApi* | [**restoreStatus**](docs/RepositoriesApi.md#restoreStatus) | **GET** /repositories/{repository}/restore | Status of a restore request +*RepositoriesApi* | [**restoreSubmit**](docs/RepositoriesApi.md#restoreSubmit) | **POST** /repositories/{repository}/restore | Restore repository from a dump in the object store *RepositoriesApi* | [**setBranchProtectionRules**](docs/RepositoriesApi.md#setBranchProtectionRules) | **PUT** /repositories/{repository}/settings/branch_protection | *RepositoriesApi* | [**setGCRules**](docs/RepositoriesApi.md#setGCRules) | **PUT** /repositories/{repository}/settings/gc_rules | *StagingApi* | [**getPhysicalAddress**](docs/StagingApi.md#getPhysicalAddress) | **GET** /repositories/{repository}/branches/{branch}/staging/backing | generate an address to which the client can upload an object @@ -318,7 +322,9 @@ Class | Method | HTTP request | Description - [RefsDump](docs/RefsDump.md) - [Repository](docs/Repository.md) - [RepositoryCreation](docs/RepositoryCreation.md) + - [RepositoryDumpStatus](docs/RepositoryDumpStatus.md) - [RepositoryList](docs/RepositoryList.md) + - [RepositoryRestoreStatus](docs/RepositoryRestoreStatus.md) - [ResetCreation](docs/ResetCreation.md) - [RevertCreation](docs/RevertCreation.md) - [Setup](docs/Setup.md) @@ -331,6 +337,7 @@ Class | Method | HTTP request | Description - [StorageConfig](docs/StorageConfig.md) - [StorageURI](docs/StorageURI.md) - [TagCreation](docs/TagCreation.md) + - [TaskInfo](docs/TaskInfo.md) - [UnderlyingObjectProperties](docs/UnderlyingObjectProperties.md) - [UpdateToken](docs/UpdateToken.md) - [User](docs/User.md) diff --git a/clients/java/api/openapi.yaml b/clients/java/api/openapi.yaml index 318c55d2ba5..2c74869deb5 100644 --- a/clients/java/api/openapi.yaml +++ b/clients/java/api/openapi.yaml @@ -2303,6 +2303,214 @@ paths: - internal x-content-type: application/json x-accepts: application/json + /repositories/{repository}/dump: + get: + operationId: dumpStatus + parameters: + - explode: false + in: path + name: repository + required: true + schema: + type: string + style: simple + - explode: true + in: query + name: task_id + required: true + schema: + type: string + style: form + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/RepositoryDumpStatus' + description: dump task status + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Validation Error + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Unauthorized + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Resource Not Found + "420": + description: too many requests + default: + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Internal Server Error + summary: Status of a repository dump task + tags: + - repositories + x-accepts: application/json + post: + operationId: dumpSubmit + parameters: + - explode: false + in: path + name: repository + required: true + schema: + type: string + style: simple + responses: + "202": + content: + application/json: + schema: + $ref: '#/components/schemas/TaskInfo' + description: dump task information + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Validation Error + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Unauthorized + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Resource Not Found + default: + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Internal Server Error + summary: "Backup the repository metadata (tags, commits, branches) and save\ + \ the backup to the object store." + tags: + - repositories + x-accepts: application/json + /repositories/{repository}/restore: + get: + operationId: restoreStatus + parameters: + - explode: false + in: path + name: repository + required: true + schema: + type: string + style: simple + - explode: true + in: query + name: task_id + required: true + schema: + type: string + style: form + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/RepositoryRestoreStatus' + description: restore task status + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Validation Error + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Unauthorized + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Resource Not Found + "420": + description: too many requests + default: + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Internal Server Error + summary: Status of a restore request + tags: + - repositories + x-accepts: application/json + post: + operationId: restoreSubmit + parameters: + - explode: false + in: path + name: repository + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/RefsDump' + required: true + responses: + "202": + content: + application/json: + schema: + $ref: '#/components/schemas/TaskInfo' + description: restore task created + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Validation Error + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Unauthorized + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Resource Not Found + default: + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Internal Server Error + summary: Restore repository from a dump in the object store + tags: + - repositories + x-content-type: application/json + x-accepts: application/json /repositories/{repository}/tags: get: operationId: listTags @@ -6520,6 +6728,66 @@ components: - id - ref type: object + TaskInfo: + example: + id: id + properties: + id: + description: ID of the task + type: string + required: + - id + type: object + RepositoryDumpStatus: + example: + update_time: 2000-01-23T04:56:07.000+00:00 + refs: + tags_meta_range_id: tags_meta_range_id + branches_meta_range_id: branches_meta_range_id + commits_meta_range_id: commits_meta_range_id + id: id + error: error + done: true + properties: + id: + description: ID of the task + type: string + done: + type: boolean + update_time: + format: date-time + type: string + error: + type: string + refs: + $ref: '#/components/schemas/RefsDump' + required: + - done + - id + - update_time + type: object + RepositoryRestoreStatus: + example: + update_time: 2000-01-23T04:56:07.000+00:00 + id: id + error: error + done: true + properties: + id: + description: ID of the task + type: string + done: + type: boolean + update_time: + format: date-time + type: string + error: + type: string + required: + - done + - id + - update_time + type: object RefsDump: example: tags_meta_range_id: tags_meta_range_id diff --git a/clients/java/docs/RepositoriesApi.md b/clients/java/docs/RepositoriesApi.md index bcadabca595..e18922f15bb 100644 --- a/clients/java/docs/RepositoriesApi.md +++ b/clients/java/docs/RepositoriesApi.md @@ -7,11 +7,15 @@ All URIs are relative to */api/v1* | [**createRepository**](RepositoriesApi.md#createRepository) | **POST** /repositories | create repository | | [**deleteGCRules**](RepositoriesApi.md#deleteGCRules) | **DELETE** /repositories/{repository}/settings/gc_rules | | | [**deleteRepository**](RepositoriesApi.md#deleteRepository) | **DELETE** /repositories/{repository} | delete repository | +| [**dumpStatus**](RepositoriesApi.md#dumpStatus) | **GET** /repositories/{repository}/dump | Status of a repository dump task | +| [**dumpSubmit**](RepositoriesApi.md#dumpSubmit) | **POST** /repositories/{repository}/dump | Backup the repository metadata (tags, commits, branches) and save the backup to the object store. | | [**getBranchProtectionRules**](RepositoriesApi.md#getBranchProtectionRules) | **GET** /repositories/{repository}/settings/branch_protection | get branch protection rules | | [**getGCRules**](RepositoriesApi.md#getGCRules) | **GET** /repositories/{repository}/settings/gc_rules | get repository GC rules | | [**getRepository**](RepositoriesApi.md#getRepository) | **GET** /repositories/{repository} | get repository | | [**getRepositoryMetadata**](RepositoriesApi.md#getRepositoryMetadata) | **GET** /repositories/{repository}/metadata | get repository metadata | | [**listRepositories**](RepositoriesApi.md#listRepositories) | **GET** /repositories | list repositories | +| [**restoreStatus**](RepositoriesApi.md#restoreStatus) | **GET** /repositories/{repository}/restore | Status of a restore request | +| [**restoreSubmit**](RepositoriesApi.md#restoreSubmit) | **POST** /repositories/{repository}/restore | Restore repository from a dump in the object store | | [**setBranchProtectionRules**](RepositoriesApi.md#setBranchProtectionRules) | **PUT** /repositories/{repository}/settings/branch_protection | | | [**setGCRules**](RepositoriesApi.md#setGCRules) | **PUT** /repositories/{repository}/settings/gc_rules | | @@ -297,6 +301,195 @@ null (empty response body) | **420** | too many requests | - | | **0** | Internal Server Error | - | + +# **dumpStatus** +> RepositoryDumpStatus dumpStatus(repository, taskId).execute(); + +Status of a repository dump task + +### Example +```java +// Import classes: +import io.lakefs.clients.sdk.ApiClient; +import io.lakefs.clients.sdk.ApiException; +import io.lakefs.clients.sdk.Configuration; +import io.lakefs.clients.sdk.auth.*; +import io.lakefs.clients.sdk.models.*; +import io.lakefs.clients.sdk.RepositoriesApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("/api/v1"); + + // Configure HTTP basic authorization: basic_auth + HttpBasicAuth basic_auth = (HttpBasicAuth) defaultClient.getAuthentication("basic_auth"); + basic_auth.setUsername("YOUR USERNAME"); + basic_auth.setPassword("YOUR PASSWORD"); + + // Configure API key authorization: cookie_auth + ApiKeyAuth cookie_auth = (ApiKeyAuth) defaultClient.getAuthentication("cookie_auth"); + cookie_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //cookie_auth.setApiKeyPrefix("Token"); + + // Configure API key authorization: oidc_auth + ApiKeyAuth oidc_auth = (ApiKeyAuth) defaultClient.getAuthentication("oidc_auth"); + oidc_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //oidc_auth.setApiKeyPrefix("Token"); + + // Configure API key authorization: saml_auth + ApiKeyAuth saml_auth = (ApiKeyAuth) defaultClient.getAuthentication("saml_auth"); + saml_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //saml_auth.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: jwt_token + HttpBearerAuth jwt_token = (HttpBearerAuth) defaultClient.getAuthentication("jwt_token"); + jwt_token.setBearerToken("BEARER TOKEN"); + + RepositoriesApi apiInstance = new RepositoriesApi(defaultClient); + String repository = "repository_example"; // String | + String taskId = "taskId_example"; // String | + try { + RepositoryDumpStatus result = apiInstance.dumpStatus(repository, taskId) + .execute(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling RepositoriesApi#dumpStatus"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **repository** | **String**| | | +| **taskId** | **String**| | | + +### Return type + +[**RepositoryDumpStatus**](RepositoryDumpStatus.md) + +### Authorization + +[basic_auth](../README.md#basic_auth), [cookie_auth](../README.md#cookie_auth), [oidc_auth](../README.md#oidc_auth), [saml_auth](../README.md#saml_auth), [jwt_token](../README.md#jwt_token) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | dump task status | - | +| **400** | Validation Error | - | +| **401** | Unauthorized | - | +| **404** | Resource Not Found | - | +| **420** | too many requests | - | +| **0** | Internal Server Error | - | + + +# **dumpSubmit** +> TaskInfo dumpSubmit(repository).execute(); + +Backup the repository metadata (tags, commits, branches) and save the backup to the object store. + +### Example +```java +// Import classes: +import io.lakefs.clients.sdk.ApiClient; +import io.lakefs.clients.sdk.ApiException; +import io.lakefs.clients.sdk.Configuration; +import io.lakefs.clients.sdk.auth.*; +import io.lakefs.clients.sdk.models.*; +import io.lakefs.clients.sdk.RepositoriesApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("/api/v1"); + + // Configure HTTP basic authorization: basic_auth + HttpBasicAuth basic_auth = (HttpBasicAuth) defaultClient.getAuthentication("basic_auth"); + basic_auth.setUsername("YOUR USERNAME"); + basic_auth.setPassword("YOUR PASSWORD"); + + // Configure API key authorization: cookie_auth + ApiKeyAuth cookie_auth = (ApiKeyAuth) defaultClient.getAuthentication("cookie_auth"); + cookie_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //cookie_auth.setApiKeyPrefix("Token"); + + // Configure API key authorization: oidc_auth + ApiKeyAuth oidc_auth = (ApiKeyAuth) defaultClient.getAuthentication("oidc_auth"); + oidc_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //oidc_auth.setApiKeyPrefix("Token"); + + // Configure API key authorization: saml_auth + ApiKeyAuth saml_auth = (ApiKeyAuth) defaultClient.getAuthentication("saml_auth"); + saml_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //saml_auth.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: jwt_token + HttpBearerAuth jwt_token = (HttpBearerAuth) defaultClient.getAuthentication("jwt_token"); + jwt_token.setBearerToken("BEARER TOKEN"); + + RepositoriesApi apiInstance = new RepositoriesApi(defaultClient); + String repository = "repository_example"; // String | + try { + TaskInfo result = apiInstance.dumpSubmit(repository) + .execute(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling RepositoriesApi#dumpSubmit"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **repository** | **String**| | | + +### Return type + +[**TaskInfo**](TaskInfo.md) + +### Authorization + +[basic_auth](../README.md#basic_auth), [cookie_auth](../README.md#cookie_auth), [oidc_auth](../README.md#oidc_auth), [saml_auth](../README.md#saml_auth), [jwt_token](../README.md#jwt_token) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **202** | dump task information | - | +| **400** | Validation Error | - | +| **401** | Unauthorized | - | +| **404** | Resource Not Found | - | +| **0** | Internal Server Error | - | + # **getBranchProtectionRules** > List<BranchProtectionRule> getBranchProtectionRules(repository).execute(); @@ -768,6 +961,197 @@ public class Example { | **420** | too many requests | - | | **0** | Internal Server Error | - | + +# **restoreStatus** +> RepositoryRestoreStatus restoreStatus(repository, taskId).execute(); + +Status of a restore request + +### Example +```java +// Import classes: +import io.lakefs.clients.sdk.ApiClient; +import io.lakefs.clients.sdk.ApiException; +import io.lakefs.clients.sdk.Configuration; +import io.lakefs.clients.sdk.auth.*; +import io.lakefs.clients.sdk.models.*; +import io.lakefs.clients.sdk.RepositoriesApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("/api/v1"); + + // Configure HTTP basic authorization: basic_auth + HttpBasicAuth basic_auth = (HttpBasicAuth) defaultClient.getAuthentication("basic_auth"); + basic_auth.setUsername("YOUR USERNAME"); + basic_auth.setPassword("YOUR PASSWORD"); + + // Configure API key authorization: cookie_auth + ApiKeyAuth cookie_auth = (ApiKeyAuth) defaultClient.getAuthentication("cookie_auth"); + cookie_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //cookie_auth.setApiKeyPrefix("Token"); + + // Configure API key authorization: oidc_auth + ApiKeyAuth oidc_auth = (ApiKeyAuth) defaultClient.getAuthentication("oidc_auth"); + oidc_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //oidc_auth.setApiKeyPrefix("Token"); + + // Configure API key authorization: saml_auth + ApiKeyAuth saml_auth = (ApiKeyAuth) defaultClient.getAuthentication("saml_auth"); + saml_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //saml_auth.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: jwt_token + HttpBearerAuth jwt_token = (HttpBearerAuth) defaultClient.getAuthentication("jwt_token"); + jwt_token.setBearerToken("BEARER TOKEN"); + + RepositoriesApi apiInstance = new RepositoriesApi(defaultClient); + String repository = "repository_example"; // String | + String taskId = "taskId_example"; // String | + try { + RepositoryRestoreStatus result = apiInstance.restoreStatus(repository, taskId) + .execute(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling RepositoriesApi#restoreStatus"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **repository** | **String**| | | +| **taskId** | **String**| | | + +### Return type + +[**RepositoryRestoreStatus**](RepositoryRestoreStatus.md) + +### Authorization + +[basic_auth](../README.md#basic_auth), [cookie_auth](../README.md#cookie_auth), [oidc_auth](../README.md#oidc_auth), [saml_auth](../README.md#saml_auth), [jwt_token](../README.md#jwt_token) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | restore task status | - | +| **400** | Validation Error | - | +| **401** | Unauthorized | - | +| **404** | Resource Not Found | - | +| **420** | too many requests | - | +| **0** | Internal Server Error | - | + + +# **restoreSubmit** +> TaskInfo restoreSubmit(repository, refsDump).execute(); + +Restore repository from a dump in the object store + +### Example +```java +// Import classes: +import io.lakefs.clients.sdk.ApiClient; +import io.lakefs.clients.sdk.ApiException; +import io.lakefs.clients.sdk.Configuration; +import io.lakefs.clients.sdk.auth.*; +import io.lakefs.clients.sdk.models.*; +import io.lakefs.clients.sdk.RepositoriesApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("/api/v1"); + + // Configure HTTP basic authorization: basic_auth + HttpBasicAuth basic_auth = (HttpBasicAuth) defaultClient.getAuthentication("basic_auth"); + basic_auth.setUsername("YOUR USERNAME"); + basic_auth.setPassword("YOUR PASSWORD"); + + // Configure API key authorization: cookie_auth + ApiKeyAuth cookie_auth = (ApiKeyAuth) defaultClient.getAuthentication("cookie_auth"); + cookie_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //cookie_auth.setApiKeyPrefix("Token"); + + // Configure API key authorization: oidc_auth + ApiKeyAuth oidc_auth = (ApiKeyAuth) defaultClient.getAuthentication("oidc_auth"); + oidc_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //oidc_auth.setApiKeyPrefix("Token"); + + // Configure API key authorization: saml_auth + ApiKeyAuth saml_auth = (ApiKeyAuth) defaultClient.getAuthentication("saml_auth"); + saml_auth.setApiKey("YOUR API KEY"); + // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) + //saml_auth.setApiKeyPrefix("Token"); + + // Configure HTTP bearer authorization: jwt_token + HttpBearerAuth jwt_token = (HttpBearerAuth) defaultClient.getAuthentication("jwt_token"); + jwt_token.setBearerToken("BEARER TOKEN"); + + RepositoriesApi apiInstance = new RepositoriesApi(defaultClient); + String repository = "repository_example"; // String | + RefsDump refsDump = new RefsDump(); // RefsDump | + try { + TaskInfo result = apiInstance.restoreSubmit(repository, refsDump) + .execute(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling RepositoriesApi#restoreSubmit"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **repository** | **String**| | | +| **refsDump** | [**RefsDump**](RefsDump.md)| | | + +### Return type + +[**TaskInfo**](TaskInfo.md) + +### Authorization + +[basic_auth](../README.md#basic_auth), [cookie_auth](../README.md#cookie_auth), [oidc_auth](../README.md#oidc_auth), [saml_auth](../README.md#saml_auth), [jwt_token](../README.md#jwt_token) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **202** | restore task created | - | +| **400** | Validation Error | - | +| **401** | Unauthorized | - | +| **404** | Resource Not Found | - | +| **0** | Internal Server Error | - | + # **setBranchProtectionRules** > setBranchProtectionRules(repository, branchProtectionRule).ifMatch(ifMatch).execute(); diff --git a/clients/java/docs/RepositoryDumpStatus.md b/clients/java/docs/RepositoryDumpStatus.md new file mode 100644 index 00000000000..2f00b15c709 --- /dev/null +++ b/clients/java/docs/RepositoryDumpStatus.md @@ -0,0 +1,17 @@ + + +# RepositoryDumpStatus + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **String** | ID of the task | | +|**done** | **Boolean** | | | +|**updateTime** | **OffsetDateTime** | | | +|**error** | **String** | | [optional] | +|**refs** | [**RefsDump**](RefsDump.md) | | [optional] | + + + diff --git a/clients/java/docs/RepositoryRestoreStatus.md b/clients/java/docs/RepositoryRestoreStatus.md new file mode 100644 index 00000000000..73f648d0828 --- /dev/null +++ b/clients/java/docs/RepositoryRestoreStatus.md @@ -0,0 +1,16 @@ + + +# RepositoryRestoreStatus + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **String** | ID of the task | | +|**done** | **Boolean** | | | +|**updateTime** | **OffsetDateTime** | | | +|**error** | **String** | | [optional] | + + + diff --git a/clients/java/docs/TaskInfo.md b/clients/java/docs/TaskInfo.md new file mode 100644 index 00000000000..4bf03879252 --- /dev/null +++ b/clients/java/docs/TaskInfo.md @@ -0,0 +1,13 @@ + + +# TaskInfo + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **String** | ID of the task | | + + + diff --git a/clients/java/src/main/java/io/lakefs/clients/sdk/JSON.java b/clients/java/src/main/java/io/lakefs/clients/sdk/JSON.java index 19594a07b46..a0deb1f7e0b 100644 --- a/clients/java/src/main/java/io/lakefs/clients/sdk/JSON.java +++ b/clients/java/src/main/java/io/lakefs/clients/sdk/JSON.java @@ -158,7 +158,9 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new io.lakefs.clients.sdk.model.RefsDump.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new io.lakefs.clients.sdk.model.Repository.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new io.lakefs.clients.sdk.model.RepositoryCreation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.lakefs.clients.sdk.model.RepositoryDumpStatus.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new io.lakefs.clients.sdk.model.RepositoryList.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.lakefs.clients.sdk.model.RepositoryRestoreStatus.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new io.lakefs.clients.sdk.model.ResetCreation.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new io.lakefs.clients.sdk.model.RevertCreation.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new io.lakefs.clients.sdk.model.Setup.CustomTypeAdapterFactory()); @@ -171,6 +173,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new io.lakefs.clients.sdk.model.StorageConfig.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new io.lakefs.clients.sdk.model.StorageURI.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new io.lakefs.clients.sdk.model.TagCreation.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new io.lakefs.clients.sdk.model.TaskInfo.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new io.lakefs.clients.sdk.model.UnderlyingObjectProperties.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new io.lakefs.clients.sdk.model.UpdateToken.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new io.lakefs.clients.sdk.model.User.CustomTypeAdapterFactory()); diff --git a/clients/java/src/main/java/io/lakefs/clients/sdk/RepositoriesApi.java b/clients/java/src/main/java/io/lakefs/clients/sdk/RepositoriesApi.java index 516d0a500aa..e6b101a9f9a 100644 --- a/clients/java/src/main/java/io/lakefs/clients/sdk/RepositoriesApi.java +++ b/clients/java/src/main/java/io/lakefs/clients/sdk/RepositoriesApi.java @@ -30,9 +30,13 @@ import io.lakefs.clients.sdk.model.BranchProtectionRule; import io.lakefs.clients.sdk.model.Error; import io.lakefs.clients.sdk.model.GarbageCollectionRules; +import io.lakefs.clients.sdk.model.RefsDump; import io.lakefs.clients.sdk.model.Repository; import io.lakefs.clients.sdk.model.RepositoryCreation; +import io.lakefs.clients.sdk.model.RepositoryDumpStatus; import io.lakefs.clients.sdk.model.RepositoryList; +import io.lakefs.clients.sdk.model.RepositoryRestoreStatus; +import io.lakefs.clients.sdk.model.TaskInfo; import java.lang.reflect.Type; import java.util.ArrayList; @@ -605,7 +609,7 @@ public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiEx public APIdeleteRepositoryRequest deleteRepository(String repository) { return new APIdeleteRepositoryRequest(repository); } - private okhttp3.Call getBranchProtectionRulesCall(String repository, final ApiCallback _callback) throws ApiException { + private okhttp3.Call dumpStatusCall(String repository, String taskId, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -622,7 +626,7 @@ private okhttp3.Call getBranchProtectionRulesCall(String repository, final ApiCa Object localVarPostBody = null; // create path and map variables - String localVarPath = "/repositories/{repository}/settings/branch_protection" + String localVarPath = "/repositories/{repository}/dump" .replace("{" + "repository" + "}", localVarApiClient.escapeString(repository.toString())); List localVarQueryParams = new ArrayList(); @@ -631,6 +635,10 @@ private okhttp3.Call getBranchProtectionRulesCall(String repository, final ApiCa Map localVarCookieParams = new HashMap(); Map localVarFormParams = new HashMap(); + if (taskId != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("task_id", taskId)); + } + final String[] localVarAccepts = { "application/json" }; @@ -651,47 +659,55 @@ private okhttp3.Call getBranchProtectionRulesCall(String repository, final ApiCa } @SuppressWarnings("rawtypes") - private okhttp3.Call getBranchProtectionRulesValidateBeforeCall(String repository, final ApiCallback _callback) throws ApiException { + private okhttp3.Call dumpStatusValidateBeforeCall(String repository, String taskId, final ApiCallback _callback) throws ApiException { // verify the required parameter 'repository' is set if (repository == null) { - throw new ApiException("Missing the required parameter 'repository' when calling getBranchProtectionRules(Async)"); + throw new ApiException("Missing the required parameter 'repository' when calling dumpStatus(Async)"); } - return getBranchProtectionRulesCall(repository, _callback); + // verify the required parameter 'taskId' is set + if (taskId == null) { + throw new ApiException("Missing the required parameter 'taskId' when calling dumpStatus(Async)"); + } + + return dumpStatusCall(repository, taskId, _callback); } - private ApiResponse> getBranchProtectionRulesWithHttpInfo(String repository) throws ApiException { - okhttp3.Call localVarCall = getBranchProtectionRulesValidateBeforeCall(repository, null); - Type localVarReturnType = new TypeToken>(){}.getType(); + private ApiResponse dumpStatusWithHttpInfo(String repository, String taskId) throws ApiException { + okhttp3.Call localVarCall = dumpStatusValidateBeforeCall(repository, taskId, null); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } - private okhttp3.Call getBranchProtectionRulesAsync(String repository, final ApiCallback> _callback) throws ApiException { + private okhttp3.Call dumpStatusAsync(String repository, String taskId, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = getBranchProtectionRulesValidateBeforeCall(repository, _callback); - Type localVarReturnType = new TypeToken>(){}.getType(); + okhttp3.Call localVarCall = dumpStatusValidateBeforeCall(repository, taskId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } - public class APIgetBranchProtectionRulesRequest { + public class APIdumpStatusRequest { private final String repository; + private final String taskId; - private APIgetBranchProtectionRulesRequest(String repository) { + private APIdumpStatusRequest(String repository, String taskId) { this.repository = repository; + this.taskId = taskId; } /** - * Build call for getBranchProtectionRules + * Build call for dumpStatus * @param _callback ApiCallback API callback * @return Call to execute * @throws ApiException If fail to serialize the request body object * @http.response.details - + + @@ -699,85 +715,90 @@ private APIgetBranchProtectionRulesRequest(String repository) {
Status Code Description Response Headers
200 branch protection rules * ETag -
200 dump task status -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
*/ public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { - return getBranchProtectionRulesCall(repository, _callback); + return dumpStatusCall(repository, taskId, _callback); } /** - * Execute getBranchProtectionRules request - * @return List<BranchProtectionRule> + * Execute dumpStatus request + * @return RepositoryDumpStatus * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - + +
Status Code Description Response Headers
200 branch protection rules * ETag -
200 dump task status -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public List execute() throws ApiException { - ApiResponse> localVarResp = getBranchProtectionRulesWithHttpInfo(repository); + public RepositoryDumpStatus execute() throws ApiException { + ApiResponse localVarResp = dumpStatusWithHttpInfo(repository, taskId); return localVarResp.getData(); } /** - * Execute getBranchProtectionRules request with HTTP info returned - * @return ApiResponse<List<BranchProtectionRule>> + * Execute dumpStatus request with HTTP info returned + * @return ApiResponse<RepositoryDumpStatus> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - + +
Status Code Description Response Headers
200 branch protection rules * ETag -
200 dump task status -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public ApiResponse> executeWithHttpInfo() throws ApiException { - return getBranchProtectionRulesWithHttpInfo(repository); + public ApiResponse executeWithHttpInfo() throws ApiException { + return dumpStatusWithHttpInfo(repository, taskId); } /** - * Execute getBranchProtectionRules request (asynchronously) + * Execute dumpStatus request (asynchronously) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object * @http.response.details - + +
Status Code Description Response Headers
200 branch protection rules * ETag -
200 dump task status -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public okhttp3.Call executeAsync(final ApiCallback> _callback) throws ApiException { - return getBranchProtectionRulesAsync(repository, _callback); + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return dumpStatusAsync(repository, taskId, _callback); } } /** - * get branch protection rules + * Status of a repository dump task * * @param repository (required) - * @return APIgetBranchProtectionRulesRequest + * @param taskId (required) + * @return APIdumpStatusRequest * @http.response.details - + +
Status Code Description Response Headers
200 branch protection rules * ETag -
200 dump task status -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public APIgetBranchProtectionRulesRequest getBranchProtectionRules(String repository) { - return new APIgetBranchProtectionRulesRequest(repository); + public APIdumpStatusRequest dumpStatus(String repository, String taskId) { + return new APIdumpStatusRequest(repository, taskId); } - private okhttp3.Call getGCRulesCall(String repository, final ApiCallback _callback) throws ApiException { + private okhttp3.Call dumpSubmitCall(String repository, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -794,7 +815,7 @@ private okhttp3.Call getGCRulesCall(String repository, final ApiCallback _callba Object localVarPostBody = null; // create path and map variables - String localVarPath = "/repositories/{repository}/settings/gc_rules" + String localVarPath = "/repositories/{repository}/dump" .replace("{" + "repository" + "}", localVarApiClient.escapeString(repository.toString())); List localVarQueryParams = new ArrayList(); @@ -819,137 +840,137 @@ private okhttp3.Call getGCRulesCall(String repository, final ApiCallback _callba } String[] localVarAuthNames = new String[] { "basic_auth", "cookie_auth", "oidc_auth", "saml_auth", "jwt_token" }; - return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); } @SuppressWarnings("rawtypes") - private okhttp3.Call getGCRulesValidateBeforeCall(String repository, final ApiCallback _callback) throws ApiException { + private okhttp3.Call dumpSubmitValidateBeforeCall(String repository, final ApiCallback _callback) throws ApiException { // verify the required parameter 'repository' is set if (repository == null) { - throw new ApiException("Missing the required parameter 'repository' when calling getGCRules(Async)"); + throw new ApiException("Missing the required parameter 'repository' when calling dumpSubmit(Async)"); } - return getGCRulesCall(repository, _callback); + return dumpSubmitCall(repository, _callback); } - private ApiResponse getGCRulesWithHttpInfo(String repository) throws ApiException { - okhttp3.Call localVarCall = getGCRulesValidateBeforeCall(repository, null); - Type localVarReturnType = new TypeToken(){}.getType(); + private ApiResponse dumpSubmitWithHttpInfo(String repository) throws ApiException { + okhttp3.Call localVarCall = dumpSubmitValidateBeforeCall(repository, null); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } - private okhttp3.Call getGCRulesAsync(String repository, final ApiCallback _callback) throws ApiException { + private okhttp3.Call dumpSubmitAsync(String repository, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = getGCRulesValidateBeforeCall(repository, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + okhttp3.Call localVarCall = dumpSubmitValidateBeforeCall(repository, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } - public class APIgetGCRulesRequest { + public class APIdumpSubmitRequest { private final String repository; - private APIgetGCRulesRequest(String repository) { + private APIdumpSubmitRequest(String repository) { this.repository = repository; } /** - * Build call for getGCRules + * Build call for dumpSubmit * @param _callback ApiCallback API callback * @return Call to execute * @throws ApiException If fail to serialize the request body object * @http.response.details - + + -
Status Code Description Response Headers
200 repository GC rules -
202 dump task information -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { - return getGCRulesCall(repository, _callback); + return dumpSubmitCall(repository, _callback); } /** - * Execute getGCRules request - * @return GarbageCollectionRules + * Execute dumpSubmit request + * @return TaskInfo * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - + + -
Status Code Description Response Headers
200 repository GC rules -
202 dump task information -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public GarbageCollectionRules execute() throws ApiException { - ApiResponse localVarResp = getGCRulesWithHttpInfo(repository); + public TaskInfo execute() throws ApiException { + ApiResponse localVarResp = dumpSubmitWithHttpInfo(repository); return localVarResp.getData(); } /** - * Execute getGCRules request with HTTP info returned - * @return ApiResponse<GarbageCollectionRules> + * Execute dumpSubmit request with HTTP info returned + * @return ApiResponse<TaskInfo> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - + + -
Status Code Description Response Headers
200 repository GC rules -
202 dump task information -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public ApiResponse executeWithHttpInfo() throws ApiException { - return getGCRulesWithHttpInfo(repository); + public ApiResponse executeWithHttpInfo() throws ApiException { + return dumpSubmitWithHttpInfo(repository); } /** - * Execute getGCRules request (asynchronously) + * Execute dumpSubmit request (asynchronously) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object * @http.response.details - + + -
Status Code Description Response Headers
200 repository GC rules -
202 dump task information -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { - return getGCRulesAsync(repository, _callback); + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return dumpSubmitAsync(repository, _callback); } } /** - * get repository GC rules + * Backup the repository metadata (tags, commits, branches) and save the backup to the object store. * * @param repository (required) - * @return APIgetGCRulesRequest + * @return APIdumpSubmitRequest * @http.response.details - + + -
Status Code Description Response Headers
200 repository GC rules -
202 dump task information -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public APIgetGCRulesRequest getGCRules(String repository) { - return new APIgetGCRulesRequest(repository); + public APIdumpSubmitRequest dumpSubmit(String repository) { + return new APIdumpSubmitRequest(repository); } - private okhttp3.Call getRepositoryCall(String repository, final ApiCallback _callback) throws ApiException { + private okhttp3.Call getBranchProtectionRulesCall(String repository, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -966,7 +987,7 @@ private okhttp3.Call getRepositoryCall(String repository, final ApiCallback _cal Object localVarPostBody = null; // create path and map variables - String localVarPath = "/repositories/{repository}" + String localVarPath = "/repositories/{repository}/settings/branch_protection" .replace("{" + "repository" + "}", localVarApiClient.escapeString(repository.toString())); List localVarQueryParams = new ArrayList(); @@ -995,47 +1016,47 @@ private okhttp3.Call getRepositoryCall(String repository, final ApiCallback _cal } @SuppressWarnings("rawtypes") - private okhttp3.Call getRepositoryValidateBeforeCall(String repository, final ApiCallback _callback) throws ApiException { + private okhttp3.Call getBranchProtectionRulesValidateBeforeCall(String repository, final ApiCallback _callback) throws ApiException { // verify the required parameter 'repository' is set if (repository == null) { - throw new ApiException("Missing the required parameter 'repository' when calling getRepository(Async)"); + throw new ApiException("Missing the required parameter 'repository' when calling getBranchProtectionRules(Async)"); } - return getRepositoryCall(repository, _callback); + return getBranchProtectionRulesCall(repository, _callback); } - private ApiResponse getRepositoryWithHttpInfo(String repository) throws ApiException { - okhttp3.Call localVarCall = getRepositoryValidateBeforeCall(repository, null); - Type localVarReturnType = new TypeToken(){}.getType(); + private ApiResponse> getBranchProtectionRulesWithHttpInfo(String repository) throws ApiException { + okhttp3.Call localVarCall = getBranchProtectionRulesValidateBeforeCall(repository, null); + Type localVarReturnType = new TypeToken>(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } - private okhttp3.Call getRepositoryAsync(String repository, final ApiCallback _callback) throws ApiException { + private okhttp3.Call getBranchProtectionRulesAsync(String repository, final ApiCallback> _callback) throws ApiException { - okhttp3.Call localVarCall = getRepositoryValidateBeforeCall(repository, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + okhttp3.Call localVarCall = getBranchProtectionRulesValidateBeforeCall(repository, _callback); + Type localVarReturnType = new TypeToken>(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } - public class APIgetRepositoryRequest { + public class APIgetBranchProtectionRulesRequest { private final String repository; - private APIgetRepositoryRequest(String repository) { + private APIgetBranchProtectionRulesRequest(String repository) { this.repository = repository; } /** - * Build call for getRepository + * Build call for getBranchProtectionRules * @param _callback ApiCallback API callback * @return Call to execute * @throws ApiException If fail to serialize the request body object * @http.response.details - + @@ -1043,85 +1064,85 @@ private APIgetRepositoryRequest(String repository) {
Status Code Description Response Headers
200 repository -
200 branch protection rules * ETag -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
*/ public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { - return getRepositoryCall(repository, _callback); + return getBranchProtectionRulesCall(repository, _callback); } /** - * Execute getRepository request - * @return Repository + * Execute getBranchProtectionRules request + * @return List<BranchProtectionRule> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - +
Status Code Description Response Headers
200 repository -
200 branch protection rules * ETag -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public Repository execute() throws ApiException { - ApiResponse localVarResp = getRepositoryWithHttpInfo(repository); + public List execute() throws ApiException { + ApiResponse> localVarResp = getBranchProtectionRulesWithHttpInfo(repository); return localVarResp.getData(); } /** - * Execute getRepository request with HTTP info returned - * @return ApiResponse<Repository> + * Execute getBranchProtectionRules request with HTTP info returned + * @return ApiResponse<List<BranchProtectionRule>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - +
Status Code Description Response Headers
200 repository -
200 branch protection rules * ETag -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public ApiResponse executeWithHttpInfo() throws ApiException { - return getRepositoryWithHttpInfo(repository); + public ApiResponse> executeWithHttpInfo() throws ApiException { + return getBranchProtectionRulesWithHttpInfo(repository); } /** - * Execute getRepository request (asynchronously) + * Execute getBranchProtectionRules request (asynchronously) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object * @http.response.details - +
Status Code Description Response Headers
200 repository -
200 branch protection rules * ETag -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { - return getRepositoryAsync(repository, _callback); + public okhttp3.Call executeAsync(final ApiCallback> _callback) throws ApiException { + return getBranchProtectionRulesAsync(repository, _callback); } } /** - * get repository + * get branch protection rules * * @param repository (required) - * @return APIgetRepositoryRequest + * @return APIgetBranchProtectionRulesRequest * @http.response.details - +
Status Code Description Response Headers
200 repository -
200 branch protection rules * ETag -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public APIgetRepositoryRequest getRepository(String repository) { - return new APIgetRepositoryRequest(repository); + public APIgetBranchProtectionRulesRequest getBranchProtectionRules(String repository) { + return new APIgetBranchProtectionRulesRequest(repository); } - private okhttp3.Call getRepositoryMetadataCall(String repository, final ApiCallback _callback) throws ApiException { + private okhttp3.Call getGCRulesCall(String repository, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -1138,7 +1159,7 @@ private okhttp3.Call getRepositoryMetadataCall(String repository, final ApiCallb Object localVarPostBody = null; // create path and map variables - String localVarPath = "/repositories/{repository}/metadata" + String localVarPath = "/repositories/{repository}/settings/gc_rules" .replace("{" + "repository" + "}", localVarApiClient.escapeString(repository.toString())); List localVarQueryParams = new ArrayList(); @@ -1167,47 +1188,47 @@ private okhttp3.Call getRepositoryMetadataCall(String repository, final ApiCallb } @SuppressWarnings("rawtypes") - private okhttp3.Call getRepositoryMetadataValidateBeforeCall(String repository, final ApiCallback _callback) throws ApiException { + private okhttp3.Call getGCRulesValidateBeforeCall(String repository, final ApiCallback _callback) throws ApiException { // verify the required parameter 'repository' is set if (repository == null) { - throw new ApiException("Missing the required parameter 'repository' when calling getRepositoryMetadata(Async)"); + throw new ApiException("Missing the required parameter 'repository' when calling getGCRules(Async)"); } - return getRepositoryMetadataCall(repository, _callback); + return getGCRulesCall(repository, _callback); } - private ApiResponse> getRepositoryMetadataWithHttpInfo(String repository) throws ApiException { - okhttp3.Call localVarCall = getRepositoryMetadataValidateBeforeCall(repository, null); - Type localVarReturnType = new TypeToken>(){}.getType(); + private ApiResponse getGCRulesWithHttpInfo(String repository) throws ApiException { + okhttp3.Call localVarCall = getGCRulesValidateBeforeCall(repository, null); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } - private okhttp3.Call getRepositoryMetadataAsync(String repository, final ApiCallback> _callback) throws ApiException { + private okhttp3.Call getGCRulesAsync(String repository, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = getRepositoryMetadataValidateBeforeCall(repository, _callback); - Type localVarReturnType = new TypeToken>(){}.getType(); + okhttp3.Call localVarCall = getGCRulesValidateBeforeCall(repository, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } - public class APIgetRepositoryMetadataRequest { + public class APIgetGCRulesRequest { private final String repository; - private APIgetRepositoryMetadataRequest(String repository) { + private APIgetGCRulesRequest(String repository) { this.repository = repository; } /** - * Build call for getRepositoryMetadata + * Build call for getGCRules * @param _callback ApiCallback API callback * @return Call to execute * @throws ApiException If fail to serialize the request body object * @http.response.details - + @@ -1215,85 +1236,85 @@ private APIgetRepositoryMetadataRequest(String repository) {
Status Code Description Response Headers
200 repository metadata -
200 repository GC rules -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
*/ public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { - return getRepositoryMetadataCall(repository, _callback); + return getGCRulesCall(repository, _callback); } /** - * Execute getRepositoryMetadata request - * @return Map<String, String> + * Execute getGCRules request + * @return GarbageCollectionRules * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - +
Status Code Description Response Headers
200 repository metadata -
200 repository GC rules -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public Map execute() throws ApiException { - ApiResponse> localVarResp = getRepositoryMetadataWithHttpInfo(repository); + public GarbageCollectionRules execute() throws ApiException { + ApiResponse localVarResp = getGCRulesWithHttpInfo(repository); return localVarResp.getData(); } /** - * Execute getRepositoryMetadata request with HTTP info returned - * @return ApiResponse<Map<String, String>> + * Execute getGCRules request with HTTP info returned + * @return ApiResponse<GarbageCollectionRules> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - +
Status Code Description Response Headers
200 repository metadata -
200 repository GC rules -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public ApiResponse> executeWithHttpInfo() throws ApiException { - return getRepositoryMetadataWithHttpInfo(repository); + public ApiResponse executeWithHttpInfo() throws ApiException { + return getGCRulesWithHttpInfo(repository); } /** - * Execute getRepositoryMetadata request (asynchronously) + * Execute getGCRules request (asynchronously) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object * @http.response.details - +
Status Code Description Response Headers
200 repository metadata -
200 repository GC rules -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public okhttp3.Call executeAsync(final ApiCallback> _callback) throws ApiException { - return getRepositoryMetadataAsync(repository, _callback); + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return getGCRulesAsync(repository, _callback); } } /** - * get repository metadata + * get repository GC rules * * @param repository (required) - * @return APIgetRepositoryMetadataRequest + * @return APIgetGCRulesRequest * @http.response.details - +
Status Code Description Response Headers
200 repository metadata -
200 repository GC rules -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public APIgetRepositoryMetadataRequest getRepositoryMetadata(String repository) { - return new APIgetRepositoryMetadataRequest(repository); + public APIgetGCRulesRequest getGCRules(String repository) { + return new APIgetGCRulesRequest(repository); } - private okhttp3.Call listRepositoriesCall(String prefix, String after, Integer amount, final ApiCallback _callback) throws ApiException { + private okhttp3.Call getRepositoryCall(String repository, final ApiCallback _callback) throws ApiException { String basePath = null; // Operation Servers String[] localBasePaths = new String[] { }; @@ -1310,7 +1331,8 @@ private okhttp3.Call listRepositoriesCall(String prefix, String after, Integer a Object localVarPostBody = null; // create path and map variables - String localVarPath = "/repositories"; + String localVarPath = "/repositories/{repository}" + .replace("{" + "repository" + "}", localVarApiClient.escapeString(repository.toString())); List localVarQueryParams = new ArrayList(); List localVarCollectionQueryParams = new ArrayList(); @@ -1318,18 +1340,6 @@ private okhttp3.Call listRepositoriesCall(String prefix, String after, Integer a Map localVarCookieParams = new HashMap(); Map localVarFormParams = new HashMap(); - if (prefix != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("prefix", prefix)); - } - - if (after != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("after", after)); - } - - if (amount != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("amount", amount)); - } - final String[] localVarAccepts = { "application/json" }; @@ -1350,151 +1360,876 @@ private okhttp3.Call listRepositoriesCall(String prefix, String after, Integer a } @SuppressWarnings("rawtypes") - private okhttp3.Call listRepositoriesValidateBeforeCall(String prefix, String after, Integer amount, final ApiCallback _callback) throws ApiException { - return listRepositoriesCall(prefix, after, amount, _callback); + private okhttp3.Call getRepositoryValidateBeforeCall(String repository, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'repository' is set + if (repository == null) { + throw new ApiException("Missing the required parameter 'repository' when calling getRepository(Async)"); + } - } + return getRepositoryCall(repository, _callback); + } - private ApiResponse listRepositoriesWithHttpInfo(String prefix, String after, Integer amount) throws ApiException { - okhttp3.Call localVarCall = listRepositoriesValidateBeforeCall(prefix, after, amount, null); - Type localVarReturnType = new TypeToken(){}.getType(); + + private ApiResponse getRepositoryWithHttpInfo(String repository) throws ApiException { + okhttp3.Call localVarCall = getRepositoryValidateBeforeCall(repository, null); + Type localVarReturnType = new TypeToken(){}.getType(); return localVarApiClient.execute(localVarCall, localVarReturnType); } - private okhttp3.Call listRepositoriesAsync(String prefix, String after, Integer amount, final ApiCallback _callback) throws ApiException { + private okhttp3.Call getRepositoryAsync(String repository, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = listRepositoriesValidateBeforeCall(prefix, after, amount, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); + okhttp3.Call localVarCall = getRepositoryValidateBeforeCall(repository, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } - public class APIlistRepositoriesRequest { - private String prefix; - private String after; - private Integer amount; + public class APIgetRepositoryRequest { + private final String repository; - private APIlistRepositoriesRequest() { + private APIgetRepositoryRequest(String repository) { + this.repository = repository; } /** - * Set prefix - * @param prefix return items prefixed with this value (optional) - * @return APIlistRepositoriesRequest + * Build call for getRepository + * @param _callback ApiCallback API callback + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 repository -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public APIlistRepositoriesRequest prefix(String prefix) { - this.prefix = prefix; - return this; + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return getRepositoryCall(repository, _callback); } /** - * Set after - * @param after return items after this value (optional) - * @return APIlistRepositoriesRequest + * Execute getRepository request + * @return Repository + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 repository -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public APIlistRepositoriesRequest after(String after) { - this.after = after; - return this; + public Repository execute() throws ApiException { + ApiResponse localVarResp = getRepositoryWithHttpInfo(repository); + return localVarResp.getData(); } /** - * Set amount - * @param amount how many items to return (optional, default to 100) - * @return APIlistRepositoriesRequest + * Execute getRepository request with HTTP info returned + * @return ApiResponse<Repository> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 repository -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public APIlistRepositoriesRequest amount(Integer amount) { - this.amount = amount; - return this; + public ApiResponse executeWithHttpInfo() throws ApiException { + return getRepositoryWithHttpInfo(repository); } /** - * Build call for listRepositories + * Execute getRepository request (asynchronously) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 repository -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return getRepositoryAsync(repository, _callback); + } + } + + /** + * get repository + * + * @param repository (required) + * @return APIgetRepositoryRequest + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 repository -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
+ */ + public APIgetRepositoryRequest getRepository(String repository) { + return new APIgetRepositoryRequest(repository); + } + private okhttp3.Call getRepositoryMetadataCall(String repository, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/repositories/{repository}/metadata" + .replace("{" + "repository" + "}", localVarApiClient.escapeString(repository.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "basic_auth", "cookie_auth", "oidc_auth", "saml_auth", "jwt_token" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getRepositoryMetadataValidateBeforeCall(String repository, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'repository' is set + if (repository == null) { + throw new ApiException("Missing the required parameter 'repository' when calling getRepositoryMetadata(Async)"); + } + + return getRepositoryMetadataCall(repository, _callback); + + } + + + private ApiResponse> getRepositoryMetadataWithHttpInfo(String repository) throws ApiException { + okhttp3.Call localVarCall = getRepositoryMetadataValidateBeforeCall(repository, null); + Type localVarReturnType = new TypeToken>(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + private okhttp3.Call getRepositoryMetadataAsync(String repository, final ApiCallback> _callback) throws ApiException { + + okhttp3.Call localVarCall = getRepositoryMetadataValidateBeforeCall(repository, _callback); + Type localVarReturnType = new TypeToken>(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + public class APIgetRepositoryMetadataRequest { + private final String repository; + + private APIgetRepositoryMetadataRequest(String repository) { + this.repository = repository; + } + + /** + * Build call for getRepositoryMetadata * @param _callback ApiCallback API callback * @return Call to execute * @throws ApiException If fail to serialize the request body object * @http.response.details - + +
Status Code Description Response Headers
200 repository list -
200 repository metadata -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { - return listRepositoriesCall(prefix, after, amount, _callback); + return getRepositoryMetadataCall(repository, _callback); } /** - * Execute listRepositories request - * @return RepositoryList + * Execute getRepositoryMetadata request + * @return Map<String, String> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - + +
Status Code Description Response Headers
200 repository list -
200 repository metadata -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public RepositoryList execute() throws ApiException { - ApiResponse localVarResp = listRepositoriesWithHttpInfo(prefix, after, amount); + public Map execute() throws ApiException { + ApiResponse> localVarResp = getRepositoryMetadataWithHttpInfo(repository); return localVarResp.getData(); } /** - * Execute listRepositories request with HTTP info returned - * @return ApiResponse<RepositoryList> + * Execute getRepositoryMetadata request with HTTP info returned + * @return ApiResponse<Map<String, String>> * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body * @http.response.details - + +
Status Code Description Response Headers
200 repository list -
200 repository metadata -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public ApiResponse executeWithHttpInfo() throws ApiException { - return listRepositoriesWithHttpInfo(prefix, after, amount); + public ApiResponse> executeWithHttpInfo() throws ApiException { + return getRepositoryMetadataWithHttpInfo(repository); } /** - * Execute listRepositories request (asynchronously) + * Execute getRepositoryMetadata request (asynchronously) * @param _callback The callback to be executed when the API call finishes * @return The request call * @throws ApiException If fail to process the API call, e.g. serializing the request body object * @http.response.details - + +
Status Code Description Response Headers
200 repository list -
200 repository metadata -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { - return listRepositoriesAsync(prefix, after, amount, _callback); + public okhttp3.Call executeAsync(final ApiCallback> _callback) throws ApiException { + return getRepositoryMetadataAsync(repository, _callback); } } /** - * list repositories + * get repository metadata * - * @return APIlistRepositoriesRequest + * @param repository (required) + * @return APIgetRepositoryMetadataRequest * @http.response.details - + +
Status Code Description Response Headers
200 repository list -
200 repository metadata -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
*/ - public APIlistRepositoriesRequest listRepositories() { - return new APIlistRepositoriesRequest(); + public APIgetRepositoryMetadataRequest getRepositoryMetadata(String repository) { + return new APIgetRepositoryMetadataRequest(repository); + } + private okhttp3.Call listRepositoriesCall(String prefix, String after, Integer amount, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/repositories"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (prefix != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("prefix", prefix)); + } + + if (after != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("after", after)); + } + + if (amount != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("amount", amount)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "basic_auth", "cookie_auth", "oidc_auth", "saml_auth", "jwt_token" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call listRepositoriesValidateBeforeCall(String prefix, String after, Integer amount, final ApiCallback _callback) throws ApiException { + return listRepositoriesCall(prefix, after, amount, _callback); + + } + + + private ApiResponse listRepositoriesWithHttpInfo(String prefix, String after, Integer amount) throws ApiException { + okhttp3.Call localVarCall = listRepositoriesValidateBeforeCall(prefix, after, amount, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + private okhttp3.Call listRepositoriesAsync(String prefix, String after, Integer amount, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = listRepositoriesValidateBeforeCall(prefix, after, amount, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + public class APIlistRepositoriesRequest { + private String prefix; + private String after; + private Integer amount; + + private APIlistRepositoriesRequest() { + } + + /** + * Set prefix + * @param prefix return items prefixed with this value (optional) + * @return APIlistRepositoriesRequest + */ + public APIlistRepositoriesRequest prefix(String prefix) { + this.prefix = prefix; + return this; + } + + /** + * Set after + * @param after return items after this value (optional) + * @return APIlistRepositoriesRequest + */ + public APIlistRepositoriesRequest after(String after) { + this.after = after; + return this; + } + + /** + * Set amount + * @param amount how many items to return (optional, default to 100) + * @return APIlistRepositoriesRequest + */ + public APIlistRepositoriesRequest amount(Integer amount) { + this.amount = amount; + return this; + } + + /** + * Build call for listRepositories + * @param _callback ApiCallback API callback + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + +
Status Code Description Response Headers
200 repository list -
401 Unauthorized -
420 too many requests -
0 Internal Server Error -
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return listRepositoriesCall(prefix, after, amount, _callback); + } + + /** + * Execute listRepositories request + * @return RepositoryList + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Status Code Description Response Headers
200 repository list -
401 Unauthorized -
420 too many requests -
0 Internal Server Error -
+ */ + public RepositoryList execute() throws ApiException { + ApiResponse localVarResp = listRepositoriesWithHttpInfo(prefix, after, amount); + return localVarResp.getData(); + } + + /** + * Execute listRepositories request with HTTP info returned + * @return ApiResponse<RepositoryList> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Status Code Description Response Headers
200 repository list -
401 Unauthorized -
420 too many requests -
0 Internal Server Error -
+ */ + public ApiResponse executeWithHttpInfo() throws ApiException { + return listRepositoriesWithHttpInfo(prefix, after, amount); + } + + /** + * Execute listRepositories request (asynchronously) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + +
Status Code Description Response Headers
200 repository list -
401 Unauthorized -
420 too many requests -
0 Internal Server Error -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return listRepositoriesAsync(prefix, after, amount, _callback); + } + } + + /** + * list repositories + * + * @return APIlistRepositoriesRequest + * @http.response.details + + + + + + +
Status Code Description Response Headers
200 repository list -
401 Unauthorized -
420 too many requests -
0 Internal Server Error -
+ */ + public APIlistRepositoriesRequest listRepositories() { + return new APIlistRepositoriesRequest(); + } + private okhttp3.Call restoreStatusCall(String repository, String taskId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/repositories/{repository}/restore" + .replace("{" + "repository" + "}", localVarApiClient.escapeString(repository.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (taskId != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("task_id", taskId)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "basic_auth", "cookie_auth", "oidc_auth", "saml_auth", "jwt_token" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call restoreStatusValidateBeforeCall(String repository, String taskId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'repository' is set + if (repository == null) { + throw new ApiException("Missing the required parameter 'repository' when calling restoreStatus(Async)"); + } + + // verify the required parameter 'taskId' is set + if (taskId == null) { + throw new ApiException("Missing the required parameter 'taskId' when calling restoreStatus(Async)"); + } + + return restoreStatusCall(repository, taskId, _callback); + + } + + + private ApiResponse restoreStatusWithHttpInfo(String repository, String taskId) throws ApiException { + okhttp3.Call localVarCall = restoreStatusValidateBeforeCall(repository, taskId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + private okhttp3.Call restoreStatusAsync(String repository, String taskId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = restoreStatusValidateBeforeCall(repository, taskId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + public class APIrestoreStatusRequest { + private final String repository; + private final String taskId; + + private APIrestoreStatusRequest(String repository, String taskId) { + this.repository = repository; + this.taskId = taskId; + } + + /** + * Build call for restoreStatus + * @param _callback ApiCallback API callback + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + +
Status Code Description Response Headers
200 restore task status -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return restoreStatusCall(repository, taskId, _callback); + } + + /** + * Execute restoreStatus request + * @return RepositoryRestoreStatus + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Status Code Description Response Headers
200 restore task status -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
+ */ + public RepositoryRestoreStatus execute() throws ApiException { + ApiResponse localVarResp = restoreStatusWithHttpInfo(repository, taskId); + return localVarResp.getData(); + } + + /** + * Execute restoreStatus request with HTTP info returned + * @return ApiResponse<RepositoryRestoreStatus> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + +
Status Code Description Response Headers
200 restore task status -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
+ */ + public ApiResponse executeWithHttpInfo() throws ApiException { + return restoreStatusWithHttpInfo(repository, taskId); + } + + /** + * Execute restoreStatus request (asynchronously) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + +
Status Code Description Response Headers
200 restore task status -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return restoreStatusAsync(repository, taskId, _callback); + } + } + + /** + * Status of a restore request + * + * @param repository (required) + * @param taskId (required) + * @return APIrestoreStatusRequest + * @http.response.details + + + + + + + + +
Status Code Description Response Headers
200 restore task status -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
420 too many requests -
0 Internal Server Error -
+ */ + public APIrestoreStatusRequest restoreStatus(String repository, String taskId) { + return new APIrestoreStatusRequest(repository, taskId); + } + private okhttp3.Call restoreSubmitCall(String repository, RefsDump refsDump, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = refsDump; + + // create path and map variables + String localVarPath = "/repositories/{repository}/restore" + .replace("{" + "repository" + "}", localVarApiClient.escapeString(repository.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "basic_auth", "cookie_auth", "oidc_auth", "saml_auth", "jwt_token" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call restoreSubmitValidateBeforeCall(String repository, RefsDump refsDump, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'repository' is set + if (repository == null) { + throw new ApiException("Missing the required parameter 'repository' when calling restoreSubmit(Async)"); + } + + // verify the required parameter 'refsDump' is set + if (refsDump == null) { + throw new ApiException("Missing the required parameter 'refsDump' when calling restoreSubmit(Async)"); + } + + return restoreSubmitCall(repository, refsDump, _callback); + + } + + + private ApiResponse restoreSubmitWithHttpInfo(String repository, RefsDump refsDump) throws ApiException { + okhttp3.Call localVarCall = restoreSubmitValidateBeforeCall(repository, refsDump, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + private okhttp3.Call restoreSubmitAsync(String repository, RefsDump refsDump, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = restoreSubmitValidateBeforeCall(repository, refsDump, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + public class APIrestoreSubmitRequest { + private final String repository; + private final RefsDump refsDump; + + private APIrestoreSubmitRequest(String repository, RefsDump refsDump) { + this.repository = repository; + this.refsDump = refsDump; + } + + /** + * Build call for restoreSubmit + * @param _callback ApiCallback API callback + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + +
Status Code Description Response Headers
202 restore task created -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return restoreSubmitCall(repository, refsDump, _callback); + } + + /** + * Execute restoreSubmit request + * @return TaskInfo + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
202 restore task created -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public TaskInfo execute() throws ApiException { + ApiResponse localVarResp = restoreSubmitWithHttpInfo(repository, refsDump); + return localVarResp.getData(); + } + + /** + * Execute restoreSubmit request with HTTP info returned + * @return ApiResponse<TaskInfo> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
202 restore task created -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public ApiResponse executeWithHttpInfo() throws ApiException { + return restoreSubmitWithHttpInfo(repository, refsDump); + } + + /** + * Execute restoreSubmit request (asynchronously) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + +
Status Code Description Response Headers
202 restore task created -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public okhttp3.Call executeAsync(final ApiCallback _callback) throws ApiException { + return restoreSubmitAsync(repository, refsDump, _callback); + } + } + + /** + * Restore repository from a dump in the object store + * + * @param repository (required) + * @param refsDump (required) + * @return APIrestoreSubmitRequest + * @http.response.details + + + + + + + +
Status Code Description Response Headers
202 restore task created -
400 Validation Error -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public APIrestoreSubmitRequest restoreSubmit(String repository, RefsDump refsDump) { + return new APIrestoreSubmitRequest(repository, refsDump); } private okhttp3.Call setBranchProtectionRulesCall(String repository, List branchProtectionRule, String ifMatch, final ApiCallback _callback) throws ApiException { String basePath = null; diff --git a/clients/java/src/main/java/io/lakefs/clients/sdk/model/RepositoryDumpStatus.java b/clients/java/src/main/java/io/lakefs/clients/sdk/model/RepositoryDumpStatus.java new file mode 100644 index 00000000000..bcfcbd301b4 --- /dev/null +++ b/clients/java/src/main/java/io/lakefs/clients/sdk/model/RepositoryDumpStatus.java @@ -0,0 +1,416 @@ +/* + * lakeFS API + * lakeFS HTTP API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lakefs.clients.sdk.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.lakefs.clients.sdk.model.RefsDump; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.lakefs.clients.sdk.JSON; + +/** + * RepositoryDumpStatus + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class RepositoryDumpStatus { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + private Boolean done; + + public static final String SERIALIZED_NAME_UPDATE_TIME = "update_time"; + @SerializedName(SERIALIZED_NAME_UPDATE_TIME) + private OffsetDateTime updateTime; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + private String error; + + public static final String SERIALIZED_NAME_REFS = "refs"; + @SerializedName(SERIALIZED_NAME_REFS) + private RefsDump refs; + + public RepositoryDumpStatus() { + } + + public RepositoryDumpStatus id(String id) { + + this.id = id; + return this; + } + + /** + * ID of the task + * @return id + **/ + @javax.annotation.Nonnull + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public RepositoryDumpStatus done(Boolean done) { + + this.done = done; + return this; + } + + /** + * Get done + * @return done + **/ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + + public void setDone(Boolean done) { + this.done = done; + } + + + public RepositoryDumpStatus updateTime(OffsetDateTime updateTime) { + + this.updateTime = updateTime; + return this; + } + + /** + * Get updateTime + * @return updateTime + **/ + @javax.annotation.Nonnull + public OffsetDateTime getUpdateTime() { + return updateTime; + } + + + public void setUpdateTime(OffsetDateTime updateTime) { + this.updateTime = updateTime; + } + + + public RepositoryDumpStatus error(String error) { + + this.error = error; + return this; + } + + /** + * Get error + * @return error + **/ + @javax.annotation.Nullable + public String getError() { + return error; + } + + + public void setError(String error) { + this.error = error; + } + + + public RepositoryDumpStatus refs(RefsDump refs) { + + this.refs = refs; + return this; + } + + /** + * Get refs + * @return refs + **/ + @javax.annotation.Nullable + public RefsDump getRefs() { + return refs; + } + + + public void setRefs(RefsDump refs) { + this.refs = refs; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RepositoryDumpStatus instance itself + */ + public RepositoryDumpStatus putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RepositoryDumpStatus repositoryDumpStatus = (RepositoryDumpStatus) o; + return Objects.equals(this.id, repositoryDumpStatus.id) && + Objects.equals(this.done, repositoryDumpStatus.done) && + Objects.equals(this.updateTime, repositoryDumpStatus.updateTime) && + Objects.equals(this.error, repositoryDumpStatus.error) && + Objects.equals(this.refs, repositoryDumpStatus.refs)&& + Objects.equals(this.additionalProperties, repositoryDumpStatus.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, done, updateTime, error, refs, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RepositoryDumpStatus {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" updateTime: ").append(toIndentedString(updateTime)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" refs: ").append(toIndentedString(refs)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("done"); + openapiFields.add("update_time"); + openapiFields.add("error"); + openapiFields.add("refs"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("done"); + openapiRequiredFields.add("update_time"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RepositoryDumpStatus + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RepositoryDumpStatus.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RepositoryDumpStatus is not found in the empty JSON string", RepositoryDumpStatus.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RepositoryDumpStatus.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if ((jsonObj.get("error") != null && !jsonObj.get("error").isJsonNull()) && !jsonObj.get("error").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `error` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error").toString())); + } + // validate the optional field `refs` + if (jsonObj.get("refs") != null && !jsonObj.get("refs").isJsonNull()) { + RefsDump.validateJsonElement(jsonObj.get("refs")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RepositoryDumpStatus.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RepositoryDumpStatus' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RepositoryDumpStatus.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RepositoryDumpStatus value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public RepositoryDumpStatus read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RepositoryDumpStatus instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RepositoryDumpStatus given an JSON string + * + * @param jsonString JSON string + * @return An instance of RepositoryDumpStatus + * @throws IOException if the JSON string is invalid with respect to RepositoryDumpStatus + */ + public static RepositoryDumpStatus fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RepositoryDumpStatus.class); + } + + /** + * Convert an instance of RepositoryDumpStatus to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/lakefs/clients/sdk/model/RepositoryRestoreStatus.java b/clients/java/src/main/java/io/lakefs/clients/sdk/model/RepositoryRestoreStatus.java new file mode 100644 index 00000000000..b9b9656949b --- /dev/null +++ b/clients/java/src/main/java/io/lakefs/clients/sdk/model/RepositoryRestoreStatus.java @@ -0,0 +1,383 @@ +/* + * lakeFS API + * lakeFS HTTP API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lakefs.clients.sdk.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.lakefs.clients.sdk.JSON; + +/** + * RepositoryRestoreStatus + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class RepositoryRestoreStatus { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public static final String SERIALIZED_NAME_DONE = "done"; + @SerializedName(SERIALIZED_NAME_DONE) + private Boolean done; + + public static final String SERIALIZED_NAME_UPDATE_TIME = "update_time"; + @SerializedName(SERIALIZED_NAME_UPDATE_TIME) + private OffsetDateTime updateTime; + + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + private String error; + + public RepositoryRestoreStatus() { + } + + public RepositoryRestoreStatus id(String id) { + + this.id = id; + return this; + } + + /** + * ID of the task + * @return id + **/ + @javax.annotation.Nonnull + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + + public RepositoryRestoreStatus done(Boolean done) { + + this.done = done; + return this; + } + + /** + * Get done + * @return done + **/ + @javax.annotation.Nonnull + public Boolean getDone() { + return done; + } + + + public void setDone(Boolean done) { + this.done = done; + } + + + public RepositoryRestoreStatus updateTime(OffsetDateTime updateTime) { + + this.updateTime = updateTime; + return this; + } + + /** + * Get updateTime + * @return updateTime + **/ + @javax.annotation.Nonnull + public OffsetDateTime getUpdateTime() { + return updateTime; + } + + + public void setUpdateTime(OffsetDateTime updateTime) { + this.updateTime = updateTime; + } + + + public RepositoryRestoreStatus error(String error) { + + this.error = error; + return this; + } + + /** + * Get error + * @return error + **/ + @javax.annotation.Nullable + public String getError() { + return error; + } + + + public void setError(String error) { + this.error = error; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the RepositoryRestoreStatus instance itself + */ + public RepositoryRestoreStatus putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RepositoryRestoreStatus repositoryRestoreStatus = (RepositoryRestoreStatus) o; + return Objects.equals(this.id, repositoryRestoreStatus.id) && + Objects.equals(this.done, repositoryRestoreStatus.done) && + Objects.equals(this.updateTime, repositoryRestoreStatus.updateTime) && + Objects.equals(this.error, repositoryRestoreStatus.error)&& + Objects.equals(this.additionalProperties, repositoryRestoreStatus.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, done, updateTime, error, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RepositoryRestoreStatus {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" done: ").append(toIndentedString(done)).append("\n"); + sb.append(" updateTime: ").append(toIndentedString(updateTime)).append("\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + openapiFields.add("done"); + openapiFields.add("update_time"); + openapiFields.add("error"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("id"); + openapiRequiredFields.add("done"); + openapiRequiredFields.add("update_time"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to RepositoryRestoreStatus + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RepositoryRestoreStatus.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in RepositoryRestoreStatus is not found in the empty JSON string", RepositoryRestoreStatus.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : RepositoryRestoreStatus.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if ((jsonObj.get("error") != null && !jsonObj.get("error").isJsonNull()) && !jsonObj.get("error").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `error` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RepositoryRestoreStatus.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RepositoryRestoreStatus' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(RepositoryRestoreStatus.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, RepositoryRestoreStatus value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public RepositoryRestoreStatus read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RepositoryRestoreStatus instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of RepositoryRestoreStatus given an JSON string + * + * @param jsonString JSON string + * @return An instance of RepositoryRestoreStatus + * @throws IOException if the JSON string is invalid with respect to RepositoryRestoreStatus + */ + public static RepositoryRestoreStatus fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RepositoryRestoreStatus.class); + } + + /** + * Convert an instance of RepositoryRestoreStatus to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/main/java/io/lakefs/clients/sdk/model/TaskInfo.java b/clients/java/src/main/java/io/lakefs/clients/sdk/model/TaskInfo.java new file mode 100644 index 00000000000..4c5dbd6eabe --- /dev/null +++ b/clients/java/src/main/java/io/lakefs/clients/sdk/model/TaskInfo.java @@ -0,0 +1,293 @@ +/* + * lakeFS API + * lakeFS HTTP API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lakefs.clients.sdk.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import io.lakefs.clients.sdk.JSON; + +/** + * TaskInfo + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TaskInfo { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public TaskInfo() { + } + + public TaskInfo id(String id) { + + this.id = id; + return this; + } + + /** + * ID of the task + * @return id + **/ + @javax.annotation.Nonnull + public String getId() { + return id; + } + + + public void setId(String id) { + this.id = id; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the TaskInfo instance itself + */ + public TaskInfo putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TaskInfo taskInfo = (TaskInfo) o; + return Objects.equals(this.id, taskInfo.id)&& + Objects.equals(this.additionalProperties, taskInfo.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TaskInfo {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("id"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + openapiRequiredFields.add("id"); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to TaskInfo + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!TaskInfo.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in TaskInfo is not found in the empty JSON string", TaskInfo.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : TaskInfo.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TaskInfo.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TaskInfo' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(TaskInfo.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, TaskInfo value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject()); + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public TaskInfo read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + TaskInfo instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of TaskInfo given an JSON string + * + * @param jsonString JSON string + * @return An instance of TaskInfo + * @throws IOException if the JSON string is invalid with respect to TaskInfo + */ + public static TaskInfo fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TaskInfo.class); + } + + /** + * Convert an instance of TaskInfo to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/clients/java/src/test/java/io/lakefs/clients/sdk/RepositoriesApiTest.java b/clients/java/src/test/java/io/lakefs/clients/sdk/RepositoriesApiTest.java index 3f25f30bad0..8388020a322 100644 --- a/clients/java/src/test/java/io/lakefs/clients/sdk/RepositoriesApiTest.java +++ b/clients/java/src/test/java/io/lakefs/clients/sdk/RepositoriesApiTest.java @@ -17,9 +17,13 @@ import io.lakefs.clients.sdk.model.BranchProtectionRule; import io.lakefs.clients.sdk.model.Error; import io.lakefs.clients.sdk.model.GarbageCollectionRules; +import io.lakefs.clients.sdk.model.RefsDump; import io.lakefs.clients.sdk.model.Repository; import io.lakefs.clients.sdk.model.RepositoryCreation; +import io.lakefs.clients.sdk.model.RepositoryDumpStatus; import io.lakefs.clients.sdk.model.RepositoryList; +import io.lakefs.clients.sdk.model.RepositoryRestoreStatus; +import io.lakefs.clients.sdk.model.TaskInfo; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -75,6 +79,33 @@ public void deleteRepositoryTest() throws ApiException { // TODO: test validations } + /** + * Status of a repository dump task + * + * @throws ApiException if the Api call fails + */ + @Test + public void dumpStatusTest() throws ApiException { + String repository = null; + String taskId = null; + RepositoryDumpStatus response = api.dumpStatus(repository, taskId) + .execute(); + // TODO: test validations + } + + /** + * Backup the repository metadata (tags, commits, branches) and save the backup to the object store. + * + * @throws ApiException if the Api call fails + */ + @Test + public void dumpSubmitTest() throws ApiException { + String repository = null; + TaskInfo response = api.dumpSubmit(repository) + .execute(); + // TODO: test validations + } + /** * get branch protection rules * @@ -145,6 +176,34 @@ public void listRepositoriesTest() throws ApiException { // TODO: test validations } + /** + * Status of a restore request + * + * @throws ApiException if the Api call fails + */ + @Test + public void restoreStatusTest() throws ApiException { + String repository = null; + String taskId = null; + RepositoryRestoreStatus response = api.restoreStatus(repository, taskId) + .execute(); + // TODO: test validations + } + + /** + * Restore repository from a dump in the object store + * + * @throws ApiException if the Api call fails + */ + @Test + public void restoreSubmitTest() throws ApiException { + String repository = null; + RefsDump refsDump = null; + TaskInfo response = api.restoreSubmit(repository, refsDump) + .execute(); + // TODO: test validations + } + /** * @throws ApiException if the Api call fails */ diff --git a/clients/java/src/test/java/io/lakefs/clients/sdk/model/RepositoryDumpStatusTest.java b/clients/java/src/test/java/io/lakefs/clients/sdk/model/RepositoryDumpStatusTest.java new file mode 100644 index 00000000000..422baa0d902 --- /dev/null +++ b/clients/java/src/test/java/io/lakefs/clients/sdk/model/RepositoryDumpStatusTest.java @@ -0,0 +1,82 @@ +/* + * lakeFS API + * lakeFS HTTP API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lakefs.clients.sdk.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.lakefs.clients.sdk.model.RefsDump; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Arrays; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for RepositoryDumpStatus + */ +public class RepositoryDumpStatusTest { + private final RepositoryDumpStatus model = new RepositoryDumpStatus(); + + /** + * Model tests for RepositoryDumpStatus + */ + @Test + public void testRepositoryDumpStatus() { + // TODO: test RepositoryDumpStatus + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'done' + */ + @Test + public void doneTest() { + // TODO: test done + } + + /** + * Test the property 'updateTime' + */ + @Test + public void updateTimeTest() { + // TODO: test updateTime + } + + /** + * Test the property 'error' + */ + @Test + public void errorTest() { + // TODO: test error + } + + /** + * Test the property 'refs' + */ + @Test + public void refsTest() { + // TODO: test refs + } + +} diff --git a/clients/java/src/test/java/io/lakefs/clients/sdk/model/RepositoryRestoreStatusTest.java b/clients/java/src/test/java/io/lakefs/clients/sdk/model/RepositoryRestoreStatusTest.java new file mode 100644 index 00000000000..293f0a1f457 --- /dev/null +++ b/clients/java/src/test/java/io/lakefs/clients/sdk/model/RepositoryRestoreStatusTest.java @@ -0,0 +1,73 @@ +/* + * lakeFS API + * lakeFS HTTP API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lakefs.clients.sdk.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Arrays; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for RepositoryRestoreStatus + */ +public class RepositoryRestoreStatusTest { + private final RepositoryRestoreStatus model = new RepositoryRestoreStatus(); + + /** + * Model tests for RepositoryRestoreStatus + */ + @Test + public void testRepositoryRestoreStatus() { + // TODO: test RepositoryRestoreStatus + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + + /** + * Test the property 'done' + */ + @Test + public void doneTest() { + // TODO: test done + } + + /** + * Test the property 'updateTime' + */ + @Test + public void updateTimeTest() { + // TODO: test updateTime + } + + /** + * Test the property 'error' + */ + @Test + public void errorTest() { + // TODO: test error + } + +} diff --git a/clients/java/src/test/java/io/lakefs/clients/sdk/model/TaskInfoTest.java b/clients/java/src/test/java/io/lakefs/clients/sdk/model/TaskInfoTest.java new file mode 100644 index 00000000000..858ed410a9d --- /dev/null +++ b/clients/java/src/test/java/io/lakefs/clients/sdk/model/TaskInfoTest.java @@ -0,0 +1,48 @@ +/* + * lakeFS API + * lakeFS HTTP API + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package io.lakefs.clients.sdk.model; + +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * Model tests for TaskInfo + */ +public class TaskInfoTest { + private final TaskInfo model = new TaskInfo(); + + /** + * Model tests for TaskInfo + */ + @Test + public void testTaskInfo() { + // TODO: test TaskInfo + } + + /** + * Test the property 'id' + */ + @Test + public void idTest() { + // TODO: test id + } + +} diff --git a/clients/python-legacy/.openapi-generator/FILES b/clients/python-legacy/.openapi-generator/FILES index b339cc07b0b..4357b13fd7b 100644 --- a/clients/python-legacy/.openapi-generator/FILES +++ b/clients/python-legacy/.openapi-generator/FILES @@ -82,8 +82,10 @@ docs/RefsDump.md docs/RepositoriesApi.md docs/Repository.md docs/RepositoryCreation.md +docs/RepositoryDumpStatus.md docs/RepositoryList.md docs/RepositoryMetadata.md +docs/RepositoryRestoreStatus.md docs/ResetCreation.md docs/RevertCreation.md docs/Setup.md @@ -98,6 +100,7 @@ docs/StorageConfig.md docs/StorageURI.md docs/TagCreation.md docs/TagsApi.md +docs/TaskInfo.md docs/UnderlyingObjectProperties.md docs/UpdateToken.md docs/User.md @@ -195,8 +198,10 @@ lakefs_client/model/ref_list.py lakefs_client/model/refs_dump.py lakefs_client/model/repository.py lakefs_client/model/repository_creation.py +lakefs_client/model/repository_dump_status.py lakefs_client/model/repository_list.py lakefs_client/model/repository_metadata.py +lakefs_client/model/repository_restore_status.py lakefs_client/model/reset_creation.py lakefs_client/model/revert_creation.py lakefs_client/model/setup.py @@ -209,6 +214,7 @@ lakefs_client/model/stats_events_list.py lakefs_client/model/storage_config.py lakefs_client/model/storage_uri.py lakefs_client/model/tag_creation.py +lakefs_client/model/task_info.py lakefs_client/model/underlying_object_properties.py lakefs_client/model/update_token.py lakefs_client/model/user.py @@ -303,8 +309,10 @@ test/test_refs_dump.py test/test_repositories_api.py test/test_repository.py test/test_repository_creation.py +test/test_repository_dump_status.py test/test_repository_list.py test/test_repository_metadata.py +test/test_repository_restore_status.py test/test_reset_creation.py test/test_revert_creation.py test/test_setup.py @@ -319,6 +327,7 @@ test/test_storage_config.py test/test_storage_uri.py test/test_tag_creation.py test/test_tags_api.py +test/test_task_info.py test/test_underlying_object_properties.py test/test_update_token.py test/test_user.py diff --git a/clients/python-legacy/README.md b/clients/python-legacy/README.md index dd17fcc829c..f3e9ff77e99 100644 --- a/clients/python-legacy/README.md +++ b/clients/python-legacy/README.md @@ -209,11 +209,15 @@ Class | Method | HTTP request | Description *RepositoriesApi* | [**create_repository**](docs/RepositoriesApi.md#create_repository) | **POST** /repositories | create repository *RepositoriesApi* | [**delete_gc_rules**](docs/RepositoriesApi.md#delete_gc_rules) | **DELETE** /repositories/{repository}/settings/gc_rules | *RepositoriesApi* | [**delete_repository**](docs/RepositoriesApi.md#delete_repository) | **DELETE** /repositories/{repository} | delete repository +*RepositoriesApi* | [**dump_status**](docs/RepositoriesApi.md#dump_status) | **GET** /repositories/{repository}/dump | Status of a repository dump task +*RepositoriesApi* | [**dump_submit**](docs/RepositoriesApi.md#dump_submit) | **POST** /repositories/{repository}/dump | Backup the repository metadata (tags, commits, branches) and save the backup to the object store. *RepositoriesApi* | [**get_branch_protection_rules**](docs/RepositoriesApi.md#get_branch_protection_rules) | **GET** /repositories/{repository}/settings/branch_protection | get branch protection rules *RepositoriesApi* | [**get_gc_rules**](docs/RepositoriesApi.md#get_gc_rules) | **GET** /repositories/{repository}/settings/gc_rules | get repository GC rules *RepositoriesApi* | [**get_repository**](docs/RepositoriesApi.md#get_repository) | **GET** /repositories/{repository} | get repository *RepositoriesApi* | [**get_repository_metadata**](docs/RepositoriesApi.md#get_repository_metadata) | **GET** /repositories/{repository}/metadata | get repository metadata *RepositoriesApi* | [**list_repositories**](docs/RepositoriesApi.md#list_repositories) | **GET** /repositories | list repositories +*RepositoriesApi* | [**restore_status**](docs/RepositoriesApi.md#restore_status) | **GET** /repositories/{repository}/restore | Status of a restore request +*RepositoriesApi* | [**restore_submit**](docs/RepositoriesApi.md#restore_submit) | **POST** /repositories/{repository}/restore | Restore repository from a dump in the object store *RepositoriesApi* | [**set_branch_protection_rules**](docs/RepositoriesApi.md#set_branch_protection_rules) | **PUT** /repositories/{repository}/settings/branch_protection | *RepositoriesApi* | [**set_gc_rules**](docs/RepositoriesApi.md#set_gc_rules) | **PUT** /repositories/{repository}/settings/gc_rules | *StagingApi* | [**get_physical_address**](docs/StagingApi.md#get_physical_address) | **GET** /repositories/{repository}/branches/{branch}/staging/backing | generate an address to which the client can upload an object @@ -293,8 +297,10 @@ Class | Method | HTTP request | Description - [RefsDump](docs/RefsDump.md) - [Repository](docs/Repository.md) - [RepositoryCreation](docs/RepositoryCreation.md) + - [RepositoryDumpStatus](docs/RepositoryDumpStatus.md) - [RepositoryList](docs/RepositoryList.md) - [RepositoryMetadata](docs/RepositoryMetadata.md) + - [RepositoryRestoreStatus](docs/RepositoryRestoreStatus.md) - [ResetCreation](docs/ResetCreation.md) - [RevertCreation](docs/RevertCreation.md) - [Setup](docs/Setup.md) @@ -307,6 +313,7 @@ Class | Method | HTTP request | Description - [StorageConfig](docs/StorageConfig.md) - [StorageURI](docs/StorageURI.md) - [TagCreation](docs/TagCreation.md) + - [TaskInfo](docs/TaskInfo.md) - [UnderlyingObjectProperties](docs/UnderlyingObjectProperties.md) - [UpdateToken](docs/UpdateToken.md) - [User](docs/User.md) diff --git a/clients/python-legacy/docs/RepositoriesApi.md b/clients/python-legacy/docs/RepositoriesApi.md index 03dc30e6d25..2b855308310 100644 --- a/clients/python-legacy/docs/RepositoriesApi.md +++ b/clients/python-legacy/docs/RepositoriesApi.md @@ -7,11 +7,15 @@ Method | HTTP request | Description [**create_repository**](RepositoriesApi.md#create_repository) | **POST** /repositories | create repository [**delete_gc_rules**](RepositoriesApi.md#delete_gc_rules) | **DELETE** /repositories/{repository}/settings/gc_rules | [**delete_repository**](RepositoriesApi.md#delete_repository) | **DELETE** /repositories/{repository} | delete repository +[**dump_status**](RepositoriesApi.md#dump_status) | **GET** /repositories/{repository}/dump | Status of a repository dump task +[**dump_submit**](RepositoriesApi.md#dump_submit) | **POST** /repositories/{repository}/dump | Backup the repository metadata (tags, commits, branches) and save the backup to the object store. [**get_branch_protection_rules**](RepositoriesApi.md#get_branch_protection_rules) | **GET** /repositories/{repository}/settings/branch_protection | get branch protection rules [**get_gc_rules**](RepositoriesApi.md#get_gc_rules) | **GET** /repositories/{repository}/settings/gc_rules | get repository GC rules [**get_repository**](RepositoriesApi.md#get_repository) | **GET** /repositories/{repository} | get repository [**get_repository_metadata**](RepositoriesApi.md#get_repository_metadata) | **GET** /repositories/{repository}/metadata | get repository metadata [**list_repositories**](RepositoriesApi.md#list_repositories) | **GET** /repositories | list repositories +[**restore_status**](RepositoriesApi.md#restore_status) | **GET** /repositories/{repository}/restore | Status of a restore request +[**restore_submit**](RepositoriesApi.md#restore_submit) | **POST** /repositories/{repository}/restore | Restore repository from a dump in the object store [**set_branch_protection_rules**](RepositoriesApi.md#set_branch_protection_rules) | **PUT** /repositories/{repository}/settings/branch_protection | [**set_gc_rules**](RepositoriesApi.md#set_gc_rules) | **PUT** /repositories/{repository}/settings/gc_rules | @@ -353,6 +357,225 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **dump_status** +> RepositoryDumpStatus dump_status(repository, task_id) + +Status of a repository dump task + +### Example + +* Basic Authentication (basic_auth): +* Api Key Authentication (cookie_auth): +* Bearer (JWT) Authentication (jwt_token): +* Api Key Authentication (oidc_auth): +* Api Key Authentication (saml_auth): + +```python +import time +import lakefs_client +from lakefs_client.api import repositories_api +from lakefs_client.model.repository_dump_status import RepositoryDumpStatus +from lakefs_client.model.error import Error +from pprint import pprint +# Defining the host is optional and defaults to http://localhost/api/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = lakefs_client.Configuration( + host = "http://localhost/api/v1" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure HTTP basic authorization: basic_auth +configuration = lakefs_client.Configuration( + username = 'YOUR_USERNAME', + password = 'YOUR_PASSWORD' +) + +# Configure API key authorization: cookie_auth +configuration.api_key['cookie_auth'] = 'YOUR_API_KEY' + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['cookie_auth'] = 'Bearer' + +# Configure Bearer authorization (JWT): jwt_token +configuration = lakefs_client.Configuration( + access_token = 'YOUR_BEARER_TOKEN' +) + +# Configure API key authorization: oidc_auth +configuration.api_key['oidc_auth'] = 'YOUR_API_KEY' + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['oidc_auth'] = 'Bearer' + +# Configure API key authorization: saml_auth +configuration.api_key['saml_auth'] = 'YOUR_API_KEY' + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['saml_auth'] = 'Bearer' + +# Enter a context with an instance of the API client +with lakefs_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = repositories_api.RepositoriesApi(api_client) + repository = "repository_example" # str | + task_id = "task_id_example" # str | + + # example passing only required values which don't have defaults set + try: + # Status of a repository dump task + api_response = api_instance.dump_status(repository, task_id) + pprint(api_response) + except lakefs_client.ApiException as e: + print("Exception when calling RepositoriesApi->dump_status: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **str**| | + **task_id** | **str**| | + +### Return type + +[**RepositoryDumpStatus**](RepositoryDumpStatus.md) + +### Authorization + +[basic_auth](../README.md#basic_auth), [cookie_auth](../README.md#cookie_auth), [jwt_token](../README.md#jwt_token), [oidc_auth](../README.md#oidc_auth), [saml_auth](../README.md#saml_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | dump task status | - | +**400** | Validation Error | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**420** | too many requests | - | +**0** | Internal Server Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **dump_submit** +> TaskInfo dump_submit(repository) + +Backup the repository metadata (tags, commits, branches) and save the backup to the object store. + +### Example + +* Basic Authentication (basic_auth): +* Api Key Authentication (cookie_auth): +* Bearer (JWT) Authentication (jwt_token): +* Api Key Authentication (oidc_auth): +* Api Key Authentication (saml_auth): + +```python +import time +import lakefs_client +from lakefs_client.api import repositories_api +from lakefs_client.model.error import Error +from lakefs_client.model.task_info import TaskInfo +from pprint import pprint +# Defining the host is optional and defaults to http://localhost/api/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = lakefs_client.Configuration( + host = "http://localhost/api/v1" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure HTTP basic authorization: basic_auth +configuration = lakefs_client.Configuration( + username = 'YOUR_USERNAME', + password = 'YOUR_PASSWORD' +) + +# Configure API key authorization: cookie_auth +configuration.api_key['cookie_auth'] = 'YOUR_API_KEY' + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['cookie_auth'] = 'Bearer' + +# Configure Bearer authorization (JWT): jwt_token +configuration = lakefs_client.Configuration( + access_token = 'YOUR_BEARER_TOKEN' +) + +# Configure API key authorization: oidc_auth +configuration.api_key['oidc_auth'] = 'YOUR_API_KEY' + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['oidc_auth'] = 'Bearer' + +# Configure API key authorization: saml_auth +configuration.api_key['saml_auth'] = 'YOUR_API_KEY' + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['saml_auth'] = 'Bearer' + +# Enter a context with an instance of the API client +with lakefs_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = repositories_api.RepositoriesApi(api_client) + repository = "repository_example" # str | + + # example passing only required values which don't have defaults set + try: + # Backup the repository metadata (tags, commits, branches) and save the backup to the object store. + api_response = api_instance.dump_submit(repository) + pprint(api_response) + except lakefs_client.ApiException as e: + print("Exception when calling RepositoriesApi->dump_submit: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **str**| | + +### Return type + +[**TaskInfo**](TaskInfo.md) + +### Authorization + +[basic_auth](../README.md#basic_auth), [cookie_auth](../README.md#cookie_auth), [jwt_token](../README.md#jwt_token), [oidc_auth](../README.md#oidc_auth), [saml_auth](../README.md#saml_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**202** | dump task information | - | +**400** | Validation Error | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**0** | Internal Server Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **get_branch_protection_rules** > [BranchProtectionRule] get_branch_protection_rules(repository) @@ -897,6 +1120,232 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **restore_status** +> RepositoryRestoreStatus restore_status(repository, task_id) + +Status of a restore request + +### Example + +* Basic Authentication (basic_auth): +* Api Key Authentication (cookie_auth): +* Bearer (JWT) Authentication (jwt_token): +* Api Key Authentication (oidc_auth): +* Api Key Authentication (saml_auth): + +```python +import time +import lakefs_client +from lakefs_client.api import repositories_api +from lakefs_client.model.repository_restore_status import RepositoryRestoreStatus +from lakefs_client.model.error import Error +from pprint import pprint +# Defining the host is optional and defaults to http://localhost/api/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = lakefs_client.Configuration( + host = "http://localhost/api/v1" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure HTTP basic authorization: basic_auth +configuration = lakefs_client.Configuration( + username = 'YOUR_USERNAME', + password = 'YOUR_PASSWORD' +) + +# Configure API key authorization: cookie_auth +configuration.api_key['cookie_auth'] = 'YOUR_API_KEY' + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['cookie_auth'] = 'Bearer' + +# Configure Bearer authorization (JWT): jwt_token +configuration = lakefs_client.Configuration( + access_token = 'YOUR_BEARER_TOKEN' +) + +# Configure API key authorization: oidc_auth +configuration.api_key['oidc_auth'] = 'YOUR_API_KEY' + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['oidc_auth'] = 'Bearer' + +# Configure API key authorization: saml_auth +configuration.api_key['saml_auth'] = 'YOUR_API_KEY' + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['saml_auth'] = 'Bearer' + +# Enter a context with an instance of the API client +with lakefs_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = repositories_api.RepositoriesApi(api_client) + repository = "repository_example" # str | + task_id = "task_id_example" # str | + + # example passing only required values which don't have defaults set + try: + # Status of a restore request + api_response = api_instance.restore_status(repository, task_id) + pprint(api_response) + except lakefs_client.ApiException as e: + print("Exception when calling RepositoriesApi->restore_status: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **str**| | + **task_id** | **str**| | + +### Return type + +[**RepositoryRestoreStatus**](RepositoryRestoreStatus.md) + +### Authorization + +[basic_auth](../README.md#basic_auth), [cookie_auth](../README.md#cookie_auth), [jwt_token](../README.md#jwt_token), [oidc_auth](../README.md#oidc_auth), [saml_auth](../README.md#saml_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | restore task status | - | +**400** | Validation Error | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**420** | too many requests | - | +**0** | Internal Server Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **restore_submit** +> TaskInfo restore_submit(repository, refs_dump) + +Restore repository from a dump in the object store + +### Example + +* Basic Authentication (basic_auth): +* Api Key Authentication (cookie_auth): +* Bearer (JWT) Authentication (jwt_token): +* Api Key Authentication (oidc_auth): +* Api Key Authentication (saml_auth): + +```python +import time +import lakefs_client +from lakefs_client.api import repositories_api +from lakefs_client.model.refs_dump import RefsDump +from lakefs_client.model.error import Error +from lakefs_client.model.task_info import TaskInfo +from pprint import pprint +# Defining the host is optional and defaults to http://localhost/api/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = lakefs_client.Configuration( + host = "http://localhost/api/v1" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure HTTP basic authorization: basic_auth +configuration = lakefs_client.Configuration( + username = 'YOUR_USERNAME', + password = 'YOUR_PASSWORD' +) + +# Configure API key authorization: cookie_auth +configuration.api_key['cookie_auth'] = 'YOUR_API_KEY' + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['cookie_auth'] = 'Bearer' + +# Configure Bearer authorization (JWT): jwt_token +configuration = lakefs_client.Configuration( + access_token = 'YOUR_BEARER_TOKEN' +) + +# Configure API key authorization: oidc_auth +configuration.api_key['oidc_auth'] = 'YOUR_API_KEY' + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['oidc_auth'] = 'Bearer' + +# Configure API key authorization: saml_auth +configuration.api_key['saml_auth'] = 'YOUR_API_KEY' + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['saml_auth'] = 'Bearer' + +# Enter a context with an instance of the API client +with lakefs_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = repositories_api.RepositoriesApi(api_client) + repository = "repository_example" # str | + refs_dump = RefsDump( + commits_meta_range_id="commits_meta_range_id_example", + tags_meta_range_id="tags_meta_range_id_example", + branches_meta_range_id="branches_meta_range_id_example", + ) # RefsDump | + + # example passing only required values which don't have defaults set + try: + # Restore repository from a dump in the object store + api_response = api_instance.restore_submit(repository, refs_dump) + pprint(api_response) + except lakefs_client.ApiException as e: + print("Exception when calling RepositoriesApi->restore_submit: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **str**| | + **refs_dump** | [**RefsDump**](RefsDump.md)| | + +### Return type + +[**TaskInfo**](TaskInfo.md) + +### Authorization + +[basic_auth](../README.md#basic_auth), [cookie_auth](../README.md#cookie_auth), [jwt_token](../README.md#jwt_token), [oidc_auth](../README.md#oidc_auth), [saml_auth](../README.md#saml_auth) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**202** | restore task created | - | +**400** | Validation Error | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**0** | Internal Server Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **set_branch_protection_rules** > set_branch_protection_rules(repository, branch_protection_rule) diff --git a/clients/python-legacy/docs/RepositoryDumpStatus.md b/clients/python-legacy/docs/RepositoryDumpStatus.md new file mode 100644 index 00000000000..ea0ea95a90f --- /dev/null +++ b/clients/python-legacy/docs/RepositoryDumpStatus.md @@ -0,0 +1,16 @@ +# RepositoryDumpStatus + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **str** | ID of the task | +**done** | **bool** | | +**update_time** | **datetime** | | +**error** | **str** | | [optional] +**refs** | [**RefsDump**](RefsDump.md) | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/clients/python-legacy/docs/RepositoryRestoreStatus.md b/clients/python-legacy/docs/RepositoryRestoreStatus.md new file mode 100644 index 00000000000..e05e5f1dbb3 --- /dev/null +++ b/clients/python-legacy/docs/RepositoryRestoreStatus.md @@ -0,0 +1,15 @@ +# RepositoryRestoreStatus + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **str** | ID of the task | +**done** | **bool** | | +**update_time** | **datetime** | | +**error** | **str** | | [optional] +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/clients/python-legacy/docs/TaskInfo.md b/clients/python-legacy/docs/TaskInfo.md new file mode 100644 index 00000000000..50d9cce2106 --- /dev/null +++ b/clients/python-legacy/docs/TaskInfo.md @@ -0,0 +1,12 @@ +# TaskInfo + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **str** | ID of the task | +**any string name** | **bool, date, datetime, dict, float, int, list, str, none_type** | any string name can be used but the value must be the correct type | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/clients/python-legacy/lakefs_client/api/repositories_api.py b/clients/python-legacy/lakefs_client/api/repositories_api.py index 834fa04cc48..6d570c1fde3 100644 --- a/clients/python-legacy/lakefs_client/api/repositories_api.py +++ b/clients/python-legacy/lakefs_client/api/repositories_api.py @@ -25,10 +25,14 @@ from lakefs_client.model.branch_protection_rule import BranchProtectionRule from lakefs_client.model.error import Error from lakefs_client.model.garbage_collection_rules import GarbageCollectionRules +from lakefs_client.model.refs_dump import RefsDump from lakefs_client.model.repository import Repository from lakefs_client.model.repository_creation import RepositoryCreation +from lakefs_client.model.repository_dump_status import RepositoryDumpStatus from lakefs_client.model.repository_list import RepositoryList from lakefs_client.model.repository_metadata import RepositoryMetadata +from lakefs_client.model.repository_restore_status import RepositoryRestoreStatus +from lakefs_client.model.task_info import TaskInfo class RepositoriesApi(object): @@ -213,6 +217,122 @@ def __init__(self, api_client=None): }, api_client=api_client ) + self.dump_status_endpoint = _Endpoint( + settings={ + 'response_type': (RepositoryDumpStatus,), + 'auth': [ + 'basic_auth', + 'cookie_auth', + 'jwt_token', + 'oidc_auth', + 'saml_auth' + ], + 'endpoint_path': '/repositories/{repository}/dump', + 'operation_id': 'dump_status', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + 'repository', + 'task_id', + ], + 'required': [ + 'repository', + 'task_id', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'repository': + (str,), + 'task_id': + (str,), + }, + 'attribute_map': { + 'repository': 'repository', + 'task_id': 'task_id', + }, + 'location_map': { + 'repository': 'path', + 'task_id': 'query', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client + ) + self.dump_submit_endpoint = _Endpoint( + settings={ + 'response_type': (TaskInfo,), + 'auth': [ + 'basic_auth', + 'cookie_auth', + 'jwt_token', + 'oidc_auth', + 'saml_auth' + ], + 'endpoint_path': '/repositories/{repository}/dump', + 'operation_id': 'dump_submit', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'repository', + ], + 'required': [ + 'repository', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'repository': + (str,), + }, + 'attribute_map': { + 'repository': 'repository', + }, + 'location_map': { + 'repository': 'path', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client + ) self.get_branch_protection_rules_endpoint = _Endpoint( settings={ 'response_type': ([BranchProtectionRule],), @@ -502,6 +622,129 @@ def __init__(self, api_client=None): }, api_client=api_client ) + self.restore_status_endpoint = _Endpoint( + settings={ + 'response_type': (RepositoryRestoreStatus,), + 'auth': [ + 'basic_auth', + 'cookie_auth', + 'jwt_token', + 'oidc_auth', + 'saml_auth' + ], + 'endpoint_path': '/repositories/{repository}/restore', + 'operation_id': 'restore_status', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + 'repository', + 'task_id', + ], + 'required': [ + 'repository', + 'task_id', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'repository': + (str,), + 'task_id': + (str,), + }, + 'attribute_map': { + 'repository': 'repository', + 'task_id': 'task_id', + }, + 'location_map': { + 'repository': 'path', + 'task_id': 'query', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client + ) + self.restore_submit_endpoint = _Endpoint( + settings={ + 'response_type': (TaskInfo,), + 'auth': [ + 'basic_auth', + 'cookie_auth', + 'jwt_token', + 'oidc_auth', + 'saml_auth' + ], + 'endpoint_path': '/repositories/{repository}/restore', + 'operation_id': 'restore_submit', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'repository', + 'refs_dump', + ], + 'required': [ + 'repository', + 'refs_dump', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'repository': + (str,), + 'refs_dump': + (RefsDump,), + }, + 'attribute_map': { + 'repository': 'repository', + }, + 'location_map': { + 'repository': 'path', + 'refs_dump': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client + ) self.set_branch_protection_rules_endpoint = _Endpoint( settings={ 'response_type': None, @@ -828,6 +1071,140 @@ def delete_repository( repository return self.delete_repository_endpoint.call_with_http_info(**kwargs) + def dump_status( + self, + repository, + task_id, + **kwargs + ): + """Status of a repository dump task # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.dump_status(repository, task_id, async_req=True) + >>> result = thread.get() + + Args: + repository (str): + task_id (str): + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + RepositoryDumpStatus + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['repository'] = \ + repository + kwargs['task_id'] = \ + task_id + return self.dump_status_endpoint.call_with_http_info(**kwargs) + + def dump_submit( + self, + repository, + **kwargs + ): + """Backup the repository metadata (tags, commits, branches) and save the backup to the object store. # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.dump_submit(repository, async_req=True) + >>> result = thread.get() + + Args: + repository (str): + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + TaskInfo + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['repository'] = \ + repository + return self.dump_submit_endpoint.call_with_http_info(**kwargs) + def get_branch_protection_rules( self, repository, @@ -1151,6 +1528,144 @@ def list_repositories( kwargs['_host_index'] = kwargs.get('_host_index') return self.list_repositories_endpoint.call_with_http_info(**kwargs) + def restore_status( + self, + repository, + task_id, + **kwargs + ): + """Status of a restore request # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.restore_status(repository, task_id, async_req=True) + >>> result = thread.get() + + Args: + repository (str): + task_id (str): + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + RepositoryRestoreStatus + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['repository'] = \ + repository + kwargs['task_id'] = \ + task_id + return self.restore_status_endpoint.call_with_http_info(**kwargs) + + def restore_submit( + self, + repository, + refs_dump, + **kwargs + ): + """Restore repository from a dump in the object store # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.restore_submit(repository, refs_dump, async_req=True) + >>> result = thread.get() + + Args: + repository (str): + refs_dump (RefsDump): + + Keyword Args: + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. + Default is True. + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also + be a pair (tuple) of (connection, read) timeouts. + Default is None. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. + Default is True. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. + Default is True. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. + async_req (bool): execute request asynchronously + + Returns: + TaskInfo + If the method is called asynchronously, returns the request + thread. + """ + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['repository'] = \ + repository + kwargs['refs_dump'] = \ + refs_dump + return self.restore_submit_endpoint.call_with_http_info(**kwargs) + def set_branch_protection_rules( self, repository, diff --git a/clients/python-legacy/lakefs_client/model/repository_dump_status.py b/clients/python-legacy/lakefs_client/model/repository_dump_status.py new file mode 100644 index 00000000000..2f93cbbbe1c --- /dev/null +++ b/clients/python-legacy/lakefs_client/model/repository_dump_status.py @@ -0,0 +1,288 @@ +""" + lakeFS API + + lakeFS HTTP API # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Contact: services@treeverse.io + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from lakefs_client.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) +from ..model_utils import OpenApiModel +from lakefs_client.exceptions import ApiAttributeError + + +def lazy_import(): + from lakefs_client.model.refs_dump import RefsDump + globals()['RefsDump'] = RefsDump + + +class RepositoryDumpStatus(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + lazy_import() + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + lazy_import() + return { + 'id': (str,), # noqa: E501 + 'done': (bool,), # noqa: E501 + 'update_time': (datetime,), # noqa: E501 + 'error': (str,), # noqa: E501 + 'refs': (RefsDump,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'id': 'id', # noqa: E501 + 'done': 'done', # noqa: E501 + 'update_time': 'update_time', # noqa: E501 + 'error': 'error', # noqa: E501 + 'refs': 'refs', # noqa: E501 + } + + read_only_vars = { + } + + _composed_schemas = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, done, update_time, *args, **kwargs): # noqa: E501 + """RepositoryDumpStatus - a model defined in OpenAPI + + Args: + id (str): ID of the task + done (bool): + update_time (datetime): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + error (str): [optional] # noqa: E501 + refs (RefsDump): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.done = done + self.update_time = update_time + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) + return self + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, id, done, update_time, *args, **kwargs): # noqa: E501 + """RepositoryDumpStatus - a model defined in OpenAPI + + Args: + id (str): ID of the task + done (bool): + update_time (datetime): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + error (str): [optional] # noqa: E501 + refs (RefsDump): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.done = done + self.update_time = update_time + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/clients/python-legacy/lakefs_client/model/repository_restore_status.py b/clients/python-legacy/lakefs_client/model/repository_restore_status.py new file mode 100644 index 00000000000..ef7b447e7db --- /dev/null +++ b/clients/python-legacy/lakefs_client/model/repository_restore_status.py @@ -0,0 +1,278 @@ +""" + lakeFS API + + lakeFS HTTP API # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Contact: services@treeverse.io + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from lakefs_client.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) +from ..model_utils import OpenApiModel +from lakefs_client.exceptions import ApiAttributeError + + + +class RepositoryRestoreStatus(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'id': (str,), # noqa: E501 + 'done': (bool,), # noqa: E501 + 'update_time': (datetime,), # noqa: E501 + 'error': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'id': 'id', # noqa: E501 + 'done': 'done', # noqa: E501 + 'update_time': 'update_time', # noqa: E501 + 'error': 'error', # noqa: E501 + } + + read_only_vars = { + } + + _composed_schemas = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, done, update_time, *args, **kwargs): # noqa: E501 + """RepositoryRestoreStatus - a model defined in OpenAPI + + Args: + id (str): ID of the task + done (bool): + update_time (datetime): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + error (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.done = done + self.update_time = update_time + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) + return self + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, id, done, update_time, *args, **kwargs): # noqa: E501 + """RepositoryRestoreStatus - a model defined in OpenAPI + + Args: + id (str): ID of the task + done (bool): + update_time (datetime): + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + error (str): [optional] # noqa: E501 + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + self.done = done + self.update_time = update_time + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/clients/python-legacy/lakefs_client/model/task_info.py b/clients/python-legacy/lakefs_client/model/task_info.py new file mode 100644 index 00000000000..0b25a6ba480 --- /dev/null +++ b/clients/python-legacy/lakefs_client/model/task_info.py @@ -0,0 +1,262 @@ +""" + lakeFS API + + lakeFS HTTP API # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Contact: services@treeverse.io + Generated by: https://openapi-generator.tech +""" + + +import re # noqa: F401 +import sys # noqa: F401 + +from lakefs_client.model_utils import ( # noqa: F401 + ApiTypeError, + ModelComposed, + ModelNormal, + ModelSimple, + cached_property, + change_keys_js_to_python, + convert_js_args_to_python_args, + date, + datetime, + file_type, + none_type, + validate_get_composed_info, +) +from ..model_utils import OpenApiModel +from lakefs_client.exceptions import ApiAttributeError + + + +class TaskInfo(ModelNormal): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + + Attributes: + allowed_values (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + with a capitalized key describing the allowed value and an allowed + value. These dicts store the allowed enum values. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + discriminator_value_class_map (dict): A dict to go from the discriminator + variable value to the discriminator class name. + validations (dict): The key is the tuple path to the attribute + and the for var_name this is (var_name,). The value is a dict + that stores validations for max_length, min_length, max_items, + min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, + inclusive_minimum, and regex. + additional_properties_type (tuple): A tuple of classes accepted + as additional properties values. + """ + + allowed_values = { + } + + validations = { + } + + @cached_property + def additional_properties_type(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + """ + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 + + _nullable = False + + @cached_property + def openapi_types(): + """ + This must be a method because a model may have properties that are + of type self, this must run after the class is loaded + + Returns + openapi_types (dict): The key is attribute name + and the value is attribute type. + """ + return { + 'id': (str,), # noqa: E501 + } + + @cached_property + def discriminator(): + return None + + + attribute_map = { + 'id': 'id', # noqa: E501 + } + + read_only_vars = { + } + + _composed_schemas = {} + + @classmethod + @convert_js_args_to_python_args + def _from_openapi_data(cls, id, *args, **kwargs): # noqa: E501 + """TaskInfo - a model defined in OpenAPI + + Args: + id (str): ID of the task + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + self = super(OpenApiModel, cls).__new__(cls) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) + return self + + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) + + @convert_js_args_to_python_args + def __init__(self, id, *args, **kwargs): # noqa: E501 + """TaskInfo - a model defined in OpenAPI + + Args: + id (str): ID of the task + + Keyword Args: + _check_type (bool): if True, values for parameters in openapi_types + will be type checked and a TypeError will be + raised if the wrong type is input. + Defaults to True + _path_to_item (tuple/list): This is a list of keys or values to + drill down to the model in received_data + when deserializing a response + _spec_property_naming (bool): True if the variable names in the input data + are serialized names, as specified in the OpenAPI document. + False if the variable names in the input data + are pythonic names, e.g. snake case (default) + _configuration (Configuration): the instance to use when + deserializing a file_type parameter. + If passed, type conversion is attempted + If omitted no type conversion is done. + _visited_composed_classes (tuple): This stores a tuple of + classes that we have traveled through so that + if we see that class again we will not use its + discriminator again. + When traveling through a discriminator, the + composed schema that is + is traveled through is added to this set. + For example if Animal has a discriminator + petType and we pass in "Dog", and the class Dog + allOf includes Animal, we move through Animal + once using the discriminator, and pick Dog. + Then in Dog, we will make an instance of the + Animal class but this time we won't travel + through its discriminator because we passed in + _visited_composed_classes = (Animal,) + """ + + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) + + if args: + raise ApiTypeError( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( + args, + self.__class__.__name__, + ), + path_to_item=_path_to_item, + valid_classes=(self.__class__,), + ) + + self._data_store = {} + self._check_type = _check_type + self._spec_property_naming = _spec_property_naming + self._path_to_item = _path_to_item + self._configuration = _configuration + self._visited_composed_classes = _visited_composed_classes + (self.__class__,) + + self.id = id + for var_name, var_value in kwargs.items(): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: + # discard variable. + continue + setattr(self, var_name, var_value) + if var_name in self.read_only_vars: + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/clients/python-legacy/lakefs_client/models/__init__.py b/clients/python-legacy/lakefs_client/models/__init__.py index 7198c6b3504..0f3ddee407b 100644 --- a/clients/python-legacy/lakefs_client/models/__init__.py +++ b/clients/python-legacy/lakefs_client/models/__init__.py @@ -76,8 +76,10 @@ from lakefs_client.model.refs_dump import RefsDump from lakefs_client.model.repository import Repository from lakefs_client.model.repository_creation import RepositoryCreation +from lakefs_client.model.repository_dump_status import RepositoryDumpStatus from lakefs_client.model.repository_list import RepositoryList from lakefs_client.model.repository_metadata import RepositoryMetadata +from lakefs_client.model.repository_restore_status import RepositoryRestoreStatus from lakefs_client.model.reset_creation import ResetCreation from lakefs_client.model.revert_creation import RevertCreation from lakefs_client.model.setup import Setup @@ -90,6 +92,7 @@ from lakefs_client.model.storage_config import StorageConfig from lakefs_client.model.storage_uri import StorageURI from lakefs_client.model.tag_creation import TagCreation +from lakefs_client.model.task_info import TaskInfo from lakefs_client.model.underlying_object_properties import UnderlyingObjectProperties from lakefs_client.model.update_token import UpdateToken from lakefs_client.model.user import User diff --git a/clients/python-legacy/test/test_repositories_api.py b/clients/python-legacy/test/test_repositories_api.py index 62340285893..a1962cfc6d2 100644 --- a/clients/python-legacy/test/test_repositories_api.py +++ b/clients/python-legacy/test/test_repositories_api.py @@ -44,6 +44,20 @@ def test_delete_repository(self): """ pass + def test_dump_status(self): + """Test case for dump_status + + Status of a repository dump task # noqa: E501 + """ + pass + + def test_dump_submit(self): + """Test case for dump_submit + + Backup the repository metadata (tags, commits, branches) and save the backup to the object store. # noqa: E501 + """ + pass + def test_get_branch_protection_rules(self): """Test case for get_branch_protection_rules @@ -79,6 +93,20 @@ def test_list_repositories(self): """ pass + def test_restore_status(self): + """Test case for restore_status + + Status of a restore request # noqa: E501 + """ + pass + + def test_restore_submit(self): + """Test case for restore_submit + + Restore repository from a dump in the object store # noqa: E501 + """ + pass + def test_set_branch_protection_rules(self): """Test case for set_branch_protection_rules diff --git a/clients/python-legacy/test/test_repository_dump_status.py b/clients/python-legacy/test/test_repository_dump_status.py new file mode 100644 index 00000000000..494f2ab22c0 --- /dev/null +++ b/clients/python-legacy/test/test_repository_dump_status.py @@ -0,0 +1,38 @@ +""" + lakeFS API + + lakeFS HTTP API # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Contact: services@treeverse.io + Generated by: https://openapi-generator.tech +""" + + +import sys +import unittest + +import lakefs_client +from lakefs_client.model.refs_dump import RefsDump +globals()['RefsDump'] = RefsDump +from lakefs_client.model.repository_dump_status import RepositoryDumpStatus + + +class TestRepositoryDumpStatus(unittest.TestCase): + """RepositoryDumpStatus unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testRepositoryDumpStatus(self): + """Test RepositoryDumpStatus""" + # FIXME: construct object with mandatory attributes with example values + # model = RepositoryDumpStatus() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/clients/python-legacy/test/test_repository_restore_status.py b/clients/python-legacy/test/test_repository_restore_status.py new file mode 100644 index 00000000000..1b12952a3de --- /dev/null +++ b/clients/python-legacy/test/test_repository_restore_status.py @@ -0,0 +1,36 @@ +""" + lakeFS API + + lakeFS HTTP API # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Contact: services@treeverse.io + Generated by: https://openapi-generator.tech +""" + + +import sys +import unittest + +import lakefs_client +from lakefs_client.model.repository_restore_status import RepositoryRestoreStatus + + +class TestRepositoryRestoreStatus(unittest.TestCase): + """RepositoryRestoreStatus unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testRepositoryRestoreStatus(self): + """Test RepositoryRestoreStatus""" + # FIXME: construct object with mandatory attributes with example values + # model = RepositoryRestoreStatus() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/clients/python-legacy/test/test_task_info.py b/clients/python-legacy/test/test_task_info.py new file mode 100644 index 00000000000..e9cb27de5b0 --- /dev/null +++ b/clients/python-legacy/test/test_task_info.py @@ -0,0 +1,36 @@ +""" + lakeFS API + + lakeFS HTTP API # noqa: E501 + + The version of the OpenAPI document: 1.0.0 + Contact: services@treeverse.io + Generated by: https://openapi-generator.tech +""" + + +import sys +import unittest + +import lakefs_client +from lakefs_client.model.task_info import TaskInfo + + +class TestTaskInfo(unittest.TestCase): + """TaskInfo unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testTaskInfo(self): + """Test TaskInfo""" + # FIXME: construct object with mandatory attributes with example values + # model = TaskInfo() # noqa: E501 + pass + + +if __name__ == '__main__': + unittest.main() diff --git a/clients/python/.openapi-generator/FILES b/clients/python/.openapi-generator/FILES index ceea121abad..b8b9d91190b 100644 --- a/clients/python/.openapi-generator/FILES +++ b/clients/python/.openapi-generator/FILES @@ -78,7 +78,9 @@ docs/RefsDump.md docs/RepositoriesApi.md docs/Repository.md docs/RepositoryCreation.md +docs/RepositoryDumpStatus.md docs/RepositoryList.md +docs/RepositoryRestoreStatus.md docs/ResetCreation.md docs/RevertCreation.md docs/Setup.md @@ -93,6 +95,7 @@ docs/StorageConfig.md docs/StorageURI.md docs/TagCreation.md docs/TagsApi.md +docs/TaskInfo.md docs/UnderlyingObjectProperties.md docs/UpdateToken.md docs/User.md @@ -187,7 +190,9 @@ lakefs_sdk/models/ref_list.py lakefs_sdk/models/refs_dump.py lakefs_sdk/models/repository.py lakefs_sdk/models/repository_creation.py +lakefs_sdk/models/repository_dump_status.py lakefs_sdk/models/repository_list.py +lakefs_sdk/models/repository_restore_status.py lakefs_sdk/models/reset_creation.py lakefs_sdk/models/revert_creation.py lakefs_sdk/models/setup.py @@ -200,6 +205,7 @@ lakefs_sdk/models/stats_events_list.py lakefs_sdk/models/storage_config.py lakefs_sdk/models/storage_uri.py lakefs_sdk/models/tag_creation.py +lakefs_sdk/models/task_info.py lakefs_sdk/models/underlying_object_properties.py lakefs_sdk/models/update_token.py lakefs_sdk/models/user.py @@ -292,7 +298,9 @@ test/test_refs_dump.py test/test_repositories_api.py test/test_repository.py test/test_repository_creation.py +test/test_repository_dump_status.py test/test_repository_list.py +test/test_repository_restore_status.py test/test_reset_creation.py test/test_revert_creation.py test/test_setup.py @@ -307,6 +315,7 @@ test/test_storage_config.py test/test_storage_uri.py test/test_tag_creation.py test/test_tags_api.py +test/test_task_info.py test/test_underlying_object_properties.py test/test_update_token.py test/test_user.py diff --git a/clients/python/README.md b/clients/python/README.md index a2d45ba1f0c..990c5329b45 100644 --- a/clients/python/README.md +++ b/clients/python/README.md @@ -212,11 +212,15 @@ Class | Method | HTTP request | Description *RepositoriesApi* | [**create_repository**](docs/RepositoriesApi.md#create_repository) | **POST** /repositories | create repository *RepositoriesApi* | [**delete_gc_rules**](docs/RepositoriesApi.md#delete_gc_rules) | **DELETE** /repositories/{repository}/settings/gc_rules | *RepositoriesApi* | [**delete_repository**](docs/RepositoriesApi.md#delete_repository) | **DELETE** /repositories/{repository} | delete repository +*RepositoriesApi* | [**dump_status**](docs/RepositoriesApi.md#dump_status) | **GET** /repositories/{repository}/dump | Status of a repository dump task +*RepositoriesApi* | [**dump_submit**](docs/RepositoriesApi.md#dump_submit) | **POST** /repositories/{repository}/dump | Backup the repository metadata (tags, commits, branches) and save the backup to the object store. *RepositoriesApi* | [**get_branch_protection_rules**](docs/RepositoriesApi.md#get_branch_protection_rules) | **GET** /repositories/{repository}/settings/branch_protection | get branch protection rules *RepositoriesApi* | [**get_gc_rules**](docs/RepositoriesApi.md#get_gc_rules) | **GET** /repositories/{repository}/settings/gc_rules | get repository GC rules *RepositoriesApi* | [**get_repository**](docs/RepositoriesApi.md#get_repository) | **GET** /repositories/{repository} | get repository *RepositoriesApi* | [**get_repository_metadata**](docs/RepositoriesApi.md#get_repository_metadata) | **GET** /repositories/{repository}/metadata | get repository metadata *RepositoriesApi* | [**list_repositories**](docs/RepositoriesApi.md#list_repositories) | **GET** /repositories | list repositories +*RepositoriesApi* | [**restore_status**](docs/RepositoriesApi.md#restore_status) | **GET** /repositories/{repository}/restore | Status of a restore request +*RepositoriesApi* | [**restore_submit**](docs/RepositoriesApi.md#restore_submit) | **POST** /repositories/{repository}/restore | Restore repository from a dump in the object store *RepositoriesApi* | [**set_branch_protection_rules**](docs/RepositoriesApi.md#set_branch_protection_rules) | **PUT** /repositories/{repository}/settings/branch_protection | *RepositoriesApi* | [**set_gc_rules**](docs/RepositoriesApi.md#set_gc_rules) | **PUT** /repositories/{repository}/settings/gc_rules | *StagingApi* | [**get_physical_address**](docs/StagingApi.md#get_physical_address) | **GET** /repositories/{repository}/branches/{branch}/staging/backing | generate an address to which the client can upload an object @@ -294,7 +298,9 @@ Class | Method | HTTP request | Description - [RefsDump](docs/RefsDump.md) - [Repository](docs/Repository.md) - [RepositoryCreation](docs/RepositoryCreation.md) + - [RepositoryDumpStatus](docs/RepositoryDumpStatus.md) - [RepositoryList](docs/RepositoryList.md) + - [RepositoryRestoreStatus](docs/RepositoryRestoreStatus.md) - [ResetCreation](docs/ResetCreation.md) - [RevertCreation](docs/RevertCreation.md) - [Setup](docs/Setup.md) @@ -307,6 +313,7 @@ Class | Method | HTTP request | Description - [StorageConfig](docs/StorageConfig.md) - [StorageURI](docs/StorageURI.md) - [TagCreation](docs/TagCreation.md) + - [TaskInfo](docs/TaskInfo.md) - [UnderlyingObjectProperties](docs/UnderlyingObjectProperties.md) - [UpdateToken](docs/UpdateToken.md) - [User](docs/User.md) diff --git a/clients/python/docs/RepositoriesApi.md b/clients/python/docs/RepositoriesApi.md index f57dea02b3f..af02d44c10e 100644 --- a/clients/python/docs/RepositoriesApi.md +++ b/clients/python/docs/RepositoriesApi.md @@ -7,11 +7,15 @@ Method | HTTP request | Description [**create_repository**](RepositoriesApi.md#create_repository) | **POST** /repositories | create repository [**delete_gc_rules**](RepositoriesApi.md#delete_gc_rules) | **DELETE** /repositories/{repository}/settings/gc_rules | [**delete_repository**](RepositoriesApi.md#delete_repository) | **DELETE** /repositories/{repository} | delete repository +[**dump_status**](RepositoriesApi.md#dump_status) | **GET** /repositories/{repository}/dump | Status of a repository dump task +[**dump_submit**](RepositoriesApi.md#dump_submit) | **POST** /repositories/{repository}/dump | Backup the repository metadata (tags, commits, branches) and save the backup to the object store. [**get_branch_protection_rules**](RepositoriesApi.md#get_branch_protection_rules) | **GET** /repositories/{repository}/settings/branch_protection | get branch protection rules [**get_gc_rules**](RepositoriesApi.md#get_gc_rules) | **GET** /repositories/{repository}/settings/gc_rules | get repository GC rules [**get_repository**](RepositoriesApi.md#get_repository) | **GET** /repositories/{repository} | get repository [**get_repository_metadata**](RepositoriesApi.md#get_repository_metadata) | **GET** /repositories/{repository}/metadata | get repository metadata [**list_repositories**](RepositoriesApi.md#list_repositories) | **GET** /repositories | list repositories +[**restore_status**](RepositoriesApi.md#restore_status) | **GET** /repositories/{repository}/restore | Status of a restore request +[**restore_submit**](RepositoriesApi.md#restore_submit) | **POST** /repositories/{repository}/restore | Restore repository from a dump in the object store [**set_branch_protection_rules**](RepositoriesApi.md#set_branch_protection_rules) | **PUT** /repositories/{repository}/settings/branch_protection | [**set_gc_rules**](RepositoriesApi.md#set_gc_rules) | **PUT** /repositories/{repository}/settings/gc_rules | @@ -343,6 +347,229 @@ void (empty response body) [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **dump_status** +> RepositoryDumpStatus dump_status(repository, task_id) + +Status of a repository dump task + +### Example + +* Basic Authentication (basic_auth): +* Api Key Authentication (cookie_auth): +* Api Key Authentication (oidc_auth): +* Api Key Authentication (saml_auth): +* Bearer (JWT) Authentication (jwt_token): + +```python +import time +import os +import lakefs_sdk +from lakefs_sdk.models.repository_dump_status import RepositoryDumpStatus +from lakefs_sdk.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to /api/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = lakefs_sdk.Configuration( + host = "/api/v1" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure HTTP basic authorization: basic_auth +configuration = lakefs_sdk.Configuration( + username = os.environ["USERNAME"], + password = os.environ["PASSWORD"] +) + +# Configure API key authorization: cookie_auth +configuration.api_key['cookie_auth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['cookie_auth'] = 'Bearer' + +# Configure API key authorization: oidc_auth +configuration.api_key['oidc_auth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['oidc_auth'] = 'Bearer' + +# Configure API key authorization: saml_auth +configuration.api_key['saml_auth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['saml_auth'] = 'Bearer' + +# Configure Bearer authorization (JWT): jwt_token +configuration = lakefs_sdk.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with lakefs_sdk.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = lakefs_sdk.RepositoriesApi(api_client) + repository = 'repository_example' # str | + task_id = 'task_id_example' # str | + + try: + # Status of a repository dump task + api_response = api_instance.dump_status(repository, task_id) + print("The response of RepositoriesApi->dump_status:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling RepositoriesApi->dump_status: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **str**| | + **task_id** | **str**| | + +### Return type + +[**RepositoryDumpStatus**](RepositoryDumpStatus.md) + +### Authorization + +[basic_auth](../README.md#basic_auth), [cookie_auth](../README.md#cookie_auth), [oidc_auth](../README.md#oidc_auth), [saml_auth](../README.md#saml_auth), [jwt_token](../README.md#jwt_token) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | dump task status | - | +**400** | Validation Error | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**420** | too many requests | - | +**0** | Internal Server Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **dump_submit** +> TaskInfo dump_submit(repository) + +Backup the repository metadata (tags, commits, branches) and save the backup to the object store. + +### Example + +* Basic Authentication (basic_auth): +* Api Key Authentication (cookie_auth): +* Api Key Authentication (oidc_auth): +* Api Key Authentication (saml_auth): +* Bearer (JWT) Authentication (jwt_token): + +```python +import time +import os +import lakefs_sdk +from lakefs_sdk.models.task_info import TaskInfo +from lakefs_sdk.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to /api/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = lakefs_sdk.Configuration( + host = "/api/v1" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure HTTP basic authorization: basic_auth +configuration = lakefs_sdk.Configuration( + username = os.environ["USERNAME"], + password = os.environ["PASSWORD"] +) + +# Configure API key authorization: cookie_auth +configuration.api_key['cookie_auth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['cookie_auth'] = 'Bearer' + +# Configure API key authorization: oidc_auth +configuration.api_key['oidc_auth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['oidc_auth'] = 'Bearer' + +# Configure API key authorization: saml_auth +configuration.api_key['saml_auth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['saml_auth'] = 'Bearer' + +# Configure Bearer authorization (JWT): jwt_token +configuration = lakefs_sdk.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with lakefs_sdk.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = lakefs_sdk.RepositoriesApi(api_client) + repository = 'repository_example' # str | + + try: + # Backup the repository metadata (tags, commits, branches) and save the backup to the object store. + api_response = api_instance.dump_submit(repository) + print("The response of RepositoriesApi->dump_submit:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling RepositoriesApi->dump_submit: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **str**| | + +### Return type + +[**TaskInfo**](TaskInfo.md) + +### Authorization + +[basic_auth](../README.md#basic_auth), [cookie_auth](../README.md#cookie_auth), [oidc_auth](../README.md#oidc_auth), [saml_auth](../README.md#saml_auth), [jwt_token](../README.md#jwt_token) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**202** | dump task information | - | +**400** | Validation Error | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**0** | Internal Server Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **get_branch_protection_rules** > List[BranchProtectionRule] get_branch_protection_rules(repository) @@ -895,6 +1122,232 @@ Name | Type | Description | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **restore_status** +> RepositoryRestoreStatus restore_status(repository, task_id) + +Status of a restore request + +### Example + +* Basic Authentication (basic_auth): +* Api Key Authentication (cookie_auth): +* Api Key Authentication (oidc_auth): +* Api Key Authentication (saml_auth): +* Bearer (JWT) Authentication (jwt_token): + +```python +import time +import os +import lakefs_sdk +from lakefs_sdk.models.repository_restore_status import RepositoryRestoreStatus +from lakefs_sdk.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to /api/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = lakefs_sdk.Configuration( + host = "/api/v1" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure HTTP basic authorization: basic_auth +configuration = lakefs_sdk.Configuration( + username = os.environ["USERNAME"], + password = os.environ["PASSWORD"] +) + +# Configure API key authorization: cookie_auth +configuration.api_key['cookie_auth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['cookie_auth'] = 'Bearer' + +# Configure API key authorization: oidc_auth +configuration.api_key['oidc_auth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['oidc_auth'] = 'Bearer' + +# Configure API key authorization: saml_auth +configuration.api_key['saml_auth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['saml_auth'] = 'Bearer' + +# Configure Bearer authorization (JWT): jwt_token +configuration = lakefs_sdk.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with lakefs_sdk.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = lakefs_sdk.RepositoriesApi(api_client) + repository = 'repository_example' # str | + task_id = 'task_id_example' # str | + + try: + # Status of a restore request + api_response = api_instance.restore_status(repository, task_id) + print("The response of RepositoriesApi->restore_status:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling RepositoriesApi->restore_status: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **str**| | + **task_id** | **str**| | + +### Return type + +[**RepositoryRestoreStatus**](RepositoryRestoreStatus.md) + +### Authorization + +[basic_auth](../README.md#basic_auth), [cookie_auth](../README.md#cookie_auth), [oidc_auth](../README.md#oidc_auth), [saml_auth](../README.md#saml_auth), [jwt_token](../README.md#jwt_token) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | restore task status | - | +**400** | Validation Error | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**420** | too many requests | - | +**0** | Internal Server Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **restore_submit** +> TaskInfo restore_submit(repository, refs_dump) + +Restore repository from a dump in the object store + +### Example + +* Basic Authentication (basic_auth): +* Api Key Authentication (cookie_auth): +* Api Key Authentication (oidc_auth): +* Api Key Authentication (saml_auth): +* Bearer (JWT) Authentication (jwt_token): + +```python +import time +import os +import lakefs_sdk +from lakefs_sdk.models.refs_dump import RefsDump +from lakefs_sdk.models.task_info import TaskInfo +from lakefs_sdk.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to /api/v1 +# See configuration.py for a list of all supported configuration parameters. +configuration = lakefs_sdk.Configuration( + host = "/api/v1" +) + +# The client must configure the authentication and authorization parameters +# in accordance with the API server security policy. +# Examples for each auth method are provided below, use the example that +# satisfies your auth use case. + +# Configure HTTP basic authorization: basic_auth +configuration = lakefs_sdk.Configuration( + username = os.environ["USERNAME"], + password = os.environ["PASSWORD"] +) + +# Configure API key authorization: cookie_auth +configuration.api_key['cookie_auth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['cookie_auth'] = 'Bearer' + +# Configure API key authorization: oidc_auth +configuration.api_key['oidc_auth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['oidc_auth'] = 'Bearer' + +# Configure API key authorization: saml_auth +configuration.api_key['saml_auth'] = os.environ["API_KEY"] + +# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed +# configuration.api_key_prefix['saml_auth'] = 'Bearer' + +# Configure Bearer authorization (JWT): jwt_token +configuration = lakefs_sdk.Configuration( + access_token = os.environ["BEARER_TOKEN"] +) + +# Enter a context with an instance of the API client +with lakefs_sdk.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = lakefs_sdk.RepositoriesApi(api_client) + repository = 'repository_example' # str | + refs_dump = lakefs_sdk.RefsDump() # RefsDump | + + try: + # Restore repository from a dump in the object store + api_response = api_instance.restore_submit(repository, refs_dump) + print("The response of RepositoriesApi->restore_submit:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling RepositoriesApi->restore_submit: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **str**| | + **refs_dump** | [**RefsDump**](RefsDump.md)| | + +### Return type + +[**TaskInfo**](TaskInfo.md) + +### Authorization + +[basic_auth](../README.md#basic_auth), [cookie_auth](../README.md#cookie_auth), [oidc_auth](../README.md#oidc_auth), [saml_auth](../README.md#saml_auth), [jwt_token](../README.md#jwt_token) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**202** | restore task created | - | +**400** | Validation Error | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**0** | Internal Server Error | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **set_branch_protection_rules** > set_branch_protection_rules(repository, branch_protection_rule, if_match=if_match) diff --git a/clients/python/docs/RepositoryDumpStatus.md b/clients/python/docs/RepositoryDumpStatus.md new file mode 100644 index 00000000000..10955b2ec4f --- /dev/null +++ b/clients/python/docs/RepositoryDumpStatus.md @@ -0,0 +1,33 @@ +# RepositoryDumpStatus + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **str** | ID of the task | +**done** | **bool** | | +**update_time** | **datetime** | | +**error** | **str** | | [optional] +**refs** | [**RefsDump**](RefsDump.md) | | [optional] + +## Example + +```python +from lakefs_sdk.models.repository_dump_status import RepositoryDumpStatus + +# TODO update the JSON string below +json = "{}" +# create an instance of RepositoryDumpStatus from a JSON string +repository_dump_status_instance = RepositoryDumpStatus.from_json(json) +# print the JSON string representation of the object +print RepositoryDumpStatus.to_json() + +# convert the object into a dict +repository_dump_status_dict = repository_dump_status_instance.to_dict() +# create an instance of RepositoryDumpStatus from a dict +repository_dump_status_form_dict = repository_dump_status.from_dict(repository_dump_status_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/clients/python/docs/RepositoryRestoreStatus.md b/clients/python/docs/RepositoryRestoreStatus.md new file mode 100644 index 00000000000..b5e23008457 --- /dev/null +++ b/clients/python/docs/RepositoryRestoreStatus.md @@ -0,0 +1,32 @@ +# RepositoryRestoreStatus + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **str** | ID of the task | +**done** | **bool** | | +**update_time** | **datetime** | | +**error** | **str** | | [optional] + +## Example + +```python +from lakefs_sdk.models.repository_restore_status import RepositoryRestoreStatus + +# TODO update the JSON string below +json = "{}" +# create an instance of RepositoryRestoreStatus from a JSON string +repository_restore_status_instance = RepositoryRestoreStatus.from_json(json) +# print the JSON string representation of the object +print RepositoryRestoreStatus.to_json() + +# convert the object into a dict +repository_restore_status_dict = repository_restore_status_instance.to_dict() +# create an instance of RepositoryRestoreStatus from a dict +repository_restore_status_form_dict = repository_restore_status.from_dict(repository_restore_status_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/clients/python/docs/TaskInfo.md b/clients/python/docs/TaskInfo.md new file mode 100644 index 00000000000..d04b0c934ee --- /dev/null +++ b/clients/python/docs/TaskInfo.md @@ -0,0 +1,29 @@ +# TaskInfo + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **str** | ID of the task | + +## Example + +```python +from lakefs_sdk.models.task_info import TaskInfo + +# TODO update the JSON string below +json = "{}" +# create an instance of TaskInfo from a JSON string +task_info_instance = TaskInfo.from_json(json) +# print the JSON string representation of the object +print TaskInfo.to_json() + +# convert the object into a dict +task_info_dict = task_info_instance.to_dict() +# create an instance of TaskInfo from a dict +task_info_form_dict = task_info.from_dict(task_info_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/clients/python/lakefs_sdk/__init__.py b/clients/python/lakefs_sdk/__init__.py index 6a61072f3e1..3e45413203a 100644 --- a/clients/python/lakefs_sdk/__init__.py +++ b/clients/python/lakefs_sdk/__init__.py @@ -111,7 +111,9 @@ from lakefs_sdk.models.refs_dump import RefsDump from lakefs_sdk.models.repository import Repository from lakefs_sdk.models.repository_creation import RepositoryCreation +from lakefs_sdk.models.repository_dump_status import RepositoryDumpStatus from lakefs_sdk.models.repository_list import RepositoryList +from lakefs_sdk.models.repository_restore_status import RepositoryRestoreStatus from lakefs_sdk.models.reset_creation import ResetCreation from lakefs_sdk.models.revert_creation import RevertCreation from lakefs_sdk.models.setup import Setup @@ -124,6 +126,7 @@ from lakefs_sdk.models.storage_config import StorageConfig from lakefs_sdk.models.storage_uri import StorageURI from lakefs_sdk.models.tag_creation import TagCreation +from lakefs_sdk.models.task_info import TaskInfo from lakefs_sdk.models.underlying_object_properties import UnderlyingObjectProperties from lakefs_sdk.models.update_token import UpdateToken from lakefs_sdk.models.user import User diff --git a/clients/python/lakefs_sdk/api/repositories_api.py b/clients/python/lakefs_sdk/api/repositories_api.py index 4861f31cb58..16b06719de8 100644 --- a/clients/python/lakefs_sdk/api/repositories_api.py +++ b/clients/python/lakefs_sdk/api/repositories_api.py @@ -26,9 +26,13 @@ from lakefs_sdk.models.branch_protection_rule import BranchProtectionRule from lakefs_sdk.models.garbage_collection_rules import GarbageCollectionRules +from lakefs_sdk.models.refs_dump import RefsDump from lakefs_sdk.models.repository import Repository from lakefs_sdk.models.repository_creation import RepositoryCreation +from lakefs_sdk.models.repository_dump_status import RepositoryDumpStatus from lakefs_sdk.models.repository_list import RepositoryList +from lakefs_sdk.models.repository_restore_status import RepositoryRestoreStatus +from lakefs_sdk.models.task_info import TaskInfo from lakefs_sdk.api_client import ApiClient from lakefs_sdk.api_response import ApiResponse @@ -476,6 +480,295 @@ def delete_repository_with_http_info(self, repository : StrictStr, **kwargs) -> collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + @validate_arguments + def dump_status(self, repository : StrictStr, task_id : StrictStr, **kwargs) -> RepositoryDumpStatus: # noqa: E501 + """Status of a repository dump task # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.dump_status(repository, task_id, async_req=True) + >>> result = thread.get() + + :param repository: (required) + :type repository: str + :param task_id: (required) + :type task_id: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: RepositoryDumpStatus + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + raise ValueError("Error! Please call the dump_status_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data") + return self.dump_status_with_http_info(repository, task_id, **kwargs) # noqa: E501 + + @validate_arguments + def dump_status_with_http_info(self, repository : StrictStr, task_id : StrictStr, **kwargs) -> ApiResponse: # noqa: E501 + """Status of a repository dump task # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.dump_status_with_http_info(repository, task_id, async_req=True) + >>> result = thread.get() + + :param repository: (required) + :type repository: str + :param task_id: (required) + :type task_id: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(RepositoryDumpStatus, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'repository', + 'task_id' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method dump_status" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['repository']: + _path_params['repository'] = _params['repository'] + + + # process the query parameters + _query_params = [] + if _params.get('task_id') is not None: # noqa: E501 + _query_params.append(('task_id', _params['task_id'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = ['basic_auth', 'cookie_auth', 'oidc_auth', 'saml_auth', 'jwt_token'] # noqa: E501 + + _response_types_map = { + '200': "RepositoryDumpStatus", + '400': "Error", + '401': "Error", + '404': "Error", + '420': None, + } + + return self.api_client.call_api( + '/repositories/{repository}/dump', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_arguments + def dump_submit(self, repository : StrictStr, **kwargs) -> TaskInfo: # noqa: E501 + """Backup the repository metadata (tags, commits, branches) and save the backup to the object store. # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.dump_submit(repository, async_req=True) + >>> result = thread.get() + + :param repository: (required) + :type repository: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: TaskInfo + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + raise ValueError("Error! Please call the dump_submit_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data") + return self.dump_submit_with_http_info(repository, **kwargs) # noqa: E501 + + @validate_arguments + def dump_submit_with_http_info(self, repository : StrictStr, **kwargs) -> ApiResponse: # noqa: E501 + """Backup the repository metadata (tags, commits, branches) and save the backup to the object store. # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.dump_submit_with_http_info(repository, async_req=True) + >>> result = thread.get() + + :param repository: (required) + :type repository: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(TaskInfo, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'repository' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method dump_submit" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['repository']: + _path_params['repository'] = _params['repository'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = ['basic_auth', 'cookie_auth', 'oidc_auth', 'saml_auth', 'jwt_token'] # noqa: E501 + + _response_types_map = { + '202': "TaskInfo", + '400': "Error", + '401': "Error", + '404': "Error", + } + + return self.api_client.call_api( + '/repositories/{repository}/dump', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + @validate_arguments def get_branch_protection_rules(self, repository : StrictStr, **kwargs) -> List[BranchProtectionRule]: # noqa: E501 """get branch protection rules # noqa: E501 @@ -1191,6 +1484,310 @@ def list_repositories_with_http_info(self, prefix : Annotated[Optional[StrictStr collection_formats=_collection_formats, _request_auth=_params.get('_request_auth')) + @validate_arguments + def restore_status(self, repository : StrictStr, task_id : StrictStr, **kwargs) -> RepositoryRestoreStatus: # noqa: E501 + """Status of a restore request # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.restore_status(repository, task_id, async_req=True) + >>> result = thread.get() + + :param repository: (required) + :type repository: str + :param task_id: (required) + :type task_id: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: RepositoryRestoreStatus + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + raise ValueError("Error! Please call the restore_status_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data") + return self.restore_status_with_http_info(repository, task_id, **kwargs) # noqa: E501 + + @validate_arguments + def restore_status_with_http_info(self, repository : StrictStr, task_id : StrictStr, **kwargs) -> ApiResponse: # noqa: E501 + """Status of a restore request # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.restore_status_with_http_info(repository, task_id, async_req=True) + >>> result = thread.get() + + :param repository: (required) + :type repository: str + :param task_id: (required) + :type task_id: str + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(RepositoryRestoreStatus, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'repository', + 'task_id' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method restore_status" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['repository']: + _path_params['repository'] = _params['repository'] + + + # process the query parameters + _query_params = [] + if _params.get('task_id') is not None: # noqa: E501 + _query_params.append(('task_id', _params['task_id'])) + + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # authentication setting + _auth_settings = ['basic_auth', 'cookie_auth', 'oidc_auth', 'saml_auth', 'jwt_token'] # noqa: E501 + + _response_types_map = { + '200': "RepositoryRestoreStatus", + '400': "Error", + '401': "Error", + '404': "Error", + '420': None, + } + + return self.api_client.call_api( + '/repositories/{repository}/restore', 'GET', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + + @validate_arguments + def restore_submit(self, repository : StrictStr, refs_dump : RefsDump, **kwargs) -> TaskInfo: # noqa: E501 + """Restore repository from a dump in the object store # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.restore_submit(repository, refs_dump, async_req=True) + >>> result = thread.get() + + :param repository: (required) + :type repository: str + :param refs_dump: (required) + :type refs_dump: RefsDump + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: TaskInfo + """ + kwargs['_return_http_data_only'] = True + if '_preload_content' in kwargs: + raise ValueError("Error! Please call the restore_submit_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data") + return self.restore_submit_with_http_info(repository, refs_dump, **kwargs) # noqa: E501 + + @validate_arguments + def restore_submit_with_http_info(self, repository : StrictStr, refs_dump : RefsDump, **kwargs) -> ApiResponse: # noqa: E501 + """Restore repository from a dump in the object store # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.restore_submit_with_http_info(repository, refs_dump, async_req=True) + >>> result = thread.get() + + :param repository: (required) + :type repository: str + :param refs_dump: (required) + :type refs_dump: RefsDump + :param async_req: Whether to execute the request asynchronously. + :type async_req: bool, optional + :param _preload_content: if False, the ApiResponse.data will + be set to none and raw_data will store the + HTTP response body without reading/decoding. + Default is True. + :type _preload_content: bool, optional + :param _return_http_data_only: response data instead of ApiResponse + object with status code, headers, etc + :type _return_http_data_only: bool, optional + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :param _request_auth: set to override the auth_settings for an a single + request; this effectively ignores the authentication + in the spec for a single request. + :type _request_auth: dict, optional + :type _content_type: string, optional: force content-type for the request + :return: Returns the result object. + If the method is called asynchronously, + returns the request thread. + :rtype: tuple(TaskInfo, status_code(int), headers(HTTPHeaderDict)) + """ + + _params = locals() + + _all_params = [ + 'repository', + 'refs_dump' + ] + _all_params.extend( + [ + 'async_req', + '_return_http_data_only', + '_preload_content', + '_request_timeout', + '_request_auth', + '_content_type', + '_headers' + ] + ) + + # validate the arguments + for _key, _val in _params['kwargs'].items(): + if _key not in _all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method restore_submit" % _key + ) + _params[_key] = _val + del _params['kwargs'] + + _collection_formats = {} + + # process the path parameters + _path_params = {} + if _params['repository']: + _path_params['repository'] = _params['repository'] + + + # process the query parameters + _query_params = [] + # process the header parameters + _header_params = dict(_params.get('_headers', {})) + # process the form parameters + _form_params = [] + _files = {} + # process the body parameter + _body_params = None + if _params['refs_dump'] is not None: + _body_params = _params['refs_dump'] + + # set the HTTP header `Accept` + _header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 + + # set the HTTP header `Content-Type` + _content_types_list = _params.get('_content_type', + self.api_client.select_header_content_type( + ['application/json'])) + if _content_types_list: + _header_params['Content-Type'] = _content_types_list + + # authentication setting + _auth_settings = ['basic_auth', 'cookie_auth', 'oidc_auth', 'saml_auth', 'jwt_token'] # noqa: E501 + + _response_types_map = { + '202': "TaskInfo", + '400': "Error", + '401': "Error", + '404': "Error", + } + + return self.api_client.call_api( + '/repositories/{repository}/restore', 'POST', + _path_params, + _query_params, + _header_params, + body=_body_params, + post_params=_form_params, + files=_files, + response_types_map=_response_types_map, + auth_settings=_auth_settings, + async_req=_params.get('async_req'), + _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=_params.get('_preload_content', True), + _request_timeout=_params.get('_request_timeout'), + collection_formats=_collection_formats, + _request_auth=_params.get('_request_auth')) + @validate_arguments def set_branch_protection_rules(self, repository : StrictStr, branch_protection_rule : conlist(BranchProtectionRule), if_match : Annotated[Optional[StrictStr], Field(description="if provided, the branch protection rules will be updated only if the current ETag match the provided value")] = None, **kwargs) -> None: # noqa: E501 """set_branch_protection_rules # noqa: E501 diff --git a/clients/python/lakefs_sdk/models/__init__.py b/clients/python/lakefs_sdk/models/__init__.py index f3c2d44026f..e58331cac58 100644 --- a/clients/python/lakefs_sdk/models/__init__.py +++ b/clients/python/lakefs_sdk/models/__init__.py @@ -80,7 +80,9 @@ from lakefs_sdk.models.refs_dump import RefsDump from lakefs_sdk.models.repository import Repository from lakefs_sdk.models.repository_creation import RepositoryCreation +from lakefs_sdk.models.repository_dump_status import RepositoryDumpStatus from lakefs_sdk.models.repository_list import RepositoryList +from lakefs_sdk.models.repository_restore_status import RepositoryRestoreStatus from lakefs_sdk.models.reset_creation import ResetCreation from lakefs_sdk.models.revert_creation import RevertCreation from lakefs_sdk.models.setup import Setup @@ -93,6 +95,7 @@ from lakefs_sdk.models.storage_config import StorageConfig from lakefs_sdk.models.storage_uri import StorageURI from lakefs_sdk.models.tag_creation import TagCreation +from lakefs_sdk.models.task_info import TaskInfo from lakefs_sdk.models.underlying_object_properties import UnderlyingObjectProperties from lakefs_sdk.models.update_token import UpdateToken from lakefs_sdk.models.user import User diff --git a/clients/python/lakefs_sdk/models/repository_dump_status.py b/clients/python/lakefs_sdk/models/repository_dump_status.py new file mode 100644 index 00000000000..b41aab2cdc3 --- /dev/null +++ b/clients/python/lakefs_sdk/models/repository_dump_status.py @@ -0,0 +1,84 @@ +# coding: utf-8 + +""" + lakeFS API + + lakeFS HTTP API + + The version of the OpenAPI document: 1.0.0 + Contact: services@treeverse.io + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import datetime +from typing import Optional +from pydantic import BaseModel, Field, StrictBool, StrictStr +from lakefs_sdk.models.refs_dump import RefsDump + +class RepositoryDumpStatus(BaseModel): + """ + RepositoryDumpStatus + """ + id: StrictStr = Field(..., description="ID of the task") + done: StrictBool = Field(...) + update_time: datetime = Field(...) + error: Optional[StrictStr] = None + refs: Optional[RefsDump] = None + __properties = ["id", "done", "update_time", "error", "refs"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> RepositoryDumpStatus: + """Create an instance of RepositoryDumpStatus from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + # override the default output from pydantic by calling `to_dict()` of refs + if self.refs: + _dict['refs'] = self.refs.to_dict() + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> RepositoryDumpStatus: + """Create an instance of RepositoryDumpStatus from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return RepositoryDumpStatus.parse_obj(obj) + + _obj = RepositoryDumpStatus.parse_obj({ + "id": obj.get("id"), + "done": obj.get("done"), + "update_time": obj.get("update_time"), + "error": obj.get("error"), + "refs": RefsDump.from_dict(obj.get("refs")) if obj.get("refs") is not None else None + }) + return _obj + + diff --git a/clients/python/lakefs_sdk/models/repository_restore_status.py b/clients/python/lakefs_sdk/models/repository_restore_status.py new file mode 100644 index 00000000000..34955368786 --- /dev/null +++ b/clients/python/lakefs_sdk/models/repository_restore_status.py @@ -0,0 +1,78 @@ +# coding: utf-8 + +""" + lakeFS API + + lakeFS HTTP API + + The version of the OpenAPI document: 1.0.0 + Contact: services@treeverse.io + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from datetime import datetime +from typing import Optional +from pydantic import BaseModel, Field, StrictBool, StrictStr + +class RepositoryRestoreStatus(BaseModel): + """ + RepositoryRestoreStatus + """ + id: StrictStr = Field(..., description="ID of the task") + done: StrictBool = Field(...) + update_time: datetime = Field(...) + error: Optional[StrictStr] = None + __properties = ["id", "done", "update_time", "error"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> RepositoryRestoreStatus: + """Create an instance of RepositoryRestoreStatus from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> RepositoryRestoreStatus: + """Create an instance of RepositoryRestoreStatus from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return RepositoryRestoreStatus.parse_obj(obj) + + _obj = RepositoryRestoreStatus.parse_obj({ + "id": obj.get("id"), + "done": obj.get("done"), + "update_time": obj.get("update_time"), + "error": obj.get("error") + }) + return _obj + + diff --git a/clients/python/lakefs_sdk/models/task_info.py b/clients/python/lakefs_sdk/models/task_info.py new file mode 100644 index 00000000000..addb7ffa7e2 --- /dev/null +++ b/clients/python/lakefs_sdk/models/task_info.py @@ -0,0 +1,72 @@ +# coding: utf-8 + +""" + lakeFS API + + lakeFS HTTP API + + The version of the OpenAPI document: 1.0.0 + Contact: services@treeverse.io + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + + + +from pydantic import BaseModel, Field, StrictStr + +class TaskInfo(BaseModel): + """ + TaskInfo + """ + id: StrictStr = Field(..., description="ID of the task") + __properties = ["id"] + + class Config: + """Pydantic configuration""" + allow_population_by_field_name = True + validate_assignment = True + + def to_str(self) -> str: + """Returns the string representation of the model using alias""" + return pprint.pformat(self.dict(by_alias=True)) + + def to_json(self) -> str: + """Returns the JSON representation of the model using alias""" + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> TaskInfo: + """Create an instance of TaskInfo from a JSON string""" + return cls.from_dict(json.loads(json_str)) + + def to_dict(self): + """Returns the dictionary representation of the model using alias""" + _dict = self.dict(by_alias=True, + exclude={ + }, + exclude_none=True) + return _dict + + @classmethod + def from_dict(cls, obj: dict) -> TaskInfo: + """Create an instance of TaskInfo from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return TaskInfo.parse_obj(obj) + + _obj = TaskInfo.parse_obj({ + "id": obj.get("id") + }) + return _obj + + diff --git a/clients/python/test/test_repositories_api.py b/clients/python/test/test_repositories_api.py index 6fb074c4dff..59ffd7d53fc 100644 --- a/clients/python/test/test_repositories_api.py +++ b/clients/python/test/test_repositories_api.py @@ -49,6 +49,20 @@ def test_delete_repository(self): """ pass + def test_dump_status(self): + """Test case for dump_status + + Status of a repository dump task # noqa: E501 + """ + pass + + def test_dump_submit(self): + """Test case for dump_submit + + Backup the repository metadata (tags, commits, branches) and save the backup to the object store. # noqa: E501 + """ + pass + def test_get_branch_protection_rules(self): """Test case for get_branch_protection_rules @@ -84,6 +98,20 @@ def test_list_repositories(self): """ pass + def test_restore_status(self): + """Test case for restore_status + + Status of a restore request # noqa: E501 + """ + pass + + def test_restore_submit(self): + """Test case for restore_submit + + Restore repository from a dump in the object store # noqa: E501 + """ + pass + def test_set_branch_protection_rules(self): """Test case for set_branch_protection_rules diff --git a/clients/python/test/test_repository_dump_status.py b/clients/python/test/test_repository_dump_status.py new file mode 100644 index 00000000000..a38ce0a3e8c --- /dev/null +++ b/clients/python/test/test_repository_dump_status.py @@ -0,0 +1,65 @@ +# coding: utf-8 + +""" + lakeFS API + + lakeFS HTTP API + + The version of the OpenAPI document: 1.0.0 + Contact: services@treeverse.io + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +import lakefs_sdk +from lakefs_sdk.models.repository_dump_status import RepositoryDumpStatus # noqa: E501 +from lakefs_sdk.rest import ApiException + +class TestRepositoryDumpStatus(unittest.TestCase): + """RepositoryDumpStatus unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test RepositoryDumpStatus + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `RepositoryDumpStatus` + """ + model = lakefs_sdk.models.repository_dump_status.RepositoryDumpStatus() # noqa: E501 + if include_optional : + return RepositoryDumpStatus( + id = '', + done = True, + update_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), + error = '', + refs = lakefs_sdk.models.refs_dump.RefsDump( + commits_meta_range_id = '', + tags_meta_range_id = '', + branches_meta_range_id = '', ) + ) + else : + return RepositoryDumpStatus( + id = '', + done = True, + update_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), + ) + """ + + def testRepositoryDumpStatus(self): + """Test RepositoryDumpStatus""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/clients/python/test/test_repository_restore_status.py b/clients/python/test/test_repository_restore_status.py new file mode 100644 index 00000000000..4d6fc3cbd7f --- /dev/null +++ b/clients/python/test/test_repository_restore_status.py @@ -0,0 +1,61 @@ +# coding: utf-8 + +""" + lakeFS API + + lakeFS HTTP API + + The version of the OpenAPI document: 1.0.0 + Contact: services@treeverse.io + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +import lakefs_sdk +from lakefs_sdk.models.repository_restore_status import RepositoryRestoreStatus # noqa: E501 +from lakefs_sdk.rest import ApiException + +class TestRepositoryRestoreStatus(unittest.TestCase): + """RepositoryRestoreStatus unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test RepositoryRestoreStatus + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `RepositoryRestoreStatus` + """ + model = lakefs_sdk.models.repository_restore_status.RepositoryRestoreStatus() # noqa: E501 + if include_optional : + return RepositoryRestoreStatus( + id = '', + done = True, + update_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), + error = '' + ) + else : + return RepositoryRestoreStatus( + id = '', + done = True, + update_time = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'), + ) + """ + + def testRepositoryRestoreStatus(self): + """Test RepositoryRestoreStatus""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/clients/python/test/test_task_info.py b/clients/python/test/test_task_info.py new file mode 100644 index 00000000000..0f7202e6793 --- /dev/null +++ b/clients/python/test/test_task_info.py @@ -0,0 +1,56 @@ +# coding: utf-8 + +""" + lakeFS API + + lakeFS HTTP API + + The version of the OpenAPI document: 1.0.0 + Contact: services@treeverse.io + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest +import datetime + +import lakefs_sdk +from lakefs_sdk.models.task_info import TaskInfo # noqa: E501 +from lakefs_sdk.rest import ApiException + +class TestTaskInfo(unittest.TestCase): + """TaskInfo unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional): + """Test TaskInfo + include_option is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `TaskInfo` + """ + model = lakefs_sdk.models.task_info.TaskInfo() # noqa: E501 + if include_optional : + return TaskInfo( + id = '' + ) + else : + return TaskInfo( + id = '', + ) + """ + + def testTaskInfo(self): + """Test TaskInfo""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/cmd/lakectl/cmd/common_helpers.go b/cmd/lakectl/cmd/common_helpers.go index 0331a4fb2ff..6af74922f6c 100644 --- a/cmd/lakectl/cmd/common_helpers.go +++ b/cmd/lakectl/cmd/common_helpers.go @@ -39,12 +39,18 @@ const ( const ( internalPageSize = 1000 // when retrieving all records, use this page size under the hood defaultAmountArgumentValue = 100 // when no amount is specified, use this value for the argument + + defaultPollInterval = 3 * time.Second // default interval while pulling tasks status + minimumPollInterval = time.Second // minimum interval while pulling tasks status + defaultPollTimeout = time.Hour // default expiry for pull status with no update ) const resourceListTemplate = `{{.Table | table -}} {{.Pagination | paginate }} ` +var ErrTaskNotCompleted = errors.New("task not completed") + //nolint:gochecknoinits func init() { // disable colors if we're not attached to interactive TTY. @@ -400,7 +406,7 @@ func OpenByPath(path string) (io.ReadSeekCloser, error) { return temp, nil } -// Must return the call value or die with err if err is not nil +// Must return the call value or die with error if err is not nil func Must[T any](v T, err error) T { if err != nil { DieErr(err) diff --git a/cmd/lakectl/cmd/refs_dump.go b/cmd/lakectl/cmd/refs_dump.go index 0c7af85b0de..04a99afa9dc 100644 --- a/cmd/lakectl/cmd/refs_dump.go +++ b/cmd/lakectl/cmd/refs_dump.go @@ -1,14 +1,20 @@ package cmd import ( + "encoding/json" + "fmt" + "io" "net/http" + "os" + "time" + "github.com/cenkalti/backoff/v4" "github.com/spf13/cobra" + "github.com/treeverse/lakefs/pkg/api/apigen" + "github.com/treeverse/lakefs/pkg/api/helpers" + "github.com/treeverse/lakefs/pkg/logging" ) -const metadataDumpTemplate = `{{ .Response | json }} -` - var refsDumpCmd = &cobra.Command{ Use: "refs-dump ", Short: "Dumps refs (branches, commits, tags) to the underlying object store", @@ -18,19 +24,94 @@ var refsDumpCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { repoURI := MustParseRepoURI("repository URI", args[0]) client := getClient() - resp, err := client.DumpRefsWithResponse(cmd.Context(), repoURI.Repository) - DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusCreated) - if resp.JSON201 == nil { + output := Must(cmd.Flags().GetString("output")) + pollInterval := Must(cmd.Flags().GetDuration("poll-interval")) + if pollInterval < minimumPollInterval { + DieFmt("Poll interval must be at least %s", minimumPollInterval) + } + timeoutDuration := Must(cmd.Flags().GetDuration("timeout")) + + // request refs dump + ctx := cmd.Context() + resp, err := client.DumpSubmitWithResponse(ctx, repoURI.Repository) + DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusAccepted) + if resp.JSON202 == nil { Die("Bad response from server", 1) } - Write(metadataDumpTemplate, struct { - Response interface{} - }{resp.JSON201}) + taskID := resp.JSON202.Id + logging.FromContext(ctx).WithField("task_id", taskID).Debug("Submitted refs dump") + + // wait for refs dump to complete + dumpStatus, err := backoff.RetryWithData(func() (*apigen.RepositoryDumpStatus, error) { + logging.FromContext(ctx). + WithFields(logging.Fields{"task_id": taskID}).Debug("Checking status of refs dump") + + resp, err := client.DumpStatusWithResponse(ctx, repoURI.Repository, &apigen.DumpStatusParams{ + TaskId: taskID, + }) + DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) + if resp.JSON200 == nil { + err := fmt.Errorf("dump status %w: %s", helpers.ErrRequestFailed, resp.Status()) + return nil, backoff.Permanent(err) + } + if resp.JSON200.Done { + return resp.JSON200, nil + } + if timeoutDuration >= 0 && time.Since(resp.JSON200.UpdateTime) > timeoutDuration { + return nil, backoff.Permanent(ErrTaskNotCompleted) + } + return nil, ErrTaskNotCompleted + }, backoff.WithContext( + backoff.NewConstantBackOff(pollInterval), ctx), + ) + + switch { + case err != nil: + DieErr(err) + case dumpStatus == nil: + Die("Refs restore failed: no status returned", 1) + case dumpStatus.Error != nil: + DieFmt("Refs dump failed: %s", *dumpStatus.Error) + case dumpStatus.Refs == nil: + Die("Refs dump failed: no refs returned", 1) + } + if err := printRefs(output, dumpStatus.Refs); err != nil { + DieErr(err) + } }, } +func printRefs(output string, refs *apigen.RefsDump) error { + // marshal refs to JSON + refsJSON, err := json.MarshalIndent(refs, "", " ") + if err != nil { + return err + } + + // select the output writer + var w io.Writer + if output == "" || output == "-" { + w = os.Stdout + } else { + fmt.Println("Writing refs to", output) + fp, err := os.Create(output) + if err != nil { + return err + } + w = fp + defer func() { _ = fp.Close() }() + } + + // print refs to output + _, err = fmt.Fprintf(w, "%s\n", refsJSON) + return err +} + //nolint:gochecknoinits func init() { + refsDumpCmd.Flags().StringP("output", "o", "", "output filename (default stdout)") + refsDumpCmd.Flags().Duration("poll-interval", defaultPollInterval, "poll status check interval") + refsDumpCmd.Flags().Duration("timeout", defaultPollTimeout, "timeout for polling status checks") rootCmd.AddCommand(refsDumpCmd) } diff --git a/cmd/lakectl/cmd/refs_restore.go b/cmd/lakectl/cmd/refs_restore.go index 3f41f3e0bab..e12cfe307d0 100644 --- a/cmd/lakectl/cmd/refs_restore.go +++ b/cmd/lakectl/cmd/refs_restore.go @@ -5,9 +5,13 @@ import ( "fmt" "io" "net/http" + "time" + "github.com/cenkalti/backoff/v4" "github.com/spf13/cobra" "github.com/treeverse/lakefs/pkg/api/apigen" + "github.com/treeverse/lakefs/pkg/api/helpers" + "github.com/treeverse/lakefs/pkg/logging" ) const refsRestoreSuccess = ` @@ -26,6 +30,12 @@ Since a bare repo is expected, in case of transient failure, delete the reposito Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { repoURI := MustParseRepoURI("repository URI", args[0]) + pollInterval := Must(cmd.Flags().GetDuration("poll-interval")) + if pollInterval < minimumPollInterval { + DieFmt("Poll interval must be at least %s", minimumPollInterval) + } + timeoutDuration := Must(cmd.Flags().GetDuration("timeout")) + fmt.Println("Repository:", repoURI) manifestFileName := Must(cmd.Flags().GetString("manifest")) fp := Must(OpenByPath(manifestFileName)) @@ -45,8 +55,48 @@ Since a bare repo is expected, in case of transient failure, delete the reposito } // execute the restore operation client := getClient() - resp, err := client.RestoreRefsWithResponse(cmd.Context(), repoURI.Repository, apigen.RestoreRefsJSONRequestBody(manifest)) - DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) + ctx := cmd.Context() + resp, err := client.RestoreSubmitWithResponse(ctx, repoURI.Repository, apigen.RestoreSubmitJSONRequestBody(manifest)) + DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusAccepted) + if resp.JSON202 == nil { + Die("Bad response from server", 1) + } + taskID := resp.JSON202.Id + logging.FromContext(ctx).WithField("task_id", taskID).Debug("Submitted refs restore") + + var bo backoff.BackOff = backoff.NewConstantBackOff(pollInterval) + bo = backoff.WithContext(bo, ctx) + + restoreStatus, err := backoff.RetryWithData(func() (*apigen.RepositoryRestoreStatus, error) { + logging.FromContext(ctx). + WithFields(logging.Fields{"task_id": taskID}). + Debug("Checking status of refs restore") + + resp, err := client.RestoreStatusWithResponse(ctx, repoURI.Repository, &apigen.RestoreStatusParams{ + TaskId: taskID, + }) + DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) + if resp.JSON200 == nil { + err := fmt.Errorf("restore status %w: %s", helpers.ErrRequestFailed, resp.Status()) + return nil, backoff.Permanent(err) + } + if resp.JSON200.Done { + return resp.JSON200, nil + } + if timeoutDuration >= 0 && time.Since(resp.JSON200.UpdateTime) > timeoutDuration { + return nil, backoff.Permanent(ErrTaskNotCompleted) + } + return nil, ErrTaskNotCompleted + }, bo) + + switch { + case err != nil: + DieErr(err) + case restoreStatus == nil: + Die("Refs restore failed: no status returned", 1) + case restoreStatus.Error != nil: + DieFmt("Refs restore failed: %s", *restoreStatus.Error) + } Write(refsRestoreSuccess, nil) }, } @@ -56,5 +106,7 @@ func init() { rootCmd.AddCommand(refsRestoreCmd) refsRestoreCmd.Flags().String("manifest", "", "path to a refs manifest json file (as generated by `refs-dump`). Alternatively, use \"-\" to read from stdin") + refsRestoreCmd.Flags().Duration("poll-interval", defaultPollInterval, "poll status check interval") + refsRestoreCmd.Flags().Duration("timeout", defaultPollTimeout, "timeout for polling status checks") _ = refsRestoreCmd.MarkFlagRequired("manifest") } diff --git a/cmd/lakefs/cmd/run.go b/cmd/lakefs/cmd/run.go index 68727e5f8ed..ff497cef1f3 100644 --- a/cmd/lakefs/cmd/run.go +++ b/cmd/lakefs/cmd/run.go @@ -174,7 +174,7 @@ var runCmd = &cobra.Command{ } defer func() { _ = c.Close() }() - deleteScheduler := getScheduler() + deleteScheduler := gocron.NewScheduler(time.UTC) err = scheduleCleanupJobs(ctx, deleteScheduler, c) if err != nil { logger.WithError(err).Fatal("Failed to schedule cleanup jobs") @@ -364,7 +364,7 @@ var runCmd = &cobra.Command{ }, } -// checkRepos iterates on all repos and validates that their settings are correct. +// checkRepos iterating on all repos and validates that their settings are correct. func checkRepos(ctx context.Context, logger logging.Logger, authMetadataManager auth.MetadataManager, blockStore block.Adapter, c *catalog.Catalog) { initialized, err := authMetadataManager.IsInitialized(ctx) if err != nil { @@ -406,36 +406,48 @@ func checkRepos(ctx context.Context, logger logging.Logger, authMetadataManager } func scheduleCleanupJobs(ctx context.Context, s *gocron.Scheduler, c *catalog.Catalog) error { - // delete expired link addresses - const deleteExpiredAddressPeriod = 3 - job1, err := s.Every(deleteExpiredAddressPeriod * ref.LinkAddressTime).Do(func() { - c.DeleteExpiredLinkAddresses(ctx) - }) - if err != nil { - return err + const ( + deleteExpiredLinkAddressesInterval = 3 * ref.LinkAddressTime + deleteExpiredTaskInterval = 24 * time.Hour + ) + + jobData := []struct { + name string + interval time.Duration + fn func(context.Context) + }{ + { + name: "delete expired link addresses", + interval: deleteExpiredLinkAddressesInterval, + fn: c.DeleteExpiredLinkAddresses, + }, + { + name: "delete expired imports", + interval: ref.ImportExpiryTime, + fn: c.DeleteExpiredImports, + }, + { + name: "delete expired tasks", + interval: deleteExpiredTaskInterval, + fn: c.DeleteExpiredTasks, + }, } - job1.SingletonMode() - // delete expired imports - job2, err := s.Every(ref.ImportExpiryTime).Do(func() { - c.DeleteExpiredImports(ctx) - }) - if err != nil { - return err + for _, jd := range jobData { + job, err := s.Every(jd.interval).Do(jd.fn, ctx) + if err != nil { + return fmt.Errorf("schedule %s failed: %w", jd.name, err) + } + job.SingletonMode() } - job2.SingletonMode() - return nil } -func getScheduler() *gocron.Scheduler { - return gocron.NewScheduler(time.UTC) -} - // checkForeignRepo checks whether a repo storage namespace matches the block adapter. // A foreign repo is a repository which namespace doesn't match the current block adapter. // A foreign repo might exist if the lakeFS instance configuration changed after a repository was -// already created. The behaviour of lakeFS for foreign repos is undefined and should be blocked. +// already created. +// The behavior of lakeFS for foreign repos is undefined and should be blocked. func checkForeignRepo(repoStorageType block.StorageType, logger logging.Logger, adapterStorageType, repoName string) { if adapterStorageType != repoStorageType.BlockstoreType() { logger.Fatalf("Mismatched adapter detected. lakeFS started with adapter of type '%s', but repository '%s' is of type '%s'", diff --git a/docs/assets/js/swagger.yml b/docs/assets/js/swagger.yml index 04cd69a5398..b12b2f39508 100644 --- a/docs/assets/js/swagger.yml +++ b/docs/assets/js/swagger.yml @@ -594,6 +594,53 @@ components: ref: type: string + TaskInfo: + type: object + required: + - id + properties: + id: + type: string + description: ID of the task + + RepositoryDumpStatus: + type: object + required: + - id + - done + - update_time + properties: + id: + type: string + description: ID of the task + done: + type: boolean + update_time: + type: string + format: date-time + error: + type: string + refs: + $ref: "#/components/schemas/RefsDump" + + RepositoryRestoreStatus: + type: object + required: + - id + - done + - update_time + properties: + id: + type: string + description: ID of the task + done: + type: boolean + update_time: + type: string + format: date-time + error: + type: string + RefsDump: type: object required: @@ -2686,6 +2733,125 @@ paths: default: $ref: "#/components/responses/ServerError" + + /repositories/{repository}/dump: + parameters: + - in: path + name: repository + required: true + schema: + type: string + post: + tags: + - repositories + operationId: dumpSubmit + summary: Backup the repository metadata (tags, commits, branches) and save the backup to the object store. + responses: + 202: + description: dump task information + content: + application/json: + schema: + $ref: "#/components/schemas/TaskInfo" + 400: + $ref: "#/components/responses/ValidationError" + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + default: + $ref: "#/components/responses/ServerError" + get: + tags: + - repositories + operationId: dumpStatus + summary: Status of a repository dump task + parameters: + - in: query + name: task_id + required: true + schema: + type: string + responses: + 200: + description: dump task status + content: + application/json: + schema: + $ref: "#/components/schemas/RepositoryDumpStatus" + 400: + $ref: "#/components/responses/ValidationError" + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + 420: + description: too many requests + default: + $ref: "#/components/responses/ServerError" + + /repositories/{repository}/restore: + parameters: + - in: path + name: repository + required: true + schema: + type: string + post: + tags: + - repositories + operationId: restoreSubmit + summary: Restore repository from a dump in the object store + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/RefsDump" + responses: + 202: + description: restore task created + content: + application/json: + schema: + $ref: "#/components/schemas/TaskInfo" + 400: + $ref: "#/components/responses/ValidationError" + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + default: + $ref: "#/components/responses/ServerError" + get: + tags: + - repositories + operationId: restoreStatus + summary: Status of a restore request + parameters: + - in: query + name: task_id + required: true + schema: + type: string + responses: + 200: + description: restore task status + content: + application/json: + schema: + $ref: "#/components/schemas/RepositoryRestoreStatus" + 400: + $ref: "#/components/responses/ValidationError" + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + 420: + description: too many requests + default: + $ref: "#/components/responses/ServerError" + /repositories/{repository}/tags: parameters: - in: path diff --git a/docs/reference/cli.md b/docs/reference/cli.md index de08bab78f3..0c29542bfdc 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -2945,7 +2945,10 @@ lakectl refs-dump [flags] {:.no_toc} ``` - -h, --help help for refs-dump + -h, --help help for refs-dump + -o, --output string output filename (default stdout) + --poll-interval duration poll status check interval (default 3s) + --timeout duration timeout for polling status checks (default 1h0m0s) ``` @@ -2980,8 +2983,10 @@ aws s3 cp s3://bucket/_lakefs/refs_manifest.json - | lakectl refs-restore lakefs {:.no_toc} ``` - -h, --help help for refs-restore - --manifest refs-dump path to a refs manifest json file (as generated by refs-dump). Alternatively, use "-" to read from stdin + -h, --help help for refs-restore + --manifest refs-dump path to a refs manifest json file (as generated by refs-dump). Alternatively, use "-" to read from stdin + --poll-interval duration poll status check interval (default 3s) + --timeout duration timeout for polling status checks (default 1h0m0s) ``` diff --git a/pkg/api/controller.go b/pkg/api/controller.go index c553b458462..647006adfeb 100644 --- a/pkg/api/controller.go +++ b/pkg/api/controller.go @@ -3358,6 +3358,192 @@ func (c *Controller) RestoreRefs(w http.ResponseWriter, r *http.Request, body ap } } +func (c *Controller) DumpSubmit(w http.ResponseWriter, r *http.Request, repository string) { + if !c.authorize(w, r, permissions.Node{ + Type: permissions.NodeTypeAnd, + Nodes: []permissions.Node{ + { + Permission: permissions.Permission{ + Action: permissions.ListTagsAction, + Resource: permissions.RepoArn(repository), + }, + }, + { + Permission: permissions.Permission{ + Action: permissions.ListBranchesAction, + Resource: permissions.RepoArn(repository), + }, + }, + { + Permission: permissions.Permission{ + Action: permissions.ListCommitsAction, + Resource: permissions.RepoArn(repository), + }, + }, + }, + }) { + return + } + ctx := r.Context() + c.LogAction(ctx, "dump_repository", r, repository, "", "") + + taskID, err := c.Catalog.DumpRepositorySubmit(ctx, repository) + if c.handleAPIError(ctx, w, r, err) { + return + } + + writeResponse(w, r, http.StatusAccepted, apigen.TaskInfo{ + Id: taskID, + }) +} + +func (c *Controller) DumpStatus(w http.ResponseWriter, r *http.Request, repository string, params apigen.DumpStatusParams) { + if !c.authorize(w, r, permissions.Node{ + Type: permissions.NodeTypeAnd, + Nodes: []permissions.Node{ + { + Permission: permissions.Permission{ + Action: permissions.ListTagsAction, + Resource: permissions.RepoArn(repository), + }, + }, + { + Permission: permissions.Permission{ + Action: permissions.ListBranchesAction, + Resource: permissions.RepoArn(repository), + }, + }, + { + Permission: permissions.Permission{ + Action: permissions.ListCommitsAction, + Resource: permissions.RepoArn(repository), + }, + }, + }, + }) { + return + } + + // get the current status + ctx := r.Context() + status, err := c.Catalog.DumpRepositoryStatus(ctx, repository, params.TaskId) + if c.handleAPIError(ctx, w, r, err) { + return + } + + // build response based on status + response := &apigen.RepositoryDumpStatus{ + Id: params.TaskId, + Done: status.Task.Done, + UpdateTime: status.Task.UpdatedAt.AsTime(), + } + if status.Task.Error != "" { + response.Error = apiutil.Ptr(status.Task.Error) + } + if status.Task.Done && status.Info != nil { + response.Refs = &apigen.RefsDump{ + CommitsMetaRangeId: status.Info.CommitsMetarangeId, + TagsMetaRangeId: status.Info.TagsMetarangeId, + BranchesMetaRangeId: status.Info.BranchesMetarangeId, + } + } + writeResponse(w, r, http.StatusOK, response) +} + +func (c *Controller) RestoreSubmit(w http.ResponseWriter, r *http.Request, body apigen.RestoreSubmitJSONRequestBody, repository string) { + if !c.authorize(w, r, permissions.Node{ + Type: permissions.NodeTypeAnd, + Nodes: []permissions.Node{ + { + Permission: permissions.Permission{ + Action: permissions.CreateTagAction, + Resource: permissions.RepoArn(repository), + }, + }, + { + Permission: permissions.Permission{ + Action: permissions.CreateBranchAction, + Resource: permissions.RepoArn(repository), + }, + }, + { + Permission: permissions.Permission{ + Action: permissions.CreateCommitAction, + Resource: permissions.RepoArn(repository), + }, + }, + }, + }) { + return + } + + ctx := r.Context() + c.LogAction(ctx, "restore_repository", r, repository, "", "") + + info := &catalog.RepositoryDumpInfo{ + CommitsMetarangeId: body.CommitsMetaRangeId, + TagsMetarangeId: body.TagsMetaRangeId, + BranchesMetarangeId: body.BranchesMetaRangeId, + } + taskID, err := c.Catalog.RestoreRepositorySubmit(ctx, repository, info) + if errors.Is(err, catalog.ErrNonEmptyRepository) { + writeError(w, r, http.StatusBadRequest, "can only restore into a bare repository") + return + } + if c.handleAPIError(ctx, w, r, err) { + return + } + writeResponse(w, r, http.StatusAccepted, apigen.TaskInfo{ + Id: taskID, + }) +} + +func (c *Controller) RestoreStatus(w http.ResponseWriter, r *http.Request, repository string, params apigen.RestoreStatusParams) { + if !c.authorize(w, r, permissions.Node{ + Type: permissions.NodeTypeAnd, + Nodes: []permissions.Node{ + { + Permission: permissions.Permission{ + Action: permissions.CreateTagAction, + Resource: permissions.RepoArn(repository), + }, + }, + { + Permission: permissions.Permission{ + Action: permissions.CreateBranchAction, + Resource: permissions.RepoArn(repository), + }, + }, + { + Permission: permissions.Permission{ + Action: permissions.CreateCommitAction, + Resource: permissions.RepoArn(repository), + }, + }, + }, + }) { + return + } + + // get the current status + ctx := r.Context() + status, err := c.Catalog.RestoreRepositoryStatus(ctx, repository, params.TaskId) + if c.handleAPIError(ctx, w, r, err) { + return + } + + // build response based on status + response := &apigen.RepositoryRestoreStatus{ + Id: params.TaskId, + Done: status.Task.Done, + UpdateTime: status.Task.UpdatedAt.AsTime(), + } + if status.Task.Error != "" { + response.Error = apiutil.Ptr(status.Task.Error) + } + writeResponse(w, r, http.StatusOK, response) +} + func (c *Controller) CreateSymlinkFile(w http.ResponseWriter, r *http.Request, repository, branch string, params apigen.CreateSymlinkFileParams) { if !c.authorize(w, r, permissions.Node{ Permission: permissions.Permission{ @@ -4106,8 +4292,9 @@ func (c *Controller) GetSetupState(w http.ResponseWriter, r *http.Request) { LoginConfig: newLoginConfig(c.Config), } - // if email subscription is disabled in the config, set missing flag to false. - // otherwise, check if the comm prefs are set. if they are, set missing flag to false. + // if email subscription is disabled in the config, set the missing flag to false. + // otherwise, check if the comm prefs are set. + // if they are, set the missing flag to false. if !c.Config.EmailSubscription.Enabled { response.CommPrefsMissing = swag.Bool(false) writeResponse(w, r, http.StatusOK, response) diff --git a/pkg/api/controller_test.go b/pkg/api/controller_test.go index 0872531aec2..909aafadefc 100644 --- a/pkg/api/controller_test.go +++ b/pkg/api/controller_test.go @@ -4527,3 +4527,155 @@ func TestController_GarbageCollectionRules(t *testing.T) { }) } } + +func TestController_DumpRestoreRepository(t *testing.T) { + clt, deps := setupClientWithAdmin(t) + ctx := context.Background() + + // setup repository with some commits + repo := testUniqueRepoName() + _, err := deps.catalog.CreateRepository(ctx, repo, onBlock(deps, repo), "main") + testutil.Must(t, err) + + const commits = 3 + for i := 0; i < commits; i++ { + n := strconv.Itoa(i + 1) + p := "foo/bar" + n + err := deps.catalog.CreateEntry(ctx, repo, "main", catalog.DBEntry{Path: p, PhysicalAddress: onBlock(deps, "bar"+n+"addr"), CreationDate: time.Now(), Size: int64(i) + 1, Checksum: "cksum" + n}) + testutil.MustDo(t, "create entry "+p, err) + _, err = deps.catalog.Commit(ctx, repo, "main", "commit"+n, "tester", nil, nil, nil) + testutil.MustDo(t, "commit "+p, err) + } + + var dumpStatus *apigen.RepositoryDumpStatus + + t.Run("dump", func(t *testing.T) { + dumpResp, err := clt.DumpSubmitWithResponse(ctx, repo) + testutil.MustDo(t, "dump submit", err) + if dumpResp.JSON202 == nil { + t.Fatal("Expected 202 response") + } + + taskID := dumpResp.JSON202.Id + ticker := time.NewTicker(500 * time.Millisecond) + started := time.Now() + for range ticker.C { + statusResp, err := clt.DumpStatusWithResponse(ctx, repo, &apigen.DumpStatusParams{TaskId: taskID}) + testutil.MustDo(t, "dump status", err) + if statusResp.JSON200 == nil { + t.Fatal("Expected 200 response") + } + if statusResp.JSON200.Done { + dumpStatus = statusResp.JSON200 + break + } + if time.Since(started) > 30*time.Second { + break + } + } + ticker.Stop() + + if dumpStatus == nil { + t.Fatal("Expected dump to complete (timed-out)") + } + if dumpStatus.Error != nil { + t.Fatalf("Failed to dump repository refs: %s", *dumpStatus.Error) + } + }) + + t.Run("dump_status_invalid_id", func(t *testing.T) { + response, err := clt.DumpStatusWithResponse(ctx, repo, &apigen.DumpStatusParams{TaskId: "invalid"}) + testutil.MustDo(t, "dump status", err) + if response.JSON404 == nil { + t.Fatalf("Expected 404 (not found) response, got %s", response.Status()) + } + }) + + t.Run("restore", func(t *testing.T) { + if dumpStatus == nil || dumpStatus.Refs == nil { + t.Skip("Skipping restore test, dump failed") + } + + newRepo := testUniqueRepoName() + _, err = deps.catalog.CreateBareRepository(ctx, newRepo, onBlock(deps, repo), "main") + testutil.MustDo(t, "create bare repository", err) + + submitResponse, err := clt.RestoreSubmitWithResponse(ctx, newRepo, apigen.RestoreSubmitJSONRequestBody{ + BranchesMetaRangeId: dumpStatus.Refs.BranchesMetaRangeId, + CommitsMetaRangeId: dumpStatus.Refs.CommitsMetaRangeId, + TagsMetaRangeId: dumpStatus.Refs.TagsMetaRangeId, + }) + testutil.MustDo(t, "restore submit", err) + if submitResponse.JSON202 == nil { + t.Fatalf("Expected 202 response, got: %s", submitResponse.Status()) + } + + restoreStatus := pollRestoreStatus(t, clt, newRepo, submitResponse.JSON202.Id) + if restoreStatus == nil { + t.Fatal("Expected restore to complete (timed-out)") + } + if restoreStatus.Error != nil { + t.Fatalf("Failed to restore repository refs: %s", *restoreStatus.Error) + } + }) + + t.Run("restore_invalid_refs", func(t *testing.T) { + // delete and recreate repository as bare for restore + newRepo := testUniqueRepoName() + _, err = deps.catalog.CreateBareRepository(ctx, newRepo, onBlock(deps, repo), "main") + testutil.MustDo(t, "create bare repository", err) + + submitResponse, err := clt.RestoreSubmitWithResponse(ctx, newRepo, apigen.RestoreSubmitJSONRequestBody{ + BranchesMetaRangeId: "invalid", + CommitsMetaRangeId: "invalid", + TagsMetaRangeId: "invalid", + }) + testutil.MustDo(t, "restore submit", err) + if submitResponse.JSON202 == nil { + t.Fatalf("Expected 202 response, got: %s", submitResponse.Status()) + } + + restoreStatus := pollRestoreStatus(t, clt, newRepo, submitResponse.JSON202.Id) + if restoreStatus == nil { + t.Fatal("Expected restore to complete (timed-out)") + } + if restoreStatus.Error == nil { + t.Fatal("Expected restore to fail, got nil Error") + } + if !strings.Contains(*restoreStatus.Error, graveler.ErrNotFound.Error()) { + t.Fatal("Expected restore to fail with not found error") + } + }) + + t.Run("restore_status_invalid_id", func(t *testing.T) { + response, err := clt.RestoreStatusWithResponse(ctx, repo, &apigen.RestoreStatusParams{TaskId: "invalid"}) + testutil.MustDo(t, "restore status", err) + if response.JSON404 == nil { + t.Fatalf("Expected 404 (not found) response, got %s", response.Status()) + } + }) +} + +// pollRestoreStatus polls the restore status endpoint until the restore is complete or times out. +// test will fail in case of error. +// will return nil in case of timeout. +func pollRestoreStatus(t *testing.T, clt apigen.ClientWithResponsesInterface, repo string, taskID string) *apigen.RepositoryRestoreStatus { + t.Helper() + ticker := time.NewTicker(500 * time.Millisecond) + defer ticker.Stop() + started := time.Now() + for range ticker.C { + statusResponse, err := clt.RestoreStatusWithResponse(context.Background(), repo, &apigen.RestoreStatusParams{TaskId: taskID}) + testutil.MustDo(t, "restore status", err) + if statusResponse.JSON200 == nil { + t.Fatalf("Expected 200 response, got: %s", statusResponse.Status()) + } + if statusResponse.JSON200.Done { + return statusResponse.JSON200 + } + if time.Since(started) > 30*time.Second { + break + } + } + return nil +} diff --git a/pkg/catalog/catalog.go b/pkg/catalog/catalog.go index c0e687792a5..866ca8a8268 100644 --- a/pkg/catalog/catalog.go +++ b/pkg/catalog/catalog.go @@ -11,6 +11,7 @@ import ( "io" "net/url" "os" + "reflect" "strings" "time" @@ -41,6 +42,7 @@ import ( "github.com/treeverse/lakefs/pkg/validator" "go.uber.org/atomic" "go.uber.org/ratelimit" + "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/types/known/timestamppb" ) @@ -63,6 +65,11 @@ const ( // Total per entry ~52 bytes // Deviation with gcPeriodicCheckSize = 100000 will be around 5 MB gcPeriodicCheckSize = 100000 + + DumpRefsTaskIDPrefix = "DR" + RestoreRefsTaskIDPrefix = "RR" + + TaskExpiryTime = 24 * time.Hour ) type Path string @@ -1819,6 +1826,217 @@ func (c *Catalog) FindMergeBase(ctx context.Context, repositoryID string, destin return fromCommit.CommitID.String(), toCommit.CommitID.String(), c.addressProvider.ContentAddress(baseCommit), nil } +func (c *Catalog) DumpRepositorySubmit(ctx context.Context, repositoryID string) (string, error) { + repository, err := c.getRepository(ctx, repositoryID) + if err != nil { + return "", err + } + + taskStatus := &RepositoryDumpStatus{} + taskSteps := []taskStep{ + { + Name: "dump commits", + Func: func(ctx context.Context) error { + commitsMetaRangeID, err := c.Store.DumpCommits(ctx, repository) + if err != nil { + return err + } + taskStatus.Info = &RepositoryDumpInfo{ + CommitsMetarangeId: string(*commitsMetaRangeID), + } + return nil + }, + }, + { + Name: "dump branches", + Func: func(ctx context.Context) error { + branchesMetaRangeID, err := c.Store.DumpBranches(ctx, repository) + if err != nil { + return err + } + taskStatus.Info.BranchesMetarangeId = string(*branchesMetaRangeID) + return nil + }, + }, + { + Name: "dump tags", + Func: func(ctx context.Context) error { + tagsMetaRangeID, err := c.Store.DumpTags(ctx, repository) + if err != nil { + return err + } + taskStatus.Info.TagsMetarangeId = string(*tagsMetaRangeID) + return nil + }, + }, + } + + // create refs dump task and update initial status. + taskID := NewTaskID(DumpRefsTaskIDPrefix) + err = c.runBackgroundTaskSteps(repository, taskID, taskSteps, taskStatus) + if err != nil { + return "", err + } + return taskID, nil +} + +func (c *Catalog) DumpRepositoryStatus(ctx context.Context, repositoryID string, id string) (*RepositoryDumpStatus, error) { + repository, err := c.getRepository(ctx, repositoryID) + if err != nil { + return nil, err + } + if !IsTaskID(DumpRefsTaskIDPrefix, id) { + return nil, graveler.ErrNotFound + } + + var taskStatus RepositoryDumpStatus + err = GetTaskStatus(ctx, c.KVStore, repository, id, &taskStatus) + if err != nil { + return nil, err + } + return &taskStatus, nil +} + +func (c *Catalog) RestoreRepositorySubmit(ctx context.Context, repositoryID string, info *RepositoryDumpInfo) (string, error) { + repository, err := c.getRepository(ctx, repositoryID) + if err != nil { + return "", err + } + + // verify bare repository - no commits + _, _, err = c.ListCommits(ctx, repository.RepositoryID.String(), repository.DefaultBranchID.String(), LogParams{ + Amount: 1, + Limit: true, + }) + if !errors.Is(err, graveler.ErrNotFound) { + return "", ErrNonEmptyRepository + } + + // create refs restore task and update initial status + taskStatus := &RepositoryRestoreStatus{} + taskSteps := []taskStep{ + { + Name: "load commits", + Func: func(ctx context.Context) error { + return c.Store.LoadCommits(ctx, repository, graveler.MetaRangeID(info.CommitsMetarangeId)) + }, + }, + { + Name: "load branches", + Func: func(ctx context.Context) error { + return c.Store.LoadBranches(ctx, repository, graveler.MetaRangeID(info.BranchesMetarangeId)) + }, + }, + { + Name: "load tags", + Func: func(ctx context.Context) error { + return c.Store.LoadTags(ctx, repository, graveler.MetaRangeID(info.TagsMetarangeId)) + }, + }, + } + taskID := NewTaskID(RestoreRefsTaskIDPrefix) + if err := c.runBackgroundTaskSteps(repository, taskID, taskSteps, taskStatus); err != nil { + return "", err + } + return taskID, nil +} + +func (c *Catalog) RestoreRepositoryStatus(ctx context.Context, repositoryID string, id string) (*RepositoryRestoreStatus, error) { + repository, err := c.getRepository(ctx, repositoryID) + if err != nil { + return nil, err + } + if !IsTaskID(RestoreRefsTaskIDPrefix, id) { + return nil, graveler.ErrNotFound + } + + var status RepositoryRestoreStatus + err = GetTaskStatus(ctx, c.KVStore, repository, id, &status) + if err != nil { + return nil, err + } + return &status, nil +} + +// runBackgroundTaskSteps update task status provided after filling the 'Task' field and update for each step provided. +// the task status is updated after each step, and the task is marked as completed if the step is the last one. +// initial update if the task is done before running the steps. +func (c *Catalog) runBackgroundTaskSteps(repository *graveler.RepositoryRecord, taskID string, steps []taskStep, taskStatus protoreflect.ProtoMessage) error { + // Allocate Task and set if on the taskStatus's 'Task' field. + // We continue to update this field while running each step. + // If the task field in the common Protobuf message is changed, we need to update the field name here as well. + task := &Task{ + Id: taskID, + UpdatedAt: timestamppb.Now(), + } + reflect.ValueOf(taskStatus).Elem().FieldByName("Task").Set(reflect.ValueOf(task)) + + // make sure we use background context as soon as we submit the task the request is done + ctx := context.Background() + + // initial task update done before we run each step in the background task + if err := UpdateTaskStatus(ctx, c.KVStore, repository, taskID, taskStatus); err != nil { + return err + } + + log := c.log(ctx).WithFields(logging.Fields{"task_id": taskID, "repository": repository.RepositoryID}) + c.workPool.Submit(func() { + for stepIdx, step := range steps { + // call the step function + err := step.Func(ctx) + // update task part + task.UpdatedAt = timestamppb.Now() + if err != nil { + log.WithError(err).WithField("step", step.Name).Errorf("Catalog background task step failed") + task.Done = true + task.Error = err.Error() + } else if stepIdx == len(steps)-1 { + task.Done = true + } + + // update task status + if err := UpdateTaskStatus(ctx, c.KVStore, repository, taskID, taskStatus); err != nil { + log.WithError(err).WithField("step", step.Name).Error("Catalog failed to update task status") + } + + // make sure we stop based on task completed status, as we may fail + if task.Done { + break + } + } + }) + return nil +} + +// DeleteExpiredRepositoryTasks deletes all expired tasks for the given repository +func (c *Catalog) deleteRepositoryExpiredTasks(ctx context.Context, repo *graveler.RepositoryRecord) error { + // new scan iterator to iterate over all tasks + repoPartition := graveler.RepoPartition(repo) + it, err := kv.NewPrimaryIterator(ctx, c.KVStoreLimited, (&TaskMsg{}).ProtoReflect().Type(), + repoPartition, []byte(TaskPath("")), kv.IteratorOptionsFrom([]byte(""))) + if err != nil { + return err + } + defer it.Close() + + // iterate over all tasks and delete expired ones + for it.Next() { + ent := it.Entry() + msg := ent.Value.(*TaskMsg) + if msg.Task == nil { + continue + } + if time.Since(msg.Task.UpdatedAt.AsTime()) < TaskExpiryTime { + continue + } + err := c.KVStoreLimited.Delete(ctx, []byte(repoPartition), ent.Key) + if err != nil { + return err + } + } + return it.Err() +} + func (c *Catalog) DumpCommits(ctx context.Context, repositoryID string) (string, error) { repository, err := c.getRepository(ctx, repositoryID) if err != nil { @@ -2389,6 +2607,21 @@ func (c *Catalog) DeleteExpiredImports(ctx context.Context) { } } +func (c *Catalog) DeleteExpiredTasks(ctx context.Context) { + repos, err := c.listRepositoriesHelper(ctx) + if err != nil { + c.log(ctx).WithError(err).Warn("Delete expired tasks, failed to list repositories") + return + } + + for _, repo := range repos { + err := c.deleteRepositoryExpiredTasks(ctx, repo) + if err != nil { + c.log(ctx).WithError(err).WithField("repository", repo.RepositoryID).Warn("Delete expired tasks failed") + } + } +} + func (c *Catalog) listRepositoriesHelper(ctx context.Context) ([]*graveler.RepositoryRecord, error) { it, err := c.Store.ListRepositories(ctx) if err != nil { diff --git a/pkg/catalog/catalog.pb.go b/pkg/catalog/catalog.pb.go index 341b255b617..078e93021f3 100644 --- a/pkg/catalog/catalog.pb.go +++ b/pkg/catalog/catalog.pb.go @@ -168,6 +168,303 @@ func (x *Entry) GetContentType() string { return "" } +// Task is a generic task status message +type Task struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Done bool `protobuf:"varint,2,opt,name=done,proto3" json:"done,omitempty"` + UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` + Progress int64 `protobuf:"varint,4,opt,name=progress,proto3" json:"progress,omitempty"` + Error string `protobuf:"bytes,5,opt,name=error,proto3" json:"error,omitempty"` +} + +func (x *Task) Reset() { + *x = Task{} + if protoimpl.UnsafeEnabled { + mi := &file_catalog_catalog_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Task) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Task) ProtoMessage() {} + +func (x *Task) ProtoReflect() protoreflect.Message { + mi := &file_catalog_catalog_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Task.ProtoReflect.Descriptor instead. +func (*Task) Descriptor() ([]byte, []int) { + return file_catalog_catalog_proto_rawDescGZIP(), []int{1} +} + +func (x *Task) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *Task) GetDone() bool { + if x != nil { + return x.Done + } + return false +} + +func (x *Task) GetUpdatedAt() *timestamppb.Timestamp { + if x != nil { + return x.UpdatedAt + } + return nil +} + +func (x *Task) GetProgress() int64 { + if x != nil { + return x.Progress + } + return 0 +} + +func (x *Task) GetError() string { + if x != nil { + return x.Error + } + return "" +} + +// RepositoryDumpInfo holds the metarange IDs for a repository dump +type RepositoryDumpInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CommitsMetarangeId string `protobuf:"bytes,1,opt,name=commits_metarange_id,json=commitsMetarangeId,proto3" json:"commits_metarange_id,omitempty"` + TagsMetarangeId string `protobuf:"bytes,2,opt,name=tags_metarange_id,json=tagsMetarangeId,proto3" json:"tags_metarange_id,omitempty"` + BranchesMetarangeId string `protobuf:"bytes,3,opt,name=branches_metarange_id,json=branchesMetarangeId,proto3" json:"branches_metarange_id,omitempty"` +} + +func (x *RepositoryDumpInfo) Reset() { + *x = RepositoryDumpInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_catalog_catalog_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RepositoryDumpInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RepositoryDumpInfo) ProtoMessage() {} + +func (x *RepositoryDumpInfo) ProtoReflect() protoreflect.Message { + mi := &file_catalog_catalog_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RepositoryDumpInfo.ProtoReflect.Descriptor instead. +func (*RepositoryDumpInfo) Descriptor() ([]byte, []int) { + return file_catalog_catalog_proto_rawDescGZIP(), []int{2} +} + +func (x *RepositoryDumpInfo) GetCommitsMetarangeId() string { + if x != nil { + return x.CommitsMetarangeId + } + return "" +} + +func (x *RepositoryDumpInfo) GetTagsMetarangeId() string { + if x != nil { + return x.TagsMetarangeId + } + return "" +} + +func (x *RepositoryDumpInfo) GetBranchesMetarangeId() string { + if x != nil { + return x.BranchesMetarangeId + } + return "" +} + +// RepositoryDumpStatus holds the status of a repository dump +type RepositoryDumpStatus struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Task *Task `protobuf:"bytes,1,opt,name=task,proto3" json:"task,omitempty"` + Info *RepositoryDumpInfo `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` +} + +func (x *RepositoryDumpStatus) Reset() { + *x = RepositoryDumpStatus{} + if protoimpl.UnsafeEnabled { + mi := &file_catalog_catalog_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RepositoryDumpStatus) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RepositoryDumpStatus) ProtoMessage() {} + +func (x *RepositoryDumpStatus) ProtoReflect() protoreflect.Message { + mi := &file_catalog_catalog_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RepositoryDumpStatus.ProtoReflect.Descriptor instead. +func (*RepositoryDumpStatus) Descriptor() ([]byte, []int) { + return file_catalog_catalog_proto_rawDescGZIP(), []int{3} +} + +func (x *RepositoryDumpStatus) GetTask() *Task { + if x != nil { + return x.Task + } + return nil +} + +func (x *RepositoryDumpStatus) GetInfo() *RepositoryDumpInfo { + if x != nil { + return x.Info + } + return nil +} + +// RepositoryRestoreStatus holds the status of a repository restore +type RepositoryRestoreStatus struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Task *Task `protobuf:"bytes,1,opt,name=task,proto3" json:"task,omitempty"` +} + +func (x *RepositoryRestoreStatus) Reset() { + *x = RepositoryRestoreStatus{} + if protoimpl.UnsafeEnabled { + mi := &file_catalog_catalog_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *RepositoryRestoreStatus) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RepositoryRestoreStatus) ProtoMessage() {} + +func (x *RepositoryRestoreStatus) ProtoReflect() protoreflect.Message { + mi := &file_catalog_catalog_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RepositoryRestoreStatus.ProtoReflect.Descriptor instead. +func (*RepositoryRestoreStatus) Descriptor() ([]byte, []int) { + return file_catalog_catalog_proto_rawDescGZIP(), []int{4} +} + +func (x *RepositoryRestoreStatus) GetTask() *Task { + if x != nil { + return x.Task + } + return nil +} + +// TaskMsg described generic message with Task field +// used for all status messages and for cleanup messages +type TaskMsg struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Task *Task `protobuf:"bytes,1,opt,name=task,proto3" json:"task,omitempty"` +} + +func (x *TaskMsg) Reset() { + *x = TaskMsg{} + if protoimpl.UnsafeEnabled { + mi := &file_catalog_catalog_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TaskMsg) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TaskMsg) ProtoMessage() {} + +func (x *TaskMsg) ProtoReflect() protoreflect.Message { + mi := &file_catalog_catalog_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use TaskMsg.ProtoReflect.Descriptor instead. +func (*TaskMsg) Descriptor() ([]byte, []int) { + return file_catalog_catalog_proto_rawDescGZIP(), []int{5} +} + +func (x *TaskMsg) GetTask() *Task { + if x != nil { + return x.Task + } + return nil +} + var File_catalog_catalog_proto protoreflect.FileDescriptor var file_catalog_catalog_proto_rawDesc = []byte{ @@ -201,10 +498,44 @@ var file_catalog_catalog_proto_rawDesc = []byte{ 0x65, 0x73, 0x73, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x14, 0x42, 0x59, 0x5f, 0x50, 0x52, 0x45, 0x46, 0x49, 0x58, 0x5f, 0x44, 0x45, 0x50, 0x52, 0x45, 0x43, 0x41, 0x54, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x52, 0x45, 0x4c, 0x41, 0x54, 0x49, 0x56, 0x45, 0x10, 0x01, 0x12, - 0x08, 0x0a, 0x04, 0x46, 0x55, 0x4c, 0x4c, 0x10, 0x02, 0x42, 0x24, 0x5a, 0x22, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x72, 0x65, 0x65, 0x76, 0x65, 0x73, 0x65, - 0x2f, 0x6c, 0x61, 0x6b, 0x65, 0x66, 0x73, 0x2f, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x08, 0x0a, 0x04, 0x46, 0x55, 0x4c, 0x4c, 0x10, 0x02, 0x22, 0x97, 0x01, 0x0a, 0x04, 0x54, 0x61, + 0x73, 0x6b, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x6f, 0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, + 0x52, 0x04, 0x64, 0x6f, 0x6e, 0x65, 0x12, 0x39, 0x0a, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x64, 0x5f, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x64, 0x41, + 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x72, 0x6f, 0x67, 0x72, 0x65, 0x73, 0x73, 0x12, 0x14, 0x0a, + 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, + 0x72, 0x6f, 0x72, 0x22, 0xa6, 0x01, 0x0a, 0x12, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, + 0x72, 0x79, 0x44, 0x75, 0x6d, 0x70, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x30, 0x0a, 0x14, 0x63, 0x6f, + 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x12, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, + 0x73, 0x4d, 0x65, 0x74, 0x61, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x11, + 0x74, 0x61, 0x67, 0x73, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x5f, 0x69, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x61, 0x67, 0x73, 0x4d, 0x65, 0x74, + 0x61, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x49, 0x64, 0x12, 0x32, 0x0a, 0x15, 0x62, 0x72, 0x61, 0x6e, + 0x63, 0x68, 0x65, 0x73, 0x5f, 0x6d, 0x65, 0x74, 0x61, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x5f, 0x69, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, + 0x73, 0x4d, 0x65, 0x74, 0x61, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x49, 0x64, 0x22, 0x6a, 0x0a, 0x14, + 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x75, 0x6d, 0x70, 0x53, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x12, 0x21, 0x0a, 0x04, 0x74, 0x61, 0x73, 0x6b, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x2e, 0x54, 0x61, 0x73, + 0x6b, 0x52, 0x04, 0x74, 0x61, 0x73, 0x6b, 0x12, 0x2f, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x2e, + 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x44, 0x75, 0x6d, 0x70, 0x49, 0x6e, + 0x66, 0x6f, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x22, 0x3c, 0x0a, 0x17, 0x52, 0x65, 0x70, 0x6f, + 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x53, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x12, 0x21, 0x0a, 0x04, 0x74, 0x61, 0x73, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0d, 0x2e, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x2e, 0x54, 0x61, 0x73, 0x6b, + 0x52, 0x04, 0x74, 0x61, 0x73, 0x6b, 0x22, 0x2c, 0x0a, 0x07, 0x54, 0x61, 0x73, 0x6b, 0x4d, 0x73, + 0x67, 0x12, 0x21, 0x0a, 0x04, 0x74, 0x61, 0x73, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0d, 0x2e, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x04, + 0x74, 0x61, 0x73, 0x6b, 0x42, 0x24, 0x5a, 0x22, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x74, 0x72, 0x65, 0x65, 0x76, 0x65, 0x73, 0x65, 0x2f, 0x6c, 0x61, 0x6b, 0x65, + 0x66, 0x73, 0x2f, 0x63, 0x61, 0x74, 0x61, 0x6c, 0x6f, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -220,22 +551,32 @@ func file_catalog_catalog_proto_rawDescGZIP() []byte { } var file_catalog_catalog_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_catalog_catalog_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_catalog_catalog_proto_msgTypes = make([]protoimpl.MessageInfo, 7) var file_catalog_catalog_proto_goTypes = []interface{}{ - (Entry_AddressType)(0), // 0: catalog.Entry.AddressType - (*Entry)(nil), // 1: catalog.Entry - nil, // 2: catalog.Entry.MetadataEntry - (*timestamppb.Timestamp)(nil), // 3: google.protobuf.Timestamp + (Entry_AddressType)(0), // 0: catalog.Entry.AddressType + (*Entry)(nil), // 1: catalog.Entry + (*Task)(nil), // 2: catalog.Task + (*RepositoryDumpInfo)(nil), // 3: catalog.RepositoryDumpInfo + (*RepositoryDumpStatus)(nil), // 4: catalog.RepositoryDumpStatus + (*RepositoryRestoreStatus)(nil), // 5: catalog.RepositoryRestoreStatus + (*TaskMsg)(nil), // 6: catalog.TaskMsg + nil, // 7: catalog.Entry.MetadataEntry + (*timestamppb.Timestamp)(nil), // 8: google.protobuf.Timestamp } var file_catalog_catalog_proto_depIdxs = []int32{ - 3, // 0: catalog.Entry.last_modified:type_name -> google.protobuf.Timestamp - 2, // 1: catalog.Entry.metadata:type_name -> catalog.Entry.MetadataEntry + 8, // 0: catalog.Entry.last_modified:type_name -> google.protobuf.Timestamp + 7, // 1: catalog.Entry.metadata:type_name -> catalog.Entry.MetadataEntry 0, // 2: catalog.Entry.address_type:type_name -> catalog.Entry.AddressType - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 8, // 3: catalog.Task.updated_at:type_name -> google.protobuf.Timestamp + 2, // 4: catalog.RepositoryDumpStatus.task:type_name -> catalog.Task + 3, // 5: catalog.RepositoryDumpStatus.info:type_name -> catalog.RepositoryDumpInfo + 2, // 6: catalog.RepositoryRestoreStatus.task:type_name -> catalog.Task + 2, // 7: catalog.TaskMsg.task:type_name -> catalog.Task + 8, // [8:8] is the sub-list for method output_type + 8, // [8:8] is the sub-list for method input_type + 8, // [8:8] is the sub-list for extension type_name + 8, // [8:8] is the sub-list for extension extendee + 0, // [0:8] is the sub-list for field type_name } func init() { file_catalog_catalog_proto_init() } @@ -256,6 +597,66 @@ func file_catalog_catalog_proto_init() { return nil } } + file_catalog_catalog_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Task); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_catalog_catalog_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RepositoryDumpInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_catalog_catalog_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RepositoryDumpStatus); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_catalog_catalog_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*RepositoryRestoreStatus); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_catalog_catalog_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TaskMsg); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -263,7 +664,7 @@ func file_catalog_catalog_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_catalog_catalog_proto_rawDesc, NumEnums: 1, - NumMessages: 2, + NumMessages: 7, NumExtensions: 0, NumServices: 0, }, diff --git a/pkg/catalog/catalog.proto b/pkg/catalog/catalog.proto index 481854152c2..2a1230e6289 100644 --- a/pkg/catalog/catalog.proto +++ b/pkg/catalog/catalog.proto @@ -22,3 +22,38 @@ message Entry { AddressType address_type = 6; string content_type = 7; } + +// Task is a generic task status message +message Task { + string id = 1; + bool done = 2; + google.protobuf.Timestamp updated_at = 3; + int64 progress = 4; + string error = 5; +} + +// RepositoryDumpInfo holds the metarange IDs for a repository dump +message RepositoryDumpInfo { + string commits_metarange_id = 1; + string tags_metarange_id = 2; + string branches_metarange_id = 3; +} + +// RepositoryDumpStatus holds the status of a repository dump +message RepositoryDumpStatus { + Task task = 1; + RepositoryDumpInfo info = 2; +} + +// RepositoryRestoreStatus holds the status of a repository restore +message RepositoryRestoreStatus { + Task task = 1; +} + +// TaskMsg described generic message with Task field +// used for all status messages and for cleanup messages +message TaskMsg { + Task task = 1; +} + + diff --git a/pkg/catalog/errors.go b/pkg/catalog/errors.go index 1c87dddc5d1..e8deeec49de 100644 --- a/pkg/catalog/errors.go +++ b/pkg/catalog/errors.go @@ -13,8 +13,10 @@ var ( ErrPathRequiredValue = fmt.Errorf("missing path: %w", graveler.ErrRequiredValue) ErrInvalidMetadataSrcFormat = errors.New("invalid metadata src format") ErrExpired = errors.New("expired from storage") + // ErrItClosed is used to determine the reason for the end of the walk ErrItClosed = errors.New("iterator closed") ErrFeatureNotSupported = errors.New("feature not supported") + ErrNonEmptyRepository = errors.New("non empty repository") ) diff --git a/pkg/catalog/task.go b/pkg/catalog/task.go new file mode 100644 index 00000000000..78efec99c48 --- /dev/null +++ b/pkg/catalog/task.go @@ -0,0 +1,53 @@ +package catalog + +import ( + "context" + "errors" + "strings" + + nanoid "github.com/matoous/go-nanoid/v2" + "github.com/treeverse/lakefs/pkg/graveler" + "github.com/treeverse/lakefs/pkg/kv" + "google.golang.org/protobuf/reflect/protoreflect" +) + +const ( + taskIDNanoLength = 20 + tasksPrefix = "tasks" +) + +type taskStep struct { + Name string + Func func(ctx context.Context) error +} + +func TaskPath(key string) string { + return kv.FormatPath(tasksPrefix, key) +} + +func NewTaskID(prefix string) string { + return prefix + nanoid.Must(taskIDNanoLength) +} + +func IsTaskID(prefix, taskID string) bool { + return len(taskID) == len(prefix)+taskIDNanoLength && strings.HasPrefix(taskID, prefix) +} + +func UpdateTaskStatus(ctx context.Context, kvStore kv.Store, repository *graveler.RepositoryRecord, taskID string, statusMsg protoreflect.ProtoMessage) error { + err := kv.SetMsg(ctx, kvStore, graveler.RepoPartition(repository), []byte(TaskPath(taskID)), statusMsg) + if err != nil { + return err + } + return nil +} + +func GetTaskStatus(ctx context.Context, kvStore kv.Store, repository *graveler.RepositoryRecord, taskID string, statusMsg protoreflect.ProtoMessage) error { + _, err := kv.GetMsg(ctx, kvStore, graveler.RepoPartition(repository), []byte(TaskPath(taskID)), statusMsg) + if err != nil { + if errors.Is(err, kv.ErrNotFound) { + return graveler.ErrNotFound + } + return err + } + return nil +}