From 42935ce9908ddf8961743dab390371a5f7686324 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 3 Dec 2024 19:13:29 -0800 Subject: [PATCH] generate api for rust --- README.md | 5 + validation/api/.gitignore | 3 + validation/api/.openapi-generator-ignore | 23 + validation/api/.openapi-generator/FILES | 26 + validation/api/.openapi-generator/VERSION | 1 + validation/api/.travis.yml | 1 + validation/api/Cargo.toml | 16 + validation/api/README.md | 64 +++ validation/api/docs/Error.md | 12 + validation/api/docs/Id.md | 11 + validation/api/docs/Pagination.md | 12 + validation/api/docs/Submission.md | 22 + validation/api/docs/SubmissionCreate.md | 18 + validation/api/docs/SubmissionFilter.md | 15 + validation/api/docs/SubmissionsApi.md | 388 ++++++++++++++ validation/api/docs/User.md | 13 + validation/api/git_push.sh | 57 +++ validation/api/src/apis/configuration.rs | 51 ++ validation/api/src/apis/mod.rs | 95 ++++ validation/api/src/apis/submissions_api.rs | 480 ++++++++++++++++++ validation/api/src/lib.rs | 11 + validation/api/src/models/error.rs | 32 ++ validation/api/src/models/id.rs | 27 + validation/api/src/models/mod.rs | 14 + validation/api/src/models/pagination.rs | 30 ++ validation/api/src/models/submission.rs | 60 +++ .../api/src/models/submission_create.rs | 48 ++ .../api/src/models/submission_filter.rs | 39 ++ validation/api/src/models/user.rs | 33 ++ 29 files changed, 1607 insertions(+) create mode 100644 validation/api/.gitignore create mode 100644 validation/api/.openapi-generator-ignore create mode 100644 validation/api/.openapi-generator/FILES create mode 100644 validation/api/.openapi-generator/VERSION create mode 100644 validation/api/.travis.yml create mode 100644 validation/api/Cargo.toml create mode 100644 validation/api/README.md create mode 100644 validation/api/docs/Error.md create mode 100644 validation/api/docs/Id.md create mode 100644 validation/api/docs/Pagination.md create mode 100644 validation/api/docs/Submission.md create mode 100644 validation/api/docs/SubmissionCreate.md create mode 100644 validation/api/docs/SubmissionFilter.md create mode 100644 validation/api/docs/SubmissionsApi.md create mode 100644 validation/api/docs/User.md create mode 100644 validation/api/git_push.sh create mode 100644 validation/api/src/apis/configuration.rs create mode 100644 validation/api/src/apis/mod.rs create mode 100644 validation/api/src/apis/submissions_api.rs create mode 100644 validation/api/src/lib.rs create mode 100644 validation/api/src/models/error.rs create mode 100644 validation/api/src/models/id.rs create mode 100644 validation/api/src/models/mod.rs create mode 100644 validation/api/src/models/pagination.rs create mode 100644 validation/api/src/models/submission.rs create mode 100644 validation/api/src/models/submission_create.rs create mode 100644 validation/api/src/models/submission_filter.rs create mode 100644 validation/api/src/models/user.rs diff --git a/README.md b/README.md index aa79d7c..9c79166 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,8 @@ ``` By default, the project opens at `localhost:8080`. + +## How to generate rust api from this directory +```bash +openapi-generator-cli generate -g rust -i openapi.yaml -o validation/api` +``` diff --git a/validation/api/.gitignore b/validation/api/.gitignore new file mode 100644 index 0000000..6aa1064 --- /dev/null +++ b/validation/api/.gitignore @@ -0,0 +1,3 @@ +/target/ +**/*.rs.bk +Cargo.lock diff --git a/validation/api/.openapi-generator-ignore b/validation/api/.openapi-generator-ignore new file mode 100644 index 0000000..7484ee5 --- /dev/null +++ b/validation/api/.openapi-generator-ignore @@ -0,0 +1,23 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/validation/api/.openapi-generator/FILES b/validation/api/.openapi-generator/FILES new file mode 100644 index 0000000..96a7ff9 --- /dev/null +++ b/validation/api/.openapi-generator/FILES @@ -0,0 +1,26 @@ +.gitignore +.openapi-generator-ignore +.travis.yml +Cargo.toml +README.md +docs/Error.md +docs/Id.md +docs/Pagination.md +docs/Submission.md +docs/SubmissionCreate.md +docs/SubmissionFilter.md +docs/SubmissionsApi.md +docs/User.md +git_push.sh +src/apis/configuration.rs +src/apis/mod.rs +src/apis/submissions_api.rs +src/lib.rs +src/models/error.rs +src/models/id.rs +src/models/mod.rs +src/models/pagination.rs +src/models/submission.rs +src/models/submission_create.rs +src/models/submission_filter.rs +src/models/user.rs diff --git a/validation/api/.openapi-generator/VERSION b/validation/api/.openapi-generator/VERSION new file mode 100644 index 0000000..758bb9c --- /dev/null +++ b/validation/api/.openapi-generator/VERSION @@ -0,0 +1 @@ +7.10.0 diff --git a/validation/api/.travis.yml b/validation/api/.travis.yml new file mode 100644 index 0000000..22761ba --- /dev/null +++ b/validation/api/.travis.yml @@ -0,0 +1 @@ +language: rust diff --git a/validation/api/Cargo.toml b/validation/api/Cargo.toml new file mode 100644 index 0000000..0b760ce --- /dev/null +++ b/validation/api/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "openapi" +version = "0.1.0" +authors = ["OpenAPI Generator team and contributors"] +description = "Browse and manage map submissions in the staging pipeline." +# Override this license by providing a License Object in the OpenAPI. +license = "Unlicense" +edition = "2021" + +[dependencies] +serde = { version = "^1.0", features = ["derive"] } +serde_json = "^1.0" +serde_repr = "^0.1" +url = "^2.5" +uuid = { version = "^1.8", features = ["serde", "v4"] } +reqwest = { version = "^0.12", features = ["json", "multipart"] } diff --git a/validation/api/README.md b/validation/api/README.md new file mode 100644 index 0000000..3d7c737 --- /dev/null +++ b/validation/api/README.md @@ -0,0 +1,64 @@ +# Rust API client for openapi + +Browse and manage map submissions in the staging pipeline. + + +## Overview + +This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. + +- API version: 0.1.0 +- Package version: 0.1.0 +- Generator version: 7.10.0 +- Build package: `org.openapitools.codegen.languages.RustClientCodegen` + +## Installation + +Put the package under your project folder in a directory named `openapi` and add the following to `Cargo.toml` under `[dependencies]`: + +``` +openapi = { path = "./openapi" } +``` + +## Documentation for API Endpoints + +All URIs are relative to *https://submissions.strafes.net/v1* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*SubmissionsApi* | [**action_submission_publish**](docs/SubmissionsApi.md#action_submission_publish) | **PATCH** /submissions/{SubmissionID}/status/publish | Role Validator changes status from Publishing -> Published +*SubmissionsApi* | [**action_submission_reject**](docs/SubmissionsApi.md#action_submission_reject) | **PATCH** /submissions/{SubmissionID}/status/reject | Role Reviewer changes status from Submitted -> Rejected +*SubmissionsApi* | [**action_submission_request_changes**](docs/SubmissionsApi.md#action_submission_request_changes) | **PATCH** /submissions/{SubmissionID}/status/request-changes | Role Reviewer changes status from Validated|Accepted|Submitted -> ChangesRequested +*SubmissionsApi* | [**action_submission_revoke**](docs/SubmissionsApi.md#action_submission_revoke) | **PATCH** /submissions/{SubmissionID}/status/revoke | Role Submitter changes status from Submitted|ChangesRequested -> UnderConstruction +*SubmissionsApi* | [**action_submission_submit**](docs/SubmissionsApi.md#action_submission_submit) | **PATCH** /submissions/{SubmissionID}/status/submit | Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted +*SubmissionsApi* | [**action_submission_trigger_publish**](docs/SubmissionsApi.md#action_submission_trigger_publish) | **PATCH** /submissions/{SubmissionID}/status/trigger-publish | Role Admin changes status from Validated -> Publishing +*SubmissionsApi* | [**action_submission_trigger_validate**](docs/SubmissionsApi.md#action_submission_trigger_validate) | **PATCH** /submissions/{SubmissionID}/status/trigger-validate | Role Reviewer triggers validation and changes status from Submitted|Accepted -> Validating +*SubmissionsApi* | [**action_submission_validate**](docs/SubmissionsApi.md#action_submission_validate) | **PATCH** /submissions/{SubmissionID}/status/validate | Role Validator changes status from Validating -> Validated +*SubmissionsApi* | [**create_submission**](docs/SubmissionsApi.md#create_submission) | **POST** /submissions | Create new submission +*SubmissionsApi* | [**get_submission**](docs/SubmissionsApi.md#get_submission) | **GET** /submissions/{SubmissionID} | Retrieve map with ID +*SubmissionsApi* | [**list_submissions**](docs/SubmissionsApi.md#list_submissions) | **GET** /submissions | Get list of submissions +*SubmissionsApi* | [**patch_submission_completed**](docs/SubmissionsApi.md#patch_submission_completed) | **PATCH** /submissions/{SubmissionID}/completed | Retrieve map with ID +*SubmissionsApi* | [**patch_submission_model**](docs/SubmissionsApi.md#patch_submission_model) | **PATCH** /submissions/{SubmissionID}/model | Update model following role restrictions + + +## Documentation For Models + + - [Error](docs/Error.md) + - [Id](docs/Id.md) + - [Pagination](docs/Pagination.md) + - [Submission](docs/Submission.md) + - [SubmissionCreate](docs/SubmissionCreate.md) + - [SubmissionFilter](docs/SubmissionFilter.md) + - [User](docs/User.md) + + +To get access to the crate's generated documentation, use: + +``` +cargo doc --open +``` + +## Author + + + diff --git a/validation/api/docs/Error.md b/validation/api/docs/Error.md new file mode 100644 index 0000000..7f3b617 --- /dev/null +++ b/validation/api/docs/Error.md @@ -0,0 +1,12 @@ +# Error + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **i64** | | +**message** | **String** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/validation/api/docs/Id.md b/validation/api/docs/Id.md new file mode 100644 index 0000000..96f5445 --- /dev/null +++ b/validation/api/docs/Id.md @@ -0,0 +1,11 @@ +# Id + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/validation/api/docs/Pagination.md b/validation/api/docs/Pagination.md new file mode 100644 index 0000000..c20a154 --- /dev/null +++ b/validation/api/docs/Pagination.md @@ -0,0 +1,12 @@ +# Pagination + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**page** | **i32** | | +**limit** | **i32** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/validation/api/docs/Submission.md b/validation/api/docs/Submission.md new file mode 100644 index 0000000..9a5c387 --- /dev/null +++ b/validation/api/docs/Submission.md @@ -0,0 +1,22 @@ +# Submission + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**display_name** | Option<**String**> | | [optional] +**creator** | Option<**String**> | | [optional] +**game_id** | Option<**i32**> | | [optional] +**date** | Option<**i64**> | | [optional] +**submitter** | Option<**i64**> | | [optional] +**asset_id** | Option<**i64**> | | [optional] +**asset_version** | Option<**i64**> | | [optional] +**completed** | Option<**bool**> | | [optional] +**submission_type** | Option<**i32**> | | [optional] +**target_asset_id** | Option<**i64**> | | [optional] +**status_id** | Option<**i32**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/validation/api/docs/SubmissionCreate.md b/validation/api/docs/SubmissionCreate.md new file mode 100644 index 0000000..42975e7 --- /dev/null +++ b/validation/api/docs/SubmissionCreate.md @@ -0,0 +1,18 @@ +# SubmissionCreate + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**display_name** | Option<**String**> | | [optional] +**creator** | Option<**String**> | | [optional] +**game_id** | Option<**i32**> | | [optional] +**submitter** | Option<**i64**> | | [optional] +**asset_id** | Option<**i64**> | | [optional] +**asset_version** | Option<**i64**> | | [optional] +**submission_type** | Option<**i32**> | | [optional] +**target_asset_id** | Option<**i64**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/validation/api/docs/SubmissionFilter.md b/validation/api/docs/SubmissionFilter.md new file mode 100644 index 0000000..7c7ebf0 --- /dev/null +++ b/validation/api/docs/SubmissionFilter.md @@ -0,0 +1,15 @@ +# SubmissionFilter + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**display_name** | Option<**String**> | | [optional] +**creator** | Option<**String**> | | [optional] +**game_id** | Option<**i32**> | | [optional] +**date** | Option<**i64**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/validation/api/docs/SubmissionsApi.md b/validation/api/docs/SubmissionsApi.md new file mode 100644 index 0000000..6f64f3a --- /dev/null +++ b/validation/api/docs/SubmissionsApi.md @@ -0,0 +1,388 @@ +# \SubmissionsApi + +All URIs are relative to *https://submissions.strafes.net/v1* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**action_submission_publish**](SubmissionsApi.md#action_submission_publish) | **PATCH** /submissions/{SubmissionID}/status/publish | Role Validator changes status from Publishing -> Published +[**action_submission_reject**](SubmissionsApi.md#action_submission_reject) | **PATCH** /submissions/{SubmissionID}/status/reject | Role Reviewer changes status from Submitted -> Rejected +[**action_submission_request_changes**](SubmissionsApi.md#action_submission_request_changes) | **PATCH** /submissions/{SubmissionID}/status/request-changes | Role Reviewer changes status from Validated|Accepted|Submitted -> ChangesRequested +[**action_submission_revoke**](SubmissionsApi.md#action_submission_revoke) | **PATCH** /submissions/{SubmissionID}/status/revoke | Role Submitter changes status from Submitted|ChangesRequested -> UnderConstruction +[**action_submission_submit**](SubmissionsApi.md#action_submission_submit) | **PATCH** /submissions/{SubmissionID}/status/submit | Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted +[**action_submission_trigger_publish**](SubmissionsApi.md#action_submission_trigger_publish) | **PATCH** /submissions/{SubmissionID}/status/trigger-publish | Role Admin changes status from Validated -> Publishing +[**action_submission_trigger_validate**](SubmissionsApi.md#action_submission_trigger_validate) | **PATCH** /submissions/{SubmissionID}/status/trigger-validate | Role Reviewer triggers validation and changes status from Submitted|Accepted -> Validating +[**action_submission_validate**](SubmissionsApi.md#action_submission_validate) | **PATCH** /submissions/{SubmissionID}/status/validate | Role Validator changes status from Validating -> Validated +[**create_submission**](SubmissionsApi.md#create_submission) | **POST** /submissions | Create new submission +[**get_submission**](SubmissionsApi.md#get_submission) | **GET** /submissions/{SubmissionID} | Retrieve map with ID +[**list_submissions**](SubmissionsApi.md#list_submissions) | **GET** /submissions | Get list of submissions +[**patch_submission_completed**](SubmissionsApi.md#patch_submission_completed) | **PATCH** /submissions/{SubmissionID}/completed | Retrieve map with ID +[**patch_submission_model**](SubmissionsApi.md#patch_submission_model) | **PATCH** /submissions/{SubmissionID}/model | Update model following role restrictions + + + +## action_submission_publish + +> action_submission_publish(submission_id) +Role Validator changes status from Publishing -> Published + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**submission_id** | **i64** | | [required] | + +### Return type + + (empty response body) + +### Authorization + +[cookieAuth](../README.md#cookieAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## action_submission_reject + +> action_submission_reject(submission_id) +Role Reviewer changes status from Submitted -> Rejected + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**submission_id** | **i64** | | [required] | + +### Return type + + (empty response body) + +### Authorization + +[cookieAuth](../README.md#cookieAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## action_submission_request_changes + +> action_submission_request_changes(submission_id) +Role Reviewer changes status from Validated|Accepted|Submitted -> ChangesRequested + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**submission_id** | **i64** | | [required] | + +### Return type + + (empty response body) + +### Authorization + +[cookieAuth](../README.md#cookieAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## action_submission_revoke + +> action_submission_revoke(submission_id) +Role Submitter changes status from Submitted|ChangesRequested -> UnderConstruction + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**submission_id** | **i64** | | [required] | + +### Return type + + (empty response body) + +### Authorization + +[cookieAuth](../README.md#cookieAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## action_submission_submit + +> action_submission_submit(submission_id) +Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**submission_id** | **i64** | | [required] | + +### Return type + + (empty response body) + +### Authorization + +[cookieAuth](../README.md#cookieAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## action_submission_trigger_publish + +> action_submission_trigger_publish(submission_id) +Role Admin changes status from Validated -> Publishing + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**submission_id** | **i64** | | [required] | + +### Return type + + (empty response body) + +### Authorization + +[cookieAuth](../README.md#cookieAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## action_submission_trigger_validate + +> action_submission_trigger_validate(submission_id) +Role Reviewer triggers validation and changes status from Submitted|Accepted -> Validating + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**submission_id** | **i64** | | [required] | + +### Return type + + (empty response body) + +### Authorization + +[cookieAuth](../README.md#cookieAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## action_submission_validate + +> action_submission_validate(submission_id) +Role Validator changes status from Validating -> Validated + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**submission_id** | **i64** | | [required] | + +### Return type + + (empty response body) + +### Authorization + +[cookieAuth](../README.md#cookieAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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_submission + +> models::Id create_submission(submission_create) +Create new submission + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**submission_create** | Option<[**SubmissionCreate**](SubmissionCreate.md)> | | | + +### Return type + +[**models::Id**](Id.md) + +### Authorization + +[cookieAuth](../README.md#cookieAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[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_submission + +> models::Submission get_submission(submission_id) +Retrieve map with ID + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**submission_id** | **i64** | | [required] | + +### Return type + +[**models::Submission**](Submission.md) + +### Authorization + +[cookieAuth](../README.md#cookieAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## list_submissions + +> Vec list_submissions(page, filter) +Get list of submissions + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**page** | [**Pagination**](.md) | | [required] | +**filter** | Option<[**SubmissionFilter**](.md)> | | | + +### Return type + +[**Vec**](Submission.md) + +### Authorization + +[cookieAuth](../README.md#cookieAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## patch_submission_completed + +> patch_submission_completed(submission_id) +Retrieve map with ID + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**submission_id** | **i64** | | [required] | + +### Return type + + (empty response body) + +### Authorization + +[cookieAuth](../README.md#cookieAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + +## patch_submission_model + +> patch_submission_model(submission_id, model_id, version_id) +Update model following role restrictions + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**submission_id** | **i64** | | [required] | +**model_id** | **i64** | | [required] | +**version_id** | **i64** | | [required] | + +### Return type + + (empty response body) + +### Authorization + +[cookieAuth](../README.md#cookieAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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/validation/api/docs/User.md b/validation/api/docs/User.md new file mode 100644 index 0000000..23b72cb --- /dev/null +++ b/validation/api/docs/User.md @@ -0,0 +1,13 @@ +# User + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | Option<**i64**> | | [optional] +**username** | Option<**String**> | | [optional] +**state_id** | Option<**i32**> | | [optional] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/validation/api/git_push.sh b/validation/api/git_push.sh new file mode 100644 index 0000000..f53a75d --- /dev/null +++ b/validation/api/git_push.sh @@ -0,0 +1,57 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=$(git remote) +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' diff --git a/validation/api/src/apis/configuration.rs b/validation/api/src/apis/configuration.rs new file mode 100644 index 0000000..7aa9658 --- /dev/null +++ b/validation/api/src/apis/configuration.rs @@ -0,0 +1,51 @@ +/* + * StrafesNET Submissions - OpenAPI 3.1 + * + * Browse and manage map submissions in the staging pipeline. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + + +#[derive(Debug, Clone)] +pub struct Configuration { + pub base_path: String, + pub user_agent: Option, + pub client: reqwest::Client, + pub basic_auth: Option, + pub oauth_access_token: Option, + pub bearer_access_token: Option, + pub api_key: Option, +} + +pub type BasicAuth = (String, Option); + +#[derive(Debug, Clone)] +pub struct ApiKey { + pub prefix: Option, + pub key: String, +} + + +impl Configuration { + pub fn new() -> Configuration { + Configuration::default() + } +} + +impl Default for Configuration { + fn default() -> Self { + Configuration { + base_path: "https://submissions.strafes.net/v1".to_owned(), + user_agent: Some("OpenAPI-Generator/0.1.0/rust".to_owned()), + client: reqwest::Client::new(), + basic_auth: None, + oauth_access_token: None, + bearer_access_token: None, + api_key: None, + } + } +} diff --git a/validation/api/src/apis/mod.rs b/validation/api/src/apis/mod.rs new file mode 100644 index 0000000..2931a60 --- /dev/null +++ b/validation/api/src/apis/mod.rs @@ -0,0 +1,95 @@ +use std::error; +use std::fmt; + +#[derive(Debug, Clone)] +pub struct ResponseContent { + pub status: reqwest::StatusCode, + pub content: String, + pub entity: Option, +} + +#[derive(Debug)] +pub enum Error { + Reqwest(reqwest::Error), + Serde(serde_json::Error), + Io(std::io::Error), + ResponseError(ResponseContent), +} + +impl fmt::Display for Error { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let (module, e) = match self { + Error::Reqwest(e) => ("reqwest", e.to_string()), + Error::Serde(e) => ("serde", e.to_string()), + Error::Io(e) => ("IO", e.to_string()), + Error::ResponseError(e) => ("response", format!("status code {}", e.status)), + }; + write!(f, "error in {}: {}", module, e) + } +} + +impl error::Error for Error { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { + Some(match self { + Error::Reqwest(e) => e, + Error::Serde(e) => e, + Error::Io(e) => e, + Error::ResponseError(_) => return None, + }) + } +} + +impl From for Error { + fn from(e: reqwest::Error) -> Self { + Error::Reqwest(e) + } +} + +impl From for Error { + fn from(e: serde_json::Error) -> Self { + Error::Serde(e) + } +} + +impl From for Error { + fn from(e: std::io::Error) -> Self { + Error::Io(e) + } +} + +pub fn urlencode>(s: T) -> String { + ::url::form_urlencoded::byte_serialize(s.as_ref().as_bytes()).collect() +} + +pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String, String)> { + if let serde_json::Value::Object(object) = value { + let mut params = vec![]; + + for (key, value) in object { + match value { + serde_json::Value::Object(_) => params.append(&mut parse_deep_object( + &format!("{}[{}]", prefix, key), + value, + )), + serde_json::Value::Array(array) => { + for (i, value) in array.iter().enumerate() { + params.append(&mut parse_deep_object( + &format!("{}[{}][{}]", prefix, key, i), + value, + )); + } + }, + serde_json::Value::String(s) => params.push((format!("{}[{}]", prefix, key), s.clone())), + _ => params.push((format!("{}[{}]", prefix, key), value.to_string())), + } + } + + return params; + } + + unimplemented!("Only objects are supported with style=deepObject") +} + +pub mod submissions_api; + +pub mod configuration; diff --git a/validation/api/src/apis/submissions_api.rs b/validation/api/src/apis/submissions_api.rs new file mode 100644 index 0000000..929bdb5 --- /dev/null +++ b/validation/api/src/apis/submissions_api.rs @@ -0,0 +1,480 @@ +/* + * StrafesNET Submissions - OpenAPI 3.1 + * + * Browse and manage map submissions in the staging pipeline. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + + +use reqwest; +use serde::{Deserialize, Serialize}; +use crate::{apis::ResponseContent, models}; +use super::{Error, configuration}; + + +/// struct for typed errors of method [`action_submission_publish`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ActionSubmissionPublishError { + DefaultResponse(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`action_submission_reject`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ActionSubmissionRejectError { + DefaultResponse(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`action_submission_request_changes`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ActionSubmissionRequestChangesError { + DefaultResponse(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`action_submission_revoke`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ActionSubmissionRevokeError { + DefaultResponse(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`action_submission_submit`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ActionSubmissionSubmitError { + DefaultResponse(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`action_submission_trigger_publish`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ActionSubmissionTriggerPublishError { + DefaultResponse(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`action_submission_trigger_validate`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ActionSubmissionTriggerValidateError { + DefaultResponse(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`action_submission_validate`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ActionSubmissionValidateError { + DefaultResponse(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`create_submission`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateSubmissionError { + DefaultResponse(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`get_submission`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetSubmissionError { + DefaultResponse(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`list_submissions`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListSubmissionsError { + DefaultResponse(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`patch_submission_completed`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PatchSubmissionCompletedError { + DefaultResponse(models::Error), + UnknownValue(serde_json::Value), +} + +/// struct for typed errors of method [`patch_submission_model`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PatchSubmissionModelError { + DefaultResponse(models::Error), + UnknownValue(serde_json::Value), +} + + +pub async fn action_submission_publish(configuration: &configuration::Configuration, submission_id: i64) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/submissions/{SubmissionID}/status/publish", local_var_configuration.base_path, SubmissionID=submission_id); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn action_submission_reject(configuration: &configuration::Configuration, submission_id: i64) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/submissions/{SubmissionID}/status/reject", local_var_configuration.base_path, SubmissionID=submission_id); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn action_submission_request_changes(configuration: &configuration::Configuration, submission_id: i64) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/submissions/{SubmissionID}/status/request-changes", local_var_configuration.base_path, SubmissionID=submission_id); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn action_submission_revoke(configuration: &configuration::Configuration, submission_id: i64) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/submissions/{SubmissionID}/status/revoke", local_var_configuration.base_path, SubmissionID=submission_id); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn action_submission_submit(configuration: &configuration::Configuration, submission_id: i64) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/submissions/{SubmissionID}/status/submit", local_var_configuration.base_path, SubmissionID=submission_id); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn action_submission_trigger_publish(configuration: &configuration::Configuration, submission_id: i64) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/submissions/{SubmissionID}/status/trigger-publish", local_var_configuration.base_path, SubmissionID=submission_id); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn action_submission_trigger_validate(configuration: &configuration::Configuration, submission_id: i64) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/submissions/{SubmissionID}/status/trigger-validate", local_var_configuration.base_path, SubmissionID=submission_id); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn action_submission_validate(configuration: &configuration::Configuration, submission_id: i64) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/submissions/{SubmissionID}/status/validate", local_var_configuration.base_path, SubmissionID=submission_id); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn create_submission(configuration: &configuration::Configuration, submission_create: Option) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/submissions", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + local_var_req_builder = local_var_req_builder.json(&submission_create); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn get_submission(configuration: &configuration::Configuration, submission_id: i64) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/submissions/{SubmissionID}", local_var_configuration.base_path, SubmissionID=submission_id); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn list_submissions(configuration: &configuration::Configuration, page: models::Pagination, filter: Option) -> Result, Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/submissions", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("page", &page.to_string())]); + if let Some(ref local_var_str) = filter { + local_var_req_builder = local_var_req_builder.query(&[("filter", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn patch_submission_completed(configuration: &configuration::Configuration, submission_id: i64) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/submissions/{SubmissionID}/completed", local_var_configuration.base_path, SubmissionID=submission_id); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + +pub async fn patch_submission_model(configuration: &configuration::Configuration, submission_id: i64, model_id: i64, version_id: i64) -> Result<(), Error> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/submissions/{SubmissionID}/model", local_var_configuration.base_path, SubmissionID=submission_id); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::PATCH, local_var_uri_str.as_str()); + + local_var_req_builder = local_var_req_builder.query(&[("ModelID", &model_id.to_string())]); + local_var_req_builder = local_var_req_builder.query(&[("VersionID", &version_id.to_string())]); + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + Ok(()) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/validation/api/src/lib.rs b/validation/api/src/lib.rs new file mode 100644 index 0000000..e152062 --- /dev/null +++ b/validation/api/src/lib.rs @@ -0,0 +1,11 @@ +#![allow(unused_imports)] +#![allow(clippy::too_many_arguments)] + +extern crate serde_repr; +extern crate serde; +extern crate serde_json; +extern crate url; +extern crate reqwest; + +pub mod apis; +pub mod models; diff --git a/validation/api/src/models/error.rs b/validation/api/src/models/error.rs new file mode 100644 index 0000000..d15c676 --- /dev/null +++ b/validation/api/src/models/error.rs @@ -0,0 +1,32 @@ +/* + * StrafesNET Submissions - OpenAPI 3.1 + * + * Browse and manage map submissions in the staging pipeline. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// Error : Represents error object +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Error { + #[serde(rename = "code")] + pub code: i64, + #[serde(rename = "message")] + pub message: String, +} + +impl Error { + /// Represents error object + pub fn new(code: i64, message: String) -> Error { + Error { + code, + message, + } + } +} + diff --git a/validation/api/src/models/id.rs b/validation/api/src/models/id.rs new file mode 100644 index 0000000..02e8996 --- /dev/null +++ b/validation/api/src/models/id.rs @@ -0,0 +1,27 @@ +/* + * StrafesNET Submissions - OpenAPI 3.1 + * + * Browse and manage map submissions in the staging pipeline. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Id { + #[serde(rename = "ID", skip_serializing_if = "Option::is_none")] + pub id: Option, +} + +impl Id { + pub fn new() -> Id { + Id { + id: None, + } + } +} + diff --git a/validation/api/src/models/mod.rs b/validation/api/src/models/mod.rs new file mode 100644 index 0000000..6bfd3d4 --- /dev/null +++ b/validation/api/src/models/mod.rs @@ -0,0 +1,14 @@ +pub mod error; +pub use self::error::Error; +pub mod id; +pub use self::id::Id; +pub mod pagination; +pub use self::pagination::Pagination; +pub mod submission; +pub use self::submission::Submission; +pub mod submission_create; +pub use self::submission_create::SubmissionCreate; +pub mod submission_filter; +pub use self::submission_filter::SubmissionFilter; +pub mod user; +pub use self::user::User; diff --git a/validation/api/src/models/pagination.rs b/validation/api/src/models/pagination.rs new file mode 100644 index 0000000..21d4236 --- /dev/null +++ b/validation/api/src/models/pagination.rs @@ -0,0 +1,30 @@ +/* + * StrafesNET Submissions - OpenAPI 3.1 + * + * Browse and manage map submissions in the staging pipeline. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Pagination { + #[serde(rename = "Page")] + pub page: i32, + #[serde(rename = "Limit")] + pub limit: i32, +} + +impl Pagination { + pub fn new(page: i32, limit: i32) -> Pagination { + Pagination { + page, + limit, + } + } +} + diff --git a/validation/api/src/models/submission.rs b/validation/api/src/models/submission.rs new file mode 100644 index 0000000..a15092a --- /dev/null +++ b/validation/api/src/models/submission.rs @@ -0,0 +1,60 @@ +/* + * StrafesNET Submissions - OpenAPI 3.1 + * + * Browse and manage map submissions in the staging pipeline. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct Submission { + #[serde(rename = "ID", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "DisplayName", skip_serializing_if = "Option::is_none")] + pub display_name: Option, + #[serde(rename = "Creator", skip_serializing_if = "Option::is_none")] + pub creator: Option, + #[serde(rename = "GameID", skip_serializing_if = "Option::is_none")] + pub game_id: Option, + #[serde(rename = "Date", skip_serializing_if = "Option::is_none")] + pub date: Option, + #[serde(rename = "Submitter", skip_serializing_if = "Option::is_none")] + pub submitter: Option, + #[serde(rename = "AssetID", skip_serializing_if = "Option::is_none")] + pub asset_id: Option, + #[serde(rename = "AssetVersion", skip_serializing_if = "Option::is_none")] + pub asset_version: Option, + #[serde(rename = "Completed", skip_serializing_if = "Option::is_none")] + pub completed: Option, + #[serde(rename = "SubmissionType", skip_serializing_if = "Option::is_none")] + pub submission_type: Option, + #[serde(rename = "TargetAssetID", skip_serializing_if = "Option::is_none")] + pub target_asset_id: Option, + #[serde(rename = "StatusID", skip_serializing_if = "Option::is_none")] + pub status_id: Option, +} + +impl Submission { + pub fn new() -> Submission { + Submission { + id: None, + display_name: None, + creator: None, + game_id: None, + date: None, + submitter: None, + asset_id: None, + asset_version: None, + completed: None, + submission_type: None, + target_asset_id: None, + status_id: None, + } + } +} + diff --git a/validation/api/src/models/submission_create.rs b/validation/api/src/models/submission_create.rs new file mode 100644 index 0000000..2ed12c9 --- /dev/null +++ b/validation/api/src/models/submission_create.rs @@ -0,0 +1,48 @@ +/* + * StrafesNET Submissions - OpenAPI 3.1 + * + * Browse and manage map submissions in the staging pipeline. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SubmissionCreate { + #[serde(rename = "DisplayName", skip_serializing_if = "Option::is_none")] + pub display_name: Option, + #[serde(rename = "Creator", skip_serializing_if = "Option::is_none")] + pub creator: Option, + #[serde(rename = "GameID", skip_serializing_if = "Option::is_none")] + pub game_id: Option, + #[serde(rename = "Submitter", skip_serializing_if = "Option::is_none")] + pub submitter: Option, + #[serde(rename = "AssetID", skip_serializing_if = "Option::is_none")] + pub asset_id: Option, + #[serde(rename = "AssetVersion", skip_serializing_if = "Option::is_none")] + pub asset_version: Option, + #[serde(rename = "SubmissionType", skip_serializing_if = "Option::is_none")] + pub submission_type: Option, + #[serde(rename = "TargetAssetID", skip_serializing_if = "Option::is_none")] + pub target_asset_id: Option, +} + +impl SubmissionCreate { + pub fn new() -> SubmissionCreate { + SubmissionCreate { + display_name: None, + creator: None, + game_id: None, + submitter: None, + asset_id: None, + asset_version: None, + submission_type: None, + target_asset_id: None, + } + } +} + diff --git a/validation/api/src/models/submission_filter.rs b/validation/api/src/models/submission_filter.rs new file mode 100644 index 0000000..6222994 --- /dev/null +++ b/validation/api/src/models/submission_filter.rs @@ -0,0 +1,39 @@ +/* + * StrafesNET Submissions - OpenAPI 3.1 + * + * Browse and manage map submissions in the staging pipeline. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct SubmissionFilter { + #[serde(rename = "ID", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "DisplayName", skip_serializing_if = "Option::is_none")] + pub display_name: Option, + #[serde(rename = "Creator", skip_serializing_if = "Option::is_none")] + pub creator: Option, + #[serde(rename = "GameID", skip_serializing_if = "Option::is_none")] + pub game_id: Option, + #[serde(rename = "Date", skip_serializing_if = "Option::is_none")] + pub date: Option, +} + +impl SubmissionFilter { + pub fn new() -> SubmissionFilter { + SubmissionFilter { + id: None, + display_name: None, + creator: None, + game_id: None, + date: None, + } + } +} + diff --git a/validation/api/src/models/user.rs b/validation/api/src/models/user.rs new file mode 100644 index 0000000..92e6459 --- /dev/null +++ b/validation/api/src/models/user.rs @@ -0,0 +1,33 @@ +/* + * StrafesNET Submissions - OpenAPI 3.1 + * + * Browse and manage map submissions in the staging pipeline. + * + * The version of the OpenAPI document: 0.1.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct User { + #[serde(rename = "ID", skip_serializing_if = "Option::is_none")] + pub id: Option, + #[serde(rename = "Username", skip_serializing_if = "Option::is_none")] + pub username: Option, + #[serde(rename = "StateID", skip_serializing_if = "Option::is_none")] + pub state_id: Option, +} + +impl User { + pub fn new() -> User { + User { + id: None, + username: None, + state_id: None, + } + } +} +