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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions applications/samples/backend/samples/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
from samples.models.inline_response202 import InlineResponse202
from samples.models.inline_response202_task import InlineResponse202Task
from samples.models.sample_resource import SampleResource
from samples.models.write_file200_response import WriteFile200Response
from samples.models.write_file_request import WriteFileRequest
113 changes: 113 additions & 0 deletions applications/samples/backend/samples/models/write_file200_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
from datetime import date, datetime # noqa: F401

from typing import List, Dict # noqa: F401

from samples.models.base_model import Model
from samples import util


class WriteFile200Response(Model):
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

Do not edit the class manually.
"""

def __init__(self, filename=None, path=None, hostname=None): # noqa: E501
"""WriteFile200Response - a model defined in OpenAPI

:param filename: The filename of this WriteFile200Response. # noqa: E501
:type filename: str
:param path: The path of this WriteFile200Response. # noqa: E501
:type path: str
:param hostname: The hostname of this WriteFile200Response. # noqa: E501
:type hostname: str
"""
self.openapi_types = {
'filename': str,
'path': str,
'hostname': str
}

self.attribute_map = {
'filename': 'filename',
'path': 'path',
'hostname': 'hostname'
}

self._filename = filename
self._path = path
self._hostname = hostname

@classmethod
def from_dict(cls, dikt) -> 'WriteFile200Response':
"""Returns the dict as a model

:param dikt: A dict.
:type: dict
:return: The write_file_200_response of this WriteFile200Response. # noqa: E501
:rtype: WriteFile200Response
"""
return util.deserialize_model(dikt, cls)

@property
def filename(self) -> str:
"""Gets the filename of this WriteFile200Response.


:return: The filename of this WriteFile200Response.
:rtype: str
"""
return self._filename

@filename.setter
def filename(self, filename: str):
"""Sets the filename of this WriteFile200Response.


:param filename: The filename of this WriteFile200Response.
:type filename: str
"""

self._filename = filename

@property
def path(self) -> str:
"""Gets the path of this WriteFile200Response.


:return: The path of this WriteFile200Response.
:rtype: str
"""
return self._path

@path.setter
def path(self, path: str):
"""Sets the path of this WriteFile200Response.


:param path: The path of this WriteFile200Response.
:type path: str
"""

self._path = path

@property
def hostname(self) -> str:
"""Gets the hostname of this WriteFile200Response.


:return: The hostname of this WriteFile200Response.
:rtype: str
"""
return self._hostname

@hostname.setter
def hostname(self, hostname: str):
"""Sets the hostname of this WriteFile200Response.


:param hostname: The hostname of this WriteFile200Response.
:type hostname: str
"""

self._hostname = hostname
61 changes: 61 additions & 0 deletions applications/samples/backend/samples/models/write_file_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
from datetime import date, datetime # noqa: F401

from typing import List, Dict # noqa: F401

from samples.models.base_model import Model
from samples import util


class WriteFileRequest(Model):
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

Do not edit the class manually.
"""

def __init__(self, content=None): # noqa: E501
"""WriteFileRequest - a model defined in OpenAPI

:param content: The content of this WriteFileRequest. # noqa: E501
:type content: str
"""
self.openapi_types = {
'content': str
}

self.attribute_map = {
'content': 'content'
}

self._content = content

@classmethod
def from_dict(cls, dikt) -> 'WriteFileRequest':
"""Returns the dict as a model

:param dikt: A dict.
:type: dict
:return: The write_file_request of this WriteFileRequest. # noqa: E501
:rtype: WriteFileRequest
"""
return util.deserialize_model(dikt, cls)

@property
def content(self) -> str:
"""Gets the content of this WriteFileRequest.


:return: The content of this WriteFileRequest.
:rtype: str
"""
return self._content

@content.setter
def content(self, content: str):
"""Sets the content of this WriteFileRequest.


:param content: The content of this WriteFileRequest.
:type content: str
"""

self._content = content
49 changes: 49 additions & 0 deletions applications/samples/backend/samples/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,31 @@ paths:
tags:
- auth
x-openapi-router-controller: samples.controllers.auth_controller
/write-file:
post:
description: "Writes a timestamped file on the application volume and returns\
\ the name of the pod that handled the request. On a statefulset deployment,\
\ route this endpoint to the leader service to have all writes land on pod\
\ 0."
operationId: write_file
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/write_file_request'
description: Optional content of the file to write.
required: false
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/write_file_200_response'
description: The file was written on the application volume
summary: writes a file on the application volume
tags:
- test
x-openapi-router-controller: samples.controllers.test_controller
components:
schemas:
inline_response_202_task:
Expand Down Expand Up @@ -343,6 +368,30 @@ components:
- a
title: SampleResource
type: object
write_file_request:
properties:
content:
title: content
type: string
title: write_file_request
type: object
write_file_200_response:
example:
path: path
hostname: hostname
filename: filename
properties:
filename:
title: filename
type: string
path:
title: path
type: string
hostname:
title: hostname
type: string
title: write_file_200_response
type: object
securitySchemes:
bearerAuth:
bearerFormat: JWT
Expand Down
10 changes: 5 additions & 5 deletions applications/samples/backend/samples/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ def deserialize_date(string):
:rtype: date
"""
if string is None:
return None

return None
try:
from dateutil.parser import parse
return parse(string).date()
Expand All @@ -87,8 +87,8 @@ def deserialize_datetime(string):
:rtype: datetime
"""
if string is None:
return None

return None
try:
from dateutil.parser import parse
return parse(string)
Expand Down Expand Up @@ -144,4 +144,4 @@ def _deserialize_dict(data, boxed_type):
:rtype: dict
"""
return {k: _deserialize(v, boxed_type)
for k, v in data.items()}
for k, v in data.items() }
2 changes: 1 addition & 1 deletion applications/samples/frontend/src/components/RestTest.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState, useEffect } from 'react';


import { TestApi } from '../rest/apis/TestApi'
import { TestApi } from '../rest/samples/apis/TestApi'
const test = new TestApi();


Expand Down
55 changes: 55 additions & 0 deletions applications/samples/frontend/src/rest/samples/apis/DatabaseApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* tslint:disable */
/* eslint-disable */
/**
* CloudHarness Sample API
* CloudHarness Sample api
*
* The version of the OpenAPI document: 0.1.0
* Contact: cloudharness@metacell.us
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/


import * as runtime from '../runtime';

/**
*
*/
export class DatabaseApi extends runtime.BaseAPI {

/**
* Returns the database connection string for the current application.
* Get database connection string
*/
async getDbConnectStringRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<string>> {
const queryParameters: any = {};

const headerParameters: runtime.HTTPHeaders = {};

const response = await this.request({
path: `/db-connect-string`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);

if (this.isJsonMime(response.headers.get('content-type'))) {
return new runtime.JSONApiResponse<string>(response);
} else {
return new runtime.TextApiResponse(response) as any;
}
}

/**
* Returns the database connection string for the current application.
* Get database connection string
*/
async getDbConnectString(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<string> {
const response = await this.getDbConnectStringRaw(initOverrides);
return await response.value();
}

}
Loading
Loading