From 59a78a87bda69214963ec8880df18dd07d1570d2 Mon Sep 17 00:00:00 2001 From: Mark Xiong Date: Wed, 7 Aug 2024 15:39:21 -0500 Subject: [PATCH] dismissed cue (#4211) --- api/cues_api.py | 14 ++- .../.openapi-generator/FILES | 4 + .../src/apis/DefaultApi.ts | 104 ++++++++++++++++++ .../src/models/DismissCueRequest.ts | 71 ++++++++++++ .../src/models/ErrorMessage.ts | 60 ++++++++++ .../src/models/GetDismissedCues400Response.ts | 60 ++++++++++ .../src/models/SuccessMessage.ts | 60 ++++++++++ .../chromestatus-openapi/src/models/index.ts | 4 + .../.openapi-generator/FILES | 4 + .../controllers/default_controller.py | 29 +++++ .../chromestatus_openapi/models/__init__.py | 4 + .../models/dismiss_cue_request.py | 67 +++++++++++ .../models/error_message.py | 61 ++++++++++ .../models/get_dismissed_cues400_response.py | 61 ++++++++++ .../models/success_message.py | 61 ++++++++++ .../chromestatus_openapi/openapi/openapi.yaml | 75 +++++++++++++ .../test/test_default_controller.py | 49 +++++++++ openapi/api.yaml | 59 ++++++++++ 18 files changed, 842 insertions(+), 5 deletions(-) create mode 100644 gen/js/chromestatus-openapi/src/models/DismissCueRequest.ts create mode 100644 gen/js/chromestatus-openapi/src/models/ErrorMessage.ts create mode 100644 gen/js/chromestatus-openapi/src/models/GetDismissedCues400Response.ts create mode 100644 gen/js/chromestatus-openapi/src/models/SuccessMessage.ts create mode 100644 gen/py/chromestatus_openapi/chromestatus_openapi/models/dismiss_cue_request.py create mode 100644 gen/py/chromestatus_openapi/chromestatus_openapi/models/error_message.py create mode 100644 gen/py/chromestatus_openapi/chromestatus_openapi/models/get_dismissed_cues400_response.py create mode 100644 gen/py/chromestatus_openapi/chromestatus_openapi/models/success_message.py diff --git a/api/cues_api.py b/api/cues_api.py index 3c35d6ca553a..e733a3081cbd 100644 --- a/api/cues_api.py +++ b/api/cues_api.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +from chromestatus_openapi.models import (DismissCueRequest) + import logging from framework import basehandlers @@ -33,12 +35,14 @@ class CuesAPI(basehandlers.APIHandler): def do_post(self, **kwargs): """Dismisses a cue card for the signed in user.""" - cue = self.get_param('cue', allowed=ALLOWED_CUES) - unused_user = self.get_current_user(required=True) - - user_models.UserPref.dismiss_cue(cue) + try: + request = DismissCueRequest.from_dict(self.request.json) + user_models.UserPref.dismiss_cue(request.cue) + return {'message': 'Done'} + except ValueError as e: + self.abort(400, str(e)) # Callers don't use the JSON response for this API call. - return {'message': 'Done'} + def do_get(self, **kwargs): """Return a list of the dismissed cue cards""" diff --git a/gen/js/chromestatus-openapi/.openapi-generator/FILES b/gen/js/chromestatus-openapi/.openapi-generator/FILES index a7e4d300c062..bbf15de690ba 100644 --- a/gen/js/chromestatus-openapi/.openapi-generator/FILES +++ b/gen/js/chromestatus-openapi/.openapi-generator/FILES @@ -12,10 +12,13 @@ src/models/ComponentsUser.ts src/models/ComponentsUsersResponse.ts src/models/CreateAccountRequest.ts src/models/DeleteAccount200Response.ts +src/models/DismissCueRequest.ts +src/models/ErrorMessage.ts src/models/ExternalReviewsResponse.ts src/models/FeatureLatency.ts src/models/FeatureLink.ts src/models/GateLatency.ts +src/models/GetDismissedCues400Response.ts src/models/GetIntentResponse.ts src/models/LinkPreview.ts src/models/LinkPreviewBase.ts @@ -37,6 +40,7 @@ src/models/OwnersAndSubscribersOfComponent.ts src/models/PostIntentRequest.ts src/models/ReviewLatency.ts src/models/SpecMentor.ts +src/models/SuccessMessage.ts src/models/index.ts src/runtime.ts tsconfig.esm.json diff --git a/gen/js/chromestatus-openapi/src/apis/DefaultApi.ts b/gen/js/chromestatus-openapi/src/apis/DefaultApi.ts index 914d0fab884f..9dd4d6abdf87 100644 --- a/gen/js/chromestatus-openapi/src/apis/DefaultApi.ts +++ b/gen/js/chromestatus-openapi/src/apis/DefaultApi.ts @@ -20,13 +20,16 @@ import type { ComponentsUsersResponse, CreateAccountRequest, DeleteAccount200Response, + DismissCueRequest, ExternalReviewsResponse, FeatureLatency, + GetDismissedCues400Response, GetIntentResponse, MessageResponse, PostIntentRequest, ReviewLatency, SpecMentor, + SuccessMessage, } from '../models/index'; import { AccountResponseFromJSON, @@ -39,10 +42,14 @@ import { CreateAccountRequestToJSON, DeleteAccount200ResponseFromJSON, DeleteAccount200ResponseToJSON, + DismissCueRequestFromJSON, + DismissCueRequestToJSON, ExternalReviewsResponseFromJSON, ExternalReviewsResponseToJSON, FeatureLatencyFromJSON, FeatureLatencyToJSON, + GetDismissedCues400ResponseFromJSON, + GetDismissedCues400ResponseToJSON, GetIntentResponseFromJSON, GetIntentResponseToJSON, MessageResponseFromJSON, @@ -53,6 +60,8 @@ import { ReviewLatencyToJSON, SpecMentorFromJSON, SpecMentorToJSON, + SuccessMessageFromJSON, + SuccessMessageToJSON, } from '../models/index'; export interface AddUserToComponentRequest { @@ -69,6 +78,10 @@ export interface DeleteAccountRequest { accountId: number; } +export interface DismissCueOperationRequest { + dismissCueRequest: DismissCueRequest; +} + export interface GetIntentBodyRequest { featureId: number; stageId: number; @@ -155,6 +168,35 @@ export interface DefaultApiInterface { */ deleteAccount(requestParameters: DeleteAccountRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; + /** + * + * @summary Dismiss a cue card for the signed-in user + * @param {DismissCueRequest} dismissCueRequest + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DefaultApiInterface + */ + dismissCueRaw(requestParameters: DismissCueOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; + + /** + * Dismiss a cue card for the signed-in user + */ + dismissCue(requestParameters: DismissCueOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise; + + /** + * + * @summary Get dismissed cues for the current user + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DefaultApiInterface + */ + getDismissedCuesRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>>; + + /** + * Get dismissed cues for the current user + */ + getDismissedCues(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>; + /** * * @summary Get the HTML body of an intent draft @@ -396,6 +438,68 @@ export class DefaultApi extends runtime.BaseAPI implements DefaultApiInterface { return await response.value(); } + /** + * Dismiss a cue card for the signed-in user + */ + async dismissCueRaw(requestParameters: DismissCueOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters['dismissCueRequest'] == null) { + throw new runtime.RequiredError( + 'dismissCueRequest', + 'Required parameter "dismissCueRequest" was null or undefined when calling dismissCue().' + ); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/currentuser/cues`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: DismissCueRequestToJSON(requestParameters['dismissCueRequest']), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => SuccessMessageFromJSON(jsonValue)); + } + + /** + * Dismiss a cue card for the signed-in user + */ + async dismissCue(requestParameters: DismissCueOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.dismissCueRaw(requestParameters, initOverrides); + return await response.value(); + } + + /** + * Get dismissed cues for the current user + */ + async getDismissedCuesRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> { + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + const response = await this.request({ + path: `/currentuser/cues`, + method: 'GET', + headers: headerParameters, + query: queryParameters, + }, initOverrides); + + return new runtime.JSONApiResponse(response); + } + + /** + * Get dismissed cues for the current user + */ + async getDismissedCues(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + const response = await this.getDismissedCuesRaw(initOverrides); + return await response.value(); + } + /** * Get the HTML body of an intent draft */ diff --git a/gen/js/chromestatus-openapi/src/models/DismissCueRequest.ts b/gen/js/chromestatus-openapi/src/models/DismissCueRequest.ts new file mode 100644 index 000000000000..0df7135bdcfd --- /dev/null +++ b/gen/js/chromestatus-openapi/src/models/DismissCueRequest.ts @@ -0,0 +1,71 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * chomestatus API + * The API for chromestatus.com. chromestatus.com is the official tool used for tracking feature launches in Blink (the browser engine that powers Chrome and many other web browsers). This tool guides feature owners through our launch process and serves as a primary source for developer information that then ripples throughout the web developer ecosystem. More details at: https://github.com/GoogleChrome/chromium-dashboard + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface DismissCueRequest + */ +export interface DismissCueRequest { + /** + * + * @type {string} + * @memberof DismissCueRequest + */ + cue: DismissCueRequestCueEnum; +} + + +/** + * @export + */ +export const DismissCueRequestCueEnum = { + progress_checkmarks: 'progress-checkmarks' +} as const; +export type DismissCueRequestCueEnum = typeof DismissCueRequestCueEnum[keyof typeof DismissCueRequestCueEnum]; + + +/** + * Check if a given object implements the DismissCueRequest interface. + */ +export function instanceOfDismissCueRequest(value: object): value is DismissCueRequest { + if (!('cue' in value) || value['cue'] === undefined) return false; + return true; +} + +export function DismissCueRequestFromJSON(json: any): DismissCueRequest { + return DismissCueRequestFromJSONTyped(json, false); +} + +export function DismissCueRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): DismissCueRequest { + if (json == null) { + return json; + } + return { + + 'cue': json['cue'], + }; +} + +export function DismissCueRequestToJSON(value?: DismissCueRequest | null): any { + if (value == null) { + return value; + } + return { + + 'cue': value['cue'], + }; +} + diff --git a/gen/js/chromestatus-openapi/src/models/ErrorMessage.ts b/gen/js/chromestatus-openapi/src/models/ErrorMessage.ts new file mode 100644 index 000000000000..6651a2c58f50 --- /dev/null +++ b/gen/js/chromestatus-openapi/src/models/ErrorMessage.ts @@ -0,0 +1,60 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * chomestatus API + * The API for chromestatus.com. chromestatus.com is the official tool used for tracking feature launches in Blink (the browser engine that powers Chrome and many other web browsers). This tool guides feature owners through our launch process and serves as a primary source for developer information that then ripples throughout the web developer ecosystem. More details at: https://github.com/GoogleChrome/chromium-dashboard + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface ErrorMessage + */ +export interface ErrorMessage { + /** + * + * @type {string} + * @memberof ErrorMessage + */ + error?: string; +} + +/** + * Check if a given object implements the ErrorMessage interface. + */ +export function instanceOfErrorMessage(value: object): value is ErrorMessage { + return true; +} + +export function ErrorMessageFromJSON(json: any): ErrorMessage { + return ErrorMessageFromJSONTyped(json, false); +} + +export function ErrorMessageFromJSONTyped(json: any, ignoreDiscriminator: boolean): ErrorMessage { + if (json == null) { + return json; + } + return { + + 'error': json['error'] == null ? undefined : json['error'], + }; +} + +export function ErrorMessageToJSON(value?: ErrorMessage | null): any { + if (value == null) { + return value; + } + return { + + 'error': value['error'], + }; +} + diff --git a/gen/js/chromestatus-openapi/src/models/GetDismissedCues400Response.ts b/gen/js/chromestatus-openapi/src/models/GetDismissedCues400Response.ts new file mode 100644 index 000000000000..c90b615a140d --- /dev/null +++ b/gen/js/chromestatus-openapi/src/models/GetDismissedCues400Response.ts @@ -0,0 +1,60 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * chomestatus API + * The API for chromestatus.com. chromestatus.com is the official tool used for tracking feature launches in Blink (the browser engine that powers Chrome and many other web browsers). This tool guides feature owners through our launch process and serves as a primary source for developer information that then ripples throughout the web developer ecosystem. More details at: https://github.com/GoogleChrome/chromium-dashboard + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface GetDismissedCues400Response + */ +export interface GetDismissedCues400Response { + /** + * + * @type {string} + * @memberof GetDismissedCues400Response + */ + error?: string; +} + +/** + * Check if a given object implements the GetDismissedCues400Response interface. + */ +export function instanceOfGetDismissedCues400Response(value: object): value is GetDismissedCues400Response { + return true; +} + +export function GetDismissedCues400ResponseFromJSON(json: any): GetDismissedCues400Response { + return GetDismissedCues400ResponseFromJSONTyped(json, false); +} + +export function GetDismissedCues400ResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): GetDismissedCues400Response { + if (json == null) { + return json; + } + return { + + 'error': json['error'] == null ? undefined : json['error'], + }; +} + +export function GetDismissedCues400ResponseToJSON(value?: GetDismissedCues400Response | null): any { + if (value == null) { + return value; + } + return { + + 'error': value['error'], + }; +} + diff --git a/gen/js/chromestatus-openapi/src/models/SuccessMessage.ts b/gen/js/chromestatus-openapi/src/models/SuccessMessage.ts new file mode 100644 index 000000000000..7e8a85d6cf55 --- /dev/null +++ b/gen/js/chromestatus-openapi/src/models/SuccessMessage.ts @@ -0,0 +1,60 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * chomestatus API + * The API for chromestatus.com. chromestatus.com is the official tool used for tracking feature launches in Blink (the browser engine that powers Chrome and many other web browsers). This tool guides feature owners through our launch process and serves as a primary source for developer information that then ripples throughout the web developer ecosystem. More details at: https://github.com/GoogleChrome/chromium-dashboard + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { mapValues } from '../runtime'; +/** + * + * @export + * @interface SuccessMessage + */ +export interface SuccessMessage { + /** + * + * @type {string} + * @memberof SuccessMessage + */ + message?: string; +} + +/** + * Check if a given object implements the SuccessMessage interface. + */ +export function instanceOfSuccessMessage(value: object): value is SuccessMessage { + return true; +} + +export function SuccessMessageFromJSON(json: any): SuccessMessage { + return SuccessMessageFromJSONTyped(json, false); +} + +export function SuccessMessageFromJSONTyped(json: any, ignoreDiscriminator: boolean): SuccessMessage { + if (json == null) { + return json; + } + return { + + 'message': json['message'] == null ? undefined : json['message'], + }; +} + +export function SuccessMessageToJSON(value?: SuccessMessage | null): any { + if (value == null) { + return value; + } + return { + + 'message': value['message'], + }; +} + diff --git a/gen/js/chromestatus-openapi/src/models/index.ts b/gen/js/chromestatus-openapi/src/models/index.ts index 714198a03a05..6807e07a4e43 100644 --- a/gen/js/chromestatus-openapi/src/models/index.ts +++ b/gen/js/chromestatus-openapi/src/models/index.ts @@ -6,10 +6,13 @@ export * from './ComponentsUser'; export * from './ComponentsUsersResponse'; export * from './CreateAccountRequest'; export * from './DeleteAccount200Response'; +export * from './DismissCueRequest'; +export * from './ErrorMessage'; export * from './ExternalReviewsResponse'; export * from './FeatureLatency'; export * from './FeatureLink'; export * from './GateLatency'; +export * from './GetDismissedCues400Response'; export * from './GetIntentResponse'; export * from './LinkPreview'; export * from './LinkPreviewBase'; @@ -31,3 +34,4 @@ export * from './OwnersAndSubscribersOfComponent'; export * from './PostIntentRequest'; export * from './ReviewLatency'; export * from './SpecMentor'; +export * from './SuccessMessage'; diff --git a/gen/py/chromestatus_openapi/.openapi-generator/FILES b/gen/py/chromestatus_openapi/.openapi-generator/FILES index 601be91f791d..7f0852350b63 100644 --- a/gen/py/chromestatus_openapi/.openapi-generator/FILES +++ b/gen/py/chromestatus_openapi/.openapi-generator/FILES @@ -18,10 +18,13 @@ chromestatus_openapi/models/components_user.py chromestatus_openapi/models/components_users_response.py chromestatus_openapi/models/create_account_request.py chromestatus_openapi/models/delete_account200_response.py +chromestatus_openapi/models/dismiss_cue_request.py +chromestatus_openapi/models/error_message.py chromestatus_openapi/models/external_reviews_response.py chromestatus_openapi/models/feature_latency.py chromestatus_openapi/models/feature_link.py chromestatus_openapi/models/gate_latency.py +chromestatus_openapi/models/get_dismissed_cues400_response.py chromestatus_openapi/models/get_intent_response.py chromestatus_openapi/models/link_preview.py chromestatus_openapi/models/link_preview_base.py @@ -43,6 +46,7 @@ chromestatus_openapi/models/owners_and_subscribers_of_component.py chromestatus_openapi/models/post_intent_request.py chromestatus_openapi/models/review_latency.py chromestatus_openapi/models/spec_mentor.py +chromestatus_openapi/models/success_message.py chromestatus_openapi/openapi/openapi.yaml chromestatus_openapi/test/__init__.py chromestatus_openapi/test/test_default_controller.py diff --git a/gen/py/chromestatus_openapi/chromestatus_openapi/controllers/default_controller.py b/gen/py/chromestatus_openapi/chromestatus_openapi/controllers/default_controller.py index d263a6dba418..b59acf78fd4a 100644 --- a/gen/py/chromestatus_openapi/chromestatus_openapi/controllers/default_controller.py +++ b/gen/py/chromestatus_openapi/chromestatus_openapi/controllers/default_controller.py @@ -8,13 +8,16 @@ from chromestatus_openapi.models.components_users_response import ComponentsUsersResponse # noqa: E501 from chromestatus_openapi.models.create_account_request import CreateAccountRequest # noqa: E501 from chromestatus_openapi.models.delete_account200_response import DeleteAccount200Response # noqa: E501 +from chromestatus_openapi.models.dismiss_cue_request import DismissCueRequest # noqa: E501 from chromestatus_openapi.models.external_reviews_response import ExternalReviewsResponse # noqa: E501 from chromestatus_openapi.models.feature_latency import FeatureLatency # noqa: E501 +from chromestatus_openapi.models.get_dismissed_cues400_response import GetDismissedCues400Response # noqa: E501 from chromestatus_openapi.models.get_intent_response import GetIntentResponse # noqa: E501 from chromestatus_openapi.models.message_response import MessageResponse # noqa: E501 from chromestatus_openapi.models.post_intent_request import PostIntentRequest # noqa: E501 from chromestatus_openapi.models.review_latency import ReviewLatency # noqa: E501 from chromestatus_openapi.models.spec_mentor import SpecMentor # noqa: E501 +from chromestatus_openapi.models.success_message import SuccessMessage # noqa: E501 from chromestatus_openapi import util @@ -65,6 +68,32 @@ def delete_account(account_id): # noqa: E501 return 'do some magic!' +def dismiss_cue(dismiss_cue_request): # noqa: E501 + """Dismiss a cue card for the signed-in user + + # noqa: E501 + + :param dismiss_cue_request: + :type dismiss_cue_request: dict | bytes + + :rtype: Union[SuccessMessage, Tuple[SuccessMessage, int], Tuple[SuccessMessage, int, Dict[str, str]] + """ + if connexion.request.is_json: + dismiss_cue_request = DismissCueRequest.from_dict(connexion.request.get_json()) # noqa: E501 + return 'do some magic!' + + +def get_dismissed_cues(): # noqa: E501 + """Get dismissed cues for the current user + + # noqa: E501 + + + :rtype: Union[List[str], Tuple[List[str], int], Tuple[List[str], int, Dict[str, str]] + """ + return 'do some magic!' + + def get_intent_body(feature_id, stage_id, gate_id): # noqa: E501 """Get the HTML body of an intent draft diff --git a/gen/py/chromestatus_openapi/chromestatus_openapi/models/__init__.py b/gen/py/chromestatus_openapi/chromestatus_openapi/models/__init__.py index 81bf29b6e9dd..87bb698c3d3a 100644 --- a/gen/py/chromestatus_openapi/chromestatus_openapi/models/__init__.py +++ b/gen/py/chromestatus_openapi/chromestatus_openapi/models/__init__.py @@ -6,10 +6,13 @@ from chromestatus_openapi.models.components_users_response import ComponentsUsersResponse from chromestatus_openapi.models.create_account_request import CreateAccountRequest from chromestatus_openapi.models.delete_account200_response import DeleteAccount200Response +from chromestatus_openapi.models.dismiss_cue_request import DismissCueRequest +from chromestatus_openapi.models.error_message import ErrorMessage from chromestatus_openapi.models.external_reviews_response import ExternalReviewsResponse from chromestatus_openapi.models.feature_latency import FeatureLatency from chromestatus_openapi.models.feature_link import FeatureLink from chromestatus_openapi.models.gate_latency import GateLatency +from chromestatus_openapi.models.get_dismissed_cues400_response import GetDismissedCues400Response from chromestatus_openapi.models.get_intent_response import GetIntentResponse from chromestatus_openapi.models.link_preview import LinkPreview from chromestatus_openapi.models.link_preview_base import LinkPreviewBase @@ -31,3 +34,4 @@ from chromestatus_openapi.models.post_intent_request import PostIntentRequest from chromestatus_openapi.models.review_latency import ReviewLatency from chromestatus_openapi.models.spec_mentor import SpecMentor +from chromestatus_openapi.models.success_message import SuccessMessage diff --git a/gen/py/chromestatus_openapi/chromestatus_openapi/models/dismiss_cue_request.py b/gen/py/chromestatus_openapi/chromestatus_openapi/models/dismiss_cue_request.py new file mode 100644 index 000000000000..044b35a7728a --- /dev/null +++ b/gen/py/chromestatus_openapi/chromestatus_openapi/models/dismiss_cue_request.py @@ -0,0 +1,67 @@ +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from chromestatus_openapi.models.base_model import Model +from chromestatus_openapi import util + + +class DismissCueRequest(Model): + """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + + Do not edit the class manually. + """ + + def __init__(self, cue=None): # noqa: E501 + """DismissCueRequest - a model defined in OpenAPI + + :param cue: The cue of this DismissCueRequest. # noqa: E501 + :type cue: str + """ + self.openapi_types = { + 'cue': str + } + + self.attribute_map = { + 'cue': 'cue' + } + + self._cue = cue + + @classmethod + def from_dict(cls, dikt) -> 'DismissCueRequest': + """Returns the dict as a model + + :param dikt: A dict. + :type: dict + :return: The DismissCueRequest of this DismissCueRequest. # noqa: E501 + :rtype: DismissCueRequest + """ + return util.deserialize_model(dikt, cls) + + @property + def cue(self) -> str: + """Gets the cue of this DismissCueRequest. + + + :return: The cue of this DismissCueRequest. + :rtype: str + """ + return self._cue + + @cue.setter + def cue(self, cue: str): + """Sets the cue of this DismissCueRequest. + + + :param cue: The cue of this DismissCueRequest. + :type cue: str + """ + allowed_values = ["progress-checkmarks"] # noqa: E501 + if cue not in allowed_values: + raise ValueError( + "Invalid value for `cue` ({0}), must be one of {1}" + .format(cue, allowed_values) + ) + + self._cue = cue diff --git a/gen/py/chromestatus_openapi/chromestatus_openapi/models/error_message.py b/gen/py/chromestatus_openapi/chromestatus_openapi/models/error_message.py new file mode 100644 index 000000000000..8a6d2a3cd94b --- /dev/null +++ b/gen/py/chromestatus_openapi/chromestatus_openapi/models/error_message.py @@ -0,0 +1,61 @@ +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from chromestatus_openapi.models.base_model import Model +from chromestatus_openapi import util + + +class ErrorMessage(Model): + """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + + Do not edit the class manually. + """ + + def __init__(self, error=None): # noqa: E501 + """ErrorMessage - a model defined in OpenAPI + + :param error: The error of this ErrorMessage. # noqa: E501 + :type error: str + """ + self.openapi_types = { + 'error': str + } + + self.attribute_map = { + 'error': 'error' + } + + self._error = error + + @classmethod + def from_dict(cls, dikt) -> 'ErrorMessage': + """Returns the dict as a model + + :param dikt: A dict. + :type: dict + :return: The ErrorMessage of this ErrorMessage. # noqa: E501 + :rtype: ErrorMessage + """ + return util.deserialize_model(dikt, cls) + + @property + def error(self) -> str: + """Gets the error of this ErrorMessage. + + + :return: The error of this ErrorMessage. + :rtype: str + """ + return self._error + + @error.setter + def error(self, error: str): + """Sets the error of this ErrorMessage. + + + :param error: The error of this ErrorMessage. + :type error: str + """ + + self._error = error diff --git a/gen/py/chromestatus_openapi/chromestatus_openapi/models/get_dismissed_cues400_response.py b/gen/py/chromestatus_openapi/chromestatus_openapi/models/get_dismissed_cues400_response.py new file mode 100644 index 000000000000..ee90f84b6e69 --- /dev/null +++ b/gen/py/chromestatus_openapi/chromestatus_openapi/models/get_dismissed_cues400_response.py @@ -0,0 +1,61 @@ +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from chromestatus_openapi.models.base_model import Model +from chromestatus_openapi import util + + +class GetDismissedCues400Response(Model): + """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + + Do not edit the class manually. + """ + + def __init__(self, error=None): # noqa: E501 + """GetDismissedCues400Response - a model defined in OpenAPI + + :param error: The error of this GetDismissedCues400Response. # noqa: E501 + :type error: str + """ + self.openapi_types = { + 'error': str + } + + self.attribute_map = { + 'error': 'error' + } + + self._error = error + + @classmethod + def from_dict(cls, dikt) -> 'GetDismissedCues400Response': + """Returns the dict as a model + + :param dikt: A dict. + :type: dict + :return: The getDismissedCues_400_response of this GetDismissedCues400Response. # noqa: E501 + :rtype: GetDismissedCues400Response + """ + return util.deserialize_model(dikt, cls) + + @property + def error(self) -> str: + """Gets the error of this GetDismissedCues400Response. + + + :return: The error of this GetDismissedCues400Response. + :rtype: str + """ + return self._error + + @error.setter + def error(self, error: str): + """Sets the error of this GetDismissedCues400Response. + + + :param error: The error of this GetDismissedCues400Response. + :type error: str + """ + + self._error = error diff --git a/gen/py/chromestatus_openapi/chromestatus_openapi/models/success_message.py b/gen/py/chromestatus_openapi/chromestatus_openapi/models/success_message.py new file mode 100644 index 000000000000..687e29d2833e --- /dev/null +++ b/gen/py/chromestatus_openapi/chromestatus_openapi/models/success_message.py @@ -0,0 +1,61 @@ +from datetime import date, datetime # noqa: F401 + +from typing import List, Dict # noqa: F401 + +from chromestatus_openapi.models.base_model import Model +from chromestatus_openapi import util + + +class SuccessMessage(Model): + """NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + + Do not edit the class manually. + """ + + def __init__(self, message=None): # noqa: E501 + """SuccessMessage - a model defined in OpenAPI + + :param message: The message of this SuccessMessage. # noqa: E501 + :type message: str + """ + self.openapi_types = { + 'message': str + } + + self.attribute_map = { + 'message': 'message' + } + + self._message = message + + @classmethod + def from_dict(cls, dikt) -> 'SuccessMessage': + """Returns the dict as a model + + :param dikt: A dict. + :type: dict + :return: The SuccessMessage of this SuccessMessage. # noqa: E501 + :rtype: SuccessMessage + """ + return util.deserialize_model(dikt, cls) + + @property + def message(self) -> str: + """Gets the message of this SuccessMessage. + + + :return: The message of this SuccessMessage. + :rtype: str + """ + return self._message + + @message.setter + def message(self, message: str): + """Sets the message of this SuccessMessage. + + + :param message: The message of this SuccessMessage. + :type message: str + """ + + self._message = message diff --git a/gen/py/chromestatus_openapi/chromestatus_openapi/openapi/openapi.yaml b/gen/py/chromestatus_openapi/chromestatus_openapi/openapi/openapi.yaml index fb3db44f3c68..0c977b2e38fe 100644 --- a/gen/py/chromestatus_openapi/chromestatus_openapi/openapi/openapi.yaml +++ b/gen/py/chromestatus_openapi/chromestatus_openapi/openapi/openapi.yaml @@ -135,6 +135,43 @@ paths: - XsrfToken: [] summary: List all components and possible users x-openapi-router-controller: chromestatus_openapi.controllers.default_controller + /currentuser/cues: + get: + operationId: get_dismissed_cues + responses: + "200": + content: + application/json: + schema: + items: + type: string + type: array + description: List of dismissed cue cards + "400": + content: + application/json: + schema: + $ref: '#/components/schemas/getDismissedCues_400_response' + description: Invalid cue provided + summary: Get dismissed cues for the current user + x-openapi-router-controller: chromestatus_openapi.controllers.default_controller + post: + operationId: dismiss_cue + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/DismissCueRequest' + required: true + responses: + "200": + content: + application/json: + schema: + $ref: '#/components/schemas/SuccessMessage' + description: Cue dismissed successfully + summary: Dismiss a cue card for the signed-in user + x-openapi-router-controller: chromestatus_openapi.controllers.default_controller /external_reviews/{review_group}: get: operationId: list_external_reviews @@ -850,6 +887,44 @@ components: type: string title: deleteAccount_200_response type: object + DismissCueRequest: + example: + cue: progress-checkmarks + properties: + cue: + enum: + - progress-checkmarks + title: cue + type: string + required: + - cue + title: DismissCueRequest + type: object + SuccessMessage: + example: + message: Done + properties: + message: + example: Done + title: message + type: string + title: SuccessMessage + type: object + ErrorMessage: + properties: + error: + example: Error + type: string + type: object + getDismissedCues_400_response: + example: + error: error + properties: + error: + title: error + type: string + title: getDismissedCues_400_response + type: object LinkPreviewGithubIssue_allOf_information: properties: url: diff --git a/gen/py/chromestatus_openapi/chromestatus_openapi/test/test_default_controller.py b/gen/py/chromestatus_openapi/chromestatus_openapi/test/test_default_controller.py index b7bec735d7c2..c98cd4dfe78f 100644 --- a/gen/py/chromestatus_openapi/chromestatus_openapi/test/test_default_controller.py +++ b/gen/py/chromestatus_openapi/chromestatus_openapi/test/test_default_controller.py @@ -2,6 +2,21 @@ from flask import json +from chromestatus_openapi.models.account_response import AccountResponse # noqa: E501 +from chromestatus_openapi.models.component_users_request import ComponentUsersRequest # noqa: E501 +from chromestatus_openapi.models.components_users_response import ComponentsUsersResponse # noqa: E501 +from chromestatus_openapi.models.create_account_request import CreateAccountRequest # noqa: E501 +from chromestatus_openapi.models.delete_account200_response import DeleteAccount200Response # noqa: E501 +from chromestatus_openapi.models.dismiss_cue_request import DismissCueRequest # noqa: E501 +from chromestatus_openapi.models.external_reviews_response import ExternalReviewsResponse # noqa: E501 +from chromestatus_openapi.models.feature_latency import FeatureLatency # noqa: E501 +from chromestatus_openapi.models.get_dismissed_cues400_response import GetDismissedCues400Response # noqa: E501 +from chromestatus_openapi.models.get_intent_response import GetIntentResponse # noqa: E501 +from chromestatus_openapi.models.message_response import MessageResponse # noqa: E501 +from chromestatus_openapi.models.post_intent_request import PostIntentRequest # noqa: E501 +from chromestatus_openapi.models.review_latency import ReviewLatency # noqa: E501 +from chromestatus_openapi.models.spec_mentor import SpecMentor # noqa: E501 +from chromestatus_openapi.models.success_message import SuccessMessage # noqa: E501 from chromestatus_openapi.test import BaseTestCase @@ -61,6 +76,40 @@ def test_delete_account(self): self.assert200(response, 'Response body is : ' + response.data.decode('utf-8')) + def test_dismiss_cue(self): + """Test case for dismiss_cue + + Dismiss a cue card for the signed-in user + """ + dismiss_cue_request = {"cue":"progress-checkmarks"} + headers = { + 'Accept': 'application/json', + 'Content-Type': 'application/json', + } + response = self.client.open( + '/api/v0/currentuser/cues', + method='POST', + headers=headers, + data=json.dumps(dismiss_cue_request), + content_type='application/json') + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) + + def test_get_dismissed_cues(self): + """Test case for get_dismissed_cues + + Get dismissed cues for the current user + """ + headers = { + 'Accept': 'application/json', + } + response = self.client.open( + '/api/v0/currentuser/cues', + method='GET', + headers=headers) + self.assert200(response, + 'Response body is : ' + response.data.decode('utf-8')) + def test_get_intent_body(self): """Test case for get_intent_body diff --git a/openapi/api.yaml b/openapi/api.yaml index 25d00d38f750..3d9866d0173d 100644 --- a/openapi/api.yaml +++ b/openapi/api.yaml @@ -125,6 +125,44 @@ paths: application/json: schema: $ref: '#/components/schemas/ComponentUsersRequest' + /currentuser/cues: + get: + summary: Get dismissed cues for the current user + operationId: getDismissedCues + responses: + '200': + description: List of dismissed cue cards + content: + application/json: + schema: + type: array + items: + type: string + '400': + description: Invalid cue provided + content: + application/json: + schema: + type: object + properties: + error: + type: string + post: + summary: Dismiss a cue card for the signed-in user + operationId: dismissCue + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/DismissCueRequest' + responses: + '200': + description: Cue dismissed successfully + content: + application/json: + schema: + $ref: '#/components/schemas/SuccessMessage' /review-latency: get: summary: List recently reviewed features and their review latency @@ -621,3 +659,24 @@ components: LinkPreviewSpecs: allOf: - $ref: '#/components/schemas/LinkPreviewOpenGraph' + DismissCueRequest: + type: object + properties: + cue: + type: string + enum: + - progress-checkmarks + required: + - cue + SuccessMessage: + type: object + properties: + message: + type: string + example: "Done" + ErrorMessage: + type: object + properties: + error: + type: string + example: "Error"