diff --git a/applications/accounts-api/api/openapi.yaml b/applications/accounts-api/api/openapi.yaml index c2d7ab18..40849d92 100644 --- a/applications/accounts-api/api/openapi.yaml +++ b/applications/accounts-api/api/openapi.yaml @@ -110,6 +110,64 @@ paths: type: string in: path required: true + '/groups/{groupname}/': + get: + tags: + - groups + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Group' + description: Get a user's public information + operationId: getGroup + put: + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true + tags: + - groups + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: The user as just saved + security: + - + bearerAuth: [] + operationId: updateGroup + parameters: + - + name: groupname + schema: + type: string + in: path + required: true + '/groups/{groupname}/users': + get: + tags: + - groups + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/Group' + description: Get a user's public information + operationId: getGroupUsers + parameters: + - + name: groupname + schema: + type: string + in: path + required: true components: schemas: Valid: @@ -166,6 +224,28 @@ components: $ref: '#/components/schemas/Profiles' description: '' additionalProperties: true + Group: + description: '' + required: + - name + type: object + properties: + quotas: + $ref: '#/components/schemas/Profiles' + description: '' + name: + description: '' + type: string + description: + description: '' + links: + $ref: '#/components/schemas/Profiles' + description: '' + keywords: + description: '' + type: array + items: + type: string securitySchemes: bearerAuth: scheme: bearer diff --git a/applications/accounts-api/backend/accounts_api/controllers/groups_controller.py b/applications/accounts-api/backend/accounts_api/controllers/groups_controller.py new file mode 100644 index 00000000..d41cf60a --- /dev/null +++ b/applications/accounts-api/backend/accounts_api/controllers/groups_controller.py @@ -0,0 +1,50 @@ +import connexion +import six +from typing import Dict +from typing import Tuple +from typing import Union + +from accounts_api.models.group import Group # noqa: E501 +from accounts_api.models.user import User # noqa: E501 +from accounts_api import util + + +def get_group(groupname): # noqa: E501 + """get_group + + # noqa: E501 + + :param groupname: + :type groupname: str + + :rtype: Union[Group, Tuple[Group, int], Tuple[Group, int, Dict[str, str]] + """ + return 'do some magic!' + + +def get_group_users(groupname): # noqa: E501 + """get_group_users + + # noqa: E501 + + :param groupname: + :type groupname: str + + :rtype: Union[Group, Tuple[Group, int], Tuple[Group, int, Dict[str, str]] + """ + return 'do some magic!' + + +def update_group(groupname, request_body): # noqa: E501 + """update_group + + # noqa: E501 + + :param groupname: + :type groupname: str + :param request_body: + :type request_body: Dict[str, ] + + :rtype: Union[User, Tuple[User, int], Tuple[User, int, Dict[str, str]] + """ + return 'do some magic!' diff --git a/applications/accounts-api/backend/accounts_api/models/__init__.py b/applications/accounts-api/backend/accounts_api/models/__init__.py index cb75b5b4..f390d9d1 100644 --- a/applications/accounts-api/backend/accounts_api/models/__init__.py +++ b/applications/accounts-api/backend/accounts_api/models/__init__.py @@ -3,5 +3,6 @@ # flake8: noqa from __future__ import absolute_import # import models into model package +from accounts_api.models.group import Group from accounts_api.models.user import User from accounts_api.models.valid import Valid diff --git a/applications/accounts-api/backend/accounts_api/models/group.py b/applications/accounts-api/backend/accounts_api/models/group.py new file mode 100644 index 00000000..0c2f9e74 --- /dev/null +++ b/applications/accounts-api/backend/accounts_api/models/group.py @@ -0,0 +1,180 @@ +# coding: utf-8 + +from __future__ import absolute_import +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from accounts_api.models.base_model_ import Model +from accounts_api import util + + +class Group(Model): + """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + + Do not edit the class manually. + """ + + def __init__(self, quotas=None, name=None, description=None, links=None, keywords=None): # noqa: E501 + """Group - a model defined in OpenAPI + + :param quotas: The quotas of this Group. # noqa: E501 + :type quotas: Dict[str, object] + :param name: The name of this Group. # noqa: E501 + :type name: str + :param description: The description of this Group. # noqa: E501 + :type description: object + :param links: The links of this Group. # noqa: E501 + :type links: Dict[str, object] + :param keywords: The keywords of this Group. # noqa: E501 + :type keywords: List[str] + """ + self.openapi_types = { + 'quotas': Dict[str, object], + 'name': str, + 'description': object, + 'links': Dict[str, object], + 'keywords': List[str] + } + + self.attribute_map = { + 'quotas': 'quotas', + 'name': 'name', + 'description': 'description', + 'links': 'links', + 'keywords': 'keywords' + } + + self._quotas = quotas + self._name = name + self._description = description + self._links = links + self._keywords = keywords + + @classmethod + def from_dict(cls, dikt) -> 'Group': + """Returns the dict as a model + + :param dikt: A dict. + :type: dict + :return: The Group of this Group. # noqa: E501 + :rtype: Group + """ + return util.deserialize_model(dikt, cls) + + @property + def quotas(self): + """Gets the quotas of this Group. + + # noqa: E501 + + :return: The quotas of this Group. + :rtype: Dict[str, object] + """ + return self._quotas + + @quotas.setter + def quotas(self, quotas): + """Sets the quotas of this Group. + + # noqa: E501 + + :param quotas: The quotas of this Group. + :type quotas: Dict[str, object] + """ + + self._quotas = quotas + + @property + def name(self): + """Gets the name of this Group. + + # noqa: E501 + + :return: The name of this Group. + :rtype: str + """ + return self._name + + @name.setter + def name(self, name): + """Sets the name of this Group. + + # noqa: E501 + + :param name: The name of this Group. + :type name: str + """ + if name is None: + raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 + + self._name = name + + @property + def description(self): + """Gets the description of this Group. + + # noqa: E501 + + :return: The description of this Group. + :rtype: object + """ + return self._description + + @description.setter + def description(self, description): + """Sets the description of this Group. + + # noqa: E501 + + :param description: The description of this Group. + :type description: object + """ + + self._description = description + + @property + def links(self): + """Gets the links of this Group. + + # noqa: E501 + + :return: The links of this Group. + :rtype: Dict[str, object] + """ + return self._links + + @links.setter + def links(self, links): + """Sets the links of this Group. + + # noqa: E501 + + :param links: The links of this Group. + :type links: Dict[str, object] + """ + + self._links = links + + @property + def keywords(self): + """Gets the keywords of this Group. + + # noqa: E501 + + :return: The keywords of this Group. + :rtype: List[str] + """ + return self._keywords + + @keywords.setter + def keywords(self, keywords): + """Sets the keywords of this Group. + + # noqa: E501 + + :param keywords: The keywords of this Group. + :type keywords: List[str] + """ + + self._keywords = keywords diff --git a/applications/accounts-api/backend/accounts_api/openapi/openapi.yaml b/applications/accounts-api/backend/accounts_api/openapi/openapi.yaml index d7407cdc..b8b7877b 100644 --- a/applications/accounts-api/backend/accounts_api/openapi/openapi.yaml +++ b/applications/accounts-api/backend/accounts_api/openapi/openapi.yaml @@ -15,6 +15,76 @@ tags: - description: "" name: users paths: + /groups/{groupname}/: + get: + operationId: get_group + parameters: + - explode: false + in: path + name: groupname + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Group' + description: Get a user's public information + tags: + - groups + x-openapi-router-controller: accounts_api.controllers.groups_controller + put: + operationId: update_group + parameters: + - explode: false + in: path + name: groupname + required: true + schema: + type: string + style: simple + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/User' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/User' + description: The user as just saved + security: + - bearerAuth: [] + tags: + - groups + x-openapi-router-controller: accounts_api.controllers.groups_controller + /groups/{groupname}/users: + get: + operationId: get_group_users + parameters: + - explode: false + in: path + name: groupname + required: true + schema: + type: string + style: simple + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/Group' + description: Get a user's public information + tags: + - groups + x-openapi-router-controller: accounts_api.controllers.groups_controller /live: get: operationId: live @@ -132,6 +202,7 @@ components: Profiles: additionalProperties: true description: "" + title: quotas type: object User: additionalProperties: true @@ -177,6 +248,7 @@ components: profiles: additionalProperties: true description: "" + title: quotas type: object registrationDate: description: "" @@ -191,9 +263,50 @@ components: quotas: additionalProperties: true description: "" + title: quotas type: object title: User type: object + Group: + description: "" + example: + quotas: + key: "" + keywords: + - keywords + - keywords + name: name + description: "" + links: + key: "" + properties: + quotas: + additionalProperties: true + description: "" + title: quotas + type: object + name: + description: "" + title: name + type: string + description: + description: "" + title: description + links: + additionalProperties: true + description: "" + title: quotas + type: object + keywords: + description: "" + items: + type: string + title: keywords + type: array + required: + - name + title: Group + type: object securitySchemes: bearerAuth: bearerFormat: JWT diff --git a/applications/accounts-api/backend/git_push.sh b/applications/accounts-api/backend/git_push.sh index ced3be2b..f53a75d4 100644 --- a/applications/accounts-api/backend/git_push.sh +++ b/applications/accounts-api/backend/git_push.sh @@ -1,7 +1,7 @@ #!/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-pestore-perl "minor update" "gitlab.com" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" git_user_id=$1 git_repo_id=$2 @@ -38,14 +38,14 @@ git add . git commit -m "$release_note" # Sets the new remote -git_remote=`git 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 + git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git fi fi @@ -55,4 +55,3 @@ 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/applications/osb-portal/src/apiclient/accounts/apis/GroupsApi.ts b/applications/osb-portal/src/apiclient/accounts/apis/GroupsApi.ts new file mode 100644 index 00000000..d436a2b0 --- /dev/null +++ b/applications/osb-portal/src/apiclient/accounts/apis/GroupsApi.ts @@ -0,0 +1,143 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * accounts_api + * Accounts rest 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'; +import { + Group, + GroupFromJSON, + GroupToJSON, + User, + UserFromJSON, + UserToJSON, +} from '../models'; + +export interface GetGroupRequest { + groupname: string; +} + +export interface GetGroupUsersRequest { + groupname: string; +} + +export interface UpdateGroupRequest { + groupname: string; + requestBody: { [key: string]: object; }; +} + +/** + * + */ +export class GroupsApi extends runtime.BaseAPI { + + /** + */ + async getGroupRaw(requestParameters: GetGroupRequest): Promise> { + if (requestParameters.groupname === null || requestParameters.groupname === undefined) { + throw new runtime.RequiredError('groupname','Required parameter requestParameters.groupname was null or undefined when calling getGroup.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/groups/{groupname}/`.replace(`{${"groupname"}}`, encodeURIComponent(String(requestParameters.groupname))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }); + + return new runtime.JSONApiResponse(response, (jsonValue) => GroupFromJSON(jsonValue)); + } + + /** + */ + async getGroup(requestParameters: GetGroupRequest): Promise { + const response = await this.getGroupRaw(requestParameters); + return await response.value(); + } + + /** + */ + async getGroupUsersRaw(requestParameters: GetGroupUsersRequest): Promise> { + if (requestParameters.groupname === null || requestParameters.groupname === undefined) { + throw new runtime.RequiredError('groupname','Required parameter requestParameters.groupname was null or undefined when calling getGroupUsers.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/groups/{groupname}/users`.replace(`{${"groupname"}}`, encodeURIComponent(String(requestParameters.groupname))), + method: 'GET', + headers: headerParameters, + query: queryParameters, + }); + + return new runtime.JSONApiResponse(response, (jsonValue) => GroupFromJSON(jsonValue)); + } + + /** + */ + async getGroupUsers(requestParameters: GetGroupUsersRequest): Promise { + const response = await this.getGroupUsersRaw(requestParameters); + return await response.value(); + } + + /** + */ + async updateGroupRaw(requestParameters: UpdateGroupRequest): Promise> { + if (requestParameters.groupname === null || requestParameters.groupname === undefined) { + throw new runtime.RequiredError('groupname','Required parameter requestParameters.groupname was null or undefined when calling updateGroup.'); + } + + if (requestParameters.requestBody === null || requestParameters.requestBody === undefined) { + throw new runtime.RequiredError('requestBody','Required parameter requestParameters.requestBody was null or undefined when calling updateGroup.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + if (this.configuration && this.configuration.accessToken) { + const token = this.configuration.accessToken; + const tokenString = typeof token === 'function' ? token("bearerAuth", []) : token; + + if (tokenString) { + headerParameters["Authorization"] = `Bearer ${tokenString}`; + } + } + const response = await this.request({ + path: `/groups/{groupname}/`.replace(`{${"groupname"}}`, encodeURIComponent(String(requestParameters.groupname))), + method: 'PUT', + headers: headerParameters, + query: queryParameters, + body: requestParameters.requestBody, + }); + + return new runtime.JSONApiResponse(response, (jsonValue) => UserFromJSON(jsonValue)); + } + + /** + */ + async updateGroup(requestParameters: UpdateGroupRequest): Promise { + const response = await this.updateGroupRaw(requestParameters); + return await response.value(); + } + +} diff --git a/applications/osb-portal/src/apiclient/accounts/apis/index.ts b/applications/osb-portal/src/apiclient/accounts/apis/index.ts index 9b2e2f39..6af9c199 100644 --- a/applications/osb-portal/src/apiclient/accounts/apis/index.ts +++ b/applications/osb-portal/src/apiclient/accounts/apis/index.ts @@ -1,2 +1,3 @@ +export * from './GroupsApi'; export * from './InfrastructureApi'; export * from './UsersApi'; diff --git a/applications/osb-portal/src/apiclient/accounts/models/Group.ts b/applications/osb-portal/src/apiclient/accounts/models/Group.ts new file mode 100644 index 00000000..4fc086c4 --- /dev/null +++ b/applications/osb-portal/src/apiclient/accounts/models/Group.ts @@ -0,0 +1,89 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * accounts_api + * Accounts rest 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 { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface Group + */ +export interface Group { + /** + * + * @type {{ [key: string]: object; }} + * @memberof Group + */ + quotas?: { [key: string]: object; }; + /** + * + * @type {string} + * @memberof Group + */ + name: string; + /** + * + * @type {any} + * @memberof Group + */ + description?: any | null; + /** + * + * @type {{ [key: string]: object; }} + * @memberof Group + */ + links?: { [key: string]: object; }; + /** + * + * @type {Array} + * @memberof Group + */ + keywords?: Array; +} + +export function GroupFromJSON(json: any): Group { + return GroupFromJSONTyped(json, false); +} + +export function GroupFromJSONTyped(json: any, ignoreDiscriminator: boolean): Group { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'quotas': !exists(json, 'quotas') ? undefined : json['quotas'], + 'name': json['name'], + 'description': !exists(json, 'description') ? undefined : json['description'], + 'links': !exists(json, 'links') ? undefined : json['links'], + 'keywords': !exists(json, 'keywords') ? undefined : json['keywords'], + }; +} + +export function GroupToJSON(value?: Group | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'quotas': value.quotas, + 'name': value.name, + 'description': value.description, + 'links': value.links, + 'keywords': value.keywords, + }; +} + + diff --git a/applications/osb-portal/src/apiclient/accounts/models/User.ts b/applications/osb-portal/src/apiclient/accounts/models/User.ts index 785683c7..6721e6fc 100644 --- a/applications/osb-portal/src/apiclient/accounts/models/User.ts +++ b/applications/osb-portal/src/apiclient/accounts/models/User.ts @@ -80,6 +80,12 @@ export interface User { * @memberof User */ website?: string; + /** + * + * @type {{ [key: string]: object; }} + * @memberof User + */ + quotas?: { [key: string]: object; }; } export function UserFromJSON(json: any): User { @@ -103,6 +109,7 @@ export function UserFromJSONTyped(json: any, ignoreDiscriminator: boolean): User 'registrationDate': !exists(json, 'registrationDate') ? undefined : (new Date(json['registrationDate'])), 'avatar': !exists(json, 'avatar') ? undefined : json['avatar'], 'website': !exists(json, 'website') ? undefined : json['website'], + 'quotas': !exists(json, 'quotas') ? undefined : json['quotas'], }; } @@ -125,6 +132,7 @@ export function UserToJSON(value?: User | null): any { 'registrationDate': value.registrationDate === undefined ? undefined : (value.registrationDate.toISOString().substr(0,10)), 'avatar': value.avatar, 'website': value.website, + 'quotas': value.quotas, }; } diff --git a/applications/osb-portal/src/apiclient/accounts/models/index.ts b/applications/osb-portal/src/apiclient/accounts/models/index.ts index 33e0be7c..5a5522df 100644 --- a/applications/osb-portal/src/apiclient/accounts/models/index.ts +++ b/applications/osb-portal/src/apiclient/accounts/models/index.ts @@ -1,2 +1,3 @@ +export * from './Group'; export * from './User'; export * from './Valid'; diff --git a/applications/osb-portal/src/apiclient/accounts/runtime.ts b/applications/osb-portal/src/apiclient/accounts/runtime.ts index f6ebf709..01640c31 100644 --- a/applications/osb-portal/src/apiclient/accounts/runtime.ts +++ b/applications/osb-portal/src/apiclient/accounts/runtime.ts @@ -79,21 +79,21 @@ export class BaseAPI { let fetchParams = { url, init }; for (const middleware of this.middleware) { if (middleware.pre) { - fetchParams = (await middleware.pre({ + fetchParams = await middleware.pre({ fetch: this.fetchApi, ...fetchParams, - })) || fetchParams; + }) || fetchParams; } } let response = await this.configuration.fetchApi(fetchParams.url, fetchParams.init); for (const middleware of this.middleware) { if (middleware.post) { - response = (await middleware.post({ + response = await middleware.post({ fetch: this.fetchApi, url, init, response: response.clone(), - })) || response; + }) || response; } } return response;