* stars get

* post

* case to model

* feature_id backward compatibility

* lint

* adjust assertion in tests
This commit is contained in:
Mark Xiong 2024-08-29 22:05:54 -05:00 коммит произвёл GitHub
Родитель 897f7a87dd
Коммит 2ea0e2f2a0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
18 изменённых файлов: 742 добавлений и 13 удалений

Просмотреть файл

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from chromestatus_openapi.models import (GetStarsResponse, SuccessMessage)
from framework import basehandlers
from internals import notifier
@ -31,10 +32,13 @@ class StarsAPI(basehandlers.APIHandler):
else:
feature_ids = [] # Anon users cannot star features.
data = {
'featureIds': feature_ids,
}
return data
result = GetStarsResponse.from_dict({
'feature_ids': feature_ids,
}).to_dict()
#TODO(markxiong0122): delete this backward compatibility code after 30 days
result['featureIds'] = result['feature_ids']
return result
def do_post(self, **kwargs):
"""Set or clear a star on the specified feature."""
@ -45,4 +49,4 @@ class StarsAPI(basehandlers.APIHandler):
notifier.FeatureStar.set_star(
user.email(), feature.key.integer_id(), starred)
# Callers don't use the JSON response for this API call.
return {'message': 'Done'}
return SuccessMessage(message='Done')

Просмотреть файл

@ -12,14 +12,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import testing_config # Must be imported before the module under test.
import flask
import werkzeug.exceptions # Flask HTTP stuff.
import testing_config # Must be imported before the module under test.
from api import stars_api
from internals.core_models import FeatureEntry
from internals import notifier
from internals.core_models import FeatureEntry
test_app = flask.Flask(__name__)
@ -43,14 +42,14 @@ class StarsAPITest(testing_config.CustomTestCase):
testing_config.sign_out()
with test_app.test_request_context(self.request_path):
actual_response = self.handler.do_get()
self.assertEqual({"featureIds": []}, actual_response)
self.assertEqual([], actual_response['feature_ids'])
def test_get__no_stars(self):
"""User has not starred any features."""
testing_config.sign_in('user7@example.com', 123567890)
with test_app.test_request_context(self.request_path):
actual_response = self.handler.do_get()
self.assertEqual({"featureIds": []}, actual_response)
self.assertEqual([], actual_response['feature_ids'])
def test_get__some_stars(self):
"""User has starred some features."""
@ -61,8 +60,8 @@ class StarsAPITest(testing_config.CustomTestCase):
with test_app.test_request_context(self.request_path):
actual_response = self.handler.do_get()
self.assertEqual(
{"featureIds": [feature_id]},
actual_response)
[feature_id],
actual_response["feature_ids"])
def test_post__invalid_feature_id(self):
"""We reject star requests that don't have an int featureId."""

Просмотреть файл

