diff --git a/api/swagger.yml b/api/swagger.yml index 2e935ceb49e..47f2c812029 100644 --- a/api/swagger.yml +++ b/api/swagger.yml @@ -2329,6 +2329,130 @@ paths: default: $ref: "#/components/responses/ServerError" + /repositories/{repository}/settings/gc_rules: + parameters: + - in: path + name: repository + required: true + schema: + type: string + get: + tags: + - repositories + operationId: getGCRules + summary: get repository GC rules + responses: + 200: + description: repository GC rules + content: + application/json: + schema: + $ref: "#/components/schemas/GarbageCollectionRules" + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + default: + $ref: "#/components/responses/ServerError" + put: + tags: + - repositories + operationId: setGCRules + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/GarbageCollectionRules" + responses: + 204: + description: set garbage collection rules successfully + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + default: + $ref: "#/components/responses/ServerError" + delete: + tags: + - repositories + operationId: deleteGCRules + responses: + 204: + description: deleted garbage collection rules successfully + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + default: + $ref: "#/components/responses/ServerError" + + /repositories/{repository}/settings/branch_protection: + parameters: + - in: path + name: repository + required: true + schema: + type: string + get: + tags: + - repositories + operationId: getBranchProtectionRules + summary: get branch protection rules + responses: + 200: + description: branch protection rules + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/BranchProtectionRule" + headers: + ETag: + schema: + type: string + description: ETag of the branch protection rules + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + default: + $ref: "#/components/responses/ServerError" + + put: + parameters: + - in: header + name: If-Match + schema: + type: string + description: if provided, the branch protection rules will be updated only if the current ETag match the provided value + allowEmptyValue: true + tags: + - repositories + operationId: setBranchProtectionRules + requestBody: + required: true + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/BranchProtectionRule" + responses: + 204: + description: branch protection rule created successfully + 400: + $ref: "#/components/responses/BadRequest" + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + 412: + $ref: "#/components/responses/PreconditionFailed" + default: + $ref: "#/components/responses/ServerError" + /otf/diffs: get: tags: @@ -4068,9 +4192,10 @@ paths: schema: type: string get: + deprecated: true tags: - - retention - operationId: getGarbageCollectionRules + - internal + operationId: internalGetGarbageCollectionRules responses: 200: description: gc rule list @@ -4086,9 +4211,10 @@ paths: $ref: "#/components/responses/ServerError" post: + deprecated: true tags: - - retention - operationId: set garbage collection rules + - internal + operationId: internalSetGarbageCollectionRules requestBody: required: true content: @@ -4105,9 +4231,10 @@ paths: default: $ref: "#/components/responses/ServerError" delete: + deprecated: true tags: - - retention - operationId: delete garbage collection rules + - internal + operationId: internalDeleteGarbageCollectionRules responses: 204: description: deleted garbage collection rules successfully @@ -4208,9 +4335,10 @@ paths: schema: type: string get: + deprecated: true tags: - - repositories - operationId: getBranchProtectionRules + - internal + operationId: internalGetBranchProtectionRules summary: get branch protection rules responses: 200: @@ -4229,9 +4357,10 @@ paths: $ref: "#/components/responses/ServerError" post: + deprecated: true tags: - - repositories - operationId: createBranchProtectionRule + - internal + operationId: internalCreateBranchProtectionRule requestBody: required: true content: @@ -4248,9 +4377,10 @@ paths: default: $ref: "#/components/responses/ServerError" delete: + deprecated: true tags: - - repositories - operationId: deleteBranchProtectionRule + - internal + operationId: internalDeleteBranchProtectionRule requestBody: required: true content: @@ -4331,7 +4461,7 @@ paths: /config/garbage-collection: get: tags: - - config + - internal operationId: getGarbageCollectionConfig description: get information of gc settings responses: diff --git a/clients/java/README.md b/clients/java/README.md index b8e7ca78fec..ceb6b36d21b 100644 --- a/clients/java/README.md +++ b/clients/java/README.md @@ -181,7 +181,6 @@ Class | Method | HTTP request | Description *CommitsApi* | [**commit**](docs/CommitsApi.md#commit) | **POST** /repositories/{repository}/branches/{branch}/commits | create commit *CommitsApi* | [**getCommit**](docs/CommitsApi.md#getCommit) | **GET** /repositories/{repository}/commits/{commitId} | get commit *ConfigApi* | [**getConfig**](docs/ConfigApi.md#getConfig) | **GET** /config | -*ConfigApi* | [**getGarbageCollectionConfig**](docs/ConfigApi.md#getGarbageCollectionConfig) | **GET** /config/garbage-collection | *ExperimentalApi* | [**getOtfDiffs**](docs/ExperimentalApi.md#getOtfDiffs) | **GET** /otf/diffs | get the available Open Table Format diffs *ExperimentalApi* | [**otfDiff**](docs/ExperimentalApi.md#otfDiff) | **GET** /repositories/{repository}/otf/refs/{left_ref}/diff/{right_ref} | perform otf diff *HealthCheckApi* | [**healthCheck**](docs/HealthCheckApi.md#healthCheck) | **GET** /healthcheck | @@ -192,9 +191,16 @@ Class | Method | HTTP request | Description *InternalApi* | [**createSymlinkFile**](docs/InternalApi.md#createSymlinkFile) | **POST** /repositories/{repository}/refs/{branch}/symlink | creates symlink files corresponding to the given directory *InternalApi* | [**dumpRefs**](docs/InternalApi.md#dumpRefs) | **PUT** /repositories/{repository}/refs/dump | Dump repository refs (tags, commits, branches) to object store Deprecated: a new API will introduce long running operations *InternalApi* | [**getAuthCapabilities**](docs/InternalApi.md#getAuthCapabilities) | **GET** /auth/capabilities | list authentication capabilities supported +*InternalApi* | [**getGarbageCollectionConfig**](docs/InternalApi.md#getGarbageCollectionConfig) | **GET** /config/garbage-collection | *InternalApi* | [**getLakeFSVersion**](docs/InternalApi.md#getLakeFSVersion) | **GET** /config/version | *InternalApi* | [**getSetupState**](docs/InternalApi.md#getSetupState) | **GET** /setup_lakefs | check if the lakeFS installation is already set up *InternalApi* | [**getStorageConfig**](docs/InternalApi.md#getStorageConfig) | **GET** /config/storage | +*InternalApi* | [**internalCreateBranchProtectionRule**](docs/InternalApi.md#internalCreateBranchProtectionRule) | **POST** /repositories/{repository}/branch_protection | +*InternalApi* | [**internalDeleteBranchProtectionRule**](docs/InternalApi.md#internalDeleteBranchProtectionRule) | **DELETE** /repositories/{repository}/branch_protection | +*InternalApi* | [**internalDeleteGarbageCollectionRules**](docs/InternalApi.md#internalDeleteGarbageCollectionRules) | **DELETE** /repositories/{repository}/gc/rules | +*InternalApi* | [**internalGetBranchProtectionRules**](docs/InternalApi.md#internalGetBranchProtectionRules) | **GET** /repositories/{repository}/branch_protection | get branch protection rules +*InternalApi* | [**internalGetGarbageCollectionRules**](docs/InternalApi.md#internalGetGarbageCollectionRules) | **GET** /repositories/{repository}/gc/rules | +*InternalApi* | [**internalSetGarbageCollectionRules**](docs/InternalApi.md#internalSetGarbageCollectionRules) | **POST** /repositories/{repository}/gc/rules | *InternalApi* | [**postStatsEvents**](docs/InternalApi.md#postStatsEvents) | **POST** /statistics | post stats events, this endpoint is meant for internal use only *InternalApi* | [**restoreRefs**](docs/InternalApi.md#restoreRefs) | **PUT** /repositories/{repository}/refs/restore | Restore repository refs (tags, commits, branches) from object store. Deprecated: a new API will introduce long running operations *InternalApi* | [**setGarbageCollectionRulesPreflight**](docs/InternalApi.md#setGarbageCollectionRulesPreflight) | **GET** /repositories/{repository}/gc/rules/set_allowed | @@ -217,19 +223,18 @@ Class | Method | HTTP request | Description *RefsApi* | [**findMergeBase**](docs/RefsApi.md#findMergeBase) | **GET** /repositories/{repository}/refs/{sourceRef}/merge/{destinationBranch} | find the merge base for 2 references *RefsApi* | [**logCommits**](docs/RefsApi.md#logCommits) | **GET** /repositories/{repository}/refs/{ref}/commits | get commit log from ref. If both objects and prefixes are empty, return all commits. *RefsApi* | [**mergeIntoBranch**](docs/RefsApi.md#mergeIntoBranch) | **POST** /repositories/{repository}/refs/{sourceRef}/merge/{destinationBranch} | merge references -*RepositoriesApi* | [**createBranchProtectionRule**](docs/RepositoriesApi.md#createBranchProtectionRule) | **POST** /repositories/{repository}/branch_protection | *RepositoriesApi* | [**createRepository**](docs/RepositoriesApi.md#createRepository) | **POST** /repositories | create repository -*RepositoriesApi* | [**deleteBranchProtectionRule**](docs/RepositoriesApi.md#deleteBranchProtectionRule) | **DELETE** /repositories/{repository}/branch_protection | +*RepositoriesApi* | [**deleteGCRules**](docs/RepositoriesApi.md#deleteGCRules) | **DELETE** /repositories/{repository}/settings/gc_rules | *RepositoriesApi* | [**deleteRepository**](docs/RepositoriesApi.md#deleteRepository) | **DELETE** /repositories/{repository} | delete repository -*RepositoriesApi* | [**getBranchProtectionRules**](docs/RepositoriesApi.md#getBranchProtectionRules) | **GET** /repositories/{repository}/branch_protection | get branch protection rules +*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 -*RetentionApi* | [**deleteGarbageCollectionRules**](docs/RetentionApi.md#deleteGarbageCollectionRules) | **DELETE** /repositories/{repository}/gc/rules | -*RetentionApi* | [**getGarbageCollectionRules**](docs/RetentionApi.md#getGarbageCollectionRules) | **GET** /repositories/{repository}/gc/rules | +*RepositoriesApi* | [**setBranchProtectionRules**](docs/RepositoriesApi.md#setBranchProtectionRules) | **PUT** /repositories/{repository}/settings/branch_protection | +*RepositoriesApi* | [**setGCRules**](docs/RepositoriesApi.md#setGCRules) | **PUT** /repositories/{repository}/settings/gc_rules | *RetentionApi* | [**prepareGarbageCollectionCommits**](docs/RetentionApi.md#prepareGarbageCollectionCommits) | **POST** /repositories/{repository}/gc/prepare_commits | save lists of active commits for garbage collection *RetentionApi* | [**prepareGarbageCollectionUncommitted**](docs/RetentionApi.md#prepareGarbageCollectionUncommitted) | **POST** /repositories/{repository}/gc/prepare_uncommited | save repository uncommitted metadata for garbage collection -*RetentionApi* | [**setGarbageCollectionRules**](docs/RetentionApi.md#setGarbageCollectionRules) | **POST** /repositories/{repository}/gc/rules | *StagingApi* | [**getPhysicalAddress**](docs/StagingApi.md#getPhysicalAddress) | **GET** /repositories/{repository}/branches/{branch}/staging/backing | get a physical address and a return token to write object to underlying storage *StagingApi* | [**linkPhysicalAddress**](docs/StagingApi.md#linkPhysicalAddress) | **PUT** /repositories/{repository}/branches/{branch}/staging/backing | associate staging on this physical address with a path *TagsApi* | [**createTag**](docs/TagsApi.md#createTag) | **POST** /repositories/{repository}/tags | create tag diff --git a/clients/java/api/openapi.yaml b/clients/java/api/openapi.yaml index 25c57d43afb..c0d3f7a1f46 100644 --- a/clients/java/api/openapi.yaml +++ b/clients/java/api/openapi.yaml @@ -1778,6 +1778,234 @@ paths: tags: - repositories x-accepts: application/json + /repositories/{repository}/settings/gc_rules: + delete: + operationId: deleteGCRules + parameters: + - explode: false + in: path + name: repository + required: true + schema: + type: string + style: simple + responses: + "204": + description: deleted garbage collection rules successfully + "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 + tags: + - repositories + x-accepts: application/json + get: + operationId: getGCRules + parameters: + - explode: false + in: path + name: repository + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/GarbageCollectionRules' + description: repository GC rules + "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: get repository GC rules + tags: + - repositories + x-accepts: application/json + put: + operationId: setGCRules + parameters: + - explode: false + in: path + name: repository + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/GarbageCollectionRules' + required: true + responses: + "204": + description: set garbage collection rules successfully + "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 + tags: + - repositories + x-contentType: application/json + x-accepts: application/json + /repositories/{repository}/settings/branch_protection: + get: + operationId: getBranchProtectionRules + parameters: + - explode: false + in: path + name: repository + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/json: + schema: + items: + $ref: '#/components/schemas/BranchProtectionRule' + type: array + description: branch protection rules + headers: + ETag: + explode: false + schema: + description: ETag of the branch protection rules + type: string + style: simple + "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: get branch protection rules + tags: + - repositories + x-accepts: application/json + put: + operationId: setBranchProtectionRules + parameters: + - explode: false + in: path + name: repository + required: true + schema: + type: string + style: simple + - description: if provided, the branch protection rules will be updated only + if the current ETag match the provided value + explode: false + in: header + name: If-Match + required: false + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + items: + $ref: '#/components/schemas/BranchProtectionRule' + type: array + required: true + responses: + "204": + description: branch protection rule created successfully + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Bad Request + "401": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Unauthorized + "404": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Resource Not Found + "412": + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Precondition Failed + default: + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + description: Internal Server Error + tags: + - repositories + x-contentType: application/json + x-accepts: application/json /otf/diffs: get: operationId: getOtfDiffs @@ -4811,7 +5039,8 @@ paths: x-accepts: application/json /repositories/{repository}/gc/rules: delete: - operationId: delete garbage collection rules + deprecated: true + operationId: internalDeleteGarbageCollectionRules parameters: - explode: false in: path @@ -4842,10 +5071,11 @@ paths: $ref: '#/components/schemas/Error' description: Internal Server Error tags: - - retention + - internal x-accepts: application/json get: - operationId: getGarbageCollectionRules + deprecated: true + operationId: internalGetGarbageCollectionRules parameters: - explode: false in: path @@ -4880,10 +5110,11 @@ paths: $ref: '#/components/schemas/Error' description: Internal Server Error tags: - - retention + - internal x-accepts: application/json post: - operationId: set garbage collection rules + deprecated: true + operationId: internalSetGarbageCollectionRules parameters: - explode: false in: path @@ -4920,7 +5151,7 @@ paths: $ref: '#/components/schemas/Error' description: Internal Server Error tags: - - retention + - internal x-contentType: application/json x-accepts: application/json /repositories/{repository}/gc/prepare_commits: @@ -5059,7 +5290,8 @@ paths: x-accepts: application/json /repositories/{repository}/branch_protection: delete: - operationId: deleteBranchProtectionRule + deprecated: true + operationId: internalDeleteBranchProtectionRule parameters: - explode: false in: path @@ -5102,11 +5334,12 @@ paths: $ref: '#/components/schemas/Error' description: Internal Server Error tags: - - repositories + - internal x-contentType: application/json x-accepts: application/json get: - operationId: getBranchProtectionRules + deprecated: true + operationId: internalGetBranchProtectionRules parameters: - explode: false in: path @@ -5144,10 +5377,11 @@ paths: description: Internal Server Error summary: get branch protection rules tags: - - repositories + - internal x-accepts: application/json post: - operationId: createBranchProtectionRule + deprecated: true + operationId: internalCreateBranchProtectionRule parameters: - explode: false in: path @@ -5184,7 +5418,7 @@ paths: $ref: '#/components/schemas/Error' description: Internal Server Error tags: - - repositories + - internal x-contentType: application/json x-accepts: application/json /healthcheck: @@ -5278,7 +5512,7 @@ paths: $ref: '#/components/schemas/Error' description: Unauthorized tags: - - config + - internal x-accepts: application/json /statistics: post: diff --git a/clients/java/docs/ConfigApi.md b/clients/java/docs/ConfigApi.md index 358be7be0ae..df872aca7ca 100644 --- a/clients/java/docs/ConfigApi.md +++ b/clients/java/docs/ConfigApi.md @@ -5,7 +5,6 @@ All URIs are relative to *http://localhost/api/v1* Method | HTTP request | Description ------------- | ------------- | ------------- [**getConfig**](ConfigApi.md#getConfig) | **GET** /config | -[**getGarbageCollectionConfig**](ConfigApi.md#getGarbageCollectionConfig) | **GET** /config/garbage-collection | @@ -95,90 +94,3 @@ This endpoint does not need any parameter. **200** | lakeFS configuration | - | **401** | Unauthorized | - | - -# **getGarbageCollectionConfig** -> GarbageCollectionConfig getGarbageCollectionConfig() - - - -get information of gc settings - -### 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.ConfigApi; - -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"); - - ConfigApi apiInstance = new ConfigApi(defaultClient); - try { - GarbageCollectionConfig result = apiInstance.getGarbageCollectionConfig(); - System.out.println(result); - } catch (ApiException e) { - System.err.println("Exception when calling ConfigApi#getGarbageCollectionConfig"); - System.err.println("Status code: " + e.getCode()); - System.err.println("Reason: " + e.getResponseBody()); - System.err.println("Response headers: " + e.getResponseHeaders()); - e.printStackTrace(); - } - } -} -``` - -### Parameters -This endpoint does not need any parameter. - -### Return type - -[**GarbageCollectionConfig**](GarbageCollectionConfig.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** | lakeFS garbage collection config | - | -**401** | Unauthorized | - | - diff --git a/clients/java/docs/InternalApi.md b/clients/java/docs/InternalApi.md index 921f8102e75..3cc7a909d19 100644 --- a/clients/java/docs/InternalApi.md +++ b/clients/java/docs/InternalApi.md @@ -8,9 +8,16 @@ Method | HTTP request | Description [**createSymlinkFile**](InternalApi.md#createSymlinkFile) | **POST** /repositories/{repository}/refs/{branch}/symlink | creates symlink files corresponding to the given directory [**dumpRefs**](InternalApi.md#dumpRefs) | **PUT** /repositories/{repository}/refs/dump | Dump repository refs (tags, commits, branches) to object store Deprecated: a new API will introduce long running operations [**getAuthCapabilities**](InternalApi.md#getAuthCapabilities) | **GET** /auth/capabilities | list authentication capabilities supported +[**getGarbageCollectionConfig**](InternalApi.md#getGarbageCollectionConfig) | **GET** /config/garbage-collection | [**getLakeFSVersion**](InternalApi.md#getLakeFSVersion) | **GET** /config/version | [**getSetupState**](InternalApi.md#getSetupState) | **GET** /setup_lakefs | check if the lakeFS installation is already set up [**getStorageConfig**](InternalApi.md#getStorageConfig) | **GET** /config/storage | +[**internalCreateBranchProtectionRule**](InternalApi.md#internalCreateBranchProtectionRule) | **POST** /repositories/{repository}/branch_protection | +[**internalDeleteBranchProtectionRule**](InternalApi.md#internalDeleteBranchProtectionRule) | **DELETE** /repositories/{repository}/branch_protection | +[**internalDeleteGarbageCollectionRules**](InternalApi.md#internalDeleteGarbageCollectionRules) | **DELETE** /repositories/{repository}/gc/rules | +[**internalGetBranchProtectionRules**](InternalApi.md#internalGetBranchProtectionRules) | **GET** /repositories/{repository}/branch_protection | get branch protection rules +[**internalGetGarbageCollectionRules**](InternalApi.md#internalGetGarbageCollectionRules) | **GET** /repositories/{repository}/gc/rules | +[**internalSetGarbageCollectionRules**](InternalApi.md#internalSetGarbageCollectionRules) | **POST** /repositories/{repository}/gc/rules | [**postStatsEvents**](InternalApi.md#postStatsEvents) | **POST** /statistics | post stats events, this endpoint is meant for internal use only [**restoreRefs**](InternalApi.md#restoreRefs) | **PUT** /repositories/{repository}/refs/restore | Restore repository refs (tags, commits, branches) from object store. Deprecated: a new API will introduce long running operations [**setGarbageCollectionRulesPreflight**](InternalApi.md#setGarbageCollectionRulesPreflight) | **GET** /repositories/{repository}/gc/rules/set_allowed | @@ -354,6 +361,93 @@ No authorization required **200** | auth capabilities | - | **0** | Internal Server Error | - | + +# **getGarbageCollectionConfig** +> GarbageCollectionConfig getGarbageCollectionConfig() + + + +get information of gc settings + +### 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.InternalApi; + +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"); + + InternalApi apiInstance = new InternalApi(defaultClient); + try { + GarbageCollectionConfig result = apiInstance.getGarbageCollectionConfig(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling InternalApi#getGarbageCollectionConfig"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**GarbageCollectionConfig**](GarbageCollectionConfig.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** | lakeFS garbage collection config | - | +**401** | Unauthorized | - | + # **getLakeFSVersion** > VersionConfig getLakeFSVersion() @@ -585,6 +679,554 @@ This endpoint does not need any parameter. **200** | lakeFS storage configuration | - | **401** | Unauthorized | - | + +# **internalCreateBranchProtectionRule** +> internalCreateBranchProtectionRule(repository, branchProtectionRule) + + + +### 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.InternalApi; + +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"); + + InternalApi apiInstance = new InternalApi(defaultClient); + String repository = "repository_example"; // String | + BranchProtectionRule branchProtectionRule = new BranchProtectionRule(); // BranchProtectionRule | + try { + apiInstance.internalCreateBranchProtectionRule(repository, branchProtectionRule); + } catch (ApiException e) { + System.err.println("Exception when calling InternalApi#internalCreateBranchProtectionRule"); + 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**| | + **branchProtectionRule** | [**BranchProtectionRule**](BranchProtectionRule.md)| | + +### Return type + +null (empty response body) + +### 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 | +|-------------|-------------|------------------| +**204** | branch protection rule created successfully | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**0** | Internal Server Error | - | + + +# **internalDeleteBranchProtectionRule** +> internalDeleteBranchProtectionRule(repository, inlineObject1) + + + +### 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.InternalApi; + +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"); + + InternalApi apiInstance = new InternalApi(defaultClient); + String repository = "repository_example"; // String | + InlineObject1 inlineObject1 = new InlineObject1(); // InlineObject1 | + try { + apiInstance.internalDeleteBranchProtectionRule(repository, inlineObject1); + } catch (ApiException e) { + System.err.println("Exception when calling InternalApi#internalDeleteBranchProtectionRule"); + 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**| | + **inlineObject1** | [**InlineObject1**](InlineObject1.md)| | + +### Return type + +null (empty response body) + +### 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 | +|-------------|-------------|------------------| +**204** | branch protection rule deleted successfully | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**0** | Internal Server Error | - | + + +# **internalDeleteGarbageCollectionRules** +> internalDeleteGarbageCollectionRules(repository) + + + +### 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.InternalApi; + +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"); + + InternalApi apiInstance = new InternalApi(defaultClient); + String repository = "repository_example"; // String | + try { + apiInstance.internalDeleteGarbageCollectionRules(repository); + } catch (ApiException e) { + System.err.println("Exception when calling InternalApi#internalDeleteGarbageCollectionRules"); + 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 + +null (empty response body) + +### 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 | +|-------------|-------------|------------------| +**204** | deleted garbage collection rules successfully | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**0** | Internal Server Error | - | + + +# **internalGetBranchProtectionRules** +> List<BranchProtectionRule> internalGetBranchProtectionRules(repository) + +get branch protection rules + +### 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.InternalApi; + +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"); + + InternalApi apiInstance = new InternalApi(defaultClient); + String repository = "repository_example"; // String | + try { + List result = apiInstance.internalGetBranchProtectionRules(repository); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling InternalApi#internalGetBranchProtectionRules"); + 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 + +[**List<BranchProtectionRule>**](BranchProtectionRule.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** | branch protection rules | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**0** | Internal Server Error | - | + + +# **internalGetGarbageCollectionRules** +> GarbageCollectionRules internalGetGarbageCollectionRules(repository) + + + +### 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.InternalApi; + +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"); + + InternalApi apiInstance = new InternalApi(defaultClient); + String repository = "repository_example"; // String | + try { + GarbageCollectionRules result = apiInstance.internalGetGarbageCollectionRules(repository); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling InternalApi#internalGetGarbageCollectionRules"); + 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 + +[**GarbageCollectionRules**](GarbageCollectionRules.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** | gc rule list | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**0** | Internal Server Error | - | + + +# **internalSetGarbageCollectionRules** +> internalSetGarbageCollectionRules(repository, garbageCollectionRules) + + + +### 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.InternalApi; + +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"); + + InternalApi apiInstance = new InternalApi(defaultClient); + String repository = "repository_example"; // String | + GarbageCollectionRules garbageCollectionRules = new GarbageCollectionRules(); // GarbageCollectionRules | + try { + apiInstance.internalSetGarbageCollectionRules(repository, garbageCollectionRules); + } catch (ApiException e) { + System.err.println("Exception when calling InternalApi#internalSetGarbageCollectionRules"); + 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**| | + **garbageCollectionRules** | [**GarbageCollectionRules**](GarbageCollectionRules.md)| | + +### Return type + +null (empty response body) + +### 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 | +|-------------|-------------|------------------| +**204** | set garbage collection rules successfully | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**0** | Internal Server Error | - | + # **postStatsEvents** > postStatsEvents(statsEventsList) diff --git a/clients/java/docs/RepositoriesApi.md b/clients/java/docs/RepositoriesApi.md index a067e93588a..aee158c9972 100644 --- a/clients/java/docs/RepositoriesApi.md +++ b/clients/java/docs/RepositoriesApi.md @@ -4,21 +4,23 @@ All URIs are relative to *http://localhost/api/v1* Method | HTTP request | Description ------------- | ------------- | ------------- -[**createBranchProtectionRule**](RepositoriesApi.md#createBranchProtectionRule) | **POST** /repositories/{repository}/branch_protection | [**createRepository**](RepositoriesApi.md#createRepository) | **POST** /repositories | create repository -[**deleteBranchProtectionRule**](RepositoriesApi.md#deleteBranchProtectionRule) | **DELETE** /repositories/{repository}/branch_protection | +[**deleteGCRules**](RepositoriesApi.md#deleteGCRules) | **DELETE** /repositories/{repository}/settings/gc_rules | [**deleteRepository**](RepositoriesApi.md#deleteRepository) | **DELETE** /repositories/{repository} | delete repository -[**getBranchProtectionRules**](RepositoriesApi.md#getBranchProtectionRules) | **GET** /repositories/{repository}/branch_protection | get branch protection rules +[**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 +[**setBranchProtectionRules**](RepositoriesApi.md#setBranchProtectionRules) | **PUT** /repositories/{repository}/settings/branch_protection | +[**setGCRules**](RepositoriesApi.md#setGCRules) | **PUT** /repositories/{repository}/settings/gc_rules | - -# **createBranchProtectionRule** -> createBranchProtectionRule(repository, branchProtectionRule) - + +# **createRepository** +> Repository createRepository(repositoryCreation, bare) +create repository ### Example ```java @@ -63,12 +65,13 @@ public class Example { //saml_auth.setApiKeyPrefix("Token"); RepositoriesApi apiInstance = new RepositoriesApi(defaultClient); - String repository = "repository_example"; // String | - BranchProtectionRule branchProtectionRule = new BranchProtectionRule(); // BranchProtectionRule | + RepositoryCreation repositoryCreation = new RepositoryCreation(); // RepositoryCreation | + Boolean bare = false; // Boolean | If true, create a bare repository with no initial commit and branch try { - apiInstance.createBranchProtectionRule(repository, branchProtectionRule); + Repository result = apiInstance.createRepository(repositoryCreation, bare); + System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling RepositoriesApi#createBranchProtectionRule"); + System.err.println("Exception when calling RepositoriesApi#createRepository"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -82,12 +85,12 @@ public class Example { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **repository** | **String**| | - **branchProtectionRule** | [**BranchProtectionRule**](BranchProtectionRule.md)| | + **repositoryCreation** | [**RepositoryCreation**](RepositoryCreation.md)| | + **bare** | **Boolean**| If true, create a bare repository with no initial commit and branch | [optional] [default to false] ### Return type -null (empty response body) +[**Repository**](Repository.md) ### Authorization @@ -101,16 +104,17 @@ null (empty response body) ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| -**204** | branch protection rule created successfully | - | +**201** | repository | - | +**400** | Validation Error | - | **401** | Unauthorized | - | -**404** | Resource Not Found | - | +**409** | Resource Conflicts With Target | - | **0** | Internal Server Error | - | - -# **createRepository** -> Repository createRepository(repositoryCreation, bare) + +# **deleteGCRules** +> deleteGCRules(repository) + -create repository ### Example ```java @@ -155,13 +159,11 @@ public class Example { //saml_auth.setApiKeyPrefix("Token"); RepositoriesApi apiInstance = new RepositoriesApi(defaultClient); - RepositoryCreation repositoryCreation = new RepositoryCreation(); // RepositoryCreation | - Boolean bare = false; // Boolean | If true, create a bare repository with no initial commit and branch + String repository = "repository_example"; // String | try { - Repository result = apiInstance.createRepository(repositoryCreation, bare); - System.out.println(result); + apiInstance.deleteGCRules(repository); } catch (ApiException e) { - System.err.println("Exception when calling RepositoriesApi#createRepository"); + System.err.println("Exception when calling RepositoriesApi#deleteGCRules"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -175,12 +177,11 @@ public class Example { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **repositoryCreation** | [**RepositoryCreation**](RepositoryCreation.md)| | - **bare** | **Boolean**| If true, create a bare repository with no initial commit and branch | [optional] [default to false] + **repository** | **String**| | ### Return type -[**Repository**](Repository.md) +null (empty response body) ### Authorization @@ -188,23 +189,22 @@ Name | Type | Description | Notes ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| -**201** | repository | - | -**400** | Validation Error | - | +**204** | deleted garbage collection rules successfully | - | **401** | Unauthorized | - | -**409** | Resource Conflicts With Target | - | +**404** | Resource Not Found | - | **0** | Internal Server Error | - | - -# **deleteBranchProtectionRule** -> deleteBranchProtectionRule(repository, inlineObject1) - + +# **deleteRepository** +> deleteRepository(repository) +delete repository ### Example ```java @@ -250,11 +250,10 @@ public class Example { RepositoriesApi apiInstance = new RepositoriesApi(defaultClient); String repository = "repository_example"; // String | - InlineObject1 inlineObject1 = new InlineObject1(); // InlineObject1 | try { - apiInstance.deleteBranchProtectionRule(repository, inlineObject1); + apiInstance.deleteRepository(repository); } catch (ApiException e) { - System.err.println("Exception when calling RepositoriesApi#deleteBranchProtectionRule"); + System.err.println("Exception when calling RepositoriesApi#deleteRepository"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -269,7 +268,6 @@ public class Example { Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **repository** | **String**| | - **inlineObject1** | [**InlineObject1**](InlineObject1.md)| | ### Return type @@ -281,22 +279,22 @@ null (empty response body) ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: application/json ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| -**204** | branch protection rule deleted successfully | - | +**204** | repository deleted successfully | - | **401** | Unauthorized | - | **404** | Resource Not Found | - | **0** | Internal Server Error | - | - -# **deleteRepository** -> deleteRepository(repository) + +# **getBranchProtectionRules** +> List<BranchProtectionRule> getBranchProtectionRules(repository) -delete repository +get branch protection rules ### Example ```java @@ -343,9 +341,10 @@ public class Example { RepositoriesApi apiInstance = new RepositoriesApi(defaultClient); String repository = "repository_example"; // String | try { - apiInstance.deleteRepository(repository); + List result = apiInstance.getBranchProtectionRules(repository); + System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling RepositoriesApi#deleteRepository"); + System.err.println("Exception when calling RepositoriesApi#getBranchProtectionRules"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -363,7 +362,7 @@ Name | Type | Description | Notes ### Return type -null (empty response body) +[**List<BranchProtectionRule>**](BranchProtectionRule.md) ### Authorization @@ -377,16 +376,16 @@ null (empty response body) ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| -**204** | repository deleted successfully | - | +**200** | branch protection rules | * ETag -
| **401** | Unauthorized | - | **404** | Resource Not Found | - | **0** | Internal Server Error | - | - -# **getBranchProtectionRules** -> List<BranchProtectionRule> getBranchProtectionRules(repository) + +# **getGCRules** +> GarbageCollectionRules getGCRules(repository) -get branch protection rules +get repository GC rules ### Example ```java @@ -433,10 +432,10 @@ public class Example { RepositoriesApi apiInstance = new RepositoriesApi(defaultClient); String repository = "repository_example"; // String | try { - List result = apiInstance.getBranchProtectionRules(repository); + GarbageCollectionRules result = apiInstance.getGCRules(repository); System.out.println(result); } catch (ApiException e) { - System.err.println("Exception when calling RepositoriesApi#getBranchProtectionRules"); + System.err.println("Exception when calling RepositoriesApi#getGCRules"); System.err.println("Status code: " + e.getCode()); System.err.println("Reason: " + e.getResponseBody()); System.err.println("Response headers: " + e.getResponseHeaders()); @@ -454,7 +453,7 @@ Name | Type | Description | Notes ### Return type -[**List<BranchProtectionRule>**](BranchProtectionRule.md) +[**GarbageCollectionRules**](GarbageCollectionRules.md) ### Authorization @@ -468,7 +467,7 @@ Name | Type | Description | Notes ### HTTP response details | Status code | Description | Response headers | |-------------|-------------|------------------| -**200** | branch protection rules | - | +**200** | repository GC rules | - | **401** | Unauthorized | - | **404** | Resource Not Found | - | **0** | Internal Server Error | - | @@ -749,3 +748,191 @@ Name | Type | Description | Notes **401** | Unauthorized | - | **0** | Internal Server Error | - | + +# **setBranchProtectionRules** +> setBranchProtectionRules(repository, branchProtectionRule, ifMatch) + + + +### 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 | + List branchProtectionRule = Arrays.asList(); // List | + String ifMatch = "ifMatch_example"; // String | if provided, the branch protection rules will be updated only if the current ETag match the provided value + try { + apiInstance.setBranchProtectionRules(repository, branchProtectionRule, ifMatch); + } catch (ApiException e) { + System.err.println("Exception when calling RepositoriesApi#setBranchProtectionRules"); + 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**| | + **branchProtectionRule** | [**List<BranchProtectionRule>**](BranchProtectionRule.md)| | + **ifMatch** | **String**| if provided, the branch protection rules will be updated only if the current ETag match the provided value | [optional] + +### Return type + +null (empty response body) + +### 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 | +|-------------|-------------|------------------| +**204** | branch protection rule created successfully | - | +**400** | Bad Request | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**412** | Precondition Failed | - | +**0** | Internal Server Error | - | + + +# **setGCRules** +> setGCRules(repository, garbageCollectionRules) + + + +### 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 | + GarbageCollectionRules garbageCollectionRules = new GarbageCollectionRules(); // GarbageCollectionRules | + try { + apiInstance.setGCRules(repository, garbageCollectionRules); + } catch (ApiException e) { + System.err.println("Exception when calling RepositoriesApi#setGCRules"); + 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**| | + **garbageCollectionRules** | [**GarbageCollectionRules**](GarbageCollectionRules.md)| | + +### Return type + +null (empty response body) + +### 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 | +|-------------|-------------|------------------| +**204** | set garbage collection rules successfully | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**0** | Internal Server Error | - | + diff --git a/clients/java/docs/RetentionApi.md b/clients/java/docs/RetentionApi.md index 898dcad9ff3..bb227f59fec 100644 --- a/clients/java/docs/RetentionApi.md +++ b/clients/java/docs/RetentionApi.md @@ -4,194 +4,10 @@ All URIs are relative to *http://localhost/api/v1* Method | HTTP request | Description ------------- | ------------- | ------------- -[**deleteGarbageCollectionRules**](RetentionApi.md#deleteGarbageCollectionRules) | **DELETE** /repositories/{repository}/gc/rules | -[**getGarbageCollectionRules**](RetentionApi.md#getGarbageCollectionRules) | **GET** /repositories/{repository}/gc/rules | [**prepareGarbageCollectionCommits**](RetentionApi.md#prepareGarbageCollectionCommits) | **POST** /repositories/{repository}/gc/prepare_commits | save lists of active commits for garbage collection [**prepareGarbageCollectionUncommitted**](RetentionApi.md#prepareGarbageCollectionUncommitted) | **POST** /repositories/{repository}/gc/prepare_uncommited | save repository uncommitted metadata for garbage collection -[**setGarbageCollectionRules**](RetentionApi.md#setGarbageCollectionRules) | **POST** /repositories/{repository}/gc/rules | - -# **deleteGarbageCollectionRules** -> deleteGarbageCollectionRules(repository) - - - -### 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.RetentionApi; - -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"); - - RetentionApi apiInstance = new RetentionApi(defaultClient); - String repository = "repository_example"; // String | - try { - apiInstance.deleteGarbageCollectionRules(repository); - } catch (ApiException e) { - System.err.println("Exception when calling RetentionApi#deleteGarbageCollectionRules"); - 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 - -null (empty response body) - -### 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 | -|-------------|-------------|------------------| -**204** | deleted garbage collection rules successfully | - | -**401** | Unauthorized | - | -**404** | Resource Not Found | - | -**0** | Internal Server Error | - | - - -# **getGarbageCollectionRules** -> GarbageCollectionRules getGarbageCollectionRules(repository) - - - -### 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.RetentionApi; - -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"); - - RetentionApi apiInstance = new RetentionApi(defaultClient); - String repository = "repository_example"; // String | - try { - GarbageCollectionRules result = apiInstance.getGarbageCollectionRules(repository); - System.out.println(result); - } catch (ApiException e) { - System.err.println("Exception when calling RetentionApi#getGarbageCollectionRules"); - 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 - -[**GarbageCollectionRules**](GarbageCollectionRules.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** | gc rule list | - | -**401** | Unauthorized | - | -**404** | Resource Not Found | - | -**0** | Internal Server Error | - | - # **prepareGarbageCollectionCommits** > GarbageCollectionPrepareResponse prepareGarbageCollectionCommits(repository) @@ -377,95 +193,3 @@ Name | Type | Description | Notes **404** | Resource Not Found | - | **0** | Internal Server Error | - | - -# **setGarbageCollectionRules** -> setGarbageCollectionRules(repository, garbageCollectionRules) - - - -### 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.RetentionApi; - -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"); - - RetentionApi apiInstance = new RetentionApi(defaultClient); - String repository = "repository_example"; // String | - GarbageCollectionRules garbageCollectionRules = new GarbageCollectionRules(); // GarbageCollectionRules | - try { - apiInstance.setGarbageCollectionRules(repository, garbageCollectionRules); - } catch (ApiException e) { - System.err.println("Exception when calling RetentionApi#setGarbageCollectionRules"); - 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**| | - **garbageCollectionRules** | [**GarbageCollectionRules**](GarbageCollectionRules.md)| | - -### Return type - -null (empty response body) - -### 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 | -|-------------|-------------|------------------| -**204** | set garbage collection rules successfully | - | -**401** | Unauthorized | - | -**404** | Resource Not Found | - | -**0** | Internal Server Error | - | - diff --git a/clients/java/src/main/java/io/lakefs/clients/api/ConfigApi.java b/clients/java/src/main/java/io/lakefs/clients/api/ConfigApi.java index a764d8489d5..57d11975d60 100644 --- a/clients/java/src/main/java/io/lakefs/clients/api/ConfigApi.java +++ b/clients/java/src/main/java/io/lakefs/clients/api/ConfigApi.java @@ -29,7 +29,6 @@ import io.lakefs.clients.api.model.Config; import io.lakefs.clients.api.model.Error; -import io.lakefs.clients.api.model.GarbageCollectionConfig; import java.lang.reflect.Type; import java.util.ArrayList; @@ -162,110 +161,4 @@ public okhttp3.Call getConfigAsync(final ApiCallback _callback) throws A localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } - /** - * Build call for getGarbageCollectionConfig - * @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 lakeFS garbage collection config -
401 Unauthorized -
- */ - public okhttp3.Call getGarbageCollectionConfigCall(final ApiCallback _callback) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/config/garbage-collection"; - - 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, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); - } - - @SuppressWarnings("rawtypes") - private okhttp3.Call getGarbageCollectionConfigValidateBeforeCall(final ApiCallback _callback) throws ApiException { - - - okhttp3.Call localVarCall = getGarbageCollectionConfigCall(_callback); - return localVarCall; - - } - - /** - * - * get information of gc settings - * @return GarbageCollectionConfig - * @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 lakeFS garbage collection config -
401 Unauthorized -
- */ - public GarbageCollectionConfig getGarbageCollectionConfig() throws ApiException { - ApiResponse localVarResp = getGarbageCollectionConfigWithHttpInfo(); - return localVarResp.getData(); - } - - /** - * - * get information of gc settings - * @return ApiResponse<GarbageCollectionConfig> - * @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 lakeFS garbage collection config -
401 Unauthorized -
- */ - public ApiResponse getGarbageCollectionConfigWithHttpInfo() throws ApiException { - okhttp3.Call localVarCall = getGarbageCollectionConfigValidateBeforeCall(null); - Type localVarReturnType = new TypeToken(){}.getType(); - return localVarApiClient.execute(localVarCall, localVarReturnType); - } - - /** - * (asynchronously) - * get information of gc settings - * @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 lakeFS garbage collection config -
401 Unauthorized -
- */ - public okhttp3.Call getGarbageCollectionConfigAsync(final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = getGarbageCollectionConfigValidateBeforeCall(_callback); - Type localVarReturnType = new TypeToken(){}.getType(); - localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); - return localVarCall; - } } diff --git a/clients/java/src/main/java/io/lakefs/clients/api/InternalApi.java b/clients/java/src/main/java/io/lakefs/clients/api/InternalApi.java index 9a958b103f4..fe25719f2cf 100644 --- a/clients/java/src/main/java/io/lakefs/clients/api/InternalApi.java +++ b/clients/java/src/main/java/io/lakefs/clients/api/InternalApi.java @@ -28,9 +28,13 @@ import io.lakefs.clients.api.model.AuthCapabilities; +import io.lakefs.clients.api.model.BranchProtectionRule; import io.lakefs.clients.api.model.CommPrefsInput; import io.lakefs.clients.api.model.CredentialsWithSecret; import io.lakefs.clients.api.model.Error; +import io.lakefs.clients.api.model.GarbageCollectionConfig; +import io.lakefs.clients.api.model.GarbageCollectionRules; +import io.lakefs.clients.api.model.InlineObject1; import io.lakefs.clients.api.model.RefsDump; import io.lakefs.clients.api.model.Setup; import io.lakefs.clients.api.model.SetupState; @@ -564,6 +568,112 @@ public okhttp3.Call getAuthCapabilitiesAsync(final ApiCallback localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for getGarbageCollectionConfig + * @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 lakeFS garbage collection config -
401 Unauthorized -
+ */ + public okhttp3.Call getGarbageCollectionConfigCall(final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/config/garbage-collection"; + + 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, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getGarbageCollectionConfigValidateBeforeCall(final ApiCallback _callback) throws ApiException { + + + okhttp3.Call localVarCall = getGarbageCollectionConfigCall(_callback); + return localVarCall; + + } + + /** + * + * get information of gc settings + * @return GarbageCollectionConfig + * @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 lakeFS garbage collection config -
401 Unauthorized -
+ */ + public GarbageCollectionConfig getGarbageCollectionConfig() throws ApiException { + ApiResponse localVarResp = getGarbageCollectionConfigWithHttpInfo(); + return localVarResp.getData(); + } + + /** + * + * get information of gc settings + * @return ApiResponse<GarbageCollectionConfig> + * @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 lakeFS garbage collection config -
401 Unauthorized -
+ */ + public ApiResponse getGarbageCollectionConfigWithHttpInfo() throws ApiException { + okhttp3.Call localVarCall = getGarbageCollectionConfigValidateBeforeCall(null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * (asynchronously) + * get information of gc settings + * @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 lakeFS garbage collection config -
401 Unauthorized -
+ */ + public okhttp3.Call getGarbageCollectionConfigAsync(final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getGarbageCollectionConfigValidateBeforeCall(_callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } /** * Build call for getLakeFSVersion * @param _callback Callback for upload/download progress @@ -900,6 +1010,815 @@ public okhttp3.Call getStorageConfigAsync(final ApiCallback _call localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for internalCreateBranchProtectionRule + * @param repository (required) + * @param branchProtectionRule (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
204 branch protection rule created successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call internalCreateBranchProtectionRuleCall(String repository, BranchProtectionRule branchProtectionRule, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = branchProtectionRule; + + // create path and map variables + String localVarPath = "/repositories/{repository}/branch_protection" + .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); + } + + @Deprecated + @SuppressWarnings("rawtypes") + private okhttp3.Call internalCreateBranchProtectionRuleValidateBeforeCall(String repository, BranchProtectionRule branchProtectionRule, 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 internalCreateBranchProtectionRule(Async)"); + } + + // verify the required parameter 'branchProtectionRule' is set + if (branchProtectionRule == null) { + throw new ApiException("Missing the required parameter 'branchProtectionRule' when calling internalCreateBranchProtectionRule(Async)"); + } + + + okhttp3.Call localVarCall = internalCreateBranchProtectionRuleCall(repository, branchProtectionRule, _callback); + return localVarCall; + + } + + /** + * + * + * @param repository (required) + * @param branchProtectionRule (required) + * @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
204 branch protection rule created successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public void internalCreateBranchProtectionRule(String repository, BranchProtectionRule branchProtectionRule) throws ApiException { + internalCreateBranchProtectionRuleWithHttpInfo(repository, branchProtectionRule); + } + + /** + * + * + * @param repository (required) + * @param branchProtectionRule (required) + * @return ApiResponse<Void> + * @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
204 branch protection rule created successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public ApiResponse internalCreateBranchProtectionRuleWithHttpInfo(String repository, BranchProtectionRule branchProtectionRule) throws ApiException { + okhttp3.Call localVarCall = internalCreateBranchProtectionRuleValidateBeforeCall(repository, branchProtectionRule, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * (asynchronously) + * + * @param repository (required) + * @param branchProtectionRule (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
204 branch protection rule created successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call internalCreateBranchProtectionRuleAsync(String repository, BranchProtectionRule branchProtectionRule, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = internalCreateBranchProtectionRuleValidateBeforeCall(repository, branchProtectionRule, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for internalDeleteBranchProtectionRule + * @param repository (required) + * @param inlineObject1 (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
204 branch protection rule deleted successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call internalDeleteBranchProtectionRuleCall(String repository, InlineObject1 inlineObject1, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = inlineObject1; + + // create path and map variables + String localVarPath = "/repositories/{repository}/branch_protection" + .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, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @Deprecated + @SuppressWarnings("rawtypes") + private okhttp3.Call internalDeleteBranchProtectionRuleValidateBeforeCall(String repository, InlineObject1 inlineObject1, 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 internalDeleteBranchProtectionRule(Async)"); + } + + // verify the required parameter 'inlineObject1' is set + if (inlineObject1 == null) { + throw new ApiException("Missing the required parameter 'inlineObject1' when calling internalDeleteBranchProtectionRule(Async)"); + } + + + okhttp3.Call localVarCall = internalDeleteBranchProtectionRuleCall(repository, inlineObject1, _callback); + return localVarCall; + + } + + /** + * + * + * @param repository (required) + * @param inlineObject1 (required) + * @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
204 branch protection rule deleted successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public void internalDeleteBranchProtectionRule(String repository, InlineObject1 inlineObject1) throws ApiException { + internalDeleteBranchProtectionRuleWithHttpInfo(repository, inlineObject1); + } + + /** + * + * + * @param repository (required) + * @param inlineObject1 (required) + * @return ApiResponse<Void> + * @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
204 branch protection rule deleted successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public ApiResponse internalDeleteBranchProtectionRuleWithHttpInfo(String repository, InlineObject1 inlineObject1) throws ApiException { + okhttp3.Call localVarCall = internalDeleteBranchProtectionRuleValidateBeforeCall(repository, inlineObject1, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * (asynchronously) + * + * @param repository (required) + * @param inlineObject1 (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
204 branch protection rule deleted successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call internalDeleteBranchProtectionRuleAsync(String repository, InlineObject1 inlineObject1, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = internalDeleteBranchProtectionRuleValidateBeforeCall(repository, inlineObject1, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for internalDeleteGarbageCollectionRules + * @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
204 deleted garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call internalDeleteGarbageCollectionRulesCall(String repository, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/repositories/{repository}/gc/rules" + .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, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @Deprecated + @SuppressWarnings("rawtypes") + private okhttp3.Call internalDeleteGarbageCollectionRulesValidateBeforeCall(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 internalDeleteGarbageCollectionRules(Async)"); + } + + + okhttp3.Call localVarCall = internalDeleteGarbageCollectionRulesCall(repository, _callback); + return localVarCall; + + } + + /** + * + * + * @param repository (required) + * @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
204 deleted garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public void internalDeleteGarbageCollectionRules(String repository) throws ApiException { + internalDeleteGarbageCollectionRulesWithHttpInfo(repository); + } + + /** + * + * + * @param repository (required) + * @return ApiResponse<Void> + * @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
204 deleted garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public ApiResponse internalDeleteGarbageCollectionRulesWithHttpInfo(String repository) throws ApiException { + okhttp3.Call localVarCall = internalDeleteGarbageCollectionRulesValidateBeforeCall(repository, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * (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
204 deleted garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call internalDeleteGarbageCollectionRulesAsync(String repository, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = internalDeleteGarbageCollectionRulesValidateBeforeCall(repository, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for internalGetBranchProtectionRules + * @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
200 branch protection rules -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call internalGetBranchProtectionRulesCall(String repository, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/repositories/{repository}/branch_protection" + .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, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @Deprecated + @SuppressWarnings("rawtypes") + private okhttp3.Call internalGetBranchProtectionRulesValidateBeforeCall(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 internalGetBranchProtectionRules(Async)"); + } + + + okhttp3.Call localVarCall = internalGetBranchProtectionRulesCall(repository, _callback); + return localVarCall; + + } + + /** + * get branch protection rules + * + * @param repository (required) + * @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 branch protection rules -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public List internalGetBranchProtectionRules(String repository) throws ApiException { + ApiResponse> localVarResp = internalGetBranchProtectionRulesWithHttpInfo(repository); + return localVarResp.getData(); + } + + /** + * get branch protection rules + * + * @param repository (required) + * @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 branch protection rules -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public ApiResponse> internalGetBranchProtectionRulesWithHttpInfo(String repository) throws ApiException { + okhttp3.Call localVarCall = internalGetBranchProtectionRulesValidateBeforeCall(repository, null); + Type localVarReturnType = new TypeToken>(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * get branch protection rules (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
200 branch protection rules -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call internalGetBranchProtectionRulesAsync(String repository, final ApiCallback> _callback) throws ApiException { + + okhttp3.Call localVarCall = internalGetBranchProtectionRulesValidateBeforeCall(repository, _callback); + Type localVarReturnType = new TypeToken>(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for internalGetGarbageCollectionRules + * @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
200 gc rule list -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call internalGetGarbageCollectionRulesCall(String repository, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/repositories/{repository}/gc/rules" + .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, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @Deprecated + @SuppressWarnings("rawtypes") + private okhttp3.Call internalGetGarbageCollectionRulesValidateBeforeCall(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 internalGetGarbageCollectionRules(Async)"); + } + + + okhttp3.Call localVarCall = internalGetGarbageCollectionRulesCall(repository, _callback); + return localVarCall; + + } + + /** + * + * + * @param repository (required) + * @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 gc rule list -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public GarbageCollectionRules internalGetGarbageCollectionRules(String repository) throws ApiException { + ApiResponse localVarResp = internalGetGarbageCollectionRulesWithHttpInfo(repository); + return localVarResp.getData(); + } + + /** + * + * + * @param repository (required) + * @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 gc rule list -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public ApiResponse internalGetGarbageCollectionRulesWithHttpInfo(String repository) throws ApiException { + okhttp3.Call localVarCall = internalGetGarbageCollectionRulesValidateBeforeCall(repository, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * (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
200 gc rule list -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call internalGetGarbageCollectionRulesAsync(String repository, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = internalGetGarbageCollectionRulesValidateBeforeCall(repository, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for internalSetGarbageCollectionRules + * @param repository (required) + * @param garbageCollectionRules (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
204 set garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call internalSetGarbageCollectionRulesCall(String repository, GarbageCollectionRules garbageCollectionRules, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = garbageCollectionRules; + + // create path and map variables + String localVarPath = "/repositories/{repository}/gc/rules" + .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); + } + + @Deprecated + @SuppressWarnings("rawtypes") + private okhttp3.Call internalSetGarbageCollectionRulesValidateBeforeCall(String repository, GarbageCollectionRules garbageCollectionRules, 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 internalSetGarbageCollectionRules(Async)"); + } + + // verify the required parameter 'garbageCollectionRules' is set + if (garbageCollectionRules == null) { + throw new ApiException("Missing the required parameter 'garbageCollectionRules' when calling internalSetGarbageCollectionRules(Async)"); + } + + + okhttp3.Call localVarCall = internalSetGarbageCollectionRulesCall(repository, garbageCollectionRules, _callback); + return localVarCall; + + } + + /** + * + * + * @param repository (required) + * @param garbageCollectionRules (required) + * @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
204 set garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public void internalSetGarbageCollectionRules(String repository, GarbageCollectionRules garbageCollectionRules) throws ApiException { + internalSetGarbageCollectionRulesWithHttpInfo(repository, garbageCollectionRules); + } + + /** + * + * + * @param repository (required) + * @param garbageCollectionRules (required) + * @return ApiResponse<Void> + * @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
204 set garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public ApiResponse internalSetGarbageCollectionRulesWithHttpInfo(String repository, GarbageCollectionRules garbageCollectionRules) throws ApiException { + okhttp3.Call localVarCall = internalSetGarbageCollectionRulesValidateBeforeCall(repository, garbageCollectionRules, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * (asynchronously) + * + * @param repository (required) + * @param garbageCollectionRules (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
204 set garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ * @deprecated + */ + @Deprecated + public okhttp3.Call internalSetGarbageCollectionRulesAsync(String repository, GarbageCollectionRules garbageCollectionRules, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = internalSetGarbageCollectionRulesValidateBeforeCall(repository, garbageCollectionRules, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } /** * Build call for postStatsEvents * @param statsEventsList (required) diff --git a/clients/java/src/main/java/io/lakefs/clients/api/RepositoriesApi.java b/clients/java/src/main/java/io/lakefs/clients/api/RepositoriesApi.java index 8e96ed2703b..ee6b2a7d999 100644 --- a/clients/java/src/main/java/io/lakefs/clients/api/RepositoriesApi.java +++ b/clients/java/src/main/java/io/lakefs/clients/api/RepositoriesApi.java @@ -29,7 +29,7 @@ import io.lakefs.clients.api.model.BranchProtectionRule; import io.lakefs.clients.api.model.Error; -import io.lakefs.clients.api.model.InlineObject1; +import io.lakefs.clients.api.model.GarbageCollectionRules; import io.lakefs.clients.api.model.Repository; import io.lakefs.clients.api.model.RepositoryCreation; import io.lakefs.clients.api.model.RepositoryList; @@ -59,135 +59,6 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } - /** - * Build call for createBranchProtectionRule - * @param repository (required) - * @param branchProtectionRule (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
204 branch protection rule created successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- */ - public okhttp3.Call createBranchProtectionRuleCall(String repository, BranchProtectionRule branchProtectionRule, final ApiCallback _callback) throws ApiException { - Object localVarPostBody = branchProtectionRule; - - // create path and map variables - String localVarPath = "/repositories/{repository}/branch_protection" - .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 createBranchProtectionRuleValidateBeforeCall(String repository, BranchProtectionRule branchProtectionRule, 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 createBranchProtectionRule(Async)"); - } - - // verify the required parameter 'branchProtectionRule' is set - if (branchProtectionRule == null) { - throw new ApiException("Missing the required parameter 'branchProtectionRule' when calling createBranchProtectionRule(Async)"); - } - - - okhttp3.Call localVarCall = createBranchProtectionRuleCall(repository, branchProtectionRule, _callback); - return localVarCall; - - } - - /** - * - * - * @param repository (required) - * @param branchProtectionRule (required) - * @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
204 branch protection rule created successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- */ - public void createBranchProtectionRule(String repository, BranchProtectionRule branchProtectionRule) throws ApiException { - createBranchProtectionRuleWithHttpInfo(repository, branchProtectionRule); - } - - /** - * - * - * @param repository (required) - * @param branchProtectionRule (required) - * @return ApiResponse<Void> - * @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
204 branch protection rule created successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- */ - public ApiResponse createBranchProtectionRuleWithHttpInfo(String repository, BranchProtectionRule branchProtectionRule) throws ApiException { - okhttp3.Call localVarCall = createBranchProtectionRuleValidateBeforeCall(repository, branchProtectionRule, null); - return localVarApiClient.execute(localVarCall); - } - - /** - * (asynchronously) - * - * @param repository (required) - * @param branchProtectionRule (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
204 branch protection rule created successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- */ - public okhttp3.Call createBranchProtectionRuleAsync(String repository, BranchProtectionRule branchProtectionRule, final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = createBranchProtectionRuleValidateBeforeCall(repository, branchProtectionRule, _callback); - localVarApiClient.executeAsync(localVarCall, _callback); - return localVarCall; - } /** * Build call for createRepository * @param repositoryCreation (required) @@ -324,26 +195,25 @@ public okhttp3.Call createRepositoryAsync(RepositoryCreation repositoryCreation, return localVarCall; } /** - * Build call for deleteBranchProtectionRule + * Build call for deleteGCRules * @param repository (required) - * @param inlineObject1 (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
204 branch protection rule deleted successfully -
204 deleted garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
*/ - public okhttp3.Call deleteBranchProtectionRuleCall(String repository, InlineObject1 inlineObject1, final ApiCallback _callback) throws ApiException { - Object localVarPostBody = inlineObject1; + public okhttp3.Call deleteGCRulesCall(String repository, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; // create path and map variables - String localVarPath = "/repositories/{repository}/branch_protection" + String localVarPath = "/repositories/{repository}/settings/gc_rules" .replaceAll("\\{" + "repository" + "\\}", localVarApiClient.escapeString(repository.toString())); List localVarQueryParams = new ArrayList(); @@ -361,7 +231,7 @@ public okhttp3.Call deleteBranchProtectionRuleCall(String repository, InlineObje } final String[] localVarContentTypes = { - "application/json" + }; final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); localVarHeaderParams.put("Content-Type", localVarContentType); @@ -371,20 +241,15 @@ public okhttp3.Call deleteBranchProtectionRuleCall(String repository, InlineObje } @SuppressWarnings("rawtypes") - private okhttp3.Call deleteBranchProtectionRuleValidateBeforeCall(String repository, InlineObject1 inlineObject1, final ApiCallback _callback) throws ApiException { + private okhttp3.Call deleteGCRulesValidateBeforeCall(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 deleteBranchProtectionRule(Async)"); - } - - // verify the required parameter 'inlineObject1' is set - if (inlineObject1 == null) { - throw new ApiException("Missing the required parameter 'inlineObject1' when calling deleteBranchProtectionRule(Async)"); + throw new ApiException("Missing the required parameter 'repository' when calling deleteGCRules(Async)"); } - okhttp3.Call localVarCall = deleteBranchProtectionRuleCall(repository, inlineObject1, _callback); + okhttp3.Call localVarCall = deleteGCRulesCall(repository, _callback); return localVarCall; } @@ -393,39 +258,37 @@ private okhttp3.Call deleteBranchProtectionRuleValidateBeforeCall(String reposit * * * @param repository (required) - * @param inlineObject1 (required) * @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
204 branch protection rule deleted successfully -
204 deleted garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
*/ - public void deleteBranchProtectionRule(String repository, InlineObject1 inlineObject1) throws ApiException { - deleteBranchProtectionRuleWithHttpInfo(repository, inlineObject1); + public void deleteGCRules(String repository) throws ApiException { + deleteGCRulesWithHttpInfo(repository); } /** * * * @param repository (required) - * @param inlineObject1 (required) * @return ApiResponse<Void> * @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
204 branch protection rule deleted successfully -
204 deleted garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
*/ - public ApiResponse deleteBranchProtectionRuleWithHttpInfo(String repository, InlineObject1 inlineObject1) throws ApiException { - okhttp3.Call localVarCall = deleteBranchProtectionRuleValidateBeforeCall(repository, inlineObject1, null); + public ApiResponse deleteGCRulesWithHttpInfo(String repository) throws ApiException { + okhttp3.Call localVarCall = deleteGCRulesValidateBeforeCall(repository, null); return localVarApiClient.execute(localVarCall); } @@ -433,22 +296,21 @@ public ApiResponse deleteBranchProtectionRuleWithHttpInfo(String repositor * (asynchronously) * * @param repository (required) - * @param inlineObject1 (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
204 branch protection rule deleted successfully -
204 deleted garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
*/ - public okhttp3.Call deleteBranchProtectionRuleAsync(String repository, InlineObject1 inlineObject1, final ApiCallback _callback) throws ApiException { + public okhttp3.Call deleteGCRulesAsync(String repository, final ApiCallback _callback) throws ApiException { - okhttp3.Call localVarCall = deleteBranchProtectionRuleValidateBeforeCall(repository, inlineObject1, _callback); + okhttp3.Call localVarCall = deleteGCRulesValidateBeforeCall(repository, _callback); localVarApiClient.executeAsync(localVarCall, _callback); return localVarCall; } @@ -581,7 +443,7 @@ public okhttp3.Call deleteRepositoryAsync(String repository, final ApiCallback Status Code Description Response Headers - 200 branch protection rules - + 200 branch protection rules * ETag -
401 Unauthorized - 404 Resource Not Found - 0 Internal Server Error - @@ -591,7 +453,7 @@ public okhttp3.Call getBranchProtectionRulesCall(String repository, final ApiCal Object localVarPostBody = null; // create path and map variables - String localVarPath = "/repositories/{repository}/branch_protection" + String localVarPath = "/repositories/{repository}/settings/branch_protection" .replaceAll("\\{" + "repository" + "\\}", localVarApiClient.escapeString(repository.toString())); List localVarQueryParams = new ArrayList(); @@ -641,7 +503,7 @@ private okhttp3.Call getBranchProtectionRulesValidateBeforeCall(String repositor * @http.response.details - + @@ -661,7 +523,7 @@ public List getBranchProtectionRules(String repository) th * @http.response.details
Status Code Description Response Headers
200 branch protection rules -
200 branch protection rules * ETag -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- + @@ -683,7 +545,7 @@ public ApiResponse> getBranchProtectionRulesWithHttpI * @http.response.details
Status Code Description Response Headers
200 branch protection rules -
200 branch protection rules * ETag -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- + @@ -696,6 +558,130 @@ public okhttp3.Call getBranchProtectionRulesAsync(String repository, final ApiCa localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for getGCRules + * @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
200 branch protection rules -
200 branch protection rules * ETag -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ + + + + +
Status Code Description Response Headers
200 repository GC rules -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public okhttp3.Call getGCRulesCall(String repository, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/repositories/{repository}/settings/gc_rules" + .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, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + 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 getGCRules(Async)"); + } + + + okhttp3.Call localVarCall = getGCRulesCall(repository, _callback); + return localVarCall; + + } + + /** + * get repository GC rules + * + * @param repository (required) + * @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 GC rules -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public GarbageCollectionRules getGCRules(String repository) throws ApiException { + ApiResponse localVarResp = getGCRulesWithHttpInfo(repository); + return localVarResp.getData(); + } + + /** + * get repository GC rules + * + * @param repository (required) + * @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 GC rules -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public ApiResponse getGCRulesWithHttpInfo(String repository) throws ApiException { + okhttp3.Call localVarCall = getGCRulesValidateBeforeCall(repository, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * get repository GC rules (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
200 repository GC rules -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public okhttp3.Call getGCRulesAsync(String repository, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getGCRulesValidateBeforeCall(repository, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } /** * Build call for getRepository * @param repository (required) @@ -1078,4 +1064,278 @@ public okhttp3.Call listRepositoriesAsync(String prefix, String after, Integer a localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } + /** + * Build call for setBranchProtectionRules + * @param repository (required) + * @param branchProtectionRule (required) + * @param ifMatch if provided, the branch protection rules will be updated only if the current ETag match the provided value (optional) + * @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
204 branch protection rule created successfully -
400 Bad Request -
401 Unauthorized -
404 Resource Not Found -
412 Precondition Failed -
0 Internal Server Error -
+ */ + public okhttp3.Call setBranchProtectionRulesCall(String repository, List branchProtectionRule, String ifMatch, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = branchProtectionRule; + + // create path and map variables + String localVarPath = "/repositories/{repository}/settings/branch_protection" + .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 (ifMatch != null) { + localVarHeaderParams.put("If-Match", localVarApiClient.parameterToString(ifMatch)); + } + + 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, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call setBranchProtectionRulesValidateBeforeCall(String repository, List branchProtectionRule, String ifMatch, 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 setBranchProtectionRules(Async)"); + } + + // verify the required parameter 'branchProtectionRule' is set + if (branchProtectionRule == null) { + throw new ApiException("Missing the required parameter 'branchProtectionRule' when calling setBranchProtectionRules(Async)"); + } + + + okhttp3.Call localVarCall = setBranchProtectionRulesCall(repository, branchProtectionRule, ifMatch, _callback); + return localVarCall; + + } + + /** + * + * + * @param repository (required) + * @param branchProtectionRule (required) + * @param ifMatch if provided, the branch protection rules will be updated only if the current ETag match the provided value (optional) + * @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
204 branch protection rule created successfully -
400 Bad Request -
401 Unauthorized -
404 Resource Not Found -
412 Precondition Failed -
0 Internal Server Error -
+ */ + public void setBranchProtectionRules(String repository, List branchProtectionRule, String ifMatch) throws ApiException { + setBranchProtectionRulesWithHttpInfo(repository, branchProtectionRule, ifMatch); + } + + /** + * + * + * @param repository (required) + * @param branchProtectionRule (required) + * @param ifMatch if provided, the branch protection rules will be updated only if the current ETag match the provided value (optional) + * @return ApiResponse<Void> + * @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
204 branch protection rule created successfully -
400 Bad Request -
401 Unauthorized -
404 Resource Not Found -
412 Precondition Failed -
0 Internal Server Error -
+ */ + public ApiResponse setBranchProtectionRulesWithHttpInfo(String repository, List branchProtectionRule, String ifMatch) throws ApiException { + okhttp3.Call localVarCall = setBranchProtectionRulesValidateBeforeCall(repository, branchProtectionRule, ifMatch, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * (asynchronously) + * + * @param repository (required) + * @param branchProtectionRule (required) + * @param ifMatch if provided, the branch protection rules will be updated only if the current ETag match the provided value (optional) + * @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
204 branch protection rule created successfully -
400 Bad Request -
401 Unauthorized -
404 Resource Not Found -
412 Precondition Failed -
0 Internal Server Error -
+ */ + public okhttp3.Call setBranchProtectionRulesAsync(String repository, List branchProtectionRule, String ifMatch, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = setBranchProtectionRulesValidateBeforeCall(repository, branchProtectionRule, ifMatch, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for setGCRules + * @param repository (required) + * @param garbageCollectionRules (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
204 set garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public okhttp3.Call setGCRulesCall(String repository, GarbageCollectionRules garbageCollectionRules, final ApiCallback _callback) throws ApiException { + Object localVarPostBody = garbageCollectionRules; + + // create path and map variables + String localVarPath = "/repositories/{repository}/settings/gc_rules" + .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, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call setGCRulesValidateBeforeCall(String repository, GarbageCollectionRules garbageCollectionRules, 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 setGCRules(Async)"); + } + + // verify the required parameter 'garbageCollectionRules' is set + if (garbageCollectionRules == null) { + throw new ApiException("Missing the required parameter 'garbageCollectionRules' when calling setGCRules(Async)"); + } + + + okhttp3.Call localVarCall = setGCRulesCall(repository, garbageCollectionRules, _callback); + return localVarCall; + + } + + /** + * + * + * @param repository (required) + * @param garbageCollectionRules (required) + * @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
204 set garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public void setGCRules(String repository, GarbageCollectionRules garbageCollectionRules) throws ApiException { + setGCRulesWithHttpInfo(repository, garbageCollectionRules); + } + + /** + * + * + * @param repository (required) + * @param garbageCollectionRules (required) + * @return ApiResponse<Void> + * @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
204 set garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public ApiResponse setGCRulesWithHttpInfo(String repository, GarbageCollectionRules garbageCollectionRules) throws ApiException { + okhttp3.Call localVarCall = setGCRulesValidateBeforeCall(repository, garbageCollectionRules, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * (asynchronously) + * + * @param repository (required) + * @param garbageCollectionRules (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
204 set garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
+ */ + public okhttp3.Call setGCRulesAsync(String repository, GarbageCollectionRules garbageCollectionRules, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = setGCRulesValidateBeforeCall(repository, garbageCollectionRules, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } } diff --git a/clients/java/src/main/java/io/lakefs/clients/api/RetentionApi.java b/clients/java/src/main/java/io/lakefs/clients/api/RetentionApi.java index ed20d0be152..3eaa71e96ee 100644 --- a/clients/java/src/main/java/io/lakefs/clients/api/RetentionApi.java +++ b/clients/java/src/main/java/io/lakefs/clients/api/RetentionApi.java @@ -29,7 +29,6 @@ import io.lakefs.clients.api.model.Error; import io.lakefs.clients.api.model.GarbageCollectionPrepareResponse; -import io.lakefs.clients.api.model.GarbageCollectionRules; import io.lakefs.clients.api.model.PrepareGCUncommittedRequest; import io.lakefs.clients.api.model.PrepareGCUncommittedResponse; @@ -58,250 +57,6 @@ public void setApiClient(ApiClient apiClient) { this.localVarApiClient = apiClient; } - /** - * Build call for deleteGarbageCollectionRules - * @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
204 deleted garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- */ - public okhttp3.Call deleteGarbageCollectionRulesCall(String repository, final ApiCallback _callback) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/repositories/{repository}/gc/rules" - .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, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); - } - - @SuppressWarnings("rawtypes") - private okhttp3.Call deleteGarbageCollectionRulesValidateBeforeCall(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 deleteGarbageCollectionRules(Async)"); - } - - - okhttp3.Call localVarCall = deleteGarbageCollectionRulesCall(repository, _callback); - return localVarCall; - - } - - /** - * - * - * @param repository (required) - * @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
204 deleted garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- */ - public void deleteGarbageCollectionRules(String repository) throws ApiException { - deleteGarbageCollectionRulesWithHttpInfo(repository); - } - - /** - * - * - * @param repository (required) - * @return ApiResponse<Void> - * @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
204 deleted garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- */ - public ApiResponse deleteGarbageCollectionRulesWithHttpInfo(String repository) throws ApiException { - okhttp3.Call localVarCall = deleteGarbageCollectionRulesValidateBeforeCall(repository, null); - return localVarApiClient.execute(localVarCall); - } - - /** - * (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
204 deleted garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- */ - public okhttp3.Call deleteGarbageCollectionRulesAsync(String repository, final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = deleteGarbageCollectionRulesValidateBeforeCall(repository, _callback); - localVarApiClient.executeAsync(localVarCall, _callback); - return localVarCall; - } - /** - * Build call for getGarbageCollectionRules - * @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
200 gc rule list -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- */ - public okhttp3.Call getGarbageCollectionRulesCall(String repository, final ApiCallback _callback) throws ApiException { - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/repositories/{repository}/gc/rules" - .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, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); - } - - @SuppressWarnings("rawtypes") - private okhttp3.Call getGarbageCollectionRulesValidateBeforeCall(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 getGarbageCollectionRules(Async)"); - } - - - okhttp3.Call localVarCall = getGarbageCollectionRulesCall(repository, _callback); - return localVarCall; - - } - - /** - * - * - * @param repository (required) - * @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 gc rule list -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- */ - public GarbageCollectionRules getGarbageCollectionRules(String repository) throws ApiException { - ApiResponse localVarResp = getGarbageCollectionRulesWithHttpInfo(repository); - return localVarResp.getData(); - } - - /** - * - * - * @param repository (required) - * @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 gc rule list -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- */ - public ApiResponse getGarbageCollectionRulesWithHttpInfo(String repository) throws ApiException { - okhttp3.Call localVarCall = getGarbageCollectionRulesValidateBeforeCall(repository, null); - Type localVarReturnType = new TypeToken(){}.getType(); - return localVarApiClient.execute(localVarCall, localVarReturnType); - } - - /** - * (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
200 gc rule list -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- */ - public okhttp3.Call getGarbageCollectionRulesAsync(String repository, final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = getGarbageCollectionRulesValidateBeforeCall(repository, _callback); - Type localVarReturnType = new TypeToken(){}.getType(); - localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); - return localVarCall; - } /** * Build call for prepareGarbageCollectionCommits * @param repository (required) @@ -558,133 +313,4 @@ public okhttp3.Call prepareGarbageCollectionUncommittedAsync(String repository, localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); return localVarCall; } - /** - * Build call for setGarbageCollectionRules - * @param repository (required) - * @param garbageCollectionRules (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
204 set garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- */ - public okhttp3.Call setGarbageCollectionRulesCall(String repository, GarbageCollectionRules garbageCollectionRules, final ApiCallback _callback) throws ApiException { - Object localVarPostBody = garbageCollectionRules; - - // create path and map variables - String localVarPath = "/repositories/{repository}/gc/rules" - .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 setGarbageCollectionRulesValidateBeforeCall(String repository, GarbageCollectionRules garbageCollectionRules, 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 setGarbageCollectionRules(Async)"); - } - - // verify the required parameter 'garbageCollectionRules' is set - if (garbageCollectionRules == null) { - throw new ApiException("Missing the required parameter 'garbageCollectionRules' when calling setGarbageCollectionRules(Async)"); - } - - - okhttp3.Call localVarCall = setGarbageCollectionRulesCall(repository, garbageCollectionRules, _callback); - return localVarCall; - - } - - /** - * - * - * @param repository (required) - * @param garbageCollectionRules (required) - * @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
204 set garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- */ - public void setGarbageCollectionRules(String repository, GarbageCollectionRules garbageCollectionRules) throws ApiException { - setGarbageCollectionRulesWithHttpInfo(repository, garbageCollectionRules); - } - - /** - * - * - * @param repository (required) - * @param garbageCollectionRules (required) - * @return ApiResponse<Void> - * @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
204 set garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- */ - public ApiResponse setGarbageCollectionRulesWithHttpInfo(String repository, GarbageCollectionRules garbageCollectionRules) throws ApiException { - okhttp3.Call localVarCall = setGarbageCollectionRulesValidateBeforeCall(repository, garbageCollectionRules, null); - return localVarApiClient.execute(localVarCall); - } - - /** - * (asynchronously) - * - * @param repository (required) - * @param garbageCollectionRules (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
204 set garbage collection rules successfully -
401 Unauthorized -
404 Resource Not Found -
0 Internal Server Error -
- */ - public okhttp3.Call setGarbageCollectionRulesAsync(String repository, GarbageCollectionRules garbageCollectionRules, final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = setGarbageCollectionRulesValidateBeforeCall(repository, garbageCollectionRules, _callback); - localVarApiClient.executeAsync(localVarCall, _callback); - return localVarCall; - } } diff --git a/clients/java/src/test/java/io/lakefs/clients/api/ConfigApiTest.java b/clients/java/src/test/java/io/lakefs/clients/api/ConfigApiTest.java index 1b48f59cceb..d542b89f76f 100644 --- a/clients/java/src/test/java/io/lakefs/clients/api/ConfigApiTest.java +++ b/clients/java/src/test/java/io/lakefs/clients/api/ConfigApiTest.java @@ -16,7 +16,6 @@ import io.lakefs.clients.api.ApiException; import io.lakefs.clients.api.model.Config; import io.lakefs.clients.api.model.Error; -import io.lakefs.clients.api.model.GarbageCollectionConfig; import org.junit.Test; import org.junit.Ignore; @@ -48,18 +47,4 @@ public void getConfigTest() throws ApiException { // TODO: test validations } - /** - * - * - * get information of gc settings - * - * @throws ApiException - * if the Api call fails - */ - @Test - public void getGarbageCollectionConfigTest() throws ApiException { - GarbageCollectionConfig response = api.getGarbageCollectionConfig(); - // TODO: test validations - } - } diff --git a/clients/java/src/test/java/io/lakefs/clients/api/InternalApiTest.java b/clients/java/src/test/java/io/lakefs/clients/api/InternalApiTest.java index d37d5661c77..b7aa7afac81 100644 --- a/clients/java/src/test/java/io/lakefs/clients/api/InternalApiTest.java +++ b/clients/java/src/test/java/io/lakefs/clients/api/InternalApiTest.java @@ -15,9 +15,13 @@ import io.lakefs.clients.api.ApiException; import io.lakefs.clients.api.model.AuthCapabilities; +import io.lakefs.clients.api.model.BranchProtectionRule; import io.lakefs.clients.api.model.CommPrefsInput; import io.lakefs.clients.api.model.CredentialsWithSecret; import io.lakefs.clients.api.model.Error; +import io.lakefs.clients.api.model.GarbageCollectionConfig; +import io.lakefs.clients.api.model.GarbageCollectionRules; +import io.lakefs.clients.api.model.InlineObject1; import io.lakefs.clients.api.model.RefsDump; import io.lakefs.clients.api.model.Setup; import io.lakefs.clients.api.model.SetupState; @@ -103,6 +107,20 @@ public void getAuthCapabilitiesTest() throws ApiException { // TODO: test validations } + /** + * + * + * get information of gc settings + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getGarbageCollectionConfigTest() throws ApiException { + GarbageCollectionConfig response = api.getGarbageCollectionConfig(); + // TODO: test validations + } + /** * * @@ -145,6 +163,99 @@ public void getStorageConfigTest() throws ApiException { // TODO: test validations } + /** + * + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void internalCreateBranchProtectionRuleTest() throws ApiException { + String repository = null; + BranchProtectionRule branchProtectionRule = null; + api.internalCreateBranchProtectionRule(repository, branchProtectionRule); + // TODO: test validations + } + + /** + * + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void internalDeleteBranchProtectionRuleTest() throws ApiException { + String repository = null; + InlineObject1 inlineObject1 = null; + api.internalDeleteBranchProtectionRule(repository, inlineObject1); + // TODO: test validations + } + + /** + * + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void internalDeleteGarbageCollectionRulesTest() throws ApiException { + String repository = null; + api.internalDeleteGarbageCollectionRules(repository); + // TODO: test validations + } + + /** + * get branch protection rules + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void internalGetBranchProtectionRulesTest() throws ApiException { + String repository = null; + List response = api.internalGetBranchProtectionRules(repository); + // TODO: test validations + } + + /** + * + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void internalGetGarbageCollectionRulesTest() throws ApiException { + String repository = null; + GarbageCollectionRules response = api.internalGetGarbageCollectionRules(repository); + // TODO: test validations + } + + /** + * + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void internalSetGarbageCollectionRulesTest() throws ApiException { + String repository = null; + GarbageCollectionRules garbageCollectionRules = null; + api.internalSetGarbageCollectionRules(repository, garbageCollectionRules); + // TODO: test validations + } + /** * post stats events, this endpoint is meant for internal use only * diff --git a/clients/java/src/test/java/io/lakefs/clients/api/RepositoriesApiTest.java b/clients/java/src/test/java/io/lakefs/clients/api/RepositoriesApiTest.java index a80a69febbb..24852b35f0d 100644 --- a/clients/java/src/test/java/io/lakefs/clients/api/RepositoriesApiTest.java +++ b/clients/java/src/test/java/io/lakefs/clients/api/RepositoriesApiTest.java @@ -16,7 +16,7 @@ import io.lakefs.clients.api.ApiException; import io.lakefs.clients.api.model.BranchProtectionRule; import io.lakefs.clients.api.model.Error; -import io.lakefs.clients.api.model.InlineObject1; +import io.lakefs.clients.api.model.GarbageCollectionRules; import io.lakefs.clients.api.model.Repository; import io.lakefs.clients.api.model.RepositoryCreation; import io.lakefs.clients.api.model.RepositoryList; @@ -37,22 +37,6 @@ public class RepositoriesApiTest { private final RepositoriesApi api = new RepositoriesApi(); - /** - * - * - * - * - * @throws ApiException - * if the Api call fails - */ - @Test - public void createBranchProtectionRuleTest() throws ApiException { - String repository = null; - BranchProtectionRule branchProtectionRule = null; - api.createBranchProtectionRule(repository, branchProtectionRule); - // TODO: test validations - } - /** * create repository * @@ -78,10 +62,9 @@ public void createRepositoryTest() throws ApiException { * if the Api call fails */ @Test - public void deleteBranchProtectionRuleTest() throws ApiException { + public void deleteGCRulesTest() throws ApiException { String repository = null; - InlineObject1 inlineObject1 = null; - api.deleteBranchProtectionRule(repository, inlineObject1); + api.deleteGCRules(repository); // TODO: test validations } @@ -115,6 +98,21 @@ public void getBranchProtectionRulesTest() throws ApiException { // TODO: test validations } + /** + * get repository GC rules + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void getGCRulesTest() throws ApiException { + String repository = null; + GarbageCollectionRules response = api.getGCRules(repository); + // TODO: test validations + } + /** * get repository * @@ -162,4 +160,37 @@ public void listRepositoriesTest() throws ApiException { // TODO: test validations } + /** + * + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void setBranchProtectionRulesTest() throws ApiException { + String repository = null; + List branchProtectionRule = null; + String ifMatch = null; + api.setBranchProtectionRules(repository, branchProtectionRule, ifMatch); + // TODO: test validations + } + + /** + * + * + * + * + * @throws ApiException + * if the Api call fails + */ + @Test + public void setGCRulesTest() throws ApiException { + String repository = null; + GarbageCollectionRules garbageCollectionRules = null; + api.setGCRules(repository, garbageCollectionRules); + // TODO: test validations + } + } diff --git a/clients/java/src/test/java/io/lakefs/clients/api/RetentionApiTest.java b/clients/java/src/test/java/io/lakefs/clients/api/RetentionApiTest.java index 24ad27fd5d4..916aa38eee4 100644 --- a/clients/java/src/test/java/io/lakefs/clients/api/RetentionApiTest.java +++ b/clients/java/src/test/java/io/lakefs/clients/api/RetentionApiTest.java @@ -16,7 +16,6 @@ import io.lakefs.clients.api.ApiException; import io.lakefs.clients.api.model.Error; import io.lakefs.clients.api.model.GarbageCollectionPrepareResponse; -import io.lakefs.clients.api.model.GarbageCollectionRules; import io.lakefs.clients.api.model.PrepareGCUncommittedRequest; import io.lakefs.clients.api.model.PrepareGCUncommittedResponse; import org.junit.Test; @@ -36,36 +35,6 @@ public class RetentionApiTest { private final RetentionApi api = new RetentionApi(); - /** - * - * - * - * - * @throws ApiException - * if the Api call fails - */ - @Test - public void deleteGarbageCollectionRulesTest() throws ApiException { - String repository = null; - api.deleteGarbageCollectionRules(repository); - // TODO: test validations - } - - /** - * - * - * - * - * @throws ApiException - * if the Api call fails - */ - @Test - public void getGarbageCollectionRulesTest() throws ApiException { - String repository = null; - GarbageCollectionRules response = api.getGarbageCollectionRules(repository); - // TODO: test validations - } - /** * save lists of active commits for garbage collection * @@ -97,20 +66,4 @@ public void prepareGarbageCollectionUncommittedTest() throws ApiException { // TODO: test validations } - /** - * - * - * - * - * @throws ApiException - * if the Api call fails - */ - @Test - public void setGarbageCollectionRulesTest() throws ApiException { - String repository = null; - GarbageCollectionRules garbageCollectionRules = null; - api.setGarbageCollectionRules(repository, garbageCollectionRules); - // TODO: test validations - } - } diff --git a/clients/python/README.md b/clients/python/README.md index b84581814d5..e7f45e7e4c1 100644 --- a/clients/python/README.md +++ b/clients/python/README.md @@ -162,7 +162,6 @@ Class | Method | HTTP request | Description *CommitsApi* | [**commit**](docs/CommitsApi.md#commit) | **POST** /repositories/{repository}/branches/{branch}/commits | create commit *CommitsApi* | [**get_commit**](docs/CommitsApi.md#get_commit) | **GET** /repositories/{repository}/commits/{commitId} | get commit *ConfigApi* | [**get_config**](docs/ConfigApi.md#get_config) | **GET** /config | -*ConfigApi* | [**get_garbage_collection_config**](docs/ConfigApi.md#get_garbage_collection_config) | **GET** /config/garbage-collection | *ExperimentalApi* | [**get_otf_diffs**](docs/ExperimentalApi.md#get_otf_diffs) | **GET** /otf/diffs | get the available Open Table Format diffs *ExperimentalApi* | [**otf_diff**](docs/ExperimentalApi.md#otf_diff) | **GET** /repositories/{repository}/otf/refs/{left_ref}/diff/{right_ref} | perform otf diff *HealthCheckApi* | [**health_check**](docs/HealthCheckApi.md#health_check) | **GET** /healthcheck | @@ -173,9 +172,16 @@ Class | Method | HTTP request | Description *InternalApi* | [**create_symlink_file**](docs/InternalApi.md#create_symlink_file) | **POST** /repositories/{repository}/refs/{branch}/symlink | creates symlink files corresponding to the given directory *InternalApi* | [**dump_refs**](docs/InternalApi.md#dump_refs) | **PUT** /repositories/{repository}/refs/dump | Dump repository refs (tags, commits, branches) to object store Deprecated: a new API will introduce long running operations *InternalApi* | [**get_auth_capabilities**](docs/InternalApi.md#get_auth_capabilities) | **GET** /auth/capabilities | list authentication capabilities supported +*InternalApi* | [**get_garbage_collection_config**](docs/InternalApi.md#get_garbage_collection_config) | **GET** /config/garbage-collection | *InternalApi* | [**get_lake_fs_version**](docs/InternalApi.md#get_lake_fs_version) | **GET** /config/version | *InternalApi* | [**get_setup_state**](docs/InternalApi.md#get_setup_state) | **GET** /setup_lakefs | check if the lakeFS installation is already set up *InternalApi* | [**get_storage_config**](docs/InternalApi.md#get_storage_config) | **GET** /config/storage | +*InternalApi* | [**internal_create_branch_protection_rule**](docs/InternalApi.md#internal_create_branch_protection_rule) | **POST** /repositories/{repository}/branch_protection | +*InternalApi* | [**internal_delete_branch_protection_rule**](docs/InternalApi.md#internal_delete_branch_protection_rule) | **DELETE** /repositories/{repository}/branch_protection | +*InternalApi* | [**internal_delete_garbage_collection_rules**](docs/InternalApi.md#internal_delete_garbage_collection_rules) | **DELETE** /repositories/{repository}/gc/rules | +*InternalApi* | [**internal_get_branch_protection_rules**](docs/InternalApi.md#internal_get_branch_protection_rules) | **GET** /repositories/{repository}/branch_protection | get branch protection rules +*InternalApi* | [**internal_get_garbage_collection_rules**](docs/InternalApi.md#internal_get_garbage_collection_rules) | **GET** /repositories/{repository}/gc/rules | +*InternalApi* | [**internal_set_garbage_collection_rules**](docs/InternalApi.md#internal_set_garbage_collection_rules) | **POST** /repositories/{repository}/gc/rules | *InternalApi* | [**post_stats_events**](docs/InternalApi.md#post_stats_events) | **POST** /statistics | post stats events, this endpoint is meant for internal use only *InternalApi* | [**restore_refs**](docs/InternalApi.md#restore_refs) | **PUT** /repositories/{repository}/refs/restore | Restore repository refs (tags, commits, branches) from object store. Deprecated: a new API will introduce long running operations *InternalApi* | [**set_garbage_collection_rules_preflight**](docs/InternalApi.md#set_garbage_collection_rules_preflight) | **GET** /repositories/{repository}/gc/rules/set_allowed | @@ -198,19 +204,18 @@ Class | Method | HTTP request | Description *RefsApi* | [**find_merge_base**](docs/RefsApi.md#find_merge_base) | **GET** /repositories/{repository}/refs/{sourceRef}/merge/{destinationBranch} | find the merge base for 2 references *RefsApi* | [**log_commits**](docs/RefsApi.md#log_commits) | **GET** /repositories/{repository}/refs/{ref}/commits | get commit log from ref. If both objects and prefixes are empty, return all commits. *RefsApi* | [**merge_into_branch**](docs/RefsApi.md#merge_into_branch) | **POST** /repositories/{repository}/refs/{sourceRef}/merge/{destinationBranch} | merge references -*RepositoriesApi* | [**create_branch_protection_rule**](docs/RepositoriesApi.md#create_branch_protection_rule) | **POST** /repositories/{repository}/branch_protection | *RepositoriesApi* | [**create_repository**](docs/RepositoriesApi.md#create_repository) | **POST** /repositories | create repository -*RepositoriesApi* | [**delete_branch_protection_rule**](docs/RepositoriesApi.md#delete_branch_protection_rule) | **DELETE** /repositories/{repository}/branch_protection | +*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* | [**get_branch_protection_rules**](docs/RepositoriesApi.md#get_branch_protection_rules) | **GET** /repositories/{repository}/branch_protection | get branch protection rules +*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 -*RetentionApi* | [**delete_garbage_collection_rules**](docs/RetentionApi.md#delete_garbage_collection_rules) | **DELETE** /repositories/{repository}/gc/rules | -*RetentionApi* | [**get_garbage_collection_rules**](docs/RetentionApi.md#get_garbage_collection_rules) | **GET** /repositories/{repository}/gc/rules | +*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 | *RetentionApi* | [**prepare_garbage_collection_commits**](docs/RetentionApi.md#prepare_garbage_collection_commits) | **POST** /repositories/{repository}/gc/prepare_commits | save lists of active commits for garbage collection *RetentionApi* | [**prepare_garbage_collection_uncommitted**](docs/RetentionApi.md#prepare_garbage_collection_uncommitted) | **POST** /repositories/{repository}/gc/prepare_uncommited | save repository uncommitted metadata for garbage collection -*RetentionApi* | [**set_garbage_collection_rules**](docs/RetentionApi.md#set_garbage_collection_rules) | **POST** /repositories/{repository}/gc/rules | *StagingApi* | [**get_physical_address**](docs/StagingApi.md#get_physical_address) | **GET** /repositories/{repository}/branches/{branch}/staging/backing | get a physical address and a return token to write object to underlying storage *StagingApi* | [**link_physical_address**](docs/StagingApi.md#link_physical_address) | **PUT** /repositories/{repository}/branches/{branch}/staging/backing | associate staging on this physical address with a path *TagsApi* | [**create_tag**](docs/TagsApi.md#create_tag) | **POST** /repositories/{repository}/tags | create tag diff --git a/clients/python/docs/ConfigApi.md b/clients/python/docs/ConfigApi.md index d5beb61edfb..dd037b3ae89 100644 --- a/clients/python/docs/ConfigApi.md +++ b/clients/python/docs/ConfigApi.md @@ -5,7 +5,6 @@ All URIs are relative to *http://localhost/api/v1* Method | HTTP request | Description ------------- | ------------- | ------------- [**get_config**](ConfigApi.md#get_config) | **GET** /config | -[**get_garbage_collection_config**](ConfigApi.md#get_garbage_collection_config) | **GET** /config/garbage-collection | # **get_config** @@ -110,105 +109,3 @@ This endpoint does not need any parameter. [[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_garbage_collection_config** -> GarbageCollectionConfig get_garbage_collection_config() - - - -get information of gc settings - -### 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 config_api -from lakefs_client.model.garbage_collection_config import GarbageCollectionConfig -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 = config_api.ConfigApi(api_client) - - # example, this endpoint has no required or optional parameters - try: - api_response = api_instance.get_garbage_collection_config() - pprint(api_response) - except lakefs_client.ApiException as e: - print("Exception when calling ConfigApi->get_garbage_collection_config: %s\n" % e) -``` - - -### Parameters -This endpoint does not need any parameter. - -### Return type - -[**GarbageCollectionConfig**](GarbageCollectionConfig.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** | lakeFS garbage collection config | - | -**401** | Unauthorized | - | - -[[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) - diff --git a/clients/python/docs/InternalApi.md b/clients/python/docs/InternalApi.md index aebce91d21b..bf825f6c45f 100644 --- a/clients/python/docs/InternalApi.md +++ b/clients/python/docs/InternalApi.md @@ -8,9 +8,16 @@ Method | HTTP request | Description [**create_symlink_file**](InternalApi.md#create_symlink_file) | **POST** /repositories/{repository}/refs/{branch}/symlink | creates symlink files corresponding to the given directory [**dump_refs**](InternalApi.md#dump_refs) | **PUT** /repositories/{repository}/refs/dump | Dump repository refs (tags, commits, branches) to object store Deprecated: a new API will introduce long running operations [**get_auth_capabilities**](InternalApi.md#get_auth_capabilities) | **GET** /auth/capabilities | list authentication capabilities supported +[**get_garbage_collection_config**](InternalApi.md#get_garbage_collection_config) | **GET** /config/garbage-collection | [**get_lake_fs_version**](InternalApi.md#get_lake_fs_version) | **GET** /config/version | [**get_setup_state**](InternalApi.md#get_setup_state) | **GET** /setup_lakefs | check if the lakeFS installation is already set up [**get_storage_config**](InternalApi.md#get_storage_config) | **GET** /config/storage | +[**internal_create_branch_protection_rule**](InternalApi.md#internal_create_branch_protection_rule) | **POST** /repositories/{repository}/branch_protection | +[**internal_delete_branch_protection_rule**](InternalApi.md#internal_delete_branch_protection_rule) | **DELETE** /repositories/{repository}/branch_protection | +[**internal_delete_garbage_collection_rules**](InternalApi.md#internal_delete_garbage_collection_rules) | **DELETE** /repositories/{repository}/gc/rules | +[**internal_get_branch_protection_rules**](InternalApi.md#internal_get_branch_protection_rules) | **GET** /repositories/{repository}/branch_protection | get branch protection rules +[**internal_get_garbage_collection_rules**](InternalApi.md#internal_get_garbage_collection_rules) | **GET** /repositories/{repository}/gc/rules | +[**internal_set_garbage_collection_rules**](InternalApi.md#internal_set_garbage_collection_rules) | **POST** /repositories/{repository}/gc/rules | [**post_stats_events**](InternalApi.md#post_stats_events) | **POST** /statistics | post stats events, this endpoint is meant for internal use only [**restore_refs**](InternalApi.md#restore_refs) | **PUT** /repositories/{repository}/refs/restore | Restore repository refs (tags, commits, branches) from object store. Deprecated: a new API will introduce long running operations [**set_garbage_collection_rules_preflight**](InternalApi.md#set_garbage_collection_rules_preflight) | **GET** /repositories/{repository}/gc/rules/set_allowed | @@ -415,6 +422,108 @@ No authorization required [[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_garbage_collection_config** +> GarbageCollectionConfig get_garbage_collection_config() + + + +get information of gc settings + +### 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 internal_api +from lakefs_client.model.garbage_collection_config import GarbageCollectionConfig +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 = internal_api.InternalApi(api_client) + + # example, this endpoint has no required or optional parameters + try: + api_response = api_instance.get_garbage_collection_config() + pprint(api_response) + except lakefs_client.ApiException as e: + print("Exception when calling InternalApi->get_garbage_collection_config: %s\n" % e) +``` + + +### Parameters +This endpoint does not need any parameter. + +### Return type + +[**GarbageCollectionConfig**](GarbageCollectionConfig.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** | lakeFS garbage collection config | - | +**401** | Unauthorized | - | + +[[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_lake_fs_version** > VersionConfig get_lake_fs_version() @@ -682,6 +791,656 @@ This endpoint does not need any parameter. [[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) +# **internal_create_branch_protection_rule** +> internal_create_branch_protection_rule(repository, branch_protection_rule) + + + +### 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 internal_api +from lakefs_client.model.error import Error +from lakefs_client.model.branch_protection_rule import BranchProtectionRule +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 = internal_api.InternalApi(api_client) + repository = "repository_example" # str | + branch_protection_rule = BranchProtectionRule( + pattern="stable_*", + ) # BranchProtectionRule | + + # example passing only required values which don't have defaults set + try: + api_instance.internal_create_branch_protection_rule(repository, branch_protection_rule) + except lakefs_client.ApiException as e: + print("Exception when calling InternalApi->internal_create_branch_protection_rule: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **str**| | + **branch_protection_rule** | [**BranchProtectionRule**](BranchProtectionRule.md)| | + +### Return type + +void (empty response body) + +### 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 | +|-------------|-------------|------------------| +**204** | branch protection rule created successfully | - | +**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) + +# **internal_delete_branch_protection_rule** +> internal_delete_branch_protection_rule(repository, inline_object1) + + + +### 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 internal_api +from lakefs_client.model.error import Error +from lakefs_client.model.inline_object1 import InlineObject1 +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 = internal_api.InternalApi(api_client) + repository = "repository_example" # str | + inline_object1 = InlineObject1( + pattern="pattern_example", + ) # InlineObject1 | + + # example passing only required values which don't have defaults set + try: + api_instance.internal_delete_branch_protection_rule(repository, inline_object1) + except lakefs_client.ApiException as e: + print("Exception when calling InternalApi->internal_delete_branch_protection_rule: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **str**| | + **inline_object1** | [**InlineObject1**](InlineObject1.md)| | + +### Return type + +void (empty response body) + +### 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 | +|-------------|-------------|------------------| +**204** | branch protection rule deleted successfully | - | +**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) + +# **internal_delete_garbage_collection_rules** +> internal_delete_garbage_collection_rules(repository) + + + +### 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 internal_api +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 = internal_api.InternalApi(api_client) + repository = "repository_example" # str | + + # example passing only required values which don't have defaults set + try: + api_instance.internal_delete_garbage_collection_rules(repository) + except lakefs_client.ApiException as e: + print("Exception when calling InternalApi->internal_delete_garbage_collection_rules: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **str**| | + +### Return type + +void (empty response body) + +### 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 | +|-------------|-------------|------------------| +**204** | deleted garbage collection rules successfully | - | +**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) + +# **internal_get_branch_protection_rules** +> [BranchProtectionRule] internal_get_branch_protection_rules(repository) + +get branch protection rules + +### 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 internal_api +from lakefs_client.model.error import Error +from lakefs_client.model.branch_protection_rule import BranchProtectionRule +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 = internal_api.InternalApi(api_client) + repository = "repository_example" # str | + + # example passing only required values which don't have defaults set + try: + # get branch protection rules + api_response = api_instance.internal_get_branch_protection_rules(repository) + pprint(api_response) + except lakefs_client.ApiException as e: + print("Exception when calling InternalApi->internal_get_branch_protection_rules: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **str**| | + +### Return type + +[**[BranchProtectionRule]**](BranchProtectionRule.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** | branch protection rules | - | +**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) + +# **internal_get_garbage_collection_rules** +> GarbageCollectionRules internal_get_garbage_collection_rules(repository) + + + +### 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 internal_api +from lakefs_client.model.garbage_collection_rules import GarbageCollectionRules +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 = internal_api.InternalApi(api_client) + repository = "repository_example" # str | + + # example passing only required values which don't have defaults set + try: + api_response = api_instance.internal_get_garbage_collection_rules(repository) + pprint(api_response) + except lakefs_client.ApiException as e: + print("Exception when calling InternalApi->internal_get_garbage_collection_rules: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **str**| | + +### Return type + +[**GarbageCollectionRules**](GarbageCollectionRules.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** | gc rule list | - | +**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) + +# **internal_set_garbage_collection_rules** +> internal_set_garbage_collection_rules(repository, garbage_collection_rules) + + + +### 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 internal_api +from lakefs_client.model.garbage_collection_rules import GarbageCollectionRules +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 = internal_api.InternalApi(api_client) + repository = "repository_example" # str | + garbage_collection_rules = GarbageCollectionRules( + default_retention_days=1, + branches=[ + GarbageCollectionRule( + branch_id="branch_id_example", + retention_days=1, + ), + ], + ) # GarbageCollectionRules | + + # example passing only required values which don't have defaults set + try: + api_instance.internal_set_garbage_collection_rules(repository, garbage_collection_rules) + except lakefs_client.ApiException as e: + print("Exception when calling InternalApi->internal_set_garbage_collection_rules: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **str**| | + **garbage_collection_rules** | [**GarbageCollectionRules**](GarbageCollectionRules.md)| | + +### Return type + +void (empty response body) + +### 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 | +|-------------|-------------|------------------| +**204** | set garbage collection rules successfully | - | +**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) + # **post_stats_events** > post_stats_events(stats_events_list) diff --git a/clients/python/docs/RepositoriesApi.md b/clients/python/docs/RepositoriesApi.md index 03d88bd7e9e..c2b149d1436 100644 --- a/clients/python/docs/RepositoriesApi.md +++ b/clients/python/docs/RepositoriesApi.md @@ -4,20 +4,22 @@ All URIs are relative to *http://localhost/api/v1* Method | HTTP request | Description ------------- | ------------- | ------------- -[**create_branch_protection_rule**](RepositoriesApi.md#create_branch_protection_rule) | **POST** /repositories/{repository}/branch_protection | [**create_repository**](RepositoriesApi.md#create_repository) | **POST** /repositories | create repository -[**delete_branch_protection_rule**](RepositoriesApi.md#delete_branch_protection_rule) | **DELETE** /repositories/{repository}/branch_protection | +[**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 -[**get_branch_protection_rules**](RepositoriesApi.md#get_branch_protection_rules) | **GET** /repositories/{repository}/branch_protection | get branch protection rules +[**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 +[**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 | -# **create_branch_protection_rule** -> create_branch_protection_rule(repository, branch_protection_rule) - +# **create_repository** +> Repository create_repository(repository_creation) +create repository ### Example @@ -31,8 +33,9 @@ Method | HTTP request | Description import time import lakefs_client from lakefs_client.api import repositories_api +from lakefs_client.model.repository import Repository from lakefs_client.model.error import Error -from lakefs_client.model.branch_protection_rule import BranchProtectionRule +from lakefs_client.model.repository_creation import RepositoryCreation 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. @@ -78,16 +81,30 @@ configuration.api_key['saml_auth'] = 'YOUR_API_KEY' 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 | - branch_protection_rule = BranchProtectionRule( - pattern="stable_*", - ) # BranchProtectionRule | + repository_creation = RepositoryCreation( + name="wr1c2v7s6djuy1zmeto", + storage_namespace="s3://example-bucket/", + default_branch="main", + sample_data=True, + ) # RepositoryCreation | + bare = False # bool | If true, create a bare repository with no initial commit and branch (optional) if omitted the server will use the default value of False + + # example passing only required values which don't have defaults set + try: + # create repository + api_response = api_instance.create_repository(repository_creation) + pprint(api_response) + except lakefs_client.ApiException as e: + print("Exception when calling RepositoriesApi->create_repository: %s\n" % e) # example passing only required values which don't have defaults set + # and optional values try: - api_instance.create_branch_protection_rule(repository, branch_protection_rule) + # create repository + api_response = api_instance.create_repository(repository_creation, bare=bare) + pprint(api_response) except lakefs_client.ApiException as e: - print("Exception when calling RepositoriesApi->create_branch_protection_rule: %s\n" % e) + print("Exception when calling RepositoriesApi->create_repository: %s\n" % e) ``` @@ -95,12 +112,12 @@ with lakefs_client.ApiClient(configuration) as api_client: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **repository** | **str**| | - **branch_protection_rule** | [**BranchProtectionRule**](BranchProtectionRule.md)| | + **repository_creation** | [**RepositoryCreation**](RepositoryCreation.md)| | + **bare** | **bool**| If true, create a bare repository with no initial commit and branch | [optional] if omitted the server will use the default value of False ### Return type -void (empty response body) +[**Repository**](Repository.md) ### Authorization @@ -116,17 +133,18 @@ void (empty response body) | Status code | Description | Response headers | |-------------|-------------|------------------| -**204** | branch protection rule created successfully | - | +**201** | repository | - | +**400** | Validation Error | - | **401** | Unauthorized | - | -**404** | Resource Not Found | - | +**409** | Resource Conflicts With Target | - | **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) -# **create_repository** -> Repository create_repository(repository_creation) +# **delete_gc_rules** +> delete_gc_rules(repository) + -create repository ### Example @@ -140,9 +158,7 @@ create repository import time import lakefs_client from lakefs_client.api import repositories_api -from lakefs_client.model.repository import Repository from lakefs_client.model.error import Error -from lakefs_client.model.repository_creation import RepositoryCreation 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. @@ -188,30 +204,13 @@ configuration.api_key['saml_auth'] = 'YOUR_API_KEY' with lakefs_client.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = repositories_api.RepositoriesApi(api_client) - repository_creation = RepositoryCreation( - name="wr1c2v7s6djuy1zmeto", - storage_namespace="s3://example-bucket/", - default_branch="main", - sample_data=True, - ) # RepositoryCreation | - bare = False # bool | If true, create a bare repository with no initial commit and branch (optional) if omitted the server will use the default value of False + repository = "repository_example" # str | # example passing only required values which don't have defaults set try: - # create repository - api_response = api_instance.create_repository(repository_creation) - pprint(api_response) + api_instance.delete_gc_rules(repository) except lakefs_client.ApiException as e: - print("Exception when calling RepositoriesApi->create_repository: %s\n" % e) - - # example passing only required values which don't have defaults set - # and optional values - try: - # create repository - api_response = api_instance.create_repository(repository_creation, bare=bare) - pprint(api_response) - except lakefs_client.ApiException as e: - print("Exception when calling RepositoriesApi->create_repository: %s\n" % e) + print("Exception when calling RepositoriesApi->delete_gc_rules: %s\n" % e) ``` @@ -219,12 +218,11 @@ with lakefs_client.ApiClient(configuration) as api_client: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **repository_creation** | [**RepositoryCreation**](RepositoryCreation.md)| | - **bare** | **bool**| If true, create a bare repository with no initial commit and branch | [optional] if omitted the server will use the default value of False + **repository** | **str**| | ### Return type -[**Repository**](Repository.md) +void (empty response body) ### Authorization @@ -232,7 +230,7 @@ Name | Type | Description | Notes ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: application/json @@ -240,18 +238,17 @@ Name | Type | Description | Notes | Status code | Description | Response headers | |-------------|-------------|------------------| -**201** | repository | - | -**400** | Validation Error | - | +**204** | deleted garbage collection rules successfully | - | **401** | Unauthorized | - | -**409** | Resource Conflicts With Target | - | +**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) -# **delete_branch_protection_rule** -> delete_branch_protection_rule(repository, inline_object1) - +# **delete_repository** +> delete_repository(repository) +delete repository ### Example @@ -266,7 +263,6 @@ import time import lakefs_client from lakefs_client.api import repositories_api from lakefs_client.model.error import Error -from lakefs_client.model.inline_object1 import InlineObject1 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. @@ -313,15 +309,13 @@ 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 | - inline_object1 = InlineObject1( - pattern="pattern_example", - ) # InlineObject1 | # example passing only required values which don't have defaults set try: - api_instance.delete_branch_protection_rule(repository, inline_object1) + # delete repository + api_instance.delete_repository(repository) except lakefs_client.ApiException as e: - print("Exception when calling RepositoriesApi->delete_branch_protection_rule: %s\n" % e) + print("Exception when calling RepositoriesApi->delete_repository: %s\n" % e) ``` @@ -330,7 +324,6 @@ with lakefs_client.ApiClient(configuration) as api_client: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **repository** | **str**| | - **inline_object1** | [**InlineObject1**](InlineObject1.md)| | ### Return type @@ -342,7 +335,7 @@ void (empty response body) ### HTTP request headers - - **Content-Type**: application/json + - **Content-Type**: Not defined - **Accept**: application/json @@ -350,17 +343,17 @@ void (empty response body) | Status code | Description | Response headers | |-------------|-------------|------------------| -**204** | branch protection rule deleted successfully | - | +**204** | repository deleted successfully | - | **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) -# **delete_repository** -> delete_repository(repository) +# **get_branch_protection_rules** +> [BranchProtectionRule] get_branch_protection_rules(repository) -delete repository +get branch protection rules ### Example @@ -375,6 +368,7 @@ import time import lakefs_client from lakefs_client.api import repositories_api from lakefs_client.model.error import Error +from lakefs_client.model.branch_protection_rule import BranchProtectionRule 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. @@ -424,10 +418,11 @@ with lakefs_client.ApiClient(configuration) as api_client: # example passing only required values which don't have defaults set try: - # delete repository - api_instance.delete_repository(repository) + # get branch protection rules + api_response = api_instance.get_branch_protection_rules(repository) + pprint(api_response) except lakefs_client.ApiException as e: - print("Exception when calling RepositoriesApi->delete_repository: %s\n" % e) + print("Exception when calling RepositoriesApi->get_branch_protection_rules: %s\n" % e) ``` @@ -439,7 +434,7 @@ Name | Type | Description | Notes ### Return type -void (empty response body) +[**[BranchProtectionRule]**](BranchProtectionRule.md) ### Authorization @@ -455,17 +450,17 @@ void (empty response body) | Status code | Description | Response headers | |-------------|-------------|------------------| -**204** | repository deleted successfully | - | +**200** | branch protection rules | * ETag -
| **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) +# **get_gc_rules** +> GarbageCollectionRules get_gc_rules(repository) -get branch protection rules +get repository GC rules ### Example @@ -479,8 +474,8 @@ get branch protection rules import time import lakefs_client from lakefs_client.api import repositories_api +from lakefs_client.model.garbage_collection_rules import GarbageCollectionRules from lakefs_client.model.error import Error -from lakefs_client.model.branch_protection_rule import BranchProtectionRule 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. @@ -530,11 +525,11 @@ with lakefs_client.ApiClient(configuration) as api_client: # example passing only required values which don't have defaults set try: - # get branch protection rules - api_response = api_instance.get_branch_protection_rules(repository) + # get repository GC rules + api_response = api_instance.get_gc_rules(repository) pprint(api_response) except lakefs_client.ApiException as e: - print("Exception when calling RepositoriesApi->get_branch_protection_rules: %s\n" % e) + print("Exception when calling RepositoriesApi->get_gc_rules: %s\n" % e) ``` @@ -546,7 +541,7 @@ Name | Type | Description | Notes ### Return type -[**[BranchProtectionRule]**](BranchProtectionRule.md) +[**GarbageCollectionRules**](GarbageCollectionRules.md) ### Authorization @@ -562,7 +557,7 @@ Name | Type | Description | Notes | Status code | Description | Response headers | |-------------|-------------|------------------| -**200** | branch protection rules | - | +**200** | repository GC rules | - | **401** | Unauthorized | - | **404** | Resource Not Found | - | **0** | Internal Server Error | - | @@ -894,3 +889,240 @@ 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) +# **set_branch_protection_rules** +> set_branch_protection_rules(repository, branch_protection_rule) + + + +### 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.branch_protection_rule import BranchProtectionRule +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 | + branch_protection_rule = [ + BranchProtectionRule( + pattern="stable_*", + ), + ] # [BranchProtectionRule] | + if_match = "If-Match_example" # str | if provided, the branch protection rules will be updated only if the current ETag match the provided value (optional) + + # example passing only required values which don't have defaults set + try: + api_instance.set_branch_protection_rules(repository, branch_protection_rule) + except lakefs_client.ApiException as e: + print("Exception when calling RepositoriesApi->set_branch_protection_rules: %s\n" % e) + + # example passing only required values which don't have defaults set + # and optional values + try: + api_instance.set_branch_protection_rules(repository, branch_protection_rule, if_match=if_match) + except lakefs_client.ApiException as e: + print("Exception when calling RepositoriesApi->set_branch_protection_rules: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **str**| | + **branch_protection_rule** | [**[BranchProtectionRule]**](BranchProtectionRule.md)| | + **if_match** | **str**| if provided, the branch protection rules will be updated only if the current ETag match the provided value | [optional] + +### Return type + +void (empty response body) + +### 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 | +|-------------|-------------|------------------| +**204** | branch protection rule created successfully | - | +**400** | Bad Request | - | +**401** | Unauthorized | - | +**404** | Resource Not Found | - | +**412** | Precondition Failed | - | +**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_gc_rules** +> set_gc_rules(repository, garbage_collection_rules) + + + +### 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.garbage_collection_rules import GarbageCollectionRules +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 | + garbage_collection_rules = GarbageCollectionRules( + default_retention_days=1, + branches=[ + GarbageCollectionRule( + branch_id="branch_id_example", + retention_days=1, + ), + ], + ) # GarbageCollectionRules | + + # example passing only required values which don't have defaults set + try: + api_instance.set_gc_rules(repository, garbage_collection_rules) + except lakefs_client.ApiException as e: + print("Exception when calling RepositoriesApi->set_gc_rules: %s\n" % e) +``` + + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **repository** | **str**| | + **garbage_collection_rules** | [**GarbageCollectionRules**](GarbageCollectionRules.md)| | + +### Return type + +void (empty response body) + +### 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 | +|-------------|-------------|------------------| +**204** | set garbage collection rules successfully | - | +**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) + diff --git a/clients/python/docs/RetentionApi.md b/clients/python/docs/RetentionApi.md index f6e7f248245..aa4b6c0d7b7 100644 --- a/clients/python/docs/RetentionApi.md +++ b/clients/python/docs/RetentionApi.md @@ -4,223 +4,10 @@ All URIs are relative to *http://localhost/api/v1* Method | HTTP request | Description ------------- | ------------- | ------------- -[**delete_garbage_collection_rules**](RetentionApi.md#delete_garbage_collection_rules) | **DELETE** /repositories/{repository}/gc/rules | -[**get_garbage_collection_rules**](RetentionApi.md#get_garbage_collection_rules) | **GET** /repositories/{repository}/gc/rules | [**prepare_garbage_collection_commits**](RetentionApi.md#prepare_garbage_collection_commits) | **POST** /repositories/{repository}/gc/prepare_commits | save lists of active commits for garbage collection [**prepare_garbage_collection_uncommitted**](RetentionApi.md#prepare_garbage_collection_uncommitted) | **POST** /repositories/{repository}/gc/prepare_uncommited | save repository uncommitted metadata for garbage collection -[**set_garbage_collection_rules**](RetentionApi.md#set_garbage_collection_rules) | **POST** /repositories/{repository}/gc/rules | -# **delete_garbage_collection_rules** -> delete_garbage_collection_rules(repository) - - - -### 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 retention_api -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 = retention_api.RetentionApi(api_client) - repository = "repository_example" # str | - - # example passing only required values which don't have defaults set - try: - api_instance.delete_garbage_collection_rules(repository) - except lakefs_client.ApiException as e: - print("Exception when calling RetentionApi->delete_garbage_collection_rules: %s\n" % e) -``` - - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **repository** | **str**| | - -### Return type - -void (empty response body) - -### 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 | -|-------------|-------------|------------------| -**204** | deleted garbage collection rules successfully | - | -**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_garbage_collection_rules** -> GarbageCollectionRules get_garbage_collection_rules(repository) - - - -### 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 retention_api -from lakefs_client.model.garbage_collection_rules import GarbageCollectionRules -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 = retention_api.RetentionApi(api_client) - repository = "repository_example" # str | - - # example passing only required values which don't have defaults set - try: - api_response = api_instance.get_garbage_collection_rules(repository) - pprint(api_response) - except lakefs_client.ApiException as e: - print("Exception when calling RetentionApi->get_garbage_collection_rules: %s\n" % e) -``` - - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **repository** | **str**| | - -### Return type - -[**GarbageCollectionRules**](GarbageCollectionRules.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** | gc rule list | - | -**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) - # **prepare_garbage_collection_commits** > GarbageCollectionPrepareResponse prepare_garbage_collection_commits(repository) @@ -450,118 +237,3 @@ 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) -# **set_garbage_collection_rules** -> set_garbage_collection_rules(repository, garbage_collection_rules) - - - -### 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 retention_api -from lakefs_client.model.garbage_collection_rules import GarbageCollectionRules -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 = retention_api.RetentionApi(api_client) - repository = "repository_example" # str | - garbage_collection_rules = GarbageCollectionRules( - default_retention_days=1, - branches=[ - GarbageCollectionRule( - branch_id="branch_id_example", - retention_days=1, - ), - ], - ) # GarbageCollectionRules | - - # example passing only required values which don't have defaults set - try: - api_instance.set_garbage_collection_rules(repository, garbage_collection_rules) - except lakefs_client.ApiException as e: - print("Exception when calling RetentionApi->set_garbage_collection_rules: %s\n" % e) -``` - - -### Parameters - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **repository** | **str**| | - **garbage_collection_rules** | [**GarbageCollectionRules**](GarbageCollectionRules.md)| | - -### Return type - -void (empty response body) - -### 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 | -|-------------|-------------|------------------| -**204** | set garbage collection rules successfully | - | -**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) - diff --git a/clients/python/lakefs_client/api/config_api.py b/clients/python/lakefs_client/api/config_api.py index cb6591f1b65..bb8802111c0 100644 --- a/clients/python/lakefs_client/api/config_api.py +++ b/clients/python/lakefs_client/api/config_api.py @@ -24,7 +24,6 @@ ) from lakefs_client.model.config import Config from lakefs_client.model.error import Error -from lakefs_client.model.garbage_collection_config import GarbageCollectionConfig class ConfigApi(object): @@ -86,54 +85,6 @@ def __init__(self, api_client=None): }, api_client=api_client ) - self.get_garbage_collection_config_endpoint = _Endpoint( - settings={ - 'response_type': (GarbageCollectionConfig,), - 'auth': [ - 'basic_auth', - 'cookie_auth', - 'jwt_token', - 'oidc_auth', - 'saml_auth' - ], - 'endpoint_path': '/config/garbage-collection', - 'operation_id': 'get_garbage_collection_config', - 'http_method': 'GET', - 'servers': None, - }, - params_map={ - 'all': [ - ], - 'required': [], - 'nullable': [ - ], - 'enum': [ - ], - 'validation': [ - ] - }, - root_map={ - 'validations': { - }, - 'allowed_values': { - }, - 'openapi_types': { - }, - 'attribute_map': { - }, - 'location_map': { - }, - 'collection_format_map': { - } - }, - headers_map={ - 'accept': [ - 'application/json' - ], - 'content_type': [], - }, - api_client=api_client - ) def get_config( self, @@ -196,64 +147,3 @@ def get_config( kwargs['_host_index'] = kwargs.get('_host_index') return self.get_config_endpoint.call_with_http_info(**kwargs) - def get_garbage_collection_config( - self, - **kwargs - ): - """get_garbage_collection_config # noqa: E501 - - get information of gc settings # noqa: E501 - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.get_garbage_collection_config(async_req=True) - >>> result = thread.get() - - - 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: - GarbageCollectionConfig - 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') - return self.get_garbage_collection_config_endpoint.call_with_http_info(**kwargs) - diff --git a/clients/python/lakefs_client/api/internal_api.py b/clients/python/lakefs_client/api/internal_api.py index daf63fc4299..896563772a5 100644 --- a/clients/python/lakefs_client/api/internal_api.py +++ b/clients/python/lakefs_client/api/internal_api.py @@ -23,9 +23,13 @@ validate_and_convert_types ) from lakefs_client.model.auth_capabilities import AuthCapabilities +from lakefs_client.model.branch_protection_rule import BranchProtectionRule from lakefs_client.model.comm_prefs_input import CommPrefsInput from lakefs_client.model.credentials_with_secret import CredentialsWithSecret from lakefs_client.model.error import Error +from lakefs_client.model.garbage_collection_config import GarbageCollectionConfig +from lakefs_client.model.garbage_collection_rules import GarbageCollectionRules +from lakefs_client.model.inline_object1 import InlineObject1 from lakefs_client.model.refs_dump import RefsDump from lakefs_client.model.setup import Setup from lakefs_client.model.setup_state import SetupState @@ -264,6 +268,54 @@ def __init__(self, api_client=None): }, api_client=api_client ) + self.get_garbage_collection_config_endpoint = _Endpoint( + settings={ + 'response_type': (GarbageCollectionConfig,), + 'auth': [ + 'basic_auth', + 'cookie_auth', + 'jwt_token', + 'oidc_auth', + 'saml_auth' + ], + 'endpoint_path': '/config/garbage-collection', + 'operation_id': 'get_garbage_collection_config', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + }, + 'attribute_map': { + }, + 'location_map': { + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client + ) self.get_lake_fs_version_endpoint = _Endpoint( settings={ 'response_type': (VersionConfig,), @@ -402,7 +454,7 @@ def __init__(self, api_client=None): }, api_client=api_client ) - self.post_stats_events_endpoint = _Endpoint( + self.internal_create_branch_protection_rule_endpoint = _Endpoint( settings={ 'response_type': None, 'auth': [ @@ -412,17 +464,19 @@ def __init__(self, api_client=None): 'oidc_auth', 'saml_auth' ], - 'endpoint_path': '/statistics', - 'operation_id': 'post_stats_events', + 'endpoint_path': '/repositories/{repository}/branch_protection', + 'operation_id': 'internal_create_branch_protection_rule', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ - 'stats_events_list', + 'repository', + 'branch_protection_rule', ], 'required': [ - 'stats_events_list', + 'repository', + 'branch_protection_rule', ], 'nullable': [ ], @@ -437,13 +491,17 @@ def __init__(self, api_client=None): 'allowed_values': { }, 'openapi_types': { - 'stats_events_list': - (StatsEventsList,), + 'repository': + (str,), + 'branch_protection_rule': + (BranchProtectionRule,), }, 'attribute_map': { + 'repository': 'repository', }, 'location_map': { - 'stats_events_list': 'body', + 'repository': 'path', + 'branch_protection_rule': 'body', }, 'collection_format_map': { } @@ -458,7 +516,7 @@ def __init__(self, api_client=None): }, api_client=api_client ) - self.restore_refs_endpoint = _Endpoint( + self.internal_delete_branch_protection_rule_endpoint = _Endpoint( settings={ 'response_type': None, 'auth': [ @@ -468,19 +526,19 @@ def __init__(self, api_client=None): 'oidc_auth', 'saml_auth' ], - 'endpoint_path': '/repositories/{repository}/refs/restore', - 'operation_id': 'restore_refs', - 'http_method': 'PUT', + 'endpoint_path': '/repositories/{repository}/branch_protection', + 'operation_id': 'internal_delete_branch_protection_rule', + 'http_method': 'DELETE', 'servers': None, }, params_map={ 'all': [ 'repository', - 'refs_dump', + 'inline_object1', ], 'required': [ 'repository', - 'refs_dump', + 'inline_object1', ], 'nullable': [ ], @@ -497,15 +555,15 @@ def __init__(self, api_client=None): 'openapi_types': { 'repository': (str,), - 'refs_dump': - (RefsDump,), + 'inline_object1': + (InlineObject1,), }, 'attribute_map': { 'repository': 'repository', }, 'location_map': { 'repository': 'path', - 'refs_dump': 'body', + 'inline_object1': 'body', }, 'collection_format_map': { } @@ -520,7 +578,7 @@ def __init__(self, api_client=None): }, api_client=api_client ) - self.set_garbage_collection_rules_preflight_endpoint = _Endpoint( + self.internal_delete_garbage_collection_rules_endpoint = _Endpoint( settings={ 'response_type': None, 'auth': [ @@ -530,8 +588,63 @@ def __init__(self, api_client=None): 'oidc_auth', 'saml_auth' ], - 'endpoint_path': '/repositories/{repository}/gc/rules/set_allowed', - 'operation_id': 'set_garbage_collection_rules_preflight', + 'endpoint_path': '/repositories/{repository}/gc/rules', + 'operation_id': 'internal_delete_garbage_collection_rules', + 'http_method': 'DELETE', + '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.internal_get_branch_protection_rules_endpoint = _Endpoint( + settings={ + 'response_type': ([BranchProtectionRule],), + 'auth': [ + 'basic_auth', + 'cookie_auth', + 'jwt_token', + 'oidc_auth', + 'saml_auth' + ], + 'endpoint_path': '/repositories/{repository}/branch_protection', + 'operation_id': 'internal_get_branch_protection_rules', 'http_method': 'GET', 'servers': None, }, @@ -575,21 +688,84 @@ def __init__(self, api_client=None): }, api_client=api_client ) - self.setup_endpoint = _Endpoint( + self.internal_get_garbage_collection_rules_endpoint = _Endpoint( settings={ - 'response_type': (CredentialsWithSecret,), - 'auth': [], - 'endpoint_path': '/setup_lakefs', - 'operation_id': 'setup', + 'response_type': (GarbageCollectionRules,), + 'auth': [ + 'basic_auth', + 'cookie_auth', + 'jwt_token', + 'oidc_auth', + 'saml_auth' + ], + 'endpoint_path': '/repositories/{repository}/gc/rules', + 'operation_id': 'internal_get_garbage_collection_rules', + 'http_method': 'GET', + '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.internal_set_garbage_collection_rules_endpoint = _Endpoint( + settings={ + 'response_type': None, + 'auth': [ + 'basic_auth', + 'cookie_auth', + 'jwt_token', + 'oidc_auth', + 'saml_auth' + ], + 'endpoint_path': '/repositories/{repository}/gc/rules', + 'operation_id': 'internal_set_garbage_collection_rules', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ - 'setup', + 'repository', + 'garbage_collection_rules', ], 'required': [ - 'setup', + 'repository', + 'garbage_collection_rules', ], 'nullable': [ ], @@ -604,13 +780,17 @@ def __init__(self, api_client=None): 'allowed_values': { }, 'openapi_types': { - 'setup': - (Setup,), + 'repository': + (str,), + 'garbage_collection_rules': + (GarbageCollectionRules,), }, 'attribute_map': { + 'repository': 'repository', }, 'location_map': { - 'setup': 'body', + 'repository': 'path', + 'garbage_collection_rules': 'body', }, 'collection_format_map': { } @@ -625,21 +805,27 @@ def __init__(self, api_client=None): }, api_client=api_client ) - self.setup_comm_prefs_endpoint = _Endpoint( + self.post_stats_events_endpoint = _Endpoint( settings={ 'response_type': None, - 'auth': [], - 'endpoint_path': '/setup_comm_prefs', - 'operation_id': 'setup_comm_prefs', + 'auth': [ + 'basic_auth', + 'cookie_auth', + 'jwt_token', + 'oidc_auth', + 'saml_auth' + ], + 'endpoint_path': '/statistics', + 'operation_id': 'post_stats_events', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ - 'comm_prefs_input', + 'stats_events_list', ], 'required': [ - 'comm_prefs_input', + 'stats_events_list', ], 'nullable': [ ], @@ -654,13 +840,13 @@ def __init__(self, api_client=None): 'allowed_values': { }, 'openapi_types': { - 'comm_prefs_input': - (CommPrefsInput,), + 'stats_events_list': + (StatsEventsList,), }, 'attribute_map': { }, 'location_map': { - 'comm_prefs_input': 'body', + 'stats_events_list': 'body', }, 'collection_format_map': { } @@ -675,7 +861,7 @@ def __init__(self, api_client=None): }, api_client=api_client ) - self.upload_object_preflight_endpoint = _Endpoint( + self.restore_refs_endpoint = _Endpoint( settings={ 'response_type': None, 'auth': [ @@ -685,21 +871,19 @@ def __init__(self, api_client=None): 'oidc_auth', 'saml_auth' ], - 'endpoint_path': '/repositories/{repository}/branches/{branch}/objects/stage_allowed', - 'operation_id': 'upload_object_preflight', - 'http_method': 'GET', + 'endpoint_path': '/repositories/{repository}/refs/restore', + 'operation_id': 'restore_refs', + 'http_method': 'PUT', 'servers': None, }, params_map={ 'all': [ 'repository', - 'branch', - 'path', + 'refs_dump', ], 'required': [ 'repository', - 'branch', - 'path', + 'refs_dump', ], 'nullable': [ ], @@ -716,20 +900,15 @@ def __init__(self, api_client=None): 'openapi_types': { 'repository': (str,), - 'branch': - (str,), - 'path': - (str,), + 'refs_dump': + (RefsDump,), }, 'attribute_map': { 'repository': 'repository', - 'branch': 'branch', - 'path': 'path', }, 'location_map': { 'repository': 'path', - 'branch': 'path', - 'path': 'query', + 'refs_dump': 'body', }, 'collection_format_map': { } @@ -738,18 +917,242 @@ def __init__(self, api_client=None): 'accept': [ 'application/json' ], - 'content_type': [], + 'content_type': [ + 'application/json' + ] }, api_client=api_client ) - - def create_branch_protection_rule_preflight( - self, - repository, - **kwargs - ): - """create_branch_protection_rule_preflight # noqa: E501 - + self.set_garbage_collection_rules_preflight_endpoint = _Endpoint( + settings={ + 'response_type': None, + 'auth': [ + 'basic_auth', + 'cookie_auth', + 'jwt_token', + 'oidc_auth', + 'saml_auth' + ], + 'endpoint_path': '/repositories/{repository}/gc/rules/set_allowed', + 'operation_id': 'set_garbage_collection_rules_preflight', + 'http_method': 'GET', + '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.setup_endpoint = _Endpoint( + settings={ + 'response_type': (CredentialsWithSecret,), + 'auth': [], + 'endpoint_path': '/setup_lakefs', + 'operation_id': 'setup', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'setup', + ], + 'required': [ + 'setup', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'setup': + (Setup,), + }, + 'attribute_map': { + }, + 'location_map': { + 'setup': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client + ) + self.setup_comm_prefs_endpoint = _Endpoint( + settings={ + 'response_type': None, + 'auth': [], + 'endpoint_path': '/setup_comm_prefs', + 'operation_id': 'setup_comm_prefs', + 'http_method': 'POST', + 'servers': None, + }, + params_map={ + 'all': [ + 'comm_prefs_input', + ], + 'required': [ + 'comm_prefs_input', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'comm_prefs_input': + (CommPrefsInput,), + }, + 'attribute_map': { + }, + 'location_map': { + 'comm_prefs_input': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client + ) + self.upload_object_preflight_endpoint = _Endpoint( + settings={ + 'response_type': None, + 'auth': [ + 'basic_auth', + 'cookie_auth', + 'jwt_token', + 'oidc_auth', + 'saml_auth' + ], + 'endpoint_path': '/repositories/{repository}/branches/{branch}/objects/stage_allowed', + 'operation_id': 'upload_object_preflight', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + 'repository', + 'branch', + 'path', + ], + 'required': [ + 'repository', + 'branch', + 'path', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'repository': + (str,), + 'branch': + (str,), + 'path': + (str,), + }, + 'attribute_map': { + 'repository': 'repository', + 'branch': 'branch', + 'path': 'path', + }, + 'location_map': { + 'repository': 'path', + 'branch': 'path', + 'path': 'query', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [], + }, + api_client=api_client + ) + + def create_branch_protection_rule_preflight( + self, + repository, + **kwargs + ): + """create_branch_protection_rule_preflight # noqa: E501 + This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True @@ -1003,17 +1406,17 @@ def get_auth_capabilities( kwargs['_host_index'] = kwargs.get('_host_index') return self.get_auth_capabilities_endpoint.call_with_http_info(**kwargs) - def get_lake_fs_version( + def get_garbage_collection_config( self, **kwargs ): - """get_lake_fs_version # noqa: E501 + """get_garbage_collection_config # noqa: E501 - get version of lakeFS server # noqa: E501 + get information of gc settings # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_lake_fs_version(async_req=True) + >>> thread = api.get_garbage_collection_config(async_req=True) >>> result = thread.get() @@ -1039,7 +1442,7 @@ def get_lake_fs_version( async_req (bool): execute request asynchronously Returns: - VersionConfig + GarbageCollectionConfig If the method is called asynchronously, returns the request thread. """ @@ -1062,18 +1465,19 @@ def get_lake_fs_version( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') - return self.get_lake_fs_version_endpoint.call_with_http_info(**kwargs) + return self.get_garbage_collection_config_endpoint.call_with_http_info(**kwargs) - def get_setup_state( + def get_lake_fs_version( self, **kwargs ): - """check if the lakeFS installation is already set up # noqa: E501 + """get_lake_fs_version # noqa: E501 + get version of lakeFS server # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_setup_state(async_req=True) + >>> thread = api.get_lake_fs_version(async_req=True) >>> result = thread.get() @@ -1099,7 +1503,7 @@ def get_setup_state( async_req (bool): execute request asynchronously Returns: - SetupState + VersionConfig If the method is called asynchronously, returns the request thread. """ @@ -1122,19 +1526,18 @@ def get_setup_state( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') - return self.get_setup_state_endpoint.call_with_http_info(**kwargs) + return self.get_lake_fs_version_endpoint.call_with_http_info(**kwargs) - def get_storage_config( + def get_setup_state( self, **kwargs ): - """get_storage_config # noqa: E501 + """check if the lakeFS installation is already set up # noqa: E501 - retrieve lakeFS storage configuration # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_storage_config(async_req=True) + >>> thread = api.get_setup_state(async_req=True) >>> result = thread.get() @@ -1160,7 +1563,68 @@ def get_storage_config( async_req (bool): execute request asynchronously Returns: - StorageConfig + SetupState + 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') + return self.get_setup_state_endpoint.call_with_http_info(**kwargs) + + def get_storage_config( + self, + **kwargs + ): + """get_storage_config # noqa: E501 + + retrieve lakeFS storage configuration # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.get_storage_config(async_req=True) + >>> result = thread.get() + + + 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: + StorageConfig If the method is called asynchronously, returns the request thread. """ @@ -1185,6 +1649,408 @@ def get_storage_config( kwargs['_host_index'] = kwargs.get('_host_index') return self.get_storage_config_endpoint.call_with_http_info(**kwargs) + def internal_create_branch_protection_rule( + self, + repository, + branch_protection_rule, + **kwargs + ): + """internal_create_branch_protection_rule # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.internal_create_branch_protection_rule(repository, branch_protection_rule, async_req=True) + >>> result = thread.get() + + Args: + repository (str): + branch_protection_rule (BranchProtectionRule): + + 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: + None + 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['branch_protection_rule'] = \ + branch_protection_rule + return self.internal_create_branch_protection_rule_endpoint.call_with_http_info(**kwargs) + + def internal_delete_branch_protection_rule( + self, + repository, + inline_object1, + **kwargs + ): + """internal_delete_branch_protection_rule # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.internal_delete_branch_protection_rule(repository, inline_object1, async_req=True) + >>> result = thread.get() + + Args: + repository (str): + inline_object1 (InlineObject1): + + 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: + None + 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['inline_object1'] = \ + inline_object1 + return self.internal_delete_branch_protection_rule_endpoint.call_with_http_info(**kwargs) + + def internal_delete_garbage_collection_rules( + self, + repository, + **kwargs + ): + """internal_delete_garbage_collection_rules # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.internal_delete_garbage_collection_rules(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: + None + 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.internal_delete_garbage_collection_rules_endpoint.call_with_http_info(**kwargs) + + def internal_get_branch_protection_rules( + self, + repository, + **kwargs + ): + """get branch protection rules # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.internal_get_branch_protection_rules(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: + [BranchProtectionRule] + 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.internal_get_branch_protection_rules_endpoint.call_with_http_info(**kwargs) + + def internal_get_garbage_collection_rules( + self, + repository, + **kwargs + ): + """internal_get_garbage_collection_rules # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.internal_get_garbage_collection_rules(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: + GarbageCollectionRules + 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.internal_get_garbage_collection_rules_endpoint.call_with_http_info(**kwargs) + + def internal_set_garbage_collection_rules( + self, + repository, + garbage_collection_rules, + **kwargs + ): + """internal_set_garbage_collection_rules # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.internal_set_garbage_collection_rules(repository, garbage_collection_rules, async_req=True) + >>> result = thread.get() + + Args: + repository (str): + garbage_collection_rules (GarbageCollectionRules): + + 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: + None + 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['garbage_collection_rules'] = \ + garbage_collection_rules + return self.internal_set_garbage_collection_rules_endpoint.call_with_http_info(**kwargs) + def post_stats_events( self, stats_events_list, diff --git a/clients/python/lakefs_client/api/repositories_api.py b/clients/python/lakefs_client/api/repositories_api.py index 50d1edfc0f6..d63cc8e3b83 100644 --- a/clients/python/lakefs_client/api/repositories_api.py +++ b/clients/python/lakefs_client/api/repositories_api.py @@ -24,7 +24,7 @@ ) from lakefs_client.model.branch_protection_rule import BranchProtectionRule from lakefs_client.model.error import Error -from lakefs_client.model.inline_object1 import InlineObject1 +from lakefs_client.model.garbage_collection_rules import GarbageCollectionRules from lakefs_client.model.repository import Repository from lakefs_client.model.repository_creation import RepositoryCreation from lakefs_client.model.repository_list import RepositoryList @@ -42,9 +42,9 @@ def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() self.api_client = api_client - self.create_branch_protection_rule_endpoint = _Endpoint( + self.create_repository_endpoint = _Endpoint( settings={ - 'response_type': None, + 'response_type': (Repository,), 'auth': [ 'basic_auth', 'cookie_auth', @@ -52,19 +52,18 @@ def __init__(self, api_client=None): 'oidc_auth', 'saml_auth' ], - 'endpoint_path': '/repositories/{repository}/branch_protection', - 'operation_id': 'create_branch_protection_rule', + 'endpoint_path': '/repositories', + 'operation_id': 'create_repository', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ - 'repository', - 'branch_protection_rule', + 'repository_creation', + 'bare', ], 'required': [ - 'repository', - 'branch_protection_rule', + 'repository_creation', ], 'nullable': [ ], @@ -79,17 +78,17 @@ def __init__(self, api_client=None): 'allowed_values': { }, 'openapi_types': { - 'repository': - (str,), - 'branch_protection_rule': - (BranchProtectionRule,), + 'repository_creation': + (RepositoryCreation,), + 'bare': + (bool,), }, 'attribute_map': { - 'repository': 'repository', + 'bare': 'bare', }, 'location_map': { - 'repository': 'path', - 'branch_protection_rule': 'body', + 'repository_creation': 'body', + 'bare': 'query', }, 'collection_format_map': { } @@ -104,9 +103,9 @@ def __init__(self, api_client=None): }, api_client=api_client ) - self.create_repository_endpoint = _Endpoint( + self.delete_gc_rules_endpoint = _Endpoint( settings={ - 'response_type': (Repository,), + 'response_type': None, 'auth': [ 'basic_auth', 'cookie_auth', @@ -114,18 +113,17 @@ def __init__(self, api_client=None): 'oidc_auth', 'saml_auth' ], - 'endpoint_path': '/repositories', - 'operation_id': 'create_repository', - 'http_method': 'POST', + 'endpoint_path': '/repositories/{repository}/settings/gc_rules', + 'operation_id': 'delete_gc_rules', + 'http_method': 'DELETE', 'servers': None, }, params_map={ 'all': [ - 'repository_creation', - 'bare', + 'repository', ], 'required': [ - 'repository_creation', + 'repository', ], 'nullable': [ ], @@ -140,17 +138,14 @@ def __init__(self, api_client=None): 'allowed_values': { }, 'openapi_types': { - 'repository_creation': - (RepositoryCreation,), - 'bare': - (bool,), + 'repository': + (str,), }, 'attribute_map': { - 'bare': 'bare', + 'repository': 'repository', }, 'location_map': { - 'repository_creation': 'body', - 'bare': 'query', + 'repository': 'path', }, 'collection_format_map': { } @@ -159,13 +154,11 @@ def __init__(self, api_client=None): 'accept': [ 'application/json' ], - 'content_type': [ - 'application/json' - ] + 'content_type': [], }, api_client=api_client ) - self.delete_branch_protection_rule_endpoint = _Endpoint( + self.delete_repository_endpoint = _Endpoint( settings={ 'response_type': None, 'auth': [ @@ -175,19 +168,17 @@ def __init__(self, api_client=None): 'oidc_auth', 'saml_auth' ], - 'endpoint_path': '/repositories/{repository}/branch_protection', - 'operation_id': 'delete_branch_protection_rule', + 'endpoint_path': '/repositories/{repository}', + 'operation_id': 'delete_repository', 'http_method': 'DELETE', 'servers': None, }, params_map={ 'all': [ 'repository', - 'inline_object1', ], 'required': [ 'repository', - 'inline_object1', ], 'nullable': [ ], @@ -204,15 +195,12 @@ def __init__(self, api_client=None): 'openapi_types': { 'repository': (str,), - 'inline_object1': - (InlineObject1,), }, 'attribute_map': { 'repository': 'repository', }, 'location_map': { 'repository': 'path', - 'inline_object1': 'body', }, 'collection_format_map': { } @@ -221,15 +209,13 @@ def __init__(self, api_client=None): 'accept': [ 'application/json' ], - 'content_type': [ - 'application/json' - ] + 'content_type': [], }, api_client=api_client ) - self.delete_repository_endpoint = _Endpoint( + self.get_branch_protection_rules_endpoint = _Endpoint( settings={ - 'response_type': None, + 'response_type': ([BranchProtectionRule],), 'auth': [ 'basic_auth', 'cookie_auth', @@ -237,9 +223,9 @@ def __init__(self, api_client=None): 'oidc_auth', 'saml_auth' ], - 'endpoint_path': '/repositories/{repository}', - 'operation_id': 'delete_repository', - 'http_method': 'DELETE', + 'endpoint_path': '/repositories/{repository}/settings/branch_protection', + 'operation_id': 'get_branch_protection_rules', + 'http_method': 'GET', 'servers': None, }, params_map={ @@ -282,9 +268,9 @@ def __init__(self, api_client=None): }, api_client=api_client ) - self.get_branch_protection_rules_endpoint = _Endpoint( + self.get_gc_rules_endpoint = _Endpoint( settings={ - 'response_type': ([BranchProtectionRule],), + 'response_type': (GarbageCollectionRules,), 'auth': [ 'basic_auth', 'cookie_auth', @@ -292,8 +278,8 @@ def __init__(self, api_client=None): 'oidc_auth', 'saml_auth' ], - 'endpoint_path': '/repositories/{repository}/branch_protection', - 'operation_id': 'get_branch_protection_rules', + 'endpoint_path': '/repositories/{repository}/settings/gc_rules', + 'operation_id': 'get_gc_rules', 'http_method': 'GET', 'servers': None, }, @@ -516,26 +502,154 @@ def __init__(self, api_client=None): }, api_client=api_client ) + self.set_branch_protection_rules_endpoint = _Endpoint( + settings={ + 'response_type': None, + 'auth': [ + 'basic_auth', + 'cookie_auth', + 'jwt_token', + 'oidc_auth', + 'saml_auth' + ], + 'endpoint_path': '/repositories/{repository}/settings/branch_protection', + 'operation_id': 'set_branch_protection_rules', + 'http_method': 'PUT', + 'servers': None, + }, + params_map={ + 'all': [ + 'repository', + 'branch_protection_rule', + 'if_match', + ], + 'required': [ + 'repository', + 'branch_protection_rule', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'repository': + (str,), + 'branch_protection_rule': + ([BranchProtectionRule],), + 'if_match': + (str,), + }, + 'attribute_map': { + 'repository': 'repository', + 'if_match': 'If-Match', + }, + 'location_map': { + 'repository': 'path', + 'branch_protection_rule': 'body', + 'if_match': 'header', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client + ) + self.set_gc_rules_endpoint = _Endpoint( + settings={ + 'response_type': None, + 'auth': [ + 'basic_auth', + 'cookie_auth', + 'jwt_token', + 'oidc_auth', + 'saml_auth' + ], + 'endpoint_path': '/repositories/{repository}/settings/gc_rules', + 'operation_id': 'set_gc_rules', + 'http_method': 'PUT', + 'servers': None, + }, + params_map={ + 'all': [ + 'repository', + 'garbage_collection_rules', + ], + 'required': [ + 'repository', + 'garbage_collection_rules', + ], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, + root_map={ + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'repository': + (str,), + 'garbage_collection_rules': + (GarbageCollectionRules,), + }, + 'attribute_map': { + 'repository': 'repository', + }, + 'location_map': { + 'repository': 'path', + 'garbage_collection_rules': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] + }, + api_client=api_client + ) - def create_branch_protection_rule( + def create_repository( self, - repository, - branch_protection_rule, + repository_creation, **kwargs ): - """create_branch_protection_rule # noqa: E501 + """create repository # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_branch_protection_rule(repository, branch_protection_rule, async_req=True) + >>> thread = api.create_repository(repository_creation, async_req=True) >>> result = thread.get() Args: - repository (str): - branch_protection_rule (BranchProtectionRule): + repository_creation (RepositoryCreation): Keyword Args: + bare (bool): If true, create a bare repository with no initial commit and branch. [optional] if omitted the server will use the default value of False _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 @@ -557,7 +671,7 @@ def create_branch_protection_rule( async_req (bool): execute request asynchronously Returns: - None + Repository If the method is called asynchronously, returns the request thread. """ @@ -580,30 +694,27 @@ def create_branch_protection_rule( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') - kwargs['repository'] = \ - repository - kwargs['branch_protection_rule'] = \ - branch_protection_rule - return self.create_branch_protection_rule_endpoint.call_with_http_info(**kwargs) + kwargs['repository_creation'] = \ + repository_creation + return self.create_repository_endpoint.call_with_http_info(**kwargs) - def create_repository( + def delete_gc_rules( self, - repository_creation, + repository, **kwargs ): - """create repository # noqa: E501 + """delete_gc_rules # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.create_repository(repository_creation, async_req=True) + >>> thread = api.delete_gc_rules(repository, async_req=True) >>> result = thread.get() Args: - repository_creation (RepositoryCreation): + repository (str): Keyword Args: - bare (bool): If true, create a bare repository with no initial commit and branch. [optional] if omitted the server will use the default value of False _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 @@ -625,7 +736,7 @@ def create_repository( async_req (bool): execute request asynchronously Returns: - Repository + None If the method is called asynchronously, returns the request thread. """ @@ -648,27 +759,25 @@ def create_repository( '_check_return_type', True ) kwargs['_host_index'] = kwargs.get('_host_index') - kwargs['repository_creation'] = \ - repository_creation - return self.create_repository_endpoint.call_with_http_info(**kwargs) + kwargs['repository'] = \ + repository + return self.delete_gc_rules_endpoint.call_with_http_info(**kwargs) - def delete_branch_protection_rule( + def delete_repository( self, repository, - inline_object1, **kwargs ): - """delete_branch_protection_rule # noqa: E501 + """delete repository # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.delete_branch_protection_rule(repository, inline_object1, async_req=True) + >>> thread = api.delete_repository(repository, async_req=True) >>> result = thread.get() Args: repository (str): - inline_object1 (InlineObject1): Keyword Args: _return_http_data_only (bool): response data without head status @@ -717,21 +826,19 @@ def delete_branch_protection_rule( kwargs['_host_index'] = kwargs.get('_host_index') kwargs['repository'] = \ repository - kwargs['inline_object1'] = \ - inline_object1 - return self.delete_branch_protection_rule_endpoint.call_with_http_info(**kwargs) + return self.delete_repository_endpoint.call_with_http_info(**kwargs) - def delete_repository( + def get_branch_protection_rules( self, repository, **kwargs ): - """delete repository # noqa: E501 + """get branch protection rules # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.delete_repository(repository, async_req=True) + >>> thread = api.get_branch_protection_rules(repository, async_req=True) >>> result = thread.get() Args: @@ -759,7 +866,7 @@ def delete_repository( async_req (bool): execute request asynchronously Returns: - None + [BranchProtectionRule] If the method is called asynchronously, returns the request thread. """ @@ -784,19 +891,19 @@ def delete_repository( kwargs['_host_index'] = kwargs.get('_host_index') kwargs['repository'] = \ repository - return self.delete_repository_endpoint.call_with_http_info(**kwargs) + return self.get_branch_protection_rules_endpoint.call_with_http_info(**kwargs) - def get_branch_protection_rules( + def get_gc_rules( self, repository, **kwargs ): - """get branch protection rules # noqa: E501 + """get repository GC rules # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True - >>> thread = api.get_branch_protection_rules(repository, async_req=True) + >>> thread = api.get_gc_rules(repository, async_req=True) >>> result = thread.get() Args: @@ -824,7 +931,7 @@ def get_branch_protection_rules( async_req (bool): execute request asynchronously Returns: - [BranchProtectionRule] + GarbageCollectionRules If the method is called asynchronously, returns the request thread. """ @@ -849,7 +956,7 @@ def get_branch_protection_rules( kwargs['_host_index'] = kwargs.get('_host_index') kwargs['repository'] = \ repository - return self.get_branch_protection_rules_endpoint.call_with_http_info(**kwargs) + return self.get_gc_rules_endpoint.call_with_http_info(**kwargs) def get_repository( self, @@ -1044,3 +1151,142 @@ def list_repositories( kwargs['_host_index'] = kwargs.get('_host_index') return self.list_repositories_endpoint.call_with_http_info(**kwargs) + def set_branch_protection_rules( + self, + repository, + branch_protection_rule, + **kwargs + ): + """set_branch_protection_rules # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.set_branch_protection_rules(repository, branch_protection_rule, async_req=True) + >>> result = thread.get() + + Args: + repository (str): + branch_protection_rule ([BranchProtectionRule]): + + Keyword Args: + if_match (str): if provided, the branch protection rules will be updated only if the current ETag match the provided value. [optional] + _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: + None + 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['branch_protection_rule'] = \ + branch_protection_rule + return self.set_branch_protection_rules_endpoint.call_with_http_info(**kwargs) + + def set_gc_rules( + self, + repository, + garbage_collection_rules, + **kwargs + ): + """set_gc_rules # noqa: E501 + + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + + >>> thread = api.set_gc_rules(repository, garbage_collection_rules, async_req=True) + >>> result = thread.get() + + Args: + repository (str): + garbage_collection_rules (GarbageCollectionRules): + + 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: + None + 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['garbage_collection_rules'] = \ + garbage_collection_rules + return self.set_gc_rules_endpoint.call_with_http_info(**kwargs) + diff --git a/clients/python/lakefs_client/api/retention_api.py b/clients/python/lakefs_client/api/retention_api.py index 80fc6f965ac..8d16477b497 100644 --- a/clients/python/lakefs_client/api/retention_api.py +++ b/clients/python/lakefs_client/api/retention_api.py @@ -24,7 +24,6 @@ ) from lakefs_client.model.error import Error from lakefs_client.model.garbage_collection_prepare_response import GarbageCollectionPrepareResponse -from lakefs_client.model.garbage_collection_rules import GarbageCollectionRules from lakefs_client.model.prepare_gc_uncommitted_request import PrepareGCUncommittedRequest from lakefs_client.model.prepare_gc_uncommitted_response import PrepareGCUncommittedResponse @@ -40,116 +39,6 @@ def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() self.api_client = api_client - self.delete_garbage_collection_rules_endpoint = _Endpoint( - settings={ - 'response_type': None, - 'auth': [ - 'basic_auth', - 'cookie_auth', - 'jwt_token', - 'oidc_auth', - 'saml_auth' - ], - 'endpoint_path': '/repositories/{repository}/gc/rules', - 'operation_id': 'delete_garbage_collection_rules', - 'http_method': 'DELETE', - '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_garbage_collection_rules_endpoint = _Endpoint( - settings={ - 'response_type': (GarbageCollectionRules,), - 'auth': [ - 'basic_auth', - 'cookie_auth', - 'jwt_token', - 'oidc_auth', - 'saml_auth' - ], - 'endpoint_path': '/repositories/{repository}/gc/rules', - 'operation_id': 'get_garbage_collection_rules', - 'http_method': 'GET', - '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.prepare_garbage_collection_commits_endpoint = _Endpoint( settings={ 'response_type': (GarbageCollectionPrepareResponse,), @@ -266,198 +155,6 @@ def __init__(self, api_client=None): }, api_client=api_client ) - self.set_garbage_collection_rules_endpoint = _Endpoint( - settings={ - 'response_type': None, - 'auth': [ - 'basic_auth', - 'cookie_auth', - 'jwt_token', - 'oidc_auth', - 'saml_auth' - ], - 'endpoint_path': '/repositories/{repository}/gc/rules', - 'operation_id': 'set_garbage_collection_rules', - 'http_method': 'POST', - 'servers': None, - }, - params_map={ - 'all': [ - 'repository', - 'garbage_collection_rules', - ], - 'required': [ - 'repository', - 'garbage_collection_rules', - ], - 'nullable': [ - ], - 'enum': [ - ], - 'validation': [ - ] - }, - root_map={ - 'validations': { - }, - 'allowed_values': { - }, - 'openapi_types': { - 'repository': - (str,), - 'garbage_collection_rules': - (GarbageCollectionRules,), - }, - 'attribute_map': { - 'repository': 'repository', - }, - 'location_map': { - 'repository': 'path', - 'garbage_collection_rules': 'body', - }, - 'collection_format_map': { - } - }, - headers_map={ - 'accept': [ - 'application/json' - ], - 'content_type': [ - 'application/json' - ] - }, - api_client=api_client - ) - - def delete_garbage_collection_rules( - self, - repository, - **kwargs - ): - """delete_garbage_collection_rules # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.delete_garbage_collection_rules(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: - None - 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.delete_garbage_collection_rules_endpoint.call_with_http_info(**kwargs) - - def get_garbage_collection_rules( - self, - repository, - **kwargs - ): - """get_garbage_collection_rules # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.get_garbage_collection_rules(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: - GarbageCollectionRules - 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.get_garbage_collection_rules_endpoint.call_with_http_info(**kwargs) def prepare_garbage_collection_commits( self, @@ -590,72 +287,3 @@ def prepare_garbage_collection_uncommitted( repository return self.prepare_garbage_collection_uncommitted_endpoint.call_with_http_info(**kwargs) - def set_garbage_collection_rules( - self, - repository, - garbage_collection_rules, - **kwargs - ): - """set_garbage_collection_rules # noqa: E501 - - This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, please pass async_req=True - - >>> thread = api.set_garbage_collection_rules(repository, garbage_collection_rules, async_req=True) - >>> result = thread.get() - - Args: - repository (str): - garbage_collection_rules (GarbageCollectionRules): - - 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: - None - 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['garbage_collection_rules'] = \ - garbage_collection_rules - return self.set_garbage_collection_rules_endpoint.call_with_http_info(**kwargs) - diff --git a/clients/python/test/test_config_api.py b/clients/python/test/test_config_api.py index cb1cac81ed4..e9e31c52fb1 100644 --- a/clients/python/test/test_config_api.py +++ b/clients/python/test/test_config_api.py @@ -30,12 +30,6 @@ def test_get_config(self): """ pass - def test_get_garbage_collection_config(self): - """Test case for get_garbage_collection_config - - """ - pass - if __name__ == '__main__': unittest.main() diff --git a/clients/python/test/test_internal_api.py b/clients/python/test/test_internal_api.py index 711f6d08cdb..0067d08468f 100644 --- a/clients/python/test/test_internal_api.py +++ b/clients/python/test/test_internal_api.py @@ -51,6 +51,12 @@ def test_get_auth_capabilities(self): """ pass + def test_get_garbage_collection_config(self): + """Test case for get_garbage_collection_config + + """ + pass + def test_get_lake_fs_version(self): """Test case for get_lake_fs_version @@ -70,6 +76,43 @@ def test_get_storage_config(self): """ pass + def test_internal_create_branch_protection_rule(self): + """Test case for internal_create_branch_protection_rule + + """ + pass + + def test_internal_delete_branch_protection_rule(self): + """Test case for internal_delete_branch_protection_rule + + """ + pass + + def test_internal_delete_garbage_collection_rules(self): + """Test case for internal_delete_garbage_collection_rules + + """ + pass + + def test_internal_get_branch_protection_rules(self): + """Test case for internal_get_branch_protection_rules + + get branch protection rules # noqa: E501 + """ + pass + + def test_internal_get_garbage_collection_rules(self): + """Test case for internal_get_garbage_collection_rules + + """ + pass + + def test_internal_set_garbage_collection_rules(self): + """Test case for internal_set_garbage_collection_rules + + """ + pass + def test_post_stats_events(self): """Test case for post_stats_events diff --git a/clients/python/test/test_repositories_api.py b/clients/python/test/test_repositories_api.py index 39ee3935b29..aa67244d876 100644 --- a/clients/python/test/test_repositories_api.py +++ b/clients/python/test/test_repositories_api.py @@ -24,12 +24,6 @@ def setUp(self): def tearDown(self): pass - def test_create_branch_protection_rule(self): - """Test case for create_branch_protection_rule - - """ - pass - def test_create_repository(self): """Test case for create_repository @@ -37,8 +31,8 @@ def test_create_repository(self): """ pass - def test_delete_branch_protection_rule(self): - """Test case for delete_branch_protection_rule + def test_delete_gc_rules(self): + """Test case for delete_gc_rules """ pass @@ -57,6 +51,13 @@ def test_get_branch_protection_rules(self): """ pass + def test_get_gc_rules(self): + """Test case for get_gc_rules + + get repository GC rules # noqa: E501 + """ + pass + def test_get_repository(self): """Test case for get_repository @@ -78,6 +79,18 @@ def test_list_repositories(self): """ pass + def test_set_branch_protection_rules(self): + """Test case for set_branch_protection_rules + + """ + pass + + def test_set_gc_rules(self): + """Test case for set_gc_rules + + """ + pass + if __name__ == '__main__': unittest.main() diff --git a/clients/python/test/test_retention_api.py b/clients/python/test/test_retention_api.py index f9d7792124c..d3ed880e00f 100644 --- a/clients/python/test/test_retention_api.py +++ b/clients/python/test/test_retention_api.py @@ -24,18 +24,6 @@ def setUp(self): def tearDown(self): pass - def test_delete_garbage_collection_rules(self): - """Test case for delete_garbage_collection_rules - - """ - pass - - def test_get_garbage_collection_rules(self): - """Test case for get_garbage_collection_rules - - """ - pass - def test_prepare_garbage_collection_commits(self): """Test case for prepare_garbage_collection_commits @@ -50,12 +38,6 @@ def test_prepare_garbage_collection_uncommitted(self): """ pass - def test_set_garbage_collection_rules(self): - """Test case for set_garbage_collection_rules - - """ - pass - if __name__ == '__main__': unittest.main() diff --git a/cmd/lakectl/cmd/branch_protect.go b/cmd/lakectl/cmd/branch_protect.go index 512e17393a2..989ad65b0a3 100644 --- a/cmd/lakectl/cmd/branch_protect.go +++ b/cmd/lakectl/cmd/branch_protect.go @@ -1,11 +1,12 @@ package cmd import ( - "fmt" "net/http" + "github.com/go-openapi/swag" "github.com/spf13/cobra" "github.com/treeverse/lakefs/pkg/api/apigen" + "golang.org/x/exp/slices" ) const ( @@ -54,11 +55,17 @@ var branchProtectAddCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { client := getClient() u := MustParseRepoURI("repository", args[0]) - resp, err := client.CreateBranchProtectionRuleWithResponse(cmd.Context(), u.Repository, apigen.CreateBranchProtectionRuleJSONRequestBody{ + resp, err := client.GetBranchProtectionRulesWithResponse(cmd.Context(), u.Repository) + + DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) + rules := *resp.JSON200 + rules = append(rules, apigen.BranchProtectionRule{ Pattern: args[1], }) - DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusNoContent) - fmt.Printf("Branch protection rule added to '%s' repository.\n", u.Repository) + setResp, err := client.SetBranchProtectionRulesWithResponse(cmd.Context(), u.Repository, &apigen.SetBranchProtectionRulesParams{ + IfMatch: swag.String(resp.HTTPResponse.Header.Get("ETag")), + }, rules) + DieOnErrorOrUnexpectedStatusCode(setResp, err, http.StatusNoContent) }, } @@ -72,11 +79,23 @@ var branchProtectDeleteCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { client := getClient() u := MustParseRepoURI("repository", args[0]) - resp, err := client.DeleteBranchProtectionRuleWithResponse(cmd.Context(), u.Repository, apigen.DeleteBranchProtectionRuleJSONRequestBody{ - Pattern: args[1], + resp, err := client.GetBranchProtectionRulesWithResponse(cmd.Context(), u.Repository) + DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) + found := false + rules := slices.DeleteFunc(*resp.JSON200, func(rule apigen.BranchProtectionRule) bool { + if rule.Pattern == args[1] { + found = true + return true + } + return false }) - DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusNoContent) - fmt.Printf("Branch protection rule deleted from '%s' repository.\n", u.Repository) + if !found { + Die("Branch protection rule not found", 1) + } + setResp, err := client.SetBranchProtectionRulesWithResponse(cmd.Context(), u.Repository, &apigen.SetBranchProtectionRulesParams{ + IfMatch: swag.String(resp.HTTPResponse.Header.Get("ETag")), + }, rules) + DieOnErrorOrUnexpectedStatusCode(setResp, err, http.StatusNoContent) }, } diff --git a/cmd/lakectl/cmd/gc_delete_config.go b/cmd/lakectl/cmd/gc_delete_config.go index a260d4f4147..9747afaeac5 100644 --- a/cmd/lakectl/cmd/gc_delete_config.go +++ b/cmd/lakectl/cmd/gc_delete_config.go @@ -17,7 +17,7 @@ var gcDeleteConfigCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { u := MustParseRepoURI("repository", args[0]) client := getClient() - resp, err := client.DeleteGarbageCollectionRulesWithResponse(cmd.Context(), u.Repository) + resp, err := client.DeleteGCRulesWithResponse(cmd.Context(), u.Repository) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusNoContent) }, } diff --git a/cmd/lakectl/cmd/gc_get_config.go b/cmd/lakectl/cmd/gc_get_config.go index 283decb9f67..0c42b871e74 100644 --- a/cmd/lakectl/cmd/gc_get_config.go +++ b/cmd/lakectl/cmd/gc_get_config.go @@ -24,7 +24,7 @@ var gcGetConfigCmd = &cobra.Command{ u := MustParseRepoURI("repository", args[0]) isJSON := Must(cmd.Flags().GetBool(jsonFlagName)) client := getClient() - resp, err := client.GetGarbageCollectionRulesWithResponse(cmd.Context(), u.Repository) + resp, err := client.GetGCRulesWithResponse(cmd.Context(), u.Repository) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) if resp.JSON200 == nil { Die("Bad response from server", 1) diff --git a/cmd/lakectl/cmd/gc_set_config.go b/cmd/lakectl/cmd/gc_set_config.go index 9323123a6c1..515c155bdb6 100644 --- a/cmd/lakectl/cmd/gc_set_config.go +++ b/cmd/lakectl/cmd/gc_set_config.go @@ -51,13 +51,13 @@ Example configuration file: _ = reader.Close() }() } - var body apigen.SetGarbageCollectionRulesJSONRequestBody + var body apigen.SetGCRulesJSONRequestBody err = json.NewDecoder(reader).Decode(&body) if err != nil { DieErr(err) } client := getClient() - resp, err := client.SetGarbageCollectionRulesWithResponse(cmd.Context(), u.Repository, body) + resp, err := client.SetGCRules(cmd.Context(), u.Repository, body) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusNoContent) }, } diff --git a/docs/assets/js/swagger.yml b/docs/assets/js/swagger.yml index 84852f17453..6c660866ed6 100644 --- a/docs/assets/js/swagger.yml +++ b/docs/assets/js/swagger.yml @@ -2329,6 +2329,130 @@ paths: default: $ref: "#/components/responses/ServerError" + /repositories/{repository}/settings/gc_rules: + parameters: + - in: path + name: repository + required: true + schema: + type: string + get: + tags: + - repositories + operationId: getGCRules + summary: get repository GC rules + responses: + 200: + description: repository GC rules + content: + application/json: + schema: + $ref: "#/components/schemas/GarbageCollectionRules" + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + default: + $ref: "#/components/responses/ServerError" + put: + tags: + - repositories + operationId: setGCRules + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/GarbageCollectionRules" + responses: + 204: + description: set garbage collection rules successfully + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + default: + $ref: "#/components/responses/ServerError" + delete: + tags: + - repositories + operationId: deleteGCRules + responses: + 204: + description: deleted garbage collection rules successfully + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + default: + $ref: "#/components/responses/ServerError" + + /repositories/{repository}/settings/branch_protection: + parameters: + - in: path + name: repository + required: true + schema: + type: string + get: + tags: + - repositories + operationId: getBranchProtectionRules + summary: get branch protection rules + responses: + 200: + description: branch protection rules + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/BranchProtectionRule" + headers: + ETag: + schema: + type: string + description: ETag of the branch protection rules + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + default: + $ref: "#/components/responses/ServerError" + + put: + parameters: + - in: header + name: If-Match + schema: + type: string + description: if provided, the branch protection rules will be updated only if the current ETag match the provided value + allowEmptyValue: true + tags: + - repositories + operationId: setBranchProtectionRules + requestBody: + required: true + content: + application/json: + schema: + type: array + items: + $ref: "#/components/schemas/BranchProtectionRule" + responses: + 204: + description: branch protection rule created successfully + 400: + $ref: "#/components/responses/BadRequest" + 401: + $ref: "#/components/responses/Unauthorized" + 404: + $ref: "#/components/responses/NotFound" + 412: + $ref: "#/components/responses/PreconditionFailed" + default: + $ref: "#/components/responses/ServerError" + /otf/diffs: get: tags: @@ -4068,9 +4192,10 @@ paths: schema: type: string get: + deprecated: true tags: - - retention - operationId: getGarbageCollectionRules + - internal + operationId: internalGetGarbageCollectionRules responses: 200: description: gc rule list @@ -4086,9 +4211,10 @@ paths: $ref: "#/components/responses/ServerError" post: + deprecated: true tags: - - retention - operationId: set garbage collection rules + - internal + operationId: internalSetGarbageCollectionRules requestBody: required: true content: @@ -4105,9 +4231,10 @@ paths: default: $ref: "#/components/responses/ServerError" delete: + deprecated: true tags: - - retention - operationId: delete garbage collection rules + - internal + operationId: internalDeleteGarbageCollectionRules responses: 204: description: deleted garbage collection rules successfully @@ -4208,9 +4335,10 @@ paths: schema: type: string get: + deprecated: true tags: - - repositories - operationId: getBranchProtectionRules + - internal + operationId: internalGetBranchProtectionRules summary: get branch protection rules responses: 200: @@ -4229,9 +4357,10 @@ paths: $ref: "#/components/responses/ServerError" post: + deprecated: true tags: - - repositories - operationId: createBranchProtectionRule + - internal + operationId: internalCreateBranchProtectionRule requestBody: required: true content: @@ -4248,9 +4377,10 @@ paths: default: $ref: "#/components/responses/ServerError" delete: + deprecated: true tags: - - repositories - operationId: deleteBranchProtectionRule + - internal + operationId: internalDeleteBranchProtectionRule requestBody: required: true content: @@ -4331,7 +4461,7 @@ paths: /config/garbage-collection: get: tags: - - config + - internal operationId: getGarbageCollectionConfig description: get information of gc settings responses: diff --git a/esti/gc_test.go b/esti/gc_test.go deleted file mode 100644 index eacc4386dfc..00000000000 --- a/esti/gc_test.go +++ /dev/null @@ -1,315 +0,0 @@ -package esti - -import ( - "context" - "fmt" - "testing" - "time" - - "github.com/spf13/viper" - "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/block" - "github.com/treeverse/lakefs/pkg/config" - "github.com/treeverse/lakefs/pkg/testutil" -) - -type GCMode int - -const ( - fullGCMode GCMode = iota - markOnlyMode - sweepOnlyMode -) - -const ( - committedGCRepoName = "gc" -) - -var ( - currentEpochInSeconds = time.Now().Unix() - dayInSeconds = int64(100000) // rounded up from 86400 -) - -type testCase struct { - id string - policy apigen.GarbageCollectionRules - branches []branchProperty - fileDeleted bool - description string - directUpload bool - testMode GCMode -} - -type branchProperty struct { - name string - deleteCommitDaysAgo int64 -} - -var testCases = []testCase{ - { - id: "1", - policy: apigen.GarbageCollectionRules{Branches: []apigen.GarbageCollectionRule{}, DefaultRetentionDays: 1}, - branches: []branchProperty{ - {name: "a1", deleteCommitDaysAgo: 2}, {name: "b1", deleteCommitDaysAgo: 2}, - }, - fileDeleted: true, - description: "The file is deleted according to the default retention policy", - directUpload: false, - }, - { - id: "2", - policy: apigen.GarbageCollectionRules{Branches: []apigen.GarbageCollectionRule{{BranchId: "a2", RetentionDays: 1}, {BranchId: "b2", RetentionDays: 3}}, DefaultRetentionDays: 5}, - branches: []branchProperty{ - {name: "a2", deleteCommitDaysAgo: 4}, {name: "b2", deleteCommitDaysAgo: 4}, - }, - fileDeleted: true, - description: "The file is deleted according to branches' retention policies", - directUpload: false, - }, - { - id: "3", - policy: apigen.GarbageCollectionRules{Branches: []apigen.GarbageCollectionRule{{BranchId: "a3", RetentionDays: 1}, {BranchId: "b3", RetentionDays: 3}}, DefaultRetentionDays: 5}, - branches: []branchProperty{ - {name: "a3", deleteCommitDaysAgo: 4}, {name: "b3", deleteCommitDaysAgo: 2}, - }, - fileDeleted: false, - description: "The file is not deleted because of the retention policy of the second branch", - directUpload: false, - }, - { - id: "4", - policy: apigen.GarbageCollectionRules{Branches: []apigen.GarbageCollectionRule{}, DefaultRetentionDays: 5}, - branches: []branchProperty{ - {name: "a4", deleteCommitDaysAgo: 4}, {name: "b4", deleteCommitDaysAgo: 2}, - }, - fileDeleted: false, - description: "The file isn't deleted according to default retention policy", - directUpload: false, - }, - { - id: "5", - policy: apigen.GarbageCollectionRules{Branches: []apigen.GarbageCollectionRule{{BranchId: "a5", RetentionDays: 1}, {BranchId: "b5", RetentionDays: 3}}, DefaultRetentionDays: 5}, - branches: []branchProperty{ - {name: "a5", deleteCommitDaysAgo: 1}, - }, - fileDeleted: false, - description: "The file is not deleted as it still exists in the second branch", - directUpload: false, - }, - { - id: "6", - policy: apigen.GarbageCollectionRules{Branches: []apigen.GarbageCollectionRule{{BranchId: "a6", RetentionDays: 1}}, DefaultRetentionDays: 5}, - branches: []branchProperty{ - {name: "a6", deleteCommitDaysAgo: 1}, {name: "b6", deleteCommitDaysAgo: 4}, - }, - fileDeleted: false, - description: "The file is not deleted because default retention time keeps it for the second branch", - directUpload: false, - }, - { - id: "7", - policy: apigen.GarbageCollectionRules{Branches: []apigen.GarbageCollectionRule{{BranchId: "a7", RetentionDays: 1}}, DefaultRetentionDays: 5}, - branches: []branchProperty{ - {name: "a7", deleteCommitDaysAgo: 1}, {name: "b7", deleteCommitDaysAgo: 5}, - }, - fileDeleted: true, - description: "The file is deleted as the retention policy for the branch permits the deletion from the branch, and the default retention policy permits deletion for the second branch", - directUpload: false, - }, - { - id: "8", - policy: apigen.GarbageCollectionRules{Branches: []apigen.GarbageCollectionRule{{BranchId: "a8", RetentionDays: 3}}, DefaultRetentionDays: 1}, - branches: []branchProperty{ - {name: "a8", deleteCommitDaysAgo: 2}, {name: "b8", deleteCommitDaysAgo: -1}, - }, - fileDeleted: false, - description: "The file (direct upload) is not deleted as the branch retention policy overrules the default retention policy", - directUpload: true, - }, - { - id: "9", - policy: apigen.GarbageCollectionRules{Branches: []apigen.GarbageCollectionRule{}, DefaultRetentionDays: 1}, - branches: []branchProperty{ - {name: "a9", deleteCommitDaysAgo: -1}, {name: "b9", deleteCommitDaysAgo: -1}, - }, - fileDeleted: true, - description: "The file (direct upload) is deleted because it's in a dangling commit and the default retention policy has passed", - directUpload: true, - }, - { - id: "10", - policy: apigen.GarbageCollectionRules{Branches: []apigen.GarbageCollectionRule{}, DefaultRetentionDays: 1}, - branches: []branchProperty{ - {name: "a10", deleteCommitDaysAgo: -1}, {name: "b10", deleteCommitDaysAgo: -1}, - }, - fileDeleted: false, - description: "The file (direct upload) is only marked for deletion (not actually deleted)", - directUpload: true, - testMode: markOnlyMode, - }, - { - id: "11", - policy: apigen.GarbageCollectionRules{Branches: []apigen.GarbageCollectionRule{}, DefaultRetentionDays: 1}, - branches: []branchProperty{ - {name: "a11", deleteCommitDaysAgo: -1}, {name: "b11", deleteCommitDaysAgo: -1}, - }, - fileDeleted: true, - description: "The file (direct upload) is swept after it's first marked", - directUpload: true, - testMode: sweepOnlyMode, - }, -} - -func newSubmitConfig(repo string, blockstoreType string, doMark bool, doSweep bool) *sparkSubmitConfig { - extraSubmitArgs := make([]string, 0) - if !doMark { - extraSubmitArgs = append(extraSubmitArgs, - "--conf", "spark.hadoop.lakefs.gc.do_mark=false", - "--conf", fmt.Sprintf("spark.hadoop.lakefs.gc.mark_id=marker-%s", repo)) - } - if !doSweep { - extraSubmitArgs = append(extraSubmitArgs, - "--conf", "spark.hadoop.lakefs.gc.do_sweep=false", - "--conf", fmt.Sprintf("spark.hadoop.lakefs.gc.mark_id=marker-%s", repo)) - } - if blockstoreType == block.BlockstoreTypeAzure { - extraSubmitArgs = append(extraSubmitArgs, - "--packages", "org.apache.hadoop:hadoop-azure:3.2.1", - "--conf", "spark.hadoop.lakefs.api.connection.timeout_seconds=3", "--conf", "spark.hadoop.lakefs.api.read.timeout_seconds=8", - "--conf", fmt.Sprintf("spark.hadoop.fs.azure.account.key.%s.dfs.core.windows.net=%s", azureStorageAccount, azureStorageAccessKey)) - } - extraSubmitArgs = append(extraSubmitArgs, - "--conf", "spark.hadoop.lakefs.gc.commit.num_partitions=1", - "--conf", "spark.hadoop.lakefs.gc.range.num_partitions=8", - "--conf", "spark.hadoop.lakefs.gc.address.num_partitions=16") - return &sparkSubmitConfig{ - sparkVersion: sparkImageTag, - localJar: metaClientJarPath, - entryPoint: "io.treeverse.clients.GarbageCollector", - extraSubmitArgs: extraSubmitArgs, - programArgs: []string{repo, "us-east-1"}, - logSource: fmt.Sprintf("gc-%s", repo), - } -} - -func TestCommittedGC(t *testing.T) { - blockstoreType := viper.GetString(config.BlockstoreTypeKey) - logger.Infof("Got blockstore type %s", blockstoreType) - ctx := context.Background() - for _, tst := range testCases { - tst := tst // re-define tst to be in the scope of the closure. See: https://gist.github.com/posener/92a55c4cd441fc5e5e85f27bca008721 - t.Run(fmt.Sprintf("Test case %s", tst.id), func(t *testing.T) { - fileExistingRef := prepareForGC(t, ctx, &tst, blockstoreType) - t.Parallel() - t.Logf("fileExistingRef %s", fileExistingRef) - repo := committedGCRepoName + tst.id - - if tst.testMode == sweepOnlyMode || tst.testMode == markOnlyMode { - submitConfig := newSubmitConfig(repo, blockstoreType, true, false) - testutil.MustDo(t, "run GC with do_sweep=false", runSparkSubmit(submitConfig)) - } - if tst.testMode == sweepOnlyMode { - submitConfig := newSubmitConfig(repo, blockstoreType, false, true) - testutil.MustDo(t, "run GC with do_mark=false", runSparkSubmit(submitConfig)) - } - if tst.testMode == fullGCMode { - submitConfig := newSubmitConfig(repo, blockstoreType, true, true) - testutil.MustDo(t, "run GC", runSparkSubmit(submitConfig)) - } - validateGCJob(t, ctx, &tst, fileExistingRef) - }) - } -} - -func prepareForGC(t *testing.T, ctx context.Context, testCase *testCase, blockstoreType string) string { - repo := createRepositoryByName(ctx, t, committedGCRepoName+testCase.id) - - // upload 3 files not to be deleted and commit - _, _ = uploadFileRandomData(ctx, t, repo, mainBranch, "not_deleted_file1") - _, _ = uploadFileRandomData(ctx, t, repo, mainBranch, "not_deleted_file2") - _, _ = uploadFileRandomData(ctx, t, repo, mainBranch, "not_deleted_file3") - - commitTime := int64(0) - _, err := client.CommitWithResponse(ctx, repo, mainBranch, &apigen.CommitParams{}, apigen.CommitJSONRequestBody{Message: "add three files not to be deleted", Date: &commitTime}) - if err != nil { - t.Fatalf("Commit some data %s", err) - } - - newBranch := "a" + testCase.id - _, err = client.CreateBranchWithResponse(ctx, repo, apigen.CreateBranchJSONRequestBody{Name: newBranch, Source: mainBranch}) - if err != nil { - t.Fatalf("Create new branch %s", err) - } - - objPath := "file" + testCase.id - if testCase.directUpload && blockstoreType == block.BlockstoreTypeS3 { - _, _ = uploadFileRandomDataDirect(ctx, t, repo, newBranch, objPath) - } else { - _, _ = uploadFileRandomData(ctx, t, repo, newBranch, objPath) - } - commitTime = int64(10) - - // get commit id after commit for the validation step in the tests - commitRes, err := client.CommitWithResponse(ctx, repo, newBranch, &apigen.CommitParams{}, apigen.CommitJSONRequestBody{Message: "Uploaded file" + testCase.id, Date: &commitTime}) - if err != nil || commitRes.StatusCode() != 201 { - t.Fatalf("Commit some data %s", err) - } - commit := commitRes.JSON201 - commitID := commit.Id - - _, err = client.CreateBranchWithResponse(ctx, repo, apigen.CreateBranchJSONRequestBody{Name: "b" + testCase.id, Source: newBranch}) - if err != nil { - t.Fatalf("Create new branch %s", err) - } - - _, err = client.SetGarbageCollectionRulesWithResponse(ctx, repo, apigen.SetGarbageCollectionRulesJSONRequestBody{Branches: testCase.policy.Branches, DefaultRetentionDays: testCase.policy.DefaultRetentionDays}) - if err != nil { - t.Fatalf("Set GC rules %s", err) - } - - for _, branch := range testCase.branches { - if branch.deleteCommitDaysAgo > -1 { - _, err = client.DeleteObjectWithResponse(ctx, repo, branch.name, &apigen.DeleteObjectParams{Path: objPath}) - if err != nil { - t.Fatalf("DeleteObject %s", err) - } - epochCommitDateInSeconds := currentEpochInSeconds - (dayInSeconds * branch.deleteCommitDaysAgo) - _, err = client.CommitWithResponse(ctx, repo, branch.name, &apigen.CommitParams{}, apigen.CommitJSONRequestBody{Message: "Deleted file" + testCase.id, Date: &epochCommitDateInSeconds}) - if err != nil { - t.Fatalf("Commit some data %s", err) - } - _, _ = uploadFileRandomData(ctx, t, repo, branch.name, objPath+"not_deleted") - // This is for the previous commit to be the HEAD of the branch outside the retention time (according to GC https://github.com/treeverse/lakeFS/issues/1932) - _, err = client.CommitWithResponse(ctx, repo, branch.name, &apigen.CommitParams{}, apigen.CommitJSONRequestBody{Message: "not deleted file commit: " + testCase.id, Date: &epochCommitDateInSeconds}) - if err != nil { - t.Fatalf("Commit some data %s", err) - } - } else { - _, err = client.DeleteBranchWithResponse(ctx, repo, branch.name) - if err != nil { - t.Fatalf("Delete brach %s", err) - } - } - } - return commitID -} - -func validateGCJob(t *testing.T, ctx context.Context, testCase *testCase, existingRef string) { - repo := committedGCRepoName + testCase.id - - res, _ := client.GetObjectWithResponse(ctx, repo, existingRef, &apigen.GetObjectParams{Path: "file" + testCase.id}) - fileExists := res.StatusCode() == 200 - - if fileExists && testCase.fileDeleted { - t.Errorf("Expected the file to be removed by the garbage collector but it has remained in the repository. Test case '%s'. Test description '%s'", testCase.id, testCase.description) - } else if !fileExists && !testCase.fileDeleted { - t.Errorf("Expected the file to remain in the repository but it was removed by the garbage collector. Test case '%s'. Test description '%s'", testCase.id, testCase.description) - } - locations := []string{"not_deleted_file1", "not_deleted_file2", "not_deleted_file3"} - for _, location := range locations { - res, _ = client.GetObjectWithResponse(ctx, repo, "main", &apigen.GetObjectParams{Path: location}) - if res.StatusCode() != 200 { - t.Errorf("expected '%s' to exist. Test case '%s', Test description '%s'", location, testCase.id, testCase.description) - } - } -} diff --git a/esti/ugc_test.go b/esti/ugc_test.go deleted file mode 100644 index 4e14dd20dab..00000000000 --- a/esti/ugc_test.go +++ /dev/null @@ -1,394 +0,0 @@ -package esti - -import ( - "bytes" - "context" - "encoding/json" - "fmt" - "net/http" - "os" - "path/filepath" - "strconv" - "strings" - "sync" - "testing" - "time" - - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/config" - "github.com/aws/aws-sdk-go-v2/service/s3" - "github.com/rs/xid" - "github.com/treeverse/lakefs/pkg/api/apigen" - "github.com/treeverse/lakefs/pkg/block" - blocks3 "github.com/treeverse/lakefs/pkg/block/s3" - "github.com/treeverse/lakefs/pkg/testutil" - "golang.org/x/exp/slices" -) - -const ( - uncommittedGCRepoName = "ugc" - ugcFindingsFilename = "ugc-findings.json" -) - -type UncommittedFindings struct { - All []Object - Deleted []string - preLinkAddress apigen.StagingLocation -} - -func TestUncommittedGC(t *testing.T) { - requireBlockstoreType(t, block.BlockstoreTypeS3) - ctx := context.Background() - prepareForUncommittedGC(t, ctx) - - // upload files while ugc is running - ticker := time.NewTicker(time.Second) - var durObjects []string - done := make(chan bool) - - var wg sync.WaitGroup - wg.Add(1) - go func() { - defer wg.Done() - for { - select { - case <-done: - ticker.Stop() - return - case <-ticker.C: - obj := uploadAndDeleteSafeTestData(t, ctx, uncommittedGCRepoName) - durObjects = append(durObjects, obj) - } - } - }() - - submitConfig := &sparkSubmitConfig{ - sparkVersion: sparkImageTag, - localJar: metaClientJarPath, - entryPoint: "io.treeverse.gc.UncommittedGarbageCollector", - extraSubmitArgs: []string{"--conf", "spark.hadoop.lakefs.debug.gc.uncommitted_min_age_seconds=1"}, - programArgs: []string{uncommittedGCRepoName, "us-east-1"}, - logSource: "ugc", - } - testutil.MustDo(t, "run uncommitted GC", runSparkSubmit(submitConfig)) - done <- true - wg.Wait() - - validateUncommittedGC(t, durObjects) -} - -func prepareForUncommittedGC(t *testing.T, ctx context.Context) { - repo := createRepositoryByName(ctx, t, uncommittedGCRepoName) - var gone []string - - // upload some data and commit - for i := 0; i < 3; i++ { - _, _ = uploadFileRandomData(ctx, t, repo, mainBranch, "committed/data-"+strconv.Itoa(i)) - _, _ = uploadFileRandomDataDirect(ctx, t, repo, mainBranch, "committed/data-direct-"+strconv.Itoa(i)) - } - _, err := client.CommitWithResponse(ctx, repo, mainBranch, &apigen.CommitParams{}, apigen.CommitJSONRequestBody{Message: "Commit initial data"}) - if err != nil { - t.Fatal("Commit some data", err) - } - - // upload the same file twice and commit, keep delete physical location - for _, direct := range []bool{false, true} { - objPath := fmt.Sprintf("committed/double-or-nothing-%t", direct) - _, err = uploadFileAndReport(ctx, repo, mainBranch, objPath, objPath+"1", direct) - if err != nil { - t.Fatalf("Failed to upload double-or-nothing I: %s", err) - } - addr := objectPhysicalAddress(t, ctx, repo, objPath) - gone = append(gone, addr) - - _, err = uploadFileAndReport(ctx, repo, mainBranch, objPath, objPath+"2", direct) - if err != nil { - t.Fatalf("Failed to upload double-or-nothing II: %s", err) - } - _, err = client.CommitWithResponse(ctx, repo, mainBranch, &apigen.CommitParams{}, apigen.CommitJSONRequestBody{Message: "Commit initial data"}) - if err != nil { - t.Fatal("Commit single file uploaded twice", err) - } - } - - // upload uncommitted data - - for _, direct := range []bool{false, true} { - // just leave uncommitted data - _, _ = uploadFileRandomData(ctx, t, repo, mainBranch, fmt.Sprintf("uncommitted/data1-%t", direct)) - - // delete uncommitted - objPath := fmt.Sprintf("uncommitted/data2-%t", direct) - _, _ = uploadFileRandomData(ctx, t, repo, mainBranch, objPath) - - gone = append(gone, objectPhysicalAddress(t, ctx, repo, objPath)) - - delResp, err := client.DeleteObjectWithResponse(ctx, repo, mainBranch, &apigen.DeleteObjectParams{Path: objPath}) - if err != nil { - t.Fatalf("Delete object '%s' failed: %s", objPath, err) - } - if delResp.StatusCode() != http.StatusNoContent { - t.Fatalf("Delete object '%s' failed with status code %d", objPath, delResp.StatusCode()) - } - } - - // getting physical address before the ugc run and linking it after - getPhysicalResp, err := client.GetPhysicalAddressWithResponse(ctx, repo, mainBranch, &apigen.GetPhysicalAddressParams{Path: "foo/bar"}) - if err != nil { - t.Fatalf("Failed to get physical address %s", err) - } - if getPhysicalResp.JSON200 == nil { - t.Fatalf("Failed to get physical address information: status code %d", getPhysicalResp.StatusCode()) - } - - objects, _ := listRepositoryUnderlyingStorage(t, ctx, repo) - // write findings into a file - findings, err := json.MarshalIndent( - UncommittedFindings{ - All: objects, - Deleted: gone, - preLinkAddress: apigen.StagingLocation{ - PhysicalAddress: getPhysicalResp.JSON200.PhysicalAddress, - Token: getPhysicalResp.JSON200.Token, - }, - }, "", " ") - if err != nil { - t.Fatalf("failed to marshal findings: %s", err) - } - t.Logf("Findings: %s", findings) - findingsPath := findingFilePath() - err = os.WriteFile(findingsPath, findings, 0o666) - if err != nil { - t.Fatalf("Failed to write findings file '%s': %s", findingsPath, err) - } -} - -func findingFilePath() string { - return filepath.Join(os.TempDir(), ugcFindingsFilename) -} - -func objectPhysicalAddress(t *testing.T, ctx context.Context, repo, objPath string) string { - resp, err := client.StatObjectWithResponse(ctx, repo, mainBranch, &apigen.StatObjectParams{Path: objPath}) - if err != nil { - t.Fatalf("Failed to stat object '%s': %s", objPath, err) - } - if resp.JSON200 == nil { - t.Fatalf("Failed to stat object '%s': status code %d", objPath, resp.StatusCode()) - } - return resp.JSON200.PhysicalAddress -} - -func validateUncommittedGC(t *testing.T, durObjects []string) { - ctx := context.Background() - const repo = uncommittedGCRepoName - - findingPath := findingFilePath() - b, err := os.ReadFile(findingPath) - if err != nil { - t.Fatalf("Failed to read '%s': %s", findingPath, err) - } - var findings UncommittedFindings - err = json.Unmarshal(b, &findings) - if err != nil { - t.Fatalf("Failed to unmarshal findings '%s': %s", findingPath, err) - } - - // link the pre physical address - const expectedSizeBytes = 38 - _, err = client.LinkPhysicalAddressWithResponse(ctx, "repo1", "main", &apigen.LinkPhysicalAddressParams{ - Path: "foo/bar", - }, apigen.LinkPhysicalAddressJSONRequestBody{ - Checksum: "afb0689fe58b82c5f762991453edbbec", - SizeBytes: expectedSizeBytes, - Staging: apigen.StagingLocation{ - PhysicalAddress: findings.preLinkAddress.PhysicalAddress, - Token: findings.preLinkAddress.Token, - }, - }) - if err != nil { - t.Fatalf("Failed to link physical address %s", err) - } - - // list underlying storage - objects, qk := listRepositoryUnderlyingStorage(t, ctx, repo) - - // verify that all previous objects are found or deleted, if needed - for _, obj := range findings.All { - foundIt := slices.Contains(objects, obj) - expectDeleted := slices.Contains(findings.Deleted, obj.Key) - if foundIt && expectDeleted { - t.Errorf("Object '%s' FOUND - should have been deleted", obj) - } else if !foundIt && !expectDeleted { - t.Errorf("Object '%s' NOT FOUND - should NOT been deleted", obj) - } - } - - // verify that we do not have new objects - for _, obj := range objects { - // skip uncommitted retention reports - if strings.Contains(obj.Key, "/_lakefs/retention/gc/uncommitted/") { - continue - } - // verify we know this object - if !slices.Contains(findings.All, obj) && !slices.Contains(durObjects, obj.Key) { - t.Errorf("Object '%s' FOUND KNOWN - was not found pre ugc", obj) - } - } - - bucket, key := blocks3.ExtractParamsFromQK(qk) - s3Client := newDefaultS3Client(t) - runID := getLastUGCRunID(t, ctx, s3Client, bucket, key) - reportPath := fmt.Sprintf("%s_lakefs/retention/gc/uncommitted/%s/summary.json", key, runID) - cutoffTime, err := getReportCutoffTime(ctx, s3Client, bucket, reportPath) - if err != nil { - t.Fatalf("Failed to get start list time from ugc report %s", err) - } - - objectsMap := make(map[string]Object) - for _, obj := range objects { - objectsMap[obj.Key] = obj - } - - // Validation that deleted objects that were created after the cutoff are not deleted - // and that deleted objects that were created before the cutoff are deleted - for _, obj := range durObjects { - x, foundIt := objectsMap[obj] - expectDeleted := true - if foundIt { - expectDeleted = x.LastModified.Before(cutoffTime) - } - if foundIt && expectDeleted { - t.Errorf("Object '%s' FOUND - should have been deleted", obj) - } else if !foundIt && !expectDeleted { - t.Errorf("Object '%s' NOT FOUND - should NOT been deleted", obj) - } - } -} - -// listRepositoryUnderlyingStorage list on the repository storage namespace returns its objects, and the storage namespace -func listRepositoryUnderlyingStorage(t *testing.T, ctx context.Context, repo string) ([]Object, block.CommonQualifiedKey) { - // list all objects in the physical layer - repoResponse, err := client.GetRepositoryWithResponse(ctx, repo) - if err != nil { - t.Fatalf("Failed to get repository '%s' information: %s", repo, err) - } - if repoResponse.JSON200 == nil { - t.Fatalf("Failed to get repository '%s' information: status code %d", repo, repoResponse.StatusCode()) - } - - // list committed files and keep the physical paths - storageNamespace := repoResponse.JSON200.StorageNamespace - qk, err := block.DefaultResolveNamespace(storageNamespace, "", block.IdentifierTypeRelative) - if err != nil { - t.Fatalf("Failed to resolve namespace '%s': %s", storageNamespace, err) - } - - bucket, key := blocks3.ExtractParamsFromQK(qk) - s3Client := newDefaultS3Client(t) - objects := listUnderlyingStorage(t, ctx, s3Client, bucket, key) - return objects, qk -} - -func listUnderlyingStorage(t *testing.T, ctx context.Context, s3Client *s3.Client, bucket, prefix string) []Object { - listInput := &s3.ListObjectsInput{ - Bucket: aws.String(bucket), - Prefix: aws.String(prefix), - } - listOutput, err := s3Client.ListObjects(ctx, listInput) - if err != nil { - t.Fatalf("Failed to list objects (bucket: %s, prefix: %s): %s", bucket, prefix, err) - } - - // sorted list of objects found on repository - before ugc - var objects []Object - for _, obj := range listOutput.Contents { - objects = append(objects, Object{ - Key: fmt.Sprintf("s3://%s/%s", bucket, aws.ToString(obj.Key)), - LastModified: aws.ToTime(obj.LastModified), - }) - } - return objects -} - -type Object struct { - Key string - LastModified time.Time -} - -// newDefaultS3Client setup new s3 client for direct access to the underlying storage -func newDefaultS3Client(t *testing.T) *s3.Client { - cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRegion("us-east-1")) - if err != nil { - t.Fatalf("Failed to create aws config: %s", err) - } - return s3.NewFromConfig(cfg) -} - -func getLastUGCRunID(t *testing.T, ctx context.Context, s3Client *s3.Client, bucket, prefix string) string { - runIDPrefix := prefix + "_lakefs/retention/gc/uncommitted/" - listSize := int64(1) - listInput := &s3.ListObjectsInput{ - Bucket: aws.String(bucket), - Prefix: aws.String(runIDPrefix), - Delimiter: aws.String("/"), - MaxKeys: int32(listSize), - } - listOutput, err := s3Client.ListObjects(ctx, listInput) - if err != nil { - t.Fatalf("Failed to list objects (bucket: %s, prefix: %s): %s", bucket, runIDPrefix, err) - } - - if len(listOutput.CommonPrefixes) == 0 { - t.Fatalf("Failed to list last run id (bucket: %s, prefix: %s): %s", bucket, runIDPrefix, err) - } - key := strings.ReplaceAll(*listOutput.CommonPrefixes[0].Prefix, runIDPrefix, "") - runID := strings.ReplaceAll(key, "/", "") - return runID -} - -func uploadAndDeleteSafeTestData(t *testing.T, ctx context.Context, repository string) string { - name := xid.New().String() - _, _ = uploadFileRandomData(ctx, t, repository, mainBranch, name) - - addr := objectPhysicalAddress(t, ctx, repository, name) - - _, err := client.DeleteObjectWithResponse(ctx, repository, mainBranch, &apigen.DeleteObjectParams{Path: name}) - if err != nil { - t.Fatalf("Failed to delete object %s", err) - } - return addr -} - -func getReportCutoffTime(ctx context.Context, s3Client *s3.Client, bucket, reportPath string) (time.Time, error) { - res, err := s3Client.GetObject(ctx, &s3.GetObjectInput{ - Bucket: aws.String(bucket), - Key: aws.String(reportPath), - }) - if err != nil { - return time.Time{}, err - } - defer func() { _ = res.Body.Close() }() - - buf := new(bytes.Buffer) - _, err = buf.ReadFrom(res.Body) - if err != nil { - return time.Time{}, err - } - myFileContentAsString := buf.String() - - type Report struct { - RunID string `json:"run_id"` - Success bool `json:"success"` - FirstSlice string `json:"first_slice"` - StartTime time.Time `json:"start_time"` - CutoffTime time.Time `json:"cutoff_time"` - NumDeletedObjects int `json:"num_deleted_objects"` - } - - var report Report - err = json.Unmarshal([]byte(myFileContentAsString), &report) - if err != nil { - return time.Time{}, err - } - return report.CutoffTime, nil -} diff --git a/esti/unified_gc_test.go b/esti/unified_gc_test.go index 452b0078f31..d6e4806152a 100644 --- a/esti/unified_gc_test.go +++ b/esti/unified_gc_test.go @@ -200,7 +200,7 @@ func prepareForUnifiedGC(t *testing.T, ctx context.Context) { createBranchRes, err = client.CreateBranchWithResponse(ctx, repo, apigen.CreateBranchJSONRequestBody{Name: "dev2", Source: mainBranch}) testutil.MustDo(t, "Create branch dev2", err) require.False(t, createBranchRes.StatusCode() > 299, "Create branch dev2") - setGCRulesRes, err := client.SetGarbageCollectionRulesWithResponse(ctx, repo, apigen.SetGarbageCollectionRulesJSONRequestBody{Branches: []apigen.GarbageCollectionRule{ + setGCRulesRes, err := client.SetGCRulesWithResponse(ctx, repo, apigen.SetGCRulesJSONRequestBody{Branches: []apigen.GarbageCollectionRule{ {BranchId: "main", RetentionDays: 10}, {BranchId: "dev", RetentionDays: 7}, {BranchId: "dev", RetentionDays: 7}, }, DefaultRetentionDays: 7}) testutil.MustDo(t, "Set gc rules", err) diff --git a/pkg/api/controller.go b/pkg/api/controller.go index edbacbce206..5ad387cd580 100644 --- a/pkg/api/controller.go +++ b/pkg/api/controller.go @@ -33,7 +33,7 @@ import ( "github.com/treeverse/lakefs/pkg/catalog" "github.com/treeverse/lakefs/pkg/cloud" "github.com/treeverse/lakefs/pkg/config" - "github.com/treeverse/lakefs/pkg/graveler" + graveler "github.com/treeverse/lakefs/pkg/graveler" "github.com/treeverse/lakefs/pkg/graveler/ref" "github.com/treeverse/lakefs/pkg/httputil" "github.com/treeverse/lakefs/pkg/kv" @@ -1768,6 +1768,124 @@ func (c *Controller) GetRepositoryMetadata(w http.ResponseWriter, r *http.Reques writeResponse(w, r, http.StatusOK, apigen.RepositoryMetadata{AdditionalProperties: metadata}) } +func (c *Controller) GetBranchProtectionRules(w http.ResponseWriter, r *http.Request, repository string) { + if !c.authorize(w, r, permissions.Node{ + Permission: permissions.Permission{ + Action: permissions.GetBranchProtectionRulesAction, + Resource: permissions.RepoArn(repository), + }, + }) { + return + } + ctx := r.Context() + rules, eTag, err := c.Catalog.GetBranchProtectionRules(ctx, repository) + if c.handleAPIError(ctx, w, r, err) { + return + } + resp := make([]*apigen.BranchProtectionRule, 0, len(rules.BranchPatternToBlockedActions)) + for pattern := range rules.BranchPatternToBlockedActions { + resp = append(resp, &apigen.BranchProtectionRule{ + Pattern: pattern, + }) + } + w.Header().Set("ETag", eTag) + writeResponse(w, r, http.StatusOK, resp) +} + +func (c *Controller) SetBranchProtectionRules(w http.ResponseWriter, r *http.Request, body apigen.SetBranchProtectionRulesJSONRequestBody, repository string, params apigen.SetBranchProtectionRulesParams) { + if !c.authorize(w, r, permissions.Node{ + Permission: permissions.Permission{ + Action: permissions.SetBranchProtectionRulesAction, + Resource: permissions.RepoArn(repository), + }, + }) { + return + } + ctx := r.Context() + c.LogAction(ctx, "create_branch_protection_rule", r, repository, "", "") + + // For now, all protected branches use the same default set of blocked actions. In the future this set will be user configurable. + blockedActions := []graveler.BranchProtectionBlockedAction{graveler.BranchProtectionBlockedAction_STAGING_WRITE, graveler.BranchProtectionBlockedAction_COMMIT} + + rules := &graveler.BranchProtectionRules{ + BranchPatternToBlockedActions: make(map[string]*graveler.BranchProtectionBlockedActions), + } + for _, r := range body { + rules.BranchPatternToBlockedActions[r.Pattern] = &graveler.BranchProtectionBlockedActions{ + Value: blockedActions, + } + } + eTag := params.IfMatch + err := c.Catalog.SetBranchProtectionRules(ctx, repository, rules, eTag) + if c.handleAPIError(ctx, w, r, err) { + return + } + writeResponse(w, r, http.StatusNoContent, nil) +} + +func (c *Controller) DeleteGCRules(w http.ResponseWriter, r *http.Request, repository string) { + if !c.authorize(w, r, permissions.Node{ + Permission: permissions.Permission{ + Action: permissions.SetGarbageCollectionRulesAction, + Resource: permissions.RepoArn(repository), + }, + }) { + return + } + ctx := r.Context() + err := c.Catalog.SetGarbageCollectionRules(ctx, repository, nil) + if c.handleAPIError(ctx, w, r, err) { + return + } + writeResponse(w, r, http.StatusNoContent, nil) +} + +func (c *Controller) GetGCRules(w http.ResponseWriter, r *http.Request, repository string) { + if !c.authorize(w, r, permissions.Node{ + Permission: permissions.Permission{ + Action: permissions.GetGarbageCollectionRulesAction, + Resource: permissions.RepoArn(repository), + }, + }) { + return + } + ctx := r.Context() + rules, err := c.Catalog.GetGarbageCollectionRules(ctx, repository) + if c.handleAPIError(ctx, w, r, err) { + return + } + resp := apigen.GarbageCollectionRules{} + resp.DefaultRetentionDays = int(rules.DefaultRetentionDays) + for branchID, retentionDays := range rules.BranchRetentionDays { + resp.Branches = append(resp.Branches, apigen.GarbageCollectionRule{BranchId: branchID, RetentionDays: int(retentionDays)}) + } + writeResponse(w, r, http.StatusOK, resp) +} + +func (c *Controller) SetGCRules(w http.ResponseWriter, r *http.Request, body apigen.SetGCRulesJSONRequestBody, repository string) { + if !c.authorize(w, r, permissions.Node{ + Permission: permissions.Permission{ + Action: permissions.SetGarbageCollectionRulesAction, + Resource: permissions.RepoArn(repository), + }, + }) { + return + } + ctx := r.Context() + rules := &graveler.GarbageCollectionRules{ + DefaultRetentionDays: int32(body.DefaultRetentionDays), + BranchRetentionDays: make(map[string]int32), + } + for _, rule := range body.Branches { + rules.BranchRetentionDays[rule.BranchId] = int32(rule.RetentionDays) + } + err := c.Catalog.SetGarbageCollectionRules(ctx, repository, rules) + if c.handleAPIError(ctx, w, r, err) { + return + } + writeResponse(w, r, http.StatusNoContent, nil) +} + func (c *Controller) ListRepositoryRuns(w http.ResponseWriter, r *http.Request, repository string, params apigen.ListRepositoryRunsParams) { if !c.authorize(w, r, permissions.Node{ Permission: permissions.Permission{ @@ -2150,7 +2268,9 @@ func (c *Controller) handleAPIErrorCallback(ctx context.Context, w http.Response case errors.Is(err, graveler.ErrTooManyTries): log.Debug("Retried too many times") cb(w, r, http.StatusLocked, "Too many attempts, try again later") - + case errors.Is(err, graveler.ErrPreconditionFailed): + log.Debug("Precondition failed") + cb(w, r, http.StatusPreconditionFailed, "Precondition failed") case err != nil: c.Logger.WithContext(ctx).WithError(err).Error("API call returned status internal server error") cb(w, r, http.StatusInternalServerError, err) @@ -2882,26 +3002,8 @@ func (c *Controller) GetCommit(w http.ResponseWriter, r *http.Request, repositor writeResponse(w, r, http.StatusOK, response) } -func (c *Controller) GetGarbageCollectionRules(w http.ResponseWriter, r *http.Request, repository string) { - if !c.authorize(w, r, permissions.Node{ - Permission: permissions.Permission{ - Action: permissions.GetGarbageCollectionRulesAction, - Resource: permissions.RepoArn(repository), - }, - }) { - return - } - ctx := r.Context() - rules, err := c.Catalog.GetGarbageCollectionRules(ctx, repository) - if c.handleAPIError(ctx, w, r, err) { - return - } - resp := apigen.GarbageCollectionRules{} - resp.DefaultRetentionDays = int(rules.DefaultRetentionDays) - for branchID, retentionDays := range rules.BranchRetentionDays { - resp.Branches = append(resp.Branches, apigen.GarbageCollectionRule{BranchId: branchID, RetentionDays: int(retentionDays)}) - } - writeResponse(w, r, http.StatusOK, resp) +func (c *Controller) InternalGetGarbageCollectionRules(w http.ResponseWriter, r *http.Request, repository string) { + c.GetGCRules(w, r, repository) } func (c *Controller) SetGarbageCollectionRulesPreflight(w http.ResponseWriter, r *http.Request, repository string) { @@ -2920,45 +3022,12 @@ func (c *Controller) SetGarbageCollectionRulesPreflight(w http.ResponseWriter, r writeResponse(w, r, http.StatusNoContent, nil) } -func (c *Controller) SetGarbageCollectionRules(w http.ResponseWriter, r *http.Request, body apigen.SetGarbageCollectionRulesJSONRequestBody, repository string) { - if !c.authorize(w, r, permissions.Node{ - Permission: permissions.Permission{ - Action: permissions.SetGarbageCollectionRulesAction, - Resource: permissions.RepoArn(repository), - }, - }) { - return - } - ctx := r.Context() - rules := &graveler.GarbageCollectionRules{ - DefaultRetentionDays: int32(body.DefaultRetentionDays), - BranchRetentionDays: make(map[string]int32), - } - for _, rule := range body.Branches { - rules.BranchRetentionDays[rule.BranchId] = int32(rule.RetentionDays) - } - err := c.Catalog.SetGarbageCollectionRules(ctx, repository, rules) - if c.handleAPIError(ctx, w, r, err) { - return - } - writeResponse(w, r, http.StatusNoContent, nil) +func (c *Controller) InternalSetGarbageCollectionRules(w http.ResponseWriter, r *http.Request, body apigen.InternalSetGarbageCollectionRulesJSONRequestBody, repository string) { + c.SetGCRules(w, r, apigen.SetGCRulesJSONRequestBody(body), repository) } -func (c *Controller) DeleteGarbageCollectionRules(w http.ResponseWriter, r *http.Request, repository string) { - if !c.authorize(w, r, permissions.Node{ - Permission: permissions.Permission{ - Action: permissions.SetGarbageCollectionRulesAction, - Resource: permissions.RepoArn(repository), - }, - }) { - return - } - ctx := r.Context() - err := c.Catalog.SetGarbageCollectionRules(ctx, repository, nil) - if c.handleAPIError(ctx, w, r, err) { - return - } - writeResponse(w, r, http.StatusNoContent, nil) +func (c *Controller) InternalDeleteGarbageCollectionRules(w http.ResponseWriter, r *http.Request, repository string) { + c.DeleteGCRules(w, r, repository) } func (c *Controller) PrepareGarbageCollectionCommits(w http.ResponseWriter, r *http.Request, repository string) { @@ -2991,30 +3060,11 @@ func (c *Controller) PrepareGarbageCollectionCommits(w http.ResponseWriter, r *h }) } -func (c *Controller) GetBranchProtectionRules(w http.ResponseWriter, r *http.Request, repository string) { - if !c.authorize(w, r, permissions.Node{ - Permission: permissions.Permission{ - Action: permissions.GetBranchProtectionRulesAction, - Resource: permissions.RepoArn(repository), - }, - }) { - return - } - ctx := r.Context() - rules, err := c.Catalog.GetBranchProtectionRules(ctx, repository) - if c.handleAPIError(ctx, w, r, err) { - return - } - resp := make([]*apigen.BranchProtectionRule, 0, len(rules.BranchPatternToBlockedActions)) - for pattern := range rules.BranchPatternToBlockedActions { - resp = append(resp, &apigen.BranchProtectionRule{ - Pattern: pattern, - }) - } - writeResponse(w, r, http.StatusOK, resp) +func (c *Controller) InternalGetBranchProtectionRules(w http.ResponseWriter, r *http.Request, repository string) { + c.GetBranchProtectionRules(w, r, repository) } -func (c *Controller) DeleteBranchProtectionRule(w http.ResponseWriter, r *http.Request, body apigen.DeleteBranchProtectionRuleJSONRequestBody, repository string) { +func (c *Controller) InternalDeleteBranchProtectionRule(w http.ResponseWriter, r *http.Request, body apigen.InternalDeleteBranchProtectionRuleJSONRequestBody, repository string) { if !c.authorize(w, r, permissions.Node{ Permission: permissions.Permission{ Action: permissions.SetBranchProtectionRulesAction, @@ -3026,11 +3076,22 @@ func (c *Controller) DeleteBranchProtectionRule(w http.ResponseWriter, r *http.R ctx := r.Context() c.LogAction(ctx, "delete_branch_protection_rule", r, repository, "", "") - err := c.Catalog.DeleteBranchProtectionRule(ctx, repository, body.Pattern) + rules, _, err := c.Catalog.GetBranchProtectionRules(ctx, repository) if c.handleAPIError(ctx, w, r, err) { return } - writeResponse(w, r, http.StatusNoContent, nil) + for p := range rules.BranchPatternToBlockedActions { + if p == body.Pattern { + delete(rules.BranchPatternToBlockedActions, p) + err = c.Catalog.SetBranchProtectionRules(ctx, repository, rules, nil) + if c.handleAPIError(ctx, w, r, err) { + return + } + writeResponse(w, r, http.StatusNoContent, nil) + return + } + } + writeResponse(w, r, http.StatusNotFound, nil) } func (c *Controller) CreateBranchProtectionRulePreflight(w http.ResponseWriter, r *http.Request, repository string) { @@ -3049,7 +3110,7 @@ func (c *Controller) CreateBranchProtectionRulePreflight(w http.ResponseWriter, writeResponse(w, r, http.StatusNoContent, nil) } -func (c *Controller) CreateBranchProtectionRule(w http.ResponseWriter, r *http.Request, body apigen.CreateBranchProtectionRuleJSONRequestBody, repository string) { +func (c *Controller) InternalCreateBranchProtectionRule(w http.ResponseWriter, r *http.Request, body apigen.InternalCreateBranchProtectionRuleJSONRequestBody, repository string) { if !c.authorize(w, r, permissions.Node{ Permission: permissions.Permission{ Action: permissions.SetBranchProtectionRulesAction, @@ -3060,10 +3121,23 @@ func (c *Controller) CreateBranchProtectionRule(w http.ResponseWriter, r *http.R } ctx := r.Context() c.LogAction(ctx, "create_branch_protection_rule", r, repository, "", "") - - // For now, all protected branches use the same default set of blocked actions. In the future this set will be user configurable. - blockedActions := []graveler.BranchProtectionBlockedAction{graveler.BranchProtectionBlockedAction_STAGING_WRITE, graveler.BranchProtectionBlockedAction_COMMIT} - err := c.Catalog.CreateBranchProtectionRule(ctx, repository, body.Pattern, blockedActions) + rules, _, err := c.Catalog.GetBranchProtectionRules(ctx, repository) + if !errors.Is(err, graveler.ErrNotFound) { + if c.handleAPIError(ctx, w, r, err) { + return + } + } + if rules == nil { + rules = &graveler.BranchProtectionRules{} + } + if rules.BranchPatternToBlockedActions == nil { + rules.BranchPatternToBlockedActions = make(map[string]*graveler.BranchProtectionBlockedActions) + } + blockedActions := &graveler.BranchProtectionBlockedActions{ + Value: []graveler.BranchProtectionBlockedAction{graveler.BranchProtectionBlockedAction_STAGING_WRITE, graveler.BranchProtectionBlockedAction_COMMIT}, + } + rules.BranchPatternToBlockedActions[body.Pattern] = blockedActions + err = c.Catalog.SetBranchProtectionRules(ctx, repository, rules, nil) if c.handleAPIError(ctx, w, r, err) { return } diff --git a/pkg/api/controller_test.go b/pkg/api/controller_test.go index 5800c94d04c..68e01136bf2 100644 --- a/pkg/api/controller_test.go +++ b/pkg/api/controller_test.go @@ -929,7 +929,16 @@ func TestController_CommitHandler(t *testing.T) { repo := testUniqueRepoName() _, err := deps.catalog.CreateRepository(ctx, repo, onBlock(deps, repo), "main") testutil.MustDo(t, "create repository", err) - err = deps.catalog.CreateBranchProtectionRule(ctx, repo, "main", []graveler.BranchProtectionBlockedAction{graveler.BranchProtectionBlockedAction_COMMIT}) + rules := map[string]*graveler.BranchProtectionBlockedActions{ + "main": { + Value: []graveler.BranchProtectionBlockedAction{ + graveler.BranchProtectionBlockedAction_COMMIT, + }, + }, + } + err = deps.catalog.SetBranchProtectionRules(ctx, repo, &graveler.BranchProtectionRules{ + BranchPatternToBlockedActions: rules, + }, swag.String("")) testutil.MustDo(t, "protection rule", err) err = deps.catalog.CreateEntry(ctx, repo, "main", catalog.DBEntry{Path: "foo/bar", PhysicalAddress: "pa", CreationDate: time.Now(), Size: 666, Checksum: "cs", Metadata: nil}) testutil.MustDo(t, "commit to protected branch", err) @@ -2560,7 +2569,16 @@ func TestController_ObjectsDeleteObjectHandler(t *testing.T) { resp, err := uploadObjectHelper(t, ctx, clt, p, strings.NewReader(content), repo, branch) verifyResponseOK(t, resp, err) } - err = deps.catalog.CreateBranchProtectionRule(ctx, repo, "*", []graveler.BranchProtectionBlockedAction{graveler.BranchProtectionBlockedAction_STAGING_WRITE}) + rules := map[string]*graveler.BranchProtectionBlockedActions{ + "*": { + Value: []graveler.BranchProtectionBlockedAction{ + graveler.BranchProtectionBlockedAction_STAGING_WRITE, + }, + }, + } + err = deps.catalog.SetBranchProtectionRules(ctx, repo, &graveler.BranchProtectionRules{ + BranchPatternToBlockedActions: rules, + }, swag.String("")) testutil.Must(t, err) // delete objects @@ -4378,17 +4396,17 @@ func TestController_BranchProtectionRules(t *testing.T) { } // the result of an actual call to the endpoint should have the same result - resp, err := tc.clt.CreateBranchProtectionRuleWithResponse(currCtx, repo, apigen.CreateBranchProtectionRuleJSONRequestBody{ + resp, err := tc.clt.InternalCreateBranchProtectionRuleWithResponse(currCtx, repo, apigen.InternalCreateBranchProtectionRuleJSONRequestBody{ Pattern: "main", }) if err != nil { t.Fatal(err) } if resp == nil { - t.Fatal("CreateBranchProtectionRuleWithResponse got no response") + t.Fatal("InternalCreateBranchProtectionRuleWithResponse got no response") } if resp.StatusCode() != respPreflight.StatusCode() { - t.Fatalf("CreateBranchProtectionRuleWithResponse and preflight shouls return the same unauthorized status expected %d, got %d", respPreflight.StatusCode(), resp.StatusCode()) + t.Fatalf("InternalCreateBranchProtectionRuleWithResponse and preflight should return the same unauthorized status expected %d, got %d", respPreflight.StatusCode(), resp.StatusCode()) } }) } @@ -4437,7 +4455,7 @@ func TestController_GarbageCollectionRules(t *testing.T) { } // the result of an actual call to the endpoint should have the same result - resp, err := tc.clt.SetGarbageCollectionRulesWithResponse(currCtx, repo, apigen.SetGarbageCollectionRulesJSONRequestBody{ + resp, err := tc.clt.SetGCRulesWithResponse(currCtx, repo, apigen.SetGCRulesJSONRequestBody{ Branches: []apigen.GarbageCollectionRule{{BranchId: "main", RetentionDays: 1}}, DefaultRetentionDays: 5, }) if err != nil { diff --git a/pkg/catalog/catalog.go b/pkg/catalog/catalog.go index a267c546365..b268952e8dd 100644 --- a/pkg/catalog/catalog.go +++ b/pkg/catalog/catalog.go @@ -2079,29 +2079,21 @@ func (c *Catalog) SetGarbageCollectionRules(ctx context.Context, repositoryID st return c.Store.SetGarbageCollectionRules(ctx, repository, rules) } -func (c *Catalog) GetBranchProtectionRules(ctx context.Context, repositoryID string) (*graveler.BranchProtectionRules, error) { +func (c *Catalog) GetBranchProtectionRules(ctx context.Context, repositoryID string) (*graveler.BranchProtectionRules, string, error) { repository, err := c.getRepository(ctx, repositoryID) if err != nil { - return nil, err + return nil, "", err } return c.Store.GetBranchProtectionRules(ctx, repository) } -func (c *Catalog) DeleteBranchProtectionRule(ctx context.Context, repositoryID string, pattern string) error { - repository, err := c.getRepository(ctx, repositoryID) - if err != nil { - return err - } - return c.Store.DeleteBranchProtectionRule(ctx, repository, pattern) -} - -func (c *Catalog) CreateBranchProtectionRule(ctx context.Context, repositoryID string, pattern string, blockedActions []graveler.BranchProtectionBlockedAction) error { +func (c *Catalog) SetBranchProtectionRules(ctx context.Context, repositoryID string, rules *graveler.BranchProtectionRules, lastKnownChecksum *string) error { repository, err := c.getRepository(ctx, repositoryID) if err != nil { return err } - return c.Store.CreateBranchProtectionRule(ctx, repository, pattern, blockedActions) + return c.Store.SetBranchProtectionRules(ctx, repository, rules, lastKnownChecksum) } func (c *Catalog) PrepareExpiredCommits(ctx context.Context, repositoryID string) (*graveler.GarbageCollectionRunMetadata, error) { diff --git a/pkg/catalog/interface.go b/pkg/catalog/interface.go index 5e96694d7fd..840f8c8a0fd 100644 --- a/pkg/catalog/interface.go +++ b/pkg/catalog/interface.go @@ -163,9 +163,13 @@ type Interface interface { // Consecutive calls must be made using the returned run ID, upon completion mark will return nil PrepareGCUncommitted(ctx context.Context, repositoryID string, mark *GCUncommittedMark) (*PrepareGCUncommittedInfo, error) - GetBranchProtectionRules(ctx context.Context, repositoryID string) (*graveler.BranchProtectionRules, error) - DeleteBranchProtectionRule(ctx context.Context, repositoryID string, pattern string) error - CreateBranchProtectionRule(ctx context.Context, repositoryID string, pattern string, blockedActions []graveler.BranchProtectionBlockedAction) error + // GetBranchProtectionRules returns the branch protection rules for the given repository. + // The returned checksum represents the current state of the rules, and can be passed to SetBranchProtectionRules for conditional updates. + GetBranchProtectionRules(ctx context.Context, repositoryID string) (*graveler.BranchProtectionRules, string, error) + // SetBranchProtectionRules sets the branch protection rules for the given repository. + // If lastKnownChecksum doesn't match the current state, the update will fail with ErrPreconditionFailed. + // If lastKnownChecksum is nil, the update will be performed regardless of the current state of the rules. + SetBranchProtectionRules(ctx context.Context, repositoryID string, rules *graveler.BranchProtectionRules, lastKnownChecksum *string) error // SetLinkAddress to validate single use limited in time of a given physical address SetLinkAddress(ctx context.Context, repository, token string) error diff --git a/pkg/graveler/branch/protection_manager.go b/pkg/graveler/branch/protection_manager.go index 3ca36cca65d..04aac4797b7 100644 --- a/pkg/graveler/branch/protection_manager.go +++ b/pkg/graveler/branch/protection_manager.go @@ -7,10 +7,10 @@ import ( "time" "github.com/gobwas/glob" - "github.com/gobwas/glob/syntax" "github.com/treeverse/lakefs/pkg/cache" "github.com/treeverse/lakefs/pkg/graveler" "github.com/treeverse/lakefs/pkg/graveler/settings" + "github.com/treeverse/lakefs/pkg/kv" "google.golang.org/protobuf/proto" ) @@ -23,8 +23,7 @@ const ( ) var ( - ErrRuleAlreadyExists = fmt.Errorf("branch protection rule already exists: %w", graveler.ErrNotUnique) - ErrRuleNotExists = fmt.Errorf("branch protection rule does not exist: %w", graveler.ErrNotFound) + ErrRuleNotExists = fmt.Errorf("branch protection rule does not exist: %w", graveler.ErrNotFound) ) type ProtectionManager struct { @@ -36,24 +35,6 @@ func NewProtectionManager(settingManager *settings.Manager) *ProtectionManager { return &ProtectionManager{settingManager: settingManager, matchers: cache.NewCache(matcherCacheSize, matcherCacheExpiry, cache.NewJitterFn(matcherCacheJitter))} } -func (m *ProtectionManager) Add(ctx context.Context, repository *graveler.RepositoryRecord, branchNamePattern string, blockedActions []graveler.BranchProtectionBlockedAction) error { - _, err := syntax.Parse(branchNamePattern) - if err != nil { - return fmt.Errorf("invalid branch pattern syntax: %w", err) - } - return m.settingManager.Update(ctx, repository, ProtectionSettingKey, &graveler.BranchProtectionRules{}, func(message proto.Message) (proto.Message, error) { - rules := message.(*graveler.BranchProtectionRules) - if rules.BranchPatternToBlockedActions == nil { - rules.BranchPatternToBlockedActions = make(map[string]*graveler.BranchProtectionBlockedActions) - } - if _, ok := rules.BranchPatternToBlockedActions[branchNamePattern]; ok { - return nil, ErrRuleAlreadyExists - } - rules.BranchPatternToBlockedActions[branchNamePattern] = &graveler.BranchProtectionBlockedActions{Value: blockedActions} - return rules, nil - }) -} - func (m *ProtectionManager) Delete(ctx context.Context, repository *graveler.RepositoryRecord, branchNamePattern string) error { return m.settingManager.Update(ctx, repository, ProtectionSettingKey, &graveler.BranchProtectionRules{}, func(message proto.Message) (proto.Message, error) { rules := message.(*graveler.BranchProtectionRules) @@ -68,30 +49,29 @@ func (m *ProtectionManager) Delete(ctx context.Context, repository *graveler.Rep }) } -func (m *ProtectionManager) Get(ctx context.Context, repository *graveler.RepositoryRecord, branchNamePattern string) ([]graveler.BranchProtectionBlockedAction, error) { - rules, err := m.settingManager.GetLatest(ctx, repository, ProtectionSettingKey, &graveler.BranchProtectionRules{}) +func (m *ProtectionManager) GetRules(ctx context.Context, repository *graveler.RepositoryRecord) (*graveler.BranchProtectionRules, string, error) { + rulesMsg, checksum, err := m.settingManager.GetLatest(ctx, repository, ProtectionSettingKey, &graveler.BranchProtectionRules{}) if errors.Is(err, graveler.ErrNotFound) { - return nil, nil + return &graveler.BranchProtectionRules{}, "", nil } if err != nil { - return nil, err + return nil, "", err } - actions := rules.(*graveler.BranchProtectionRules).BranchPatternToBlockedActions[branchNamePattern] - if actions == nil { - return nil, nil + if proto.Size(rulesMsg) == 0 { + return &graveler.BranchProtectionRules{}, checksum, nil } - return actions.GetValue(), nil + return rulesMsg.(*graveler.BranchProtectionRules), checksum, nil +} +func (m *ProtectionManager) SetRules(ctx context.Context, repository *graveler.RepositoryRecord, rules *graveler.BranchProtectionRules) error { + return m.settingManager.Save(ctx, repository, ProtectionSettingKey, rules) } -func (m *ProtectionManager) GetRules(ctx context.Context, repository *graveler.RepositoryRecord) (*graveler.BranchProtectionRules, error) { - rules, err := m.settingManager.GetLatest(ctx, repository, ProtectionSettingKey, &graveler.BranchProtectionRules{}) - if errors.Is(err, graveler.ErrNotFound) { - return &graveler.BranchProtectionRules{}, nil - } - if err != nil { - return nil, err +func (m *ProtectionManager) SetRulesIf(ctx context.Context, repository *graveler.RepositoryRecord, rules *graveler.BranchProtectionRules, lastKnownChecksum string) error { + err := m.settingManager.SaveIf(ctx, repository, ProtectionSettingKey, rules, lastKnownChecksum) + if errors.Is(err, kv.ErrPredicateFailed) { + return graveler.ErrPreconditionFailed } - return rules.(*graveler.BranchProtectionRules), nil + return err } func (m *ProtectionManager) IsBlocked(ctx context.Context, repository *graveler.RepositoryRecord, branchID graveler.BranchID, action graveler.BranchProtectionBlockedAction) (bool, error) { diff --git a/pkg/graveler/branch/protection_manager_test.go b/pkg/graveler/branch/protection_manager_test.go index 338ab160a05..bbd0f2d8ed0 100644 --- a/pkg/graveler/branch/protection_manager_test.go +++ b/pkg/graveler/branch/protection_manager_test.go @@ -2,6 +2,7 @@ package branch_test import ( "context" + "encoding/base64" "errors" "testing" @@ -23,34 +24,47 @@ var repository = &graveler.RepositoryRecord{ }, } -func TestGet(t *testing.T) { +func TestSetAndGet(t *testing.T) { ctx := context.Background() bpm := prepareTest(t, ctx) - rule, err := bpm.Get(ctx, repository, "main*") + rules, eTag, err := bpm.GetRules(ctx, repository) testutil.Must(t, err) - if rule != nil { - t.Fatalf("expected nil rule, got %v", rule) + if len(rules.BranchPatternToBlockedActions) != 0 { + t.Fatalf("expected no rules, got %d rules", len(rules.BranchPatternToBlockedActions)) } - testutil.Must(t, bpm.Add(ctx, repository, "main*", []graveler.BranchProtectionBlockedAction{graveler.BranchProtectionBlockedAction_STAGING_WRITE})) - rule, err = bpm.Get(ctx, repository, "main*") + testutil.Must(t, bpm.SetRulesIf(ctx, repository, &graveler.BranchProtectionRules{ + BranchPatternToBlockedActions: map[string]*graveler.BranchProtectionBlockedActions{ + "main*": {Value: []graveler.BranchProtectionBlockedAction{ + graveler.BranchProtectionBlockedAction_STAGING_WRITE}, + }, + }, + }, eTag)) + + rules, eTag, err = bpm.GetRules(ctx, repository) + testutil.Must(t, err) - if diff := deep.Equal([]graveler.BranchProtectionBlockedAction{graveler.BranchProtectionBlockedAction_STAGING_WRITE}, rule); diff != nil { - t.Fatalf("got unexpected blocked actions. diff=%s", diff) + + if len(rules.BranchPatternToBlockedActions) != 1 { + t.Fatalf("expected 1 rule, got %d", len(rules.BranchPatternToBlockedActions)) } - rule, err = bpm.Get(ctx, repository, "otherpattern") - testutil.Must(t, err) - if rule != nil { - t.Fatalf("expected nil rule, got %v", rule) + expectedActions := &graveler.BranchProtectionBlockedActions{Value: []graveler.BranchProtectionBlockedAction{graveler.BranchProtectionBlockedAction_STAGING_WRITE}} + if diff := deep.Equal(expectedActions, rules.BranchPatternToBlockedActions["main*"]); diff != nil { + t.Fatalf("got unexpected blocked actions. diff=%s", diff) } } -func TestAddAlreadyExists(t *testing.T) { +func TestSetWrongETag(t *testing.T) { ctx := context.Background() bpm := prepareTest(t, ctx) - testutil.Must(t, bpm.Add(ctx, repository, "main*", []graveler.BranchProtectionBlockedAction{graveler.BranchProtectionBlockedAction_STAGING_WRITE})) - err := bpm.Add(ctx, repository, "main*", []graveler.BranchProtectionBlockedAction{graveler.BranchProtectionBlockedAction_COMMIT}) - if !errors.Is(err, branch.ErrRuleAlreadyExists) { - t.Fatalf("expected ErrRuleAlreadyExists, got %v", err) + err := bpm.SetRulesIf(ctx, repository, &graveler.BranchProtectionRules{ + BranchPatternToBlockedActions: map[string]*graveler.BranchProtectionBlockedActions{ + "main*": {Value: []graveler.BranchProtectionBlockedAction{ + graveler.BranchProtectionBlockedAction_STAGING_WRITE}, + }, + }, + }, base64.StdEncoding.EncodeToString([]byte("WRONG_ETAG"))) + if !errors.Is(err, graveler.ErrPreconditionFailed) { + t.Fatalf("expected ErrPreconditionFailed, got %v", err) } } @@ -61,61 +75,69 @@ func TestDelete(t *testing.T) { if !errors.Is(err, branch.ErrRuleNotExists) { t.Fatalf("expected ErrRuleNotExists, got %v", err) } - testutil.Must(t, bpm.Add(ctx, repository, "main*", []graveler.BranchProtectionBlockedAction{graveler.BranchProtectionBlockedAction_STAGING_WRITE})) - rule, err := bpm.Get(ctx, repository, "main*") + testutil.Must(t, bpm.SetRules(ctx, repository, &graveler.BranchProtectionRules{ + BranchPatternToBlockedActions: map[string]*graveler.BranchProtectionBlockedActions{ + "main*": {Value: []graveler.BranchProtectionBlockedAction{ + graveler.BranchProtectionBlockedAction_STAGING_WRITE}, + }, + }, + })) + rules, _, err := bpm.GetRules(ctx, repository) testutil.Must(t, err) - if diff := deep.Equal([]graveler.BranchProtectionBlockedAction{graveler.BranchProtectionBlockedAction_STAGING_WRITE}, rule); diff != nil { + expectedActions := &graveler.BranchProtectionBlockedActions{Value: []graveler.BranchProtectionBlockedAction{graveler.BranchProtectionBlockedAction_STAGING_WRITE}} + if diff := deep.Equal(expectedActions, rules.BranchPatternToBlockedActions["main*"]); diff != nil { t.Fatalf("got unexpected blocked actions. diff=%s", diff) } testutil.Must(t, bpm.Delete(ctx, repository, "main*")) - rule, err = bpm.Get(ctx, repository, "main*") + rules, _, err = bpm.GetRules(ctx, repository) testutil.Must(t, err) - if rule != nil { - t.Fatalf("expected nil rule after delete, got %v", rule) + if len(rules.BranchPatternToBlockedActions) != 0 { + t.Fatalf("expected no rules, got %d rules", len(rules.BranchPatternToBlockedActions)) } } func TestIsBlocked(t *testing.T) { ctx := context.Background() - const ( + var ( action1 = graveler.BranchProtectionBlockedAction_STAGING_WRITE action2 = graveler.BranchProtectionBlockedAction_COMMIT - action3 = 2 - action4 = 3 + action3 = graveler.BranchProtectionBlockedAction(2) + action4 = graveler.BranchProtectionBlockedAction(3) ) tests := map[string]struct { - patternToBlockedActions map[string][]graveler.BranchProtectionBlockedAction - expectedBlockedActions map[string][]graveler.BranchProtectionBlockedAction - expectedAllowedActions map[string][]graveler.BranchProtectionBlockedAction + patternToBlockedActions map[string]*graveler.BranchProtectionBlockedActions + expectedBlockedActions map[string]*graveler.BranchProtectionBlockedActions + expectedAllowedActions map[string]*graveler.BranchProtectionBlockedActions }{ "two_rules": { - patternToBlockedActions: map[string][]graveler.BranchProtectionBlockedAction{"main*": {action1}, "dev": {action2}}, - expectedBlockedActions: map[string][]graveler.BranchProtectionBlockedAction{"main": {action1}, "main2": {action1}, "dev": {action2}}, - expectedAllowedActions: map[string][]graveler.BranchProtectionBlockedAction{"main": {action2}, "main2": {action2}, "dev": {action1}, "dev1": {action1, action2}}, + patternToBlockedActions: map[string]*graveler.BranchProtectionBlockedActions{"main*": {Value: []graveler.BranchProtectionBlockedAction{action1}}, "dev": {Value: []graveler.BranchProtectionBlockedAction{action2}}}, + expectedBlockedActions: map[string]*graveler.BranchProtectionBlockedActions{"main": {Value: []graveler.BranchProtectionBlockedAction{action1}}, "main2": {Value: []graveler.BranchProtectionBlockedAction{action1}}, "dev": {Value: []graveler.BranchProtectionBlockedAction{action2}}}, + expectedAllowedActions: map[string]*graveler.BranchProtectionBlockedActions{"main": {Value: []graveler.BranchProtectionBlockedAction{action2}}, "main2": {Value: []graveler.BranchProtectionBlockedAction{action2}}, "dev": {Value: []graveler.BranchProtectionBlockedAction{action1}}, "dev1": {Value: []graveler.BranchProtectionBlockedAction{action1, action2}}}, }, "multiple_blocked": { - patternToBlockedActions: map[string][]graveler.BranchProtectionBlockedAction{"main*": {action1, action2, action3}, "stable_*": {action3, action4}}, - expectedBlockedActions: map[string][]graveler.BranchProtectionBlockedAction{"main": {action1, action2, action3}, "main2": {action1, action2, action3}, "stable_branch": {action3, action4}}, - expectedAllowedActions: map[string][]graveler.BranchProtectionBlockedAction{"main": {action4}, "main2": {action4}, "stable_branch": {action1, action2}}, + patternToBlockedActions: map[string]*graveler.BranchProtectionBlockedActions{"main*": {Value: []graveler.BranchProtectionBlockedAction{action1, action2, action3}}, "stable_*": {Value: []graveler.BranchProtectionBlockedAction{action3, action4}}}, + expectedBlockedActions: map[string]*graveler.BranchProtectionBlockedActions{"main": {Value: []graveler.BranchProtectionBlockedAction{action1, action2, action3}}, "main2": {Value: []graveler.BranchProtectionBlockedAction{action1, action2, action3}}, "stable_branch": {Value: []graveler.BranchProtectionBlockedAction{action3, action4}}}, + expectedAllowedActions: map[string]*graveler.BranchProtectionBlockedActions{"main": {Value: []graveler.BranchProtectionBlockedAction{action4}}, "main2": {Value: []graveler.BranchProtectionBlockedAction{action4}}, "stable_branch": {Value: []graveler.BranchProtectionBlockedAction{action1, action2}}}, }, "overlapping_patterns": { - patternToBlockedActions: map[string][]graveler.BranchProtectionBlockedAction{"main*": {action1}, "mai*": {action2}, "ma*": {action2, action3}}, - expectedBlockedActions: map[string][]graveler.BranchProtectionBlockedAction{"main": {action1, action2, action3}}, - expectedAllowedActions: map[string][]graveler.BranchProtectionBlockedAction{"main": {action4}}, + patternToBlockedActions: map[string]*graveler.BranchProtectionBlockedActions{"main*": {Value: []graveler.BranchProtectionBlockedAction{action1}}, "mai*": {Value: []graveler.BranchProtectionBlockedAction{action2}}, "ma*": {Value: []graveler.BranchProtectionBlockedAction{action2, action3}}}, + expectedBlockedActions: map[string]*graveler.BranchProtectionBlockedActions{"main": {Value: []graveler.BranchProtectionBlockedAction{action1, action2, action3}}}, + expectedAllowedActions: map[string]*graveler.BranchProtectionBlockedActions{"main": {Value: []graveler.BranchProtectionBlockedAction{action4}}}, }, "no_rules": { - expectedAllowedActions: map[string][]graveler.BranchProtectionBlockedAction{"main": {action1, action2}}, + expectedAllowedActions: map[string]*graveler.BranchProtectionBlockedActions{"main": {Value: []graveler.BranchProtectionBlockedAction{action1, action2}}}, }, } for name, tst := range tests { t.Run(name, func(t *testing.T) { bpm := prepareTest(t, ctx) - for pattern, blockedActions := range tst.patternToBlockedActions { - testutil.Must(t, bpm.Add(ctx, repository, pattern, blockedActions)) - } + testutil.Must(t, bpm.SetRules(ctx, repository, &graveler.BranchProtectionRules{ + BranchPatternToBlockedActions: tst.patternToBlockedActions, + })) + for branchID, expectedBlockedActions := range tst.expectedBlockedActions { - for _, action := range expectedBlockedActions { + for _, action := range expectedBlockedActions.Value { res, err := bpm.IsBlocked(ctx, repository, graveler.BranchID(branchID), action) testutil.Must(t, err) if !res { @@ -124,7 +146,7 @@ func TestIsBlocked(t *testing.T) { } } for branchID, expectedAllowedActions := range tst.expectedAllowedActions { - for _, action := range expectedAllowedActions { + for _, action := range expectedAllowedActions.Value { res, err := bpm.IsBlocked(ctx, repository, graveler.BranchID(branchID), action) testutil.Must(t, err) if res { diff --git a/pkg/graveler/graveler.go b/pkg/graveler/graveler.go index 35105b71ac4..a793ca31fc2 100644 --- a/pkg/graveler/graveler.go +++ b/pkg/graveler/graveler.go @@ -609,16 +609,14 @@ type VersionController interface { GCNewRunID() string - // GetBranchProtectionRules return all branch protection rules for the repository - GetBranchProtectionRules(ctx context.Context, repository *RepositoryRecord) (*BranchProtectionRules, error) + // GetBranchProtectionRules return all branch protection rules for the repository. + // The returned checksum represents the current state of the rules, and can be passed to SetBranchProtectionRules for a conditional update. + GetBranchProtectionRules(ctx context.Context, repository *RepositoryRecord) (*BranchProtectionRules, string, error) - // DeleteBranchProtectionRule deletes the branch protection rule for the given pattern, - // or return ErrRuleNotExists if no such rule exists. - DeleteBranchProtectionRule(ctx context.Context, repository *RepositoryRecord, pattern string) error - - // CreateBranchProtectionRule creates a rule for the given name pattern, - // or returns ErrRuleAlreadyExists if there is already a rule for the pattern. - CreateBranchProtectionRule(ctx context.Context, repository *RepositoryRecord, pattern string, blockedActions []BranchProtectionBlockedAction) error + // SetBranchProtectionRules sets the branch protection rules for the repository. + // If lastKnownChecksum doesn't match the current state, the update fails with ErrPreconditionFailed. + // If lastKnownChecksum is nil, the update is always performed. + SetBranchProtectionRules(ctx context.Context, repository *RepositoryRecord, rules *BranchProtectionRules, lastKnownChecksum *string) error // SetLinkAddress stores the address token under the repository. The token will be valid for addressTokenTime. // or return ErrAddressTokenAlreadyExists if a token already exists. @@ -1495,16 +1493,15 @@ func (g *Graveler) GCNewRunID() string { return g.garbageCollectionManager.NewID() } -func (g *Graveler) GetBranchProtectionRules(ctx context.Context, repository *RepositoryRecord) (*BranchProtectionRules, error) { +func (g *Graveler) GetBranchProtectionRules(ctx context.Context, repository *RepositoryRecord) (*BranchProtectionRules, string, error) { return g.protectedBranchesManager.GetRules(ctx, repository) } -func (g *Graveler) DeleteBranchProtectionRule(ctx context.Context, repository *RepositoryRecord, pattern string) error { - return g.protectedBranchesManager.Delete(ctx, repository, pattern) -} - -func (g *Graveler) CreateBranchProtectionRule(ctx context.Context, repository *RepositoryRecord, pattern string, blockedActions []BranchProtectionBlockedAction) error { - return g.protectedBranchesManager.Add(ctx, repository, pattern, blockedActions) +func (g *Graveler) SetBranchProtectionRules(ctx context.Context, repository *RepositoryRecord, rules *BranchProtectionRules, lastKnownChecksum *string) error { + if lastKnownChecksum == nil { + return g.protectedBranchesManager.SetRules(ctx, repository, rules) + } + return g.protectedBranchesManager.SetRulesIf(ctx, repository, rules, *lastKnownChecksum) } // getFromStagingArea returns the most updated value of a given key in a branch staging area. @@ -3238,15 +3235,16 @@ type GarbageCollectionManager interface { } type ProtectedBranchesManager interface { - // Add creates a rule for the given name pattern, blocking the given actions. - // Returns ErrRuleAlreadyExists if there is already a rule for the given pattern. - Add(ctx context.Context, repository *RepositoryRecord, branchNamePattern string, blockedActions []BranchProtectionBlockedAction) error // Delete deletes the rule for the given name pattern, or returns ErrRuleNotExists if there is no such rule. Delete(ctx context.Context, repository *RepositoryRecord, branchNamePattern string) error - // Get returns the list of blocked actions for the given name pattern, or nil if no rule was defined for the pattern. - Get(ctx context.Context, repository *RepositoryRecord, branchNamePattern string) ([]BranchProtectionBlockedAction, error) - // GetRules returns all branch protection rules for the repository - GetRules(ctx context.Context, repository *RepositoryRecord) (*BranchProtectionRules, error) + // GetRules returns all branch protection rules for the repository. + // The returned checksum represents the current state of the rules, and can be passed to SetRulesIf for conditional updates. + GetRules(ctx context.Context, repository *RepositoryRecord) (*BranchProtectionRules, string, error) + SetRules(ctx context.Context, repository *RepositoryRecord, rules *BranchProtectionRules) error + // SetRulesIf sets the branch protection rules for the repository. + // If lastKnownChecksum does not match the current checksum, returns ErrPreconditionFailed. + // If lastKnownChecksum is empty, the rules are set only if no rules are currently set. + SetRulesIf(ctx context.Context, repository *RepositoryRecord, rules *BranchProtectionRules, lastKnownChecksum string) error // IsBlocked returns whether the action is blocked by any branch protection rule matching the given branch. IsBlocked(ctx context.Context, repository *RepositoryRecord, branchID BranchID, action BranchProtectionBlockedAction) (bool, error) } diff --git a/pkg/graveler/mock/graveler.go b/pkg/graveler/mock/graveler.go index 415cafde1ff..b62a4010e60 100644 --- a/pkg/graveler/mock/graveler.go +++ b/pkg/graveler/mock/graveler.go @@ -275,20 +275,6 @@ func (mr *MockVersionControllerMockRecorder) CreateBranch(ctx, repository, branc return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateBranch", reflect.TypeOf((*MockVersionController)(nil).CreateBranch), ctx, repository, branchID, ref) } -// CreateBranchProtectionRule mocks base method. -func (m *MockVersionController) CreateBranchProtectionRule(ctx context.Context, repository *graveler.RepositoryRecord, pattern string, blockedActions []graveler.BranchProtectionBlockedAction) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateBranchProtectionRule", ctx, repository, pattern, blockedActions) - ret0, _ := ret[0].(error) - return ret0 -} - -// CreateBranchProtectionRule indicates an expected call of CreateBranchProtectionRule. -func (mr *MockVersionControllerMockRecorder) CreateBranchProtectionRule(ctx, repository, pattern, blockedActions interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateBranchProtectionRule", reflect.TypeOf((*MockVersionController)(nil).CreateBranchProtectionRule), ctx, repository, pattern, blockedActions) -} - // CreateRepository mocks base method. func (m *MockVersionController) CreateRepository(ctx context.Context, repositoryID graveler.RepositoryID, storageNamespace graveler.StorageNamespace, branchID graveler.BranchID) (*graveler.RepositoryRecord, error) { m.ctrl.T.Helper() @@ -332,20 +318,6 @@ func (mr *MockVersionControllerMockRecorder) DeleteBranch(ctx, repository, branc return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteBranch", reflect.TypeOf((*MockVersionController)(nil).DeleteBranch), ctx, repository, branchID) } -// DeleteBranchProtectionRule mocks base method. -func (m *MockVersionController) DeleteBranchProtectionRule(ctx context.Context, repository *graveler.RepositoryRecord, pattern string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DeleteBranchProtectionRule", ctx, repository, pattern) - ret0, _ := ret[0].(error) - return ret0 -} - -// DeleteBranchProtectionRule indicates an expected call of DeleteBranchProtectionRule. -func (mr *MockVersionControllerMockRecorder) DeleteBranchProtectionRule(ctx, repository, pattern interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteBranchProtectionRule", reflect.TypeOf((*MockVersionController)(nil).DeleteBranchProtectionRule), ctx, repository, pattern) -} - // DeleteExpiredImports mocks base method. func (m *MockVersionController) DeleteExpiredImports(ctx context.Context, repository *graveler.RepositoryRecord) error { m.ctrl.T.Helper() @@ -509,12 +481,13 @@ func (mr *MockVersionControllerMockRecorder) GetBranch(ctx, repository, branchID } // GetBranchProtectionRules mocks base method. -func (m *MockVersionController) GetBranchProtectionRules(ctx context.Context, repository *graveler.RepositoryRecord) (*graveler.BranchProtectionRules, error) { +func (m *MockVersionController) GetBranchProtectionRules(ctx context.Context, repository *graveler.RepositoryRecord) (*graveler.BranchProtectionRules, string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetBranchProtectionRules", ctx, repository) ret0, _ := ret[0].(*graveler.BranchProtectionRules) - ret1, _ := ret[1].(error) - return ret0, ret1 + ret1, _ := ret[1].(string) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 } // GetBranchProtectionRules indicates an expected call of GetBranchProtectionRules. @@ -835,6 +808,20 @@ func (mr *MockVersionControllerMockRecorder) SaveGarbageCollectionCommits(ctx, r return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SaveGarbageCollectionCommits", reflect.TypeOf((*MockVersionController)(nil).SaveGarbageCollectionCommits), ctx, repository) } +// SetBranchProtectionRules mocks base method. +func (m *MockVersionController) SetBranchProtectionRules(ctx context.Context, repository *graveler.RepositoryRecord, rules *graveler.BranchProtectionRules, lastKnownChecksum *string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetBranchProtectionRules", ctx, repository, rules, lastKnownChecksum) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetBranchProtectionRules indicates an expected call of SetBranchProtectionRules. +func (mr *MockVersionControllerMockRecorder) SetBranchProtectionRules(ctx, repository, rules, lastKnownChecksum interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetBranchProtectionRules", reflect.TypeOf((*MockVersionController)(nil).SetBranchProtectionRules), ctx, repository, rules, lastKnownChecksum) +} + // SetGarbageCollectionRules mocks base method. func (m *MockVersionController) SetGarbageCollectionRules(ctx context.Context, repository *graveler.RepositoryRecord, rules *graveler.GarbageCollectionRules) error { m.ctrl.T.Helper() @@ -2883,20 +2870,6 @@ func (m *MockProtectedBranchesManager) EXPECT() *MockProtectedBranchesManagerMoc return m.recorder } -// Add mocks base method. -func (m *MockProtectedBranchesManager) Add(ctx context.Context, repository *graveler.RepositoryRecord, branchNamePattern string, blockedActions []graveler.BranchProtectionBlockedAction) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Add", ctx, repository, branchNamePattern, blockedActions) - ret0, _ := ret[0].(error) - return ret0 -} - -// Add indicates an expected call of Add. -func (mr *MockProtectedBranchesManagerMockRecorder) Add(ctx, repository, branchNamePattern, blockedActions interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Add", reflect.TypeOf((*MockProtectedBranchesManager)(nil).Add), ctx, repository, branchNamePattern, blockedActions) -} - // Delete mocks base method. func (m *MockProtectedBranchesManager) Delete(ctx context.Context, repository *graveler.RepositoryRecord, branchNamePattern string) error { m.ctrl.T.Helper() @@ -2911,28 +2884,14 @@ func (mr *MockProtectedBranchesManagerMockRecorder) Delete(ctx, repository, bran return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockProtectedBranchesManager)(nil).Delete), ctx, repository, branchNamePattern) } -// Get mocks base method. -func (m *MockProtectedBranchesManager) Get(ctx context.Context, repository *graveler.RepositoryRecord, branchNamePattern string) ([]graveler.BranchProtectionBlockedAction, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", ctx, repository, branchNamePattern) - ret0, _ := ret[0].([]graveler.BranchProtectionBlockedAction) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Get indicates an expected call of Get. -func (mr *MockProtectedBranchesManagerMockRecorder) Get(ctx, repository, branchNamePattern interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockProtectedBranchesManager)(nil).Get), ctx, repository, branchNamePattern) -} - // GetRules mocks base method. -func (m *MockProtectedBranchesManager) GetRules(ctx context.Context, repository *graveler.RepositoryRecord) (*graveler.BranchProtectionRules, error) { +func (m *MockProtectedBranchesManager) GetRules(ctx context.Context, repository *graveler.RepositoryRecord) (*graveler.BranchProtectionRules, string, error) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetRules", ctx, repository) ret0, _ := ret[0].(*graveler.BranchProtectionRules) - ret1, _ := ret[1].(error) - return ret0, ret1 + ret1, _ := ret[1].(string) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 } // GetRules indicates an expected call of GetRules. @@ -2955,3 +2914,31 @@ func (mr *MockProtectedBranchesManagerMockRecorder) IsBlocked(ctx, repository, b mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsBlocked", reflect.TypeOf((*MockProtectedBranchesManager)(nil).IsBlocked), ctx, repository, branchID, action) } + +// SetRules mocks base method. +func (m *MockProtectedBranchesManager) SetRules(ctx context.Context, repository *graveler.RepositoryRecord, rules *graveler.BranchProtectionRules) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetRules", ctx, repository, rules) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetRules indicates an expected call of SetRules. +func (mr *MockProtectedBranchesManagerMockRecorder) SetRules(ctx, repository, rules interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetRules", reflect.TypeOf((*MockProtectedBranchesManager)(nil).SetRules), ctx, repository, rules) +} + +// SetRulesIf mocks base method. +func (m *MockProtectedBranchesManager) SetRulesIf(ctx context.Context, repository *graveler.RepositoryRecord, rules *graveler.BranchProtectionRules, lastKnownChecksum string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetRulesIf", ctx, repository, rules, lastKnownChecksum) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetRulesIf indicates an expected call of SetRulesIf. +func (mr *MockProtectedBranchesManagerMockRecorder) SetRulesIf(ctx, repository, rules, lastKnownChecksum interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetRulesIf", reflect.TypeOf((*MockProtectedBranchesManager)(nil).SetRulesIf), ctx, repository, rules, lastKnownChecksum) +} diff --git a/pkg/graveler/settings/manager.go b/pkg/graveler/settings/manager.go index 970ea93fcb7..0c91b97d861 100644 --- a/pkg/graveler/settings/manager.go +++ b/pkg/graveler/settings/manager.go @@ -2,6 +2,7 @@ package settings import ( "context" + "encoding/base64" "errors" "fmt" "time" @@ -67,6 +68,17 @@ func (m *Manager) Save(ctx context.Context, repository *graveler.RepositoryRecor return kv.SetMsg(ctx, m.store, graveler.RepoPartition(repository), []byte(graveler.SettingsPath(key)), setting) } +// SaveIf persists the given setting under the given repository and key. Overrides settings key in KV Store. +// The setting is persisted only if the current version of the setting matches the given checksum. +func (m *Manager) SaveIf(ctx context.Context, repository *graveler.RepositoryRecord, key string, setting proto.Message, lastKnownChecksum string) error { + logSetting(logging.FromContext(ctx), repository.RepositoryID, key, setting, "saving repository-level setting") + decodedChecksum, err := base64.StdEncoding.DecodeString(lastKnownChecksum) + if err != nil { + return fmt.Errorf("decode checksum: %w", err) + } + return kv.SetMsgIf(ctx, m.store, graveler.RepoPartition(repository), []byte(graveler.SettingsPath(key)), setting, decodedChecksum) +} + func (m *Manager) getWithPredicate(ctx context.Context, repo *graveler.RepositoryRecord, key string, data proto.Message) (kv.Predicate, error) { pred, err := kv.GetMsg(ctx, m.store, graveler.RepoPartition(repo), []byte(graveler.SettingsPath(key)), data) if err != nil { @@ -78,29 +90,32 @@ func (m *Manager) getWithPredicate(ctx context.Context, repo *graveler.Repositor return pred, nil } -func (m *Manager) GetLatest(ctx context.Context, repository *graveler.RepositoryRecord, key string, settingTemplate proto.Message) (proto.Message, error) { +// GetLatest returns the latest setting under the given repository and key, without using the cache. +// The returned checksum represents the version of the setting, and can be passed to SaveIf for conditional updates. +func (m *Manager) GetLatest(ctx context.Context, repository *graveler.RepositoryRecord, key string, settingTemplate proto.Message) (proto.Message, string, error) { data := settingTemplate.ProtoReflect().Interface() - _, err := m.getWithPredicate(ctx, repository, key, data) + pred, err := m.getWithPredicate(ctx, repository, key, data) if err != nil { if errors.Is(err, kv.ErrNotFound) { err = graveler.ErrNotFound } - return nil, err + return nil, "", err } logSetting(logging.FromContext(ctx), repository.RepositoryID, key, data, "got repository-level setting") - return data, nil + return data, base64.StdEncoding.EncodeToString(pred.([]byte)), nil } // Get fetches the setting under the given repository and key, and returns the result. // The result is eventually consistent: it is not guaranteed to be the most up-to-date setting. The cache expiry period is 1 second. // The settingTemplate parameter is used to determine the returned type. +// The returned checksum represents the version of the setting, and can be used in SaveIf to perform an atomic update. func (m *Manager) Get(ctx context.Context, repository *graveler.RepositoryRecord, key string, settingTemplate proto.Message) (proto.Message, error) { k := cacheKey{ RepositoryID: repository.RepositoryID, Key: key, } setting, err := m.cache.GetOrSet(k, func() (v interface{}, err error) { - setting, err := m.GetLatest(ctx, repository, key, settingTemplate) + setting, _, err := m.GetLatest(ctx, repository, key, settingTemplate) if errors.Is(err, graveler.ErrNotFound) { return nil, nil } diff --git a/pkg/graveler/settings/manager_test.go b/pkg/graveler/settings/manager_test.go index f7bfd58b0a4..dfe43fac9e1 100644 --- a/pkg/graveler/settings/manager_test.go +++ b/pkg/graveler/settings/manager_test.go @@ -77,6 +77,25 @@ func TestSaveAndGet(t *testing.T) { t.Fatal("got unexpected settings:", diff) } } +func TestGetLatest(t *testing.T) { + ctx := context.Background() + m, _ := prepareTest(t, ctx, nil, nil) + emptySettings := &settings.ExampleSettings{} + setting, eTag, err := m.GetLatest(ctx, repository, "settingKey", emptySettings) + if !errors.Is(err, graveler.ErrNotFound) { + t.Fatalf("expected ErrNotFound, got %v", err) + } + err = m.Save(ctx, repository, "settingKey", &settings.ExampleSettings{ExampleInt: 5, ExampleStr: "hello", ExampleMap: map[string]int32{"boo": 6}}) + testutil.Must(t, err) + setting, eTag, err = m.GetLatest(ctx, repository, "settingKey", emptySettings) + testutil.Must(t, err) + if diff := deep.Equal(&settings.ExampleSettings{ExampleInt: 5, ExampleStr: "hello", ExampleMap: map[string]int32{"boo": 6}}, setting); diff != nil { + t.Fatal("got unexpected settings:", diff) + } + if eTag == "" { + t.Fatal("got empty eTag") + } +} func TestUpdate(t *testing.T) { ctx := context.Background() @@ -99,6 +118,7 @@ func TestUpdate(t *testing.T) { emptySettings := &settings.ExampleSettings{} require.NoError(t, m.Update(ctx, repository, "settingKey", emptySettings, update)) gotSettings, err := m.Get(ctx, repository, "settingKey", emptySettings) + require.NoError(t, err) if diff := deep.Equal(validationData, gotSettings); diff != nil { t.Fatal("got unexpected settings:", diff) @@ -136,7 +156,7 @@ func TestUpdate(t *testing.T) { return &newSettings, nil } require.ErrorIs(t, m.Update(ctx, repository, "settingKey", emptySettings, update), graveler.ErrTooManyTries) - gotSettings, err = m.GetLatest(ctx, repository, "settingKey", emptySettings) + gotSettings, eTag3, err := m.GetLatest(ctx, repository, "settingKey", emptySettings) require.NoError(t, err) if diff := deep.Equal(validationData, gotSettings); diff != nil { t.Fatal("got unexpected settings:", diff) @@ -148,7 +168,10 @@ func TestUpdate(t *testing.T) { return nil, testErr } require.ErrorIs(t, m.Update(ctx, repository, "settingKey", emptySettings, update), testErr) - gotSettings, err = m.GetLatest(ctx, repository, "settingKey", emptySettings) + gotSettings, eTag4, err := m.GetLatest(ctx, repository, "settingKey", emptySettings) + if eTag4 != eTag3 { + t.Fatal("expected eTag4 to be equal to eTag3") + } require.NoError(t, err) if diff := deep.Equal(validationData, gotSettings); diff != nil { t.Fatal("got unexpected settings:", diff) diff --git a/pkg/samplerepo/samplecontent.go b/pkg/samplerepo/samplecontent.go index cbda2829356..a8deb4d8aae 100644 --- a/pkg/samplerepo/samplecontent.go +++ b/pkg/samplerepo/samplecontent.go @@ -119,5 +119,12 @@ func PopulateSampleRepo(ctx context.Context, repo *catalog.Repository, cat catal func AddBranchProtection(ctx context.Context, repo *catalog.Repository, cat catalog.Interface) error { // Set branch protection on the main branch - return cat.CreateBranchProtectionRule(ctx, repo.Name, repo.DefaultBranch, []graveler.BranchProtectionBlockedAction{graveler.BranchProtectionBlockedAction_COMMIT}) + rules, eTag, err := cat.GetBranchProtectionRules(ctx, repo.Name) + if err != nil { + return err + } + rules.BranchPatternToBlockedActions[repo.DefaultBranch] = &graveler.BranchProtectionBlockedActions{ + Value: []graveler.BranchProtectionBlockedAction{graveler.BranchProtectionBlockedAction_COMMIT}, + } + return cat.SetBranchProtectionRules(ctx, repo.Name, rules, swag.String(eTag)) } diff --git a/webui/src/lib/api/index.js b/webui/src/lib/api/index.js index 44e71975a18..8324970e995 100644 --- a/webui/src/lib/api/index.js +++ b/webui/src/lib/api/index.js @@ -847,7 +847,7 @@ class Actions { class Retention { async getGCPolicy(repoID) { - const response = await apiRequest(`/repositories/${encodeURIComponent(repoID)}/gc/rules`); + const response = await apiRequest(`/repositories/${encodeURIComponent(repoID)}/settings/gc_rules`); if (response.status === 404) { throw new NotFoundError('policy not found') } @@ -866,8 +866,8 @@ class Retention { } async setGCPolicy(repoID, policy) { - const response = await apiRequest(`/repositories/${encodeURIComponent(repoID)}/gc/rules`, { - method: 'POST', + const response = await apiRequest(`/repositories/${encodeURIComponent(repoID)}/settings/gc_rules`, { + method: 'PUT', body: policy }); if (response.status !== 204) { @@ -877,7 +877,7 @@ class Retention { } async deleteGCPolicy(repoID) { - const response = await apiRequest(`/repositories/${encodeURIComponent(repoID)}/gc/rules`, { + const response = await apiRequest(`/repositories/${encodeURIComponent(repoID)}/settings/gc_rules`, { method: 'DELETE', }); if (response.status !== 204) { @@ -983,14 +983,17 @@ class Config { class BranchProtectionRules { async getRules(repoID) { - const response = await apiRequest(`/repositories/${encodeURIComponent(repoID)}/branch_protection`); + const response = await apiRequest(`/repositories/${encodeURIComponent(repoID)}/settings/branch_protection`); if (response.status === 404) { throw new NotFoundError('branch protection rules not found') } if (response.status !== 200) { throw new Error(`could not get branch protection rules: ${await extractError(response)}`); } - return response.json(); + return { + 'checksum': response.headers.get('ETag'), + 'rules': await response.json() + } } async createRulePreflight(repoID) { @@ -999,11 +1002,11 @@ class BranchProtectionRules { } - async createRule(repoID, pattern) { - const response = await apiRequest(`/repositories/${encodeURIComponent(repoID)}/branch_protection`, { - method: 'POST', - body: JSON.stringify({pattern: pattern}) - }); + async setRules(repoID, rules, lastKnownChecksum) { + const response = await apiRequest(`/repositories/${encodeURIComponent(repoID)}/settings/branch_protection`, { + method: 'PUT', + body: JSON.stringify(rules), + }, {'If-Match': lastKnownChecksum}); if (response.status !== 204) { throw new Error(`could not create protection rule: ${await extractError(response)}`); } diff --git a/webui/src/lib/onboarding/repoOnboardingService.tsx b/webui/src/lib/onboarding/repoOnboardingService.tsx index 9d515e3c9cf..b12505b20da 100644 --- a/webui/src/lib/onboarding/repoOnboardingService.tsx +++ b/webui/src/lib/onboarding/repoOnboardingService.tsx @@ -159,8 +159,8 @@ export const getRepoOnboardingSteps = ( showStep: () => true, isCompleted: async () => { try { - const rules = await branchProtectionRules.getRules(currentRepo); - return rules?.length > 0; + const rulesResponse = await branchProtectionRules.getRules(currentRepo); + return rulesResponse['rules']?.length > 0; } catch (e) { if (e instanceof NotFoundError) { return false; diff --git a/webui/src/pages/repositories/repository/settings/branches.jsx b/webui/src/pages/repositories/repository/settings/branches.jsx index 84d5d03279d..fa7e7c0ba2c 100644 --- a/webui/src/pages/repositories/repository/settings/branches.jsx +++ b/webui/src/pages/repositories/repository/settings/branches.jsx @@ -19,7 +19,7 @@ const SettingsContainer = () => { const [actionError, setActionError] = useState(null); const [deleteButtonDisabled, setDeleteButtonDisabled] = useState(false) - const {response: rules, error: rulesError, loading: rulesLoading} = useAPI(async () => { + const {response: rulesResponse, error: rulesError, loading: rulesLoading} = useAPI(async () => { return branchProtectionRules.getRules(repo.id) }, [repo, refresh]) if (error) return ; @@ -47,7 +47,7 @@ const SettingsContainer = () => { - {rules && rules.length > 0 ? rules.map((r) => { + {rulesResponse && rulesResponse['rules'].length > 0 ? rulesResponse['rules'].map((r) => { return
{r.pattern} @@ -69,13 +69,13 @@ const SettingsContainer = () => {
} - setShowCreateModal(false)} onSuccess={() => { + setShowCreateModal(false)} currentRulesResponse={rulesResponse} onSuccess={() => { setRefresh(!refresh) setShowCreateModal(false) }} repoID={repo.id}/> ); } -const CreateRuleModal = ({show, hideFn, onSuccess, repoID}) => { +const CreateRuleModal = ({show, hideFn, onSuccess, repoID, currentRulesResponse}) => { const [error, setError] = useState(null); const [createButtonDisabled, setCreateButtonDisabled] = useState(true); const patternField = useRef(null); @@ -86,7 +86,10 @@ const CreateRuleModal = ({show, hideFn, onSuccess, repoID}) => { } setError(null) setCreateButtonDisabled(true) - branchProtectionRules.createRule(repoID, pattern).then(onSuccess).catch(err => { + let updatedRules = [...currentRulesResponse['rules']] + let lastKnownChecksum = currentRulesResponse['checksum'] + updatedRules.push({pattern}) + branchProtectionRules.setRules(repoID, updatedRules, lastKnownChecksum).then(onSuccess).catch(err => { setError(err) setCreateButtonDisabled(false) })