Skip to content

Commit

Permalink
update openapi-client
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelmattig committed Nov 27, 2024
1 parent ee5575e commit 0c69a3a
Show file tree
Hide file tree
Showing 16 changed files with 355 additions and 60 deletions.
52 changes: 46 additions & 6 deletions .generation/input/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -3155,6 +3155,47 @@
]
}
},
"/quota/computations/{computation}": {
"get": {
"tags": [
"User"
],
"summary": "Retrieves the quota used by computations",
"operationId": "computation_quota_handler",
"parameters": [
{
"name": "computation",
"in": "path",
"description": "Computation id",
"required": true,
"schema": {
"type": "string",
"format": "uuid"
}
}
],
"responses": {
"200": {
"description": "The quota used by computation",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/OperatorQuota"
}
}
}
}
}
},
"security": [
{
"session_token": []
}
]
}
},
"/quotas/{user}": {
"get": {
"tags": [
Expand Down Expand Up @@ -5532,18 +5573,17 @@
"timestamp",
"computationId",
"workflowId",
"operators"
"count"
],
"properties": {
"computationId": {
"type": "string",
"format": "uuid"
},
"operators": {
"type": "array",
"items": {
"$ref": "#/components/schemas/OperatorQuota"
}
"count": {
"type": "integer",
"format": "int64",
"minimum": 0
},
"timestamp": {
"type": "string",
Expand Down
1 change: 1 addition & 0 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ Class | Method | HTTP request | Description
*UploadsApi* | [**upload_handler**](docs/UploadsApi.md#upload_handler) | **POST** /upload | Uploads files.
*UserApi* | [**add_role_handler**](docs/UserApi.md#add_role_handler) | **PUT** /roles | Add a new role. Requires admin privilige.
*UserApi* | [**assign_role_handler**](docs/UserApi.md#assign_role_handler) | **POST** /users/{user}/roles/{role} | Assign a role to a user. Requires admin privilige.
*UserApi* | [**computation_quota_handler**](docs/UserApi.md#computation_quota_handler) | **GET** /quota/computations/{computation} | Retrieves the quota used by computations
*UserApi* | [**computations_quota_handler**](docs/UserApi.md#computations_quota_handler) | **GET** /quota/computations | Retrieves the quota used by computations
*UserApi* | [**get_role_by_name_handler**](docs/UserApi.md#get_role_by_name_handler) | **GET** /roles/byName/{name} | Get role by name
*UserApi* | [**get_role_descriptions**](docs/UserApi.md#get_role_descriptions) | **GET** /user/roles/descriptions | Query roles for the current user.
Expand Down
139 changes: 139 additions & 0 deletions python/geoengine_openapi_client/api/user_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from geoengine_openapi_client.models.add_collection200_response import AddCollection200Response
from geoengine_openapi_client.models.add_role import AddRole
from geoengine_openapi_client.models.computation_quota import ComputationQuota
from geoengine_openapi_client.models.operator_quota import OperatorQuota
from geoengine_openapi_client.models.quota import Quota
from geoengine_openapi_client.models.role_description import RoleDescription
from geoengine_openapi_client.models.update_quota import UpdateQuota
Expand Down Expand Up @@ -336,6 +337,144 @@ def assign_role_handler_with_http_info(self, user : Annotated[StrictStr, Field(.
collection_formats=_collection_formats,
_request_auth=_params.get('_request_auth'))

@validate_arguments
def computation_quota_handler(self, computation : Annotated[StrictStr, Field(..., description="Computation id")], **kwargs) -> List[OperatorQuota]: # noqa: E501
"""Retrieves the quota used by computations # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.computation_quota_handler(computation, async_req=True)
>>> result = thread.get()
:param computation: Computation id (required)
:type computation: str
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _request_timeout: timeout setting for this request.
If one number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: List[OperatorQuota]
"""
kwargs['_return_http_data_only'] = True
if '_preload_content' in kwargs:
message = "Error! Please call the computation_quota_handler_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
raise ValueError(message)
return self.computation_quota_handler_with_http_info(computation, **kwargs) # noqa: E501

@validate_arguments
def computation_quota_handler_with_http_info(self, computation : Annotated[StrictStr, Field(..., description="Computation id")], **kwargs) -> ApiResponse: # noqa: E501
"""Retrieves the quota used by computations # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.computation_quota_handler_with_http_info(computation, async_req=True)
>>> result = thread.get()
:param computation: Computation id (required)
:type computation: str
:param async_req: Whether to execute the request asynchronously.
:type async_req: bool, optional
:param _preload_content: if False, the ApiResponse.data will
be set to none and raw_data will store the
HTTP response body without reading/decoding.
Default is True.
:type _preload_content: bool, optional
:param _return_http_data_only: response data instead of ApiResponse
object with status code, headers, etc
:type _return_http_data_only: bool, optional
:param _request_timeout: timeout setting for this request. If one
number provided, it will be total request
timeout. It can also be a pair (tuple) of
(connection, read) timeouts.
:param _request_auth: set to override the auth_settings for an a single
request; this effectively ignores the authentication
in the spec for a single request.
:type _request_auth: dict, optional
:type _content_type: string, optional: force content-type for the request
:return: Returns the result object.
If the method is called asynchronously,
returns the request thread.
:rtype: tuple(List[OperatorQuota], status_code(int), headers(HTTPHeaderDict))
"""

_params = locals()

_all_params = [
'computation'
]
_all_params.extend(
[
'async_req',
'_return_http_data_only',
'_preload_content',
'_request_timeout',
'_request_auth',
'_content_type',
'_headers'
]
)

# validate the arguments
for _key, _val in _params['kwargs'].items():
if _key not in _all_params:
raise ApiTypeError(
"Got an unexpected keyword argument '%s'"
" to method computation_quota_handler" % _key
)
_params[_key] = _val
del _params['kwargs']

_collection_formats = {}

# process the path parameters
_path_params = {}
if _params['computation']:
_path_params['computation'] = _params['computation']


# process the query parameters
_query_params = []
# process the header parameters
_header_params = dict(_params.get('_headers', {}))
# process the form parameters
_form_params = []
_files = {}
# process the body parameter
_body_params = None
# set the HTTP header `Accept`
_header_params['Accept'] = self.api_client.select_header_accept(
['application/json']) # noqa: E501

# authentication setting
_auth_settings = ['session_token'] # noqa: E501

_response_types_map = {
'200': "List[OperatorQuota]",
}

return self.api_client.call_api(
'/quota/computations/{computation}', 'GET',
_path_params,
_query_params,
_header_params,
body=_body_params,
post_params=_form_params,
files=_files,
response_types_map=_response_types_map,
auth_settings=_auth_settings,
async_req=_params.get('async_req'),
_return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501
_preload_content=_params.get('_preload_content', True),
_request_timeout=_params.get('_request_timeout'),
collection_formats=_collection_formats,
_request_auth=_params.get('_request_auth'))

@validate_arguments
def computations_quota_handler(self, offset : conint(strict=True, ge=0), limit : conint(strict=True, ge=0), **kwargs) -> List[ComputationQuota]: # noqa: E501
"""Retrieves the quota used by computations # noqa: E501
Expand Down
18 changes: 5 additions & 13 deletions python/geoengine_openapi_client/models/computation_quota.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@
import json

from datetime import datetime
from typing import List
from pydantic import BaseModel, Field, StrictStr, conlist
from geoengine_openapi_client.models.operator_quota import OperatorQuota

from pydantic import BaseModel, Field, StrictStr, conint

class ComputationQuota(BaseModel):
"""
ComputationQuota
"""
computation_id: StrictStr = Field(..., alias="computationId")
operators: conlist(OperatorQuota) = Field(...)
count: conint(strict=True, ge=0) = Field(...)
timestamp: datetime = Field(...)
workflow_id: StrictStr = Field(..., alias="workflowId")
__properties = ["computationId", "operators", "timestamp", "workflowId"]
__properties = ["computationId", "count", "timestamp", "workflowId"]

class Config:
"""Pydantic configuration"""
Expand All @@ -57,13 +56,6 @@ def to_dict(self):
exclude={
},
exclude_none=True)
# override the default output from pydantic by calling `to_dict()` of each item in operators (list)
_items = []
if self.operators:
for _item in self.operators:
if _item:
_items.append(_item.to_dict())
_dict['operators'] = _items
return _dict

@classmethod
Expand All @@ -77,7 +69,7 @@ def from_dict(cls, obj: dict) -> ComputationQuota:

_obj = ComputationQuota.parse_obj({
"computation_id": obj.get("computationId"),
"operators": [OperatorQuota.from_dict(_item) for _item in obj.get("operators")] if obj.get("operators") is not None else None,
"count": obj.get("count"),
"timestamp": obj.get("timestamp"),
"workflow_id": obj.get("workflowId")
})
Expand Down
14 changes: 2 additions & 12 deletions python/test/test_computation_quota.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,14 @@ def make_instance(self, include_optional) -> ComputationQuota:
if include_optional:
return ComputationQuota(
computation_id = '',
operators = [
geoengine_openapi_client.models.operator_quota.OperatorQuota(
count = 0,
operator_name = '',
operator_path = '', )
],
count = 0,
timestamp = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
workflow_id = ''
)
else:
return ComputationQuota(
computation_id = '',
operators = [
geoengine_openapi_client.models.operator_quota.OperatorQuota(
count = 0,
operator_name = '',
operator_path = '', )
],
count = 0,
timestamp = datetime.datetime.strptime('2013-10-20 19:20:30.00', '%Y-%m-%d %H:%M:%S.%f'),
workflow_id = '',
)
Expand Down
7 changes: 7 additions & 0 deletions python/test/test_user_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ def test_assign_role_handler(self) -> None:
"""
pass

def test_computation_quota_handler(self) -> None:
"""Test case for computation_quota_handler
Retrieves the quota used by computations # noqa: E501
"""
pass

def test_computations_quota_handler(self) -> None:
"""Test case for computations_quota_handler
Expand Down
13 changes: 12 additions & 1 deletion typescript/dist/apis/UserApi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@
* Do not edit the class manually.
*/
import * as runtime from '../runtime';
import type { AddCollection200Response, AddRole, ComputationQuota, Quota, RoleDescription, UpdateQuota } from '../models/index';
import type { AddCollection200Response, AddRole, ComputationQuota, OperatorQuota, Quota, RoleDescription, UpdateQuota } from '../models/index';
export interface AddRoleHandlerRequest {
addRole: AddRole;
}
export interface AssignRoleHandlerRequest {
user: string;
role: string;
}
export interface ComputationQuotaHandlerRequest {
computation: string;
}
export interface ComputationsQuotaHandlerRequest {
offset: number;
limit: number;
Expand Down Expand Up @@ -59,6 +62,14 @@ export declare class UserApi extends runtime.BaseAPI {
* Assign a role to a user. Requires admin privilige.
*/
assignRoleHandler(requestParameters: AssignRoleHandlerRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void>;
/**
* Retrieves the quota used by computations
*/
computationQuotaHandlerRaw(requestParameters: ComputationQuotaHandlerRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<OperatorQuota>>>;
/**
* Retrieves the quota used by computations
*/
computationQuotaHandler(requestParameters: ComputationQuotaHandlerRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<OperatorQuota>>;
/**
* Retrieves the quota used by computations
*/
Expand Down
35 changes: 35 additions & 0 deletions typescript/dist/apis/UserApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,41 @@ class UserApi extends runtime.BaseAPI {
yield this.assignRoleHandlerRaw(requestParameters, initOverrides);
});
}
/**
* Retrieves the quota used by computations
*/
computationQuotaHandlerRaw(requestParameters, initOverrides) {
return __awaiter(this, void 0, void 0, function* () {
if (requestParameters.computation === null || requestParameters.computation === undefined) {
throw new runtime.RequiredError('computation', 'Required parameter requestParameters.computation was null or undefined when calling computationQuotaHandler.');
}
const queryParameters = {};
const headerParameters = {};
if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = yield token("session_token", []);
if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
}
}
const response = yield this.request({
path: `/quota/computations/{computation}`.replace(`{${"computation"}}`, encodeURIComponent(String(requestParameters.computation))),
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(index_1.OperatorQuotaFromJSON));
});
}
/**
* Retrieves the quota used by computations
*/
computationQuotaHandler(requestParameters, initOverrides) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.computationQuotaHandlerRaw(requestParameters, initOverrides);
return yield response.value();
});
}
/**
* Retrieves the quota used by computations
*/
Expand Down
Loading

0 comments on commit 0c69a3a

Please sign in to comment.