@ -462,7 +462,10 @@ export class ChromeStatusClient {
// Star API
getStars() {
return this.doGet('/currentuser/stars').then(res => res.featureIds);
// TODO(markxiong0122): delete this backward compatibility code after 30 days
return this.doGet('/currentuser/stars').then(
res => res.featureIds || res.feature_ids
);
// TODO: catch((error) => { display message }
}

Просмотреть файл

@ -38,6 +38,7 @@ src/models/GetGateResponse.ts
src/models/GetIntentResponse.ts
src/models/GetOriginTrialsResponse.ts
src/models/GetSettingsResponse.ts
src/models/GetStarsResponse.ts
src/models/GetVotesResponse.ts
src/models/IntegerFieldInfoValue.ts
src/models/LinkPreview.ts
@ -64,12 +65,14 @@ src/models/PermissionsResponse.ts
src/models/PostGateRequest.ts
src/models/PostIntentRequest.ts
src/models/PostSettingsRequest.ts
src/models/PostStarsRequest.ts
src/models/PostVoteRequest.ts
src/models/Process.ts
src/models/ProcessStage.ts
src/models/ProgressItem.ts
src/models/RejectUnneededGetRequest.ts
src/models/ReviewLatency.ts
src/models/SetStarRequest.ts
src/models/SignInRequest.ts
src/models/SpecMentor.ts
src/models/StageField.ts

Просмотреть файл

@ -36,6 +36,7 @@ import type {
GetIntentResponse,
GetOriginTrialsResponse,
GetSettingsResponse,
GetStarsResponse,
GetVotesResponse,
MessageResponse,
PatchCommentRequest,
@ -47,6 +48,7 @@ import type {
Process,
RejectUnneededGetRequest,
ReviewLatency,
SetStarRequest,
SignInRequest,
SpecMentor,
SuccessMessage,
@ -94,6 +96,8 @@ import {
GetOriginTrialsResponseToJSON,
GetSettingsResponseFromJSON,
GetSettingsResponseToJSON,
GetStarsResponseFromJSON,
GetStarsResponseToJSON,
GetVotesResponseFromJSON,
GetVotesResponseToJSON,
MessageResponseFromJSON,
@ -116,6 +120,8 @@ import {
RejectUnneededGetRequestToJSON,
ReviewLatencyFromJSON,
ReviewLatencyToJSON,
SetStarRequestFromJSON,
SetStarRequestToJSON,
SignInRequestFromJSON,
SignInRequestToJSON,
SpecMentorFromJSON,
@ -256,6 +262,10 @@ export interface SetAssigneesForGateRequest {
postGateRequest: PostGateRequest;
}
export interface SetStarOperationRequest {
setStarRequest: SetStarRequest;
}
export interface SetUserSettingsRequest {
postSettingsRequest: PostSettingsRequest;
}
@ -619,6 +629,20 @@ export interface DefaultApiInterface {
*/
getProgress(requestParameters: GetProgressRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<{ [key: string]: any; }>;
/**
*
* @summary Get a list of all starred feature IDs for the signed-in user
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApiInterface
*/
getStarsRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<GetStarsResponse>>>;
/**
* Get a list of all starred feature IDs for the signed-in user
*/
getStars(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<GetStarsResponse>>;
/**
*
* @summary Get the permissions and email of the user
@ -861,6 +885,21 @@ export interface DefaultApiInterface {
*/
setAssigneesForGate(requestParameters: SetAssigneesForGateRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SuccessMessage>;
/**
*
* @summary Set or clear a star on the specified feature
* @param {SetStarRequest} setStarRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApiInterface
*/
setStarRaw(requestParameters: SetStarOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SuccessMessage>>;
/**
* Set or clear a star on the specified feature
*/
setStar(requestParameters: SetStarOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SuccessMessage>;
/**
*
* @summary Set the user settings (currently only the notify_as_starrer)
@ -1693,6 +1732,32 @@ export class DefaultApi extends runtime.BaseAPI implements DefaultApiInterface {
return await response.value();
}
/**
* Get a list of all starred feature IDs for the signed-in user
*/
async getStarsRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<GetStarsResponse>>> {
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
const response = await this.request({
path: `/currentuser/stars`,
method: 'GET',
headers: headerParameters,
query: queryParameters,
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(GetStarsResponseFromJSON));
}
/**
* Get a list of all starred feature IDs for the signed-in user
*/
async getStars(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<GetStarsResponse>> {
const response = await this.getStarsRaw(initOverrides);
return await response.value();
}
/**
* Get the permissions and email of the user
*/
@ -2237,6 +2302,42 @@ export class DefaultApi extends runtime.BaseAPI implements DefaultApiInterface {
return await response.value();
}
/**
* Set or clear a star on the specified feature
*/
async setStarRaw(requestParameters: SetStarOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SuccessMessage>> {
if (requestParameters['setStarRequest'] == null) {
throw new runtime.RequiredError(
'setStarRequest',
'Required parameter "setStarRequest" was null or undefined when calling setStar().'
);
}
const queryParameters: any = {};
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/json';
const response = await this.request({
path: `/currentuser/stars`,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: SetStarRequestToJSON(requestParameters['setStarRequest']),
}, initOverrides);
return new runtime.JSONApiResponse(response, (jsonValue) => SuccessMessageFromJSON(jsonValue));
}
/**
* Set or clear a star on the specified feature
*/
async setStar(requestParameters: SetStarOperationRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SuccessMessage> {
const response = await this.setStarRaw(requestParameters, initOverrides);
return await response.value();
}
/**
* Set the user settings (currently only the notify_as_starrer)
*/

Просмотреть файл

@ -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 GetStarsResponse
*/
export interface GetStarsResponse {
/**
*
* @type {Array<number>}
* @memberof GetStarsResponse
*/
feature_ids?: Array<number>;
}
/**
* Check if a given object implements the GetStarsResponse interface.
*/
export function instanceOfGetStarsResponse(value: object): value is GetStarsResponse {
return true;
}
export function GetStarsResponseFromJSON(json: any): GetStarsResponse {
return GetStarsResponseFromJSONTyped(json, false);
}
export function GetStarsResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): GetStarsResponse {
if (json == null) {
return json;
}
return {
'feature_ids': json['feature_ids'] == null ? undefined : json['feature_ids'],
};
}
export function GetStarsResponseToJSON(value?: GetStarsResponse | null): any {
if (value == null) {
return value;
}
return {
'feature_ids': value['feature_ids'],
};
}

Просмотреть файл

@ -0,0 +1,68 @@
/* 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 PostStarsRequest
*/
export interface PostStarsRequest {
/**
*
* @type {number}
* @memberof PostStarsRequest
*/
feature_id?: number;
/**
*
* @type {boolean}
* @memberof PostStarsRequest
*/
starred?: boolean;
}
/**
* Check if a given object implements the PostStarsRequest interface.
*/
export function instanceOfPostStarsRequest(value: object): value is PostStarsRequest {
return true;
}
export function PostStarsRequestFromJSON(json: any): PostStarsRequest {
return PostStarsRequestFromJSONTyped(json, false);
}
export function PostStarsRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): PostStarsRequest {
if (json == null) {
return json;
}
return {
'feature_id': json['feature_id'] == null ? undefined : json['feature_id'],
'starred': json['starred'] == null ? undefined : json['starred'],
};
}
export function PostStarsRequestToJSON(value?: PostStarsRequest | null): any {
if (value == null) {
return value;
}
return {
'feature_id': value['feature_id'],
'starred': value['starred'],
};
}

Просмотреть файл

@ -0,0 +1,68 @@
/* 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 SetStarRequest
*/
export interface SetStarRequest {
/**
*
* @type {number}
* @memberof SetStarRequest
*/
featureId?: number;
/**
*
* @type {boolean}
* @memberof SetStarRequest
*/
starred?: boolean;
}
/**
* Check if a given object implements the SetStarRequest interface.
*/
export function instanceOfSetStarRequest(value: object): value is SetStarRequest {
return true;
}
export function SetStarRequestFromJSON(json: any): SetStarRequest {
return SetStarRequestFromJSONTyped(json, false);
}
export function SetStarRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): SetStarRequest {
if (json == null) {
return json;
}
return {
'featureId': json['featureId'] == null ? undefined : json['featureId'],
'starred': json['starred'] == null ? undefined : json['starred'],
};
}
export function SetStarRequestToJSON(value?: SetStarRequest | null): any {
if (value == null) {
return value;
}
return {
'featureId': value['featureId'],
'starred': value['starred'],
};
}

Просмотреть файл

@ -32,6 +32,7 @@ export * from './GetGateResponse';
export * from './GetIntentResponse';
export * from './GetOriginTrialsResponse';
export * from './GetSettingsResponse';
export * from './GetStarsResponse';
export * from './GetVotesResponse';
export * from './IntegerFieldInfoValue';
export * from './LinkPreview';
@ -58,12 +59,14 @@ export * from './PermissionsResponse';
export * from './PostGateRequest';
export * from './PostIntentRequest';
export * from './PostSettingsRequest';
export * from './PostStarsRequest';
export * from './PostVoteRequest';
export * from './Process';
export * from './ProcessStage';
export * from './ProgressItem';
export * from './RejectUnneededGetRequest';
export * from './ReviewLatency';
export * from './SetStarRequest';
export * from './SignInRequest';
export * from './SpecMentor';
export * from './StageField';

Просмотреть файл

@ -44,6 +44,7 @@ chromestatus_openapi/models/get_gate_response.py
chromestatus_openapi/models/get_intent_response.py
chromestatus_openapi/models/get_origin_trials_response.py
chromestatus_openapi/models/get_settings_response.py
chromestatus_openapi/models/get_stars_response.py
chromestatus_openapi/models/get_votes_response.py
chromestatus_openapi/models/integer_field_info_value.py
chromestatus_openapi/models/link_preview.py
@ -70,12 +71,14 @@ chromestatus_openapi/models/permissions_response.py
chromestatus_openapi/models/post_gate_request.py
chromestatus_openapi/models/post_intent_request.py
chromestatus_openapi/models/post_settings_request.py
chromestatus_openapi/models/post_stars_request.py
chromestatus_openapi/models/post_vote_request.py
chromestatus_openapi/models/process.py
chromestatus_openapi/models/process_stage.py
chromestatus_openapi/models/progress_item.py
chromestatus_openapi/models/reject_unneeded_get_request.py
chromestatus_openapi/models/review_latency.py
chromestatus_openapi/models/set_star_request.py
chromestatus_openapi/models/sign_in_request.py
chromestatus_openapi/models/spec_mentor.py
chromestatus_openapi/models/stage_field.py

Просмотреть файл

@ -24,6 +24,7 @@ from chromestatus_openapi.models.get_gate_response import GetGateResponse # noq
from chromestatus_openapi.models.get_intent_response import GetIntentResponse # noqa: E501
from chromestatus_openapi.models.get_origin_trials_response import GetOriginTrialsResponse # noqa: E501
from chromestatus_openapi.models.get_settings_response import GetSettingsResponse # noqa: E501
from chromestatus_openapi.models.get_stars_response import GetStarsResponse # noqa: E501
from chromestatus_openapi.models.get_votes_response import GetVotesResponse # noqa: E501
from chromestatus_openapi.models.message_response import MessageResponse # noqa: E501
from chromestatus_openapi.models.patch_comment_request import PatchCommentRequest # noqa: E501
@ -35,6 +36,7 @@ from chromestatus_openapi.models.post_vote_request import PostVoteRequest # noq
from chromestatus_openapi.models.process import Process # noqa: E501
from chromestatus_openapi.models.reject_unneeded_get_request import RejectUnneededGetRequest # noqa: E501
from chromestatus_openapi.models.review_latency import ReviewLatency # noqa: E501
from chromestatus_openapi.models.set_star_request import SetStarRequest # noqa: E501
from chromestatus_openapi.models.sign_in_request import SignInRequest # noqa: E501
from chromestatus_openapi.models.spec_mentor import SpecMentor # noqa: E501
from chromestatus_openapi.models.success_message import SuccessMessage # noqa: E501
@ -363,6 +365,17 @@ def get_progress(feature_id): # noqa: E501
return 'do some magic!'
def get_stars(): # noqa: E501
"""Get a list of all starred feature IDs for the signed-in user
# noqa: E501
:rtype: Union[List[GetStarsResponse], Tuple[List[GetStarsResponse], int], Tuple[List[GetStarsResponse], int, Dict[str, str]]
"""
return 'do some magic!'
def get_user_permissions(return_paired_user=None): # noqa: E501
"""Get the permissions and email of the user
@ -584,6 +597,21 @@ def set_assignees_for_gate(feature_id, gate_id, post_gate_request): # noqa: E50
return 'do some magic!'
def set_star(set_star_request): # noqa: E501
"""Set or clear a star on the specified feature
# noqa: E501
:param set_star_request:
:type set_star_request: dict | bytes
:rtype: Union[SuccessMessage, Tuple[SuccessMessage, int], Tuple[SuccessMessage, int, Dict[str, str]]
"""
if connexion.request.is_json:
set_star_request = SetStarRequest.from_dict(connexion.request.get_json()) # noqa: E501
return 'do some magic!'
def set_user_settings(post_settings_request): # noqa: E501
"""Set the user settings (currently only the notify_as_starrer)

Просмотреть файл

@ -32,6 +32,7 @@ from chromestatus_openapi.models.get_gate_response import GetGateResponse
from chromestatus_openapi.models.get_intent_response import GetIntentResponse
from chromestatus_openapi.models.get_origin_trials_response import GetOriginTrialsResponse
from chromestatus_openapi.models.get_settings_response import GetSettingsResponse
from chromestatus_openapi.models.get_stars_response import GetStarsResponse
from chromestatus_openapi.models.get_votes_response import GetVotesResponse
from chromestatus_openapi.models.integer_field_info_value import IntegerFieldInfoValue
from chromestatus_openapi.models.link_preview import LinkPreview
@ -58,12 +59,14 @@ from chromestatus_openapi.models.permissions_response import PermissionsResponse
from chromestatus_openapi.models.post_gate_request import PostGateRequest
from chromestatus_openapi.models.post_intent_request import PostIntentRequest
from chromestatus_openapi.models.post_settings_request import PostSettingsRequest
from chromestatus_openapi.models.post_stars_request import PostStarsRequest
from chromestatus_openapi.models.post_vote_request import PostVoteRequest
from chromestatus_openapi.models.process import Process
from chromestatus_openapi.models.process_stage import ProcessStage
from chromestatus_openapi.models.progress_item import ProgressItem
from chromestatus_openapi.models.reject_unneeded_get_request import RejectUnneededGetRequest
from chromestatus_openapi.models.review_latency import ReviewLatency
from chromestatus_openapi.models.set_star_request import SetStarRequest
from chromestatus_openapi.models.sign_in_request import SignInRequest
from chromestatus_openapi.models.spec_mentor import SpecMentor
from chromestatus_openapi.models.stage_field import StageField

Просмотреть файл

@ -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 GetStarsResponse(Model):
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Do not edit the class manually.
"""
def __init__(self, feature_ids=None): # noqa: E501
"""GetStarsResponse - a model defined in OpenAPI
:param feature_ids: The feature_ids of this GetStarsResponse. # noqa: E501
:type feature_ids: List[int]
"""
self.openapi_types = {
'feature_ids': List[int]
}
self.attribute_map = {
'feature_ids': 'feature_ids'
}
self._feature_ids = feature_ids
@classmethod
def from_dict(cls, dikt) -> 'GetStarsResponse':
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The GetStarsResponse of this GetStarsResponse. # noqa: E501
:rtype: GetStarsResponse
"""
return util.deserialize_model(dikt, cls)
@property
def feature_ids(self) -> List[int]:
"""Gets the feature_ids of this GetStarsResponse.
:return: The feature_ids of this GetStarsResponse.
:rtype: List[int]
"""
return self._feature_ids
@feature_ids.setter
def feature_ids(self, feature_ids: List[int]):
"""Sets the feature_ids of this GetStarsResponse.
:param feature_ids: The feature_ids of this GetStarsResponse.
:type feature_ids: List[int]
"""
self._feature_ids = feature_ids

Просмотреть файл

@ -0,0 +1,87 @@
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 PostStarsRequest(Model):
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Do not edit the class manually.
"""
def __init__(self, feature_id=None, starred=True): # noqa: E501
"""PostStarsRequest - a model defined in OpenAPI
:param feature_id: The feature_id of this PostStarsRequest. # noqa: E501
:type feature_id: int
:param starred: The starred of this PostStarsRequest. # noqa: E501
:type starred: bool
"""
self.openapi_types = {
'feature_id': int,
'starred': bool
}
self.attribute_map = {
'feature_id': 'feature_id',
'starred': 'starred'
}
self._feature_id = feature_id
self._starred = starred
@classmethod
def from_dict(cls, dikt) -> 'PostStarsRequest':
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The PostStarsRequest of this PostStarsRequest. # noqa: E501
:rtype: PostStarsRequest
"""
return util.deserialize_model(dikt, cls)
@property
def feature_id(self) -> int:
"""Gets the feature_id of this PostStarsRequest.
:return: The feature_id of this PostStarsRequest.
:rtype: int
"""
return self._feature_id
@feature_id.setter
def feature_id(self, feature_id: int):
"""Sets the feature_id of this PostStarsRequest.
:param feature_id: The feature_id of this PostStarsRequest.
:type feature_id: int
"""
self._feature_id = feature_id
@property
def starred(self) -> bool:
"""Gets the starred of this PostStarsRequest.
:return: The starred of this PostStarsRequest.
:rtype: bool
"""
return self._starred
@starred.setter
def starred(self, starred: bool):
"""Sets the starred of this PostStarsRequest.
:param starred: The starred of this PostStarsRequest.
:type starred: bool
"""
self._starred = starred

Просмотреть файл

@ -0,0 +1,87 @@
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 SetStarRequest(Model):
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Do not edit the class manually.
"""
def __init__(self, feature_id=None, starred=None): # noqa: E501
"""SetStarRequest - a model defined in OpenAPI
:param feature_id: The feature_id of this SetStarRequest. # noqa: E501
:type feature_id: int
:param starred: The starred of this SetStarRequest. # noqa: E501
:type starred: bool
"""
self.openapi_types = {
'feature_id': int,
'starred': bool
}
self.attribute_map = {
'feature_id': 'featureId',
'starred': 'starred'
}
self._feature_id = feature_id
self._starred = starred
@classmethod
def from_dict(cls, dikt) -> 'SetStarRequest':
"""Returns the dict as a model
:param dikt: A dict.
:type: dict
:return: The setStar_request of this SetStarRequest. # noqa: E501
:rtype: SetStarRequest
"""
return util.deserialize_model(dikt, cls)
@property
def feature_id(self) -> int:
"""Gets the feature_id of this SetStarRequest.
:return: The feature_id of this SetStarRequest.
:rtype: int
"""
return self._feature_id
@feature_id.setter
def feature_id(self, feature_id: int):
"""Sets the feature_id of this SetStarRequest.
:param feature_id: The feature_id of this SetStarRequest.
:type feature_id: int
"""
self._feature_id = feature_id
@property
def starred(self) -> bool:
"""Gets the starred of this SetStarRequest.
:return: The starred of this SetStarRequest.
:rtype: bool
"""
return self._starred
@starred.setter
def starred(self, starred: bool):
"""Sets the starred of this SetStarRequest.
:param starred: The starred of this SetStarRequest.
:type starred: bool
"""
self._starred = starred

Просмотреть файл

@ -226,6 +226,37 @@ paths:
description: User not signed-in
summary: Set the user settings (currently only the notify_as_starrer)
x-openapi-router-controller: chromestatus_openapi.controllers.default_controller
/currentuser/stars:
get:
operationId: get_stars
responses:
"200":
content:
application/json:
schema:
items:
$ref: '#/components/schemas/GetStarsResponse'
type: array
description: List of starred feature IDs
summary: Get a list of all starred feature IDs for the signed-in user
x-openapi-router-controller: chromestatus_openapi.controllers.default_controller
post:
operationId: set_star
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/setStar_request'
required: true
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/SuccessMessage'
description: Star set or cleared successfully
summary: Set or clear a star on the specified feature
x-openapi-router-controller: chromestatus_openapi.controllers.default_controller
/currentuser/token:
post:
operationId: refresh_token
@ -2864,6 +2895,29 @@ components:
- is_admin
title: UserPermissions
type: object
GetStarsResponse:
example:
feature_ids:
- 0
- 0
properties:
feature_ids:
items:
type: integer
title: feature_ids
type: array
title: GetStarsResponse
type: object
PostStarsRequest:
properties:
feature_id:
type: integer
starred:
default: true
type: boolean
required:
- featureId
type: object
DismissCueRequest:
example:
cue: progress-checkmarks
@ -2946,6 +3000,16 @@ components:
type: string
title: deleteAccount_200_response
type: object
setStar_request:
properties:
featureId:
title: featureId
type: integer
starred:
title: starred
type: boolean
title: setStar_request
type: object
getDismissedCues_400_response:
example:
error: error

Просмотреть файл

@ -23,6 +23,7 @@ from chromestatus_openapi.models.get_gate_response import GetGateResponse # noq
from chromestatus_openapi.models.get_intent_response import GetIntentResponse # noqa: E501
from chromestatus_openapi.models.get_origin_trials_response import GetOriginTrialsResponse # noqa: E501
from chromestatus_openapi.models.get_settings_response import GetSettingsResponse # noqa: E501
from chromestatus_openapi.models.get_stars_response import GetStarsResponse # noqa: E501
from chromestatus_openapi.models.get_votes_response import GetVotesResponse # noqa: E501
from chromestatus_openapi.models.message_response import MessageResponse # noqa: E501
from chromestatus_openapi.models.patch_comment_request import PatchCommentRequest # noqa: E501
@ -34,6 +35,7 @@ from chromestatus_openapi.models.post_vote_request import PostVoteRequest # noq
from chromestatus_openapi.models.process import Process # noqa: E501
from chromestatus_openapi.models.reject_unneeded_get_request import RejectUnneededGetRequest # noqa: E501
from chromestatus_openapi.models.review_latency import ReviewLatency # noqa: E501
from chromestatus_openapi.models.set_star_request import SetStarRequest # noqa: E501
from chromestatus_openapi.models.sign_in_request import SignInRequest # noqa: E501
from chromestatus_openapi.models.spec_mentor import SpecMentor # noqa: E501
from chromestatus_openapi.models.success_message import SuccessMessage # noqa: E501
@ -408,6 +410,21 @@ class TestDefaultController(BaseTestCase):
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_get_stars(self):
"""Test case for get_stars
Get a list of all starred feature IDs for the signed-in user
"""
headers = {
'Accept': 'application/json',
}
response = self.client.open(
'/api/v0/currentuser/stars',
method='GET',
headers=headers)
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_get_user_permissions(self):
"""Test case for get_user_permissions
@ -668,6 +685,25 @@ class TestDefaultController(BaseTestCase):
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_set_star(self):
"""Test case for set_star
Set or clear a star on the specified feature
"""
set_star_request = chromestatus_openapi.SetStarRequest()
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
}
response = self.client.open(
'/api/v0/currentuser/stars',
method='POST',
headers=headers,
data=json.dumps(set_star_request),
content_type='application/json')
self.assert200(response,
'Response body is : ' + response.data.decode('utf-8'))
def test_set_user_settings(self):
"""Test case for set_user_settings

Просмотреть файл

@ -643,6 +643,40 @@ paths:
$ref: '#/components/schemas/SuccessMessage'
'403':
description: User not signed-in
/currentuser/stars:
get:
summary: Get a list of all starred feature IDs for the signed-in user
operationId: getStars
responses:
'200':
description: List of starred feature IDs
content:
application/json:
schema:
type: object
items:
$ref: '#/components/schemas/GetStarsResponse'
post:
summary: Set or clear a star on the specified feature
operationId: setStar
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
featureId:
type: integer
starred:
type: boolean
responses:
'200':
description: Star set or cleared successfully
content:
application/json:
schema:
$ref: '#/components/schemas/SuccessMessage'
/currentuser/cues:
get:
summary: Get dismissed cues for the current user
@ -1827,6 +1861,23 @@ components:
- is_admin
- email
- editable_features
GetStarsResponse:
type: object
properties:
feature_ids:
type: array
items:
type: integer
PostStarsRequest:
type: object
properties:
feature_id:
type: integer
starred:
type: boolean
default: true
required:
- featureId
DismissCueRequest:
type: object
properties: