Add documentation for all path parameters

This commit is contained in:
Joseph Schorr 2014-08-19 19:05:28 -04:00
parent 02d3b70013
commit 53fb7f4136
19 changed files with 107 additions and 19 deletions

View file

@ -155,6 +155,9 @@ internal_only = add_method_metadata('internal', True)
def path_param(name, description): def path_param(name, description):
def add_param(func): def add_param(func):
if not func:
return func
if '__api_path_params' not in dir(func): if '__api_path_params' not in dir(func):
func.__api_path_params = {} func.__api_path_params = {}
func.__api_path_params[name] = { func.__api_path_params[name] = {

View file

@ -4,7 +4,7 @@ from flask import request
from app import billing from app import billing
from endpoints.api import (resource, nickname, ApiResource, validate_json_request, log_action, from endpoints.api import (resource, nickname, ApiResource, validate_json_request, log_action,
related_user_resource, internal_only, Unauthorized, NotFound, related_user_resource, internal_only, Unauthorized, NotFound,
require_user_admin, show_if, hide_if) require_user_admin, show_if, hide_if, path_param)
from endpoints.api.subscribe import subscribe, subscription_view from endpoints.api.subscribe import subscribe, subscription_view
from auth.permissions import AdministerOrganizationPermission from auth.permissions import AdministerOrganizationPermission
from auth.auth_context import get_authenticated_user from auth.auth_context import get_authenticated_user
@ -135,6 +135,7 @@ class UserCard(ApiResource):
@resource('/v1/organization/<orgname>/card') @resource('/v1/organization/<orgname>/card')
@path_param('orgname', 'The name of the organization')
@internal_only @internal_only
@related_user_resource(UserCard) @related_user_resource(UserCard)
@show_if(features.BILLING) @show_if(features.BILLING)
@ -242,6 +243,7 @@ class UserPlan(ApiResource):
@resource('/v1/organization/<orgname>/plan') @resource('/v1/organization/<orgname>/plan')
@path_param('orgname', 'The name of the organization')
@internal_only @internal_only
@related_user_resource(UserPlan) @related_user_resource(UserPlan)
@show_if(features.BILLING) @show_if(features.BILLING)
@ -323,6 +325,7 @@ class UserInvoiceList(ApiResource):
@resource('/v1/organization/<orgname>/invoices') @resource('/v1/organization/<orgname>/invoices')
@path_param('orgname', 'The name of the organization')
@internal_only @internal_only
@related_user_resource(UserInvoiceList) @related_user_resource(UserInvoiceList)
@show_if(features.BILLING) @show_if(features.BILLING)

View file

@ -6,7 +6,8 @@ from flask import request
from app import app, userfiles as user_files, build_logs from app import app, userfiles as user_files, build_logs
from endpoints.api import (RepositoryParamResource, parse_args, query_param, nickname, resource, from endpoints.api import (RepositoryParamResource, parse_args, query_param, nickname, resource,
require_repo_read, require_repo_write, validate_json_request, require_repo_read, require_repo_write, validate_json_request,
ApiResource, internal_only, format_date, api, Unauthorized, NotFound) ApiResource, internal_only, format_date, api, Unauthorized, NotFound,
path_param)
from endpoints.common import start_build from endpoints.common import start_build
from endpoints.trigger import BuildTrigger from endpoints.trigger import BuildTrigger
from data import model from data import model
@ -86,6 +87,7 @@ def build_status_view(build_obj, can_write=False):
@resource('/v1/repository/<repopath:repository>/build/') @resource('/v1/repository/<repopath:repository>/build/')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
class RepositoryBuildList(RepositoryParamResource): class RepositoryBuildList(RepositoryParamResource):
""" Resource related to creating and listing repository builds. """ """ Resource related to creating and listing repository builds. """
schemas = { schemas = {
@ -190,6 +192,8 @@ class RepositoryBuildList(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/build/<build_uuid>/status') @resource('/v1/repository/<repopath:repository>/build/<build_uuid>/status')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('build_uuid', 'The UUID of the build')
class RepositoryBuildStatus(RepositoryParamResource): class RepositoryBuildStatus(RepositoryParamResource):
""" Resource for dealing with repository build status. """ """ Resource for dealing with repository build status. """
@require_repo_read @require_repo_read
@ -205,6 +209,8 @@ class RepositoryBuildStatus(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/build/<build_uuid>/logs') @resource('/v1/repository/<repopath:repository>/build/<build_uuid>/logs')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('build_uuid', 'The UUID of the build')
class RepositoryBuildLogs(RepositoryParamResource): class RepositoryBuildLogs(RepositoryParamResource):
""" Resource for loading repository build logs. """ """ Resource for loading repository build logs. """
@require_repo_write @require_repo_write

View file

@ -100,7 +100,7 @@ def swagger_route_data(include_internal=False, compact=False):
if not compact: if not compact:
new_operation.update({ new_operation.update({
'type': 'void', 'type': 'void',
'summary': method.__doc__ if method.__doc__ else '', 'summary': method.__doc__.strip() if method.__doc__ else '',
'parameters': parameters, 'parameters': parameters,
}) })
@ -125,7 +125,7 @@ def swagger_route_data(include_internal=False, compact=False):
swagger_path = PARAM_REGEX.sub(r'{\2}', rule.rule) swagger_path = PARAM_REGEX.sub(r'{\2}', rule.rule)
new_resource = { new_resource = {
'path': swagger_path, 'path': swagger_path,
'description': view_class.__doc__ if view_class.__doc__ else "", 'description': view_class.__doc__.strip() if view_class.__doc__ else "",
'operations': operations, 'operations': operations,
'name': fully_qualified_name(view_class), 'name': fully_qualified_name(view_class),
} }

View file

@ -4,7 +4,7 @@ from collections import defaultdict
from app import storage as store from app import storage as store
from endpoints.api import (resource, nickname, require_repo_read, RepositoryParamResource, from endpoints.api import (resource, nickname, require_repo_read, RepositoryParamResource,
format_date, NotFound) format_date, NotFound, path_param)
from data import model from data import model
from util.cache import cache_control_flask_restful from util.cache import cache_control_flask_restful
@ -29,6 +29,7 @@ def image_view(image):
@resource('/v1/repository/<repopath:repository>/image/') @resource('/v1/repository/<repopath:repository>/image/')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
class RepositoryImageList(RepositoryParamResource): class RepositoryImageList(RepositoryParamResource):
""" Resource for listing repository images. """ """ Resource for listing repository images. """
@require_repo_read @require_repo_read
@ -54,6 +55,8 @@ class RepositoryImageList(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/image/<image_id>') @resource('/v1/repository/<repopath:repository>/image/<image_id>')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('image_id', 'The Docker image ID')
class RepositoryImage(RepositoryParamResource): class RepositoryImage(RepositoryParamResource):
""" Resource for handling repository images. """ """ Resource for handling repository images. """
@require_repo_read @require_repo_read
@ -68,6 +71,8 @@ class RepositoryImage(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/image/<image_id>/changes') @resource('/v1/repository/<repopath:repository>/image/<image_id>/changes')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('image_id', 'The Docker image ID')
class RepositoryImageChanges(RepositoryParamResource): class RepositoryImageChanges(RepositoryParamResource):
""" Resource for handling repository image change lists. """ """ Resource for handling repository image change lists. """

View file

@ -5,7 +5,7 @@ from datetime import datetime, timedelta
from endpoints.api import (resource, nickname, ApiResource, query_param, parse_args, from endpoints.api import (resource, nickname, ApiResource, query_param, parse_args,
RepositoryParamResource, require_repo_admin, related_user_resource, RepositoryParamResource, require_repo_admin, related_user_resource,
format_date, Unauthorized, NotFound, require_user_admin, format_date, Unauthorized, NotFound, require_user_admin,
internal_only) internal_only, path_param)
from auth.permissions import AdministerOrganizationPermission, AdministerOrganizationPermission from auth.permissions import AdministerOrganizationPermission, AdministerOrganizationPermission
from auth.auth_context import get_authenticated_user from auth.auth_context import get_authenticated_user
from data import model from data import model
@ -63,6 +63,7 @@ def get_logs(start_time, end_time, performer_name=None, repository=None, namespa
@resource('/v1/repository/<repopath:repository>/logs') @resource('/v1/repository/<repopath:repository>/logs')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@internal_only @internal_only
class RepositoryLogs(RepositoryParamResource): class RepositoryLogs(RepositoryParamResource):
""" Resource for fetching logs for the specific repository. """ """ Resource for fetching logs for the specific repository. """
@ -103,6 +104,7 @@ class UserLogs(ApiResource):
@resource('/v1/organization/<orgname>/logs') @resource('/v1/organization/<orgname>/logs')
@path_param('orgname', 'The name of the organization')
@internal_only @internal_only
@related_user_resource(UserLogs) @related_user_resource(UserLogs)
class OrgLogs(ApiResource): class OrgLogs(ApiResource):

View file

@ -5,7 +5,7 @@ from flask import request
from app import billing as stripe from app import billing as stripe
from endpoints.api import (resource, nickname, ApiResource, validate_json_request, request_error, from endpoints.api import (resource, nickname, ApiResource, validate_json_request, request_error,
related_user_resource, internal_only, Unauthorized, NotFound, related_user_resource, internal_only, Unauthorized, NotFound,
require_user_admin, log_action, show_if) require_user_admin, log_action, show_if, path_param)
from endpoints.api.team import team_view from endpoints.api.team import team_view
from endpoints.api.user import User, PrivateRepositories from endpoints.api.user import User, PrivateRepositories
from auth.permissions import (AdministerOrganizationPermission, OrganizationMemberPermission, from auth.permissions import (AdministerOrganizationPermission, OrganizationMemberPermission,
@ -97,6 +97,7 @@ class OrganizationList(ApiResource):
@resource('/v1/organization/<orgname>') @resource('/v1/organization/<orgname>')
@path_param('orgname', 'The name of the organization')
@internal_only @internal_only
@related_user_resource(User) @related_user_resource(User)
class Organization(ApiResource): class Organization(ApiResource):
@ -163,6 +164,7 @@ class Organization(ApiResource):
@resource('/v1/organization/<orgname>/private') @resource('/v1/organization/<orgname>/private')
@path_param('orgname', 'The name of the organization')
@internal_only @internal_only
@related_user_resource(PrivateRepositories) @related_user_resource(PrivateRepositories)
@show_if(features.BILLING) @show_if(features.BILLING)
@ -199,6 +201,7 @@ class OrgPrivateRepositories(ApiResource):
@resource('/v1/organization/<orgname>/members') @resource('/v1/organization/<orgname>/members')
@path_param('orgname', 'The name of the organization')
@internal_only @internal_only
class OrgnaizationMemberList(ApiResource): class OrgnaizationMemberList(ApiResource):
""" Resource for listing the members of an organization. """ """ Resource for listing the members of an organization. """
@ -232,6 +235,8 @@ class OrgnaizationMemberList(ApiResource):
@resource('/v1/organization/<orgname>/members/<membername>') @resource('/v1/organization/<orgname>/members/<membername>')
@path_param('orgname', 'The name of the organization')
@path_param('membername', 'The username of the organization member')
@internal_only @internal_only
class OrganizationMember(ApiResource): class OrganizationMember(ApiResource):
""" Resource for managing individual organization members. """ """ Resource for managing individual organization members. """
@ -265,6 +270,7 @@ class OrganizationMember(ApiResource):
@resource('/v1/app/<client_id>') @resource('/v1/app/<client_id>')
@path_param('client_id', 'The OAuth client ID')
class ApplicationInformation(ApiResource): class ApplicationInformation(ApiResource):
""" Resource that returns public information about a registered application. """ """ Resource that returns public information about a registered application. """
@nickname('getApplicationInformation') @nickname('getApplicationInformation')
@ -302,6 +308,7 @@ def app_view(application):
@resource('/v1/organization/<orgname>/applications') @resource('/v1/organization/<orgname>/applications')
@path_param('orgname', 'The name of the organization')
@internal_only @internal_only
class OrganizationApplications(ApiResource): class OrganizationApplications(ApiResource):
""" Resource for managing applications defined by an organizations. """ """ Resource for managing applications defined by an organizations. """
@ -386,6 +393,8 @@ class OrganizationApplications(ApiResource):
@resource('/v1/organization/<orgname>/applications/<client_id>') @resource('/v1/organization/<orgname>/applications/<client_id>')
@path_param('orgname', 'The name of the organization')
@path_param('client_id', 'The OAuth client ID')
@internal_only @internal_only
class OrganizationApplicationResource(ApiResource): class OrganizationApplicationResource(ApiResource):
""" Resource for managing an application defined by an organizations. """ """ Resource for managing an application defined by an organizations. """
@ -498,6 +507,8 @@ class OrganizationApplicationResource(ApiResource):
@resource('/v1/organization/<orgname>/applications/<client_id>/resetclientsecret') @resource('/v1/organization/<orgname>/applications/<client_id>/resetclientsecret')
@path_param('orgname', 'The name of the organization')
@path_param('client_id', 'The OAuth client ID')
@internal_only @internal_only
class OrganizationApplicationResetClientSecret(ApiResource): class OrganizationApplicationResetClientSecret(ApiResource):
""" Custom verb for resetting the client secret of an application. """ """ Custom verb for resetting the client secret of an application. """

View file

@ -3,7 +3,7 @@ import logging
from flask import request from flask import request
from endpoints.api import (resource, nickname, require_repo_admin, RepositoryParamResource, from endpoints.api import (resource, nickname, require_repo_admin, RepositoryParamResource,
log_action, request_error, validate_json_request) log_action, request_error, validate_json_request, path_param)
from data import model from data import model
@ -26,6 +26,7 @@ def wrap_role_view_org(role_json, user, org_members):
@resource('/v1/repository/<repopath:repository>/permissions/team/') @resource('/v1/repository/<repopath:repository>/permissions/team/')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
class RepositoryTeamPermissionList(RepositoryParamResource): class RepositoryTeamPermissionList(RepositoryParamResource):
""" Resource for repository team permissions. """ """ Resource for repository team permissions. """
@require_repo_admin @require_repo_admin
@ -41,6 +42,7 @@ class RepositoryTeamPermissionList(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/permissions/user/') @resource('/v1/repository/<repopath:repository>/permissions/user/')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
class RepositoryUserPermissionList(RepositoryParamResource): class RepositoryUserPermissionList(RepositoryParamResource):
""" Resource for repository user permissions. """ """ Resource for repository user permissions. """
@require_repo_admin @require_repo_admin
@ -80,6 +82,8 @@ class RepositoryUserPermissionList(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/permissions/user/<username>') @resource('/v1/repository/<repopath:repository>/permissions/user/<username>')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('username', 'The username of the user to which the permission applies')
class RepositoryUserPermission(RepositoryParamResource): class RepositoryUserPermission(RepositoryParamResource):
""" Resource for managing individual user permissions. """ """ Resource for managing individual user permissions. """
schemas = { schemas = {
@ -175,6 +179,8 @@ class RepositoryUserPermission(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/permissions/team/<teamname>') @resource('/v1/repository/<repopath:repository>/permissions/team/<teamname>')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('teamname', 'The name of the team to which the permission applies')
class RepositoryTeamPermission(RepositoryParamResource): class RepositoryTeamPermission(RepositoryParamResource):
""" Resource for managing individual team permissions. """ """ Resource for managing individual team permissions. """
schemas = { schemas = {

View file

@ -1,7 +1,7 @@
from flask import request from flask import request
from endpoints.api import (resource, nickname, ApiResource, validate_json_request, request_error, from endpoints.api import (resource, nickname, ApiResource, validate_json_request, request_error,
log_action, Unauthorized, NotFound, internal_only) log_action, Unauthorized, NotFound, internal_only, path_param)
from auth.permissions import AdministerOrganizationPermission from auth.permissions import AdministerOrganizationPermission
from auth.auth_context import get_authenticated_user from auth.auth_context import get_authenticated_user
from data import model from data import model
@ -54,6 +54,7 @@ def log_prototype_action(action_kind, orgname, prototype, **kwargs):
@resource('/v1/organization/<orgname>/prototypes') @resource('/v1/organization/<orgname>/prototypes')
@path_param('orgname', 'The name of the organization')
@internal_only @internal_only
class PermissionPrototypeList(ApiResource): class PermissionPrototypeList(ApiResource):
""" Resource for listing and creating permission prototypes. """ """ Resource for listing and creating permission prototypes. """
@ -179,6 +180,8 @@ class PermissionPrototypeList(ApiResource):
@resource('/v1/organization/<orgname>/prototypes/<prototypeid>') @resource('/v1/organization/<orgname>/prototypes/<prototypeid>')
@path_param('orgname', 'The name of the organization')
@path_param('prototypeid', 'The ID of the prototype')
@internal_only @internal_only
class PermissionPrototype(ApiResource): class PermissionPrototype(ApiResource):
""" Resource for managingin individual permission prototypes. """ """ Resource for managingin individual permission prototypes. """

View file

@ -3,7 +3,8 @@ import logging
from flask import request, abort from flask import request, abort
from endpoints.api import (resource, nickname, require_repo_admin, RepositoryParamResource, from endpoints.api import (resource, nickname, require_repo_admin, RepositoryParamResource,
log_action, validate_json_request, NotFound, internal_only) log_action, validate_json_request, NotFound, internal_only,
path_param)
from app import tf from app import tf
from data import model from data import model
@ -26,6 +27,8 @@ def record_view(record):
@internal_only @internal_only
@resource('/v1/repository/<repopath:repository>/authorizedemail/<email>') @resource('/v1/repository/<repopath:repository>/authorizedemail/<email>')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('email', 'The e-mail address')
class RepositoryAuthorizedEmail(RepositoryParamResource): class RepositoryAuthorizedEmail(RepositoryParamResource):
""" Resource for checking and authorizing e-mail addresses to receive repo notifications. """ """ Resource for checking and authorizing e-mail addresses to receive repo notifications. """
@require_repo_admin @require_repo_admin

View file

@ -7,7 +7,9 @@ from data import model
from endpoints.api import (truthy_bool, format_date, nickname, log_action, validate_json_request, from endpoints.api import (truthy_bool, format_date, nickname, log_action, validate_json_request,
require_repo_read, require_repo_write, require_repo_admin, require_repo_read, require_repo_write, require_repo_admin,
RepositoryParamResource, resource, query_param, parse_args, ApiResource, RepositoryParamResource, resource, query_param, parse_args, ApiResource,
request_error, require_scope, Unauthorized, NotFound, InvalidRequest) request_error, require_scope, Unauthorized, NotFound, InvalidRequest,
path_param)
from auth.permissions import (ModifyRepositoryPermission, AdministerRepositoryPermission, from auth.permissions import (ModifyRepositoryPermission, AdministerRepositoryPermission,
CreateRepositoryPermission, ReadRepositoryPermission) CreateRepositoryPermission, ReadRepositoryPermission)
from auth.auth_context import get_authenticated_user from auth.auth_context import get_authenticated_user
@ -140,6 +142,7 @@ class RepositoryList(ApiResource):
@resource('/v1/repository/<repopath:repository>') @resource('/v1/repository/<repopath:repository>')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
class Repository(RepositoryParamResource): class Repository(RepositoryParamResource):
"""Operations for managing a specific repository.""" """Operations for managing a specific repository."""
schemas = { schemas = {
@ -233,6 +236,7 @@ class Repository(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/changevisibility') @resource('/v1/repository/<repopath:repository>/changevisibility')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
class RepositoryVisibility(RepositoryParamResource): class RepositoryVisibility(RepositoryParamResource):
""" Custom verb for changing the visibility of the repository. """ """ Custom verb for changing the visibility of the repository. """
schemas = { schemas = {

View file

@ -4,7 +4,8 @@ from flask import request, abort
from app import notification_queue from app import notification_queue
from endpoints.api import (RepositoryParamResource, nickname, resource, require_repo_admin, from endpoints.api import (RepositoryParamResource, nickname, resource, require_repo_admin,
log_action, validate_json_request, api, NotFound, request_error) log_action, validate_json_request, api, NotFound, request_error,
path_param)
from endpoints.notificationevent import NotificationEvent from endpoints.notificationevent import NotificationEvent
from endpoints.notificationmethod import (NotificationMethod, from endpoints.notificationmethod import (NotificationMethod,
CannotValidateNotificationMethodException) CannotValidateNotificationMethodException)
@ -28,6 +29,7 @@ def notification_view(notification):
@resource('/v1/repository/<repopath:repository>/notification/') @resource('/v1/repository/<repopath:repository>/notification/')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
class RepositoryNotificationList(RepositoryParamResource): class RepositoryNotificationList(RepositoryParamResource):
""" Resource for dealing with listing and creating notifications on a repository. """ """ Resource for dealing with listing and creating notifications on a repository. """
schemas = { schemas = {
@ -95,6 +97,8 @@ class RepositoryNotificationList(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/notification/<uuid>') @resource('/v1/repository/<repopath:repository>/notification/<uuid>')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('uuid', 'The UUID of the notification')
class RepositoryNotification(RepositoryParamResource): class RepositoryNotification(RepositoryParamResource):
""" Resource for dealing with specific notifications. """ """ Resource for dealing with specific notifications. """
@require_repo_admin @require_repo_admin
@ -122,6 +126,8 @@ class RepositoryNotification(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/notification/<uuid>/test') @resource('/v1/repository/<repopath:repository>/notification/<uuid>/test')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('uuid', 'The UUID of the notification')
class TestRepositoryNotification(RepositoryParamResource): class TestRepositoryNotification(RepositoryParamResource):
""" Resource for queuing a test of a notification. """ """ Resource for queuing a test of a notification. """
@require_repo_admin @require_repo_admin

View file

@ -3,7 +3,7 @@ import logging
from flask import request from flask import request
from endpoints.api import (resource, nickname, require_repo_admin, RepositoryParamResource, from endpoints.api import (resource, nickname, require_repo_admin, RepositoryParamResource,
log_action, validate_json_request, NotFound) log_action, validate_json_request, NotFound, path_param)
from data import model from data import model
@ -19,6 +19,7 @@ def token_view(token_obj):
@resource('/v1/repository/<repopath:repository>/tokens/') @resource('/v1/repository/<repopath:repository>/tokens/')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
class RepositoryTokenList(RepositoryParamResource): class RepositoryTokenList(RepositoryParamResource):
""" Resource for creating and listing repository tokens. """ """ Resource for creating and listing repository tokens. """
schemas = { schemas = {
@ -66,6 +67,8 @@ class RepositoryTokenList(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/tokens/<code>') @resource('/v1/repository/<repopath:repository>/tokens/<code>')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('code', 'The token code')
class RepositoryToken(RepositoryParamResource): class RepositoryToken(RepositoryParamResource):
""" Resource for managing individual tokens. """ """ Resource for managing individual tokens. """
schemas = { schemas = {

View file

@ -1,5 +1,5 @@
from endpoints.api import (ApiResource, parse_args, query_param, truthy_bool, nickname, resource, from endpoints.api import (ApiResource, parse_args, query_param, truthy_bool, nickname, resource,
require_scope) require_scope, path_param)
from data import model from data import model
from auth.permissions import (OrganizationMemberPermission, ViewTeamPermission, from auth.permissions import (OrganizationMemberPermission, ViewTeamPermission,
ReadRepositoryPermission, UserAdminPermission, ReadRepositoryPermission, UserAdminPermission,
@ -12,6 +12,7 @@ from util.gravatar import compute_hash
@resource('/v1/entities/<prefix>') @resource('/v1/entities/<prefix>')
class EntitySearch(ApiResource): class EntitySearch(ApiResource):
""" Resource for searching entities. """ """ Resource for searching entities. """
@path_param('prefix', 'The prefix of the entities being looked up')
@parse_args @parse_args
@query_param('namespace', 'Namespace to use when querying for org entities.', type=str, @query_param('namespace', 'Namespace to use when querying for org entities.', type=str,
default='') default='')

View file

@ -8,7 +8,7 @@ from flask import request
from endpoints.api import (ApiResource, nickname, resource, validate_json_request, request_error, from endpoints.api import (ApiResource, nickname, resource, validate_json_request, request_error,
log_action, internal_only, NotFound, require_user_admin, format_date, log_action, internal_only, NotFound, require_user_admin, format_date,
InvalidToken, require_scope, format_date, hide_if, show_if, parse_args, InvalidToken, require_scope, format_date, hide_if, show_if, parse_args,
query_param, abort) query_param, abort, path_param)
from endpoints.api.logs import get_logs from endpoints.api.logs import get_logs
@ -86,6 +86,7 @@ class SuperUserList(ApiResource):
@resource('/v1/superuser/users/<username>') @resource('/v1/superuser/users/<username>')
@path_param('username', 'The username of the user being managed')
@internal_only @internal_only
@show_if(features.SUPER_USERS) @show_if(features.SUPER_USERS)
class SuperUserManagement(ApiResource): class SuperUserManagement(ApiResource):

View file

@ -1,13 +1,16 @@
from flask import request from flask import request
from endpoints.api import (resource, nickname, require_repo_read, require_repo_write, from endpoints.api import (resource, nickname, require_repo_read, require_repo_write,
RepositoryParamResource, log_action, NotFound, validate_json_request) RepositoryParamResource, log_action, NotFound, validate_json_request,
path_param)
from endpoints.api.image import image_view from endpoints.api.image import image_view
from data import model from data import model
from auth.auth_context import get_authenticated_user from auth.auth_context import get_authenticated_user
@resource('/v1/repository/<repopath:repository>/tag/<tag>') @resource('/v1/repository/<repopath:repository>/tag/<tag>')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('tag', 'The name of the tag')
class RepositoryTag(RepositoryParamResource): class RepositoryTag(RepositoryParamResource):
""" Resource for managing repository tags. """ """ Resource for managing repository tags. """
schemas = { schemas = {
@ -73,6 +76,8 @@ class RepositoryTag(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/tag/<tag>/images') @resource('/v1/repository/<repopath:repository>/tag/<tag>/images')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('tag', 'The name of the tag')
class RepositoryTagImages(RepositoryParamResource): class RepositoryTagImages(RepositoryParamResource):
""" Resource for listing the images in a specific repository tag. """ """ Resource for listing the images in a specific repository tag. """
@require_repo_read @require_repo_read

View file

@ -1,7 +1,8 @@
from flask import request from flask import request
from endpoints.api import (resource, nickname, ApiResource, validate_json_request, request_error, from endpoints.api import (resource, nickname, ApiResource, validate_json_request, request_error,
log_action, Unauthorized, NotFound, internal_only, require_scope) log_action, Unauthorized, NotFound, internal_only, require_scope,
path_param)
from auth.permissions import AdministerOrganizationPermission, ViewTeamPermission from auth.permissions import AdministerOrganizationPermission, ViewTeamPermission
from auth.auth_context import get_authenticated_user from auth.auth_context import get_authenticated_user
from auth import scopes from auth import scopes
@ -28,6 +29,8 @@ def member_view(member):
@resource('/v1/organization/<orgname>/team/<teamname>') @resource('/v1/organization/<orgname>/team/<teamname>')
@path_param('orgname', 'The name of the organization')
@path_param('teamname', 'The name of the team')
@internal_only @internal_only
class OrganizationTeam(ApiResource): class OrganizationTeam(ApiResource):
""" Resource for manging an organization's teams. """ """ Resource for manging an organization's teams. """
@ -111,6 +114,8 @@ class OrganizationTeam(ApiResource):
@resource('/v1/organization/<orgname>/team/<teamname>/members') @resource('/v1/organization/<orgname>/team/<teamname>/members')
@path_param('orgname', 'The name of the organization')
@path_param('teamname', 'The name of the team')
@internal_only @internal_only
class TeamMemberList(ApiResource): class TeamMemberList(ApiResource):
""" Resource for managing the list of members for a team. """ """ Resource for managing the list of members for a team. """
@ -137,6 +142,9 @@ class TeamMemberList(ApiResource):
@resource('/v1/organization/<orgname>/team/<teamname>/members/<membername>') @resource('/v1/organization/<orgname>/team/<teamname>/members/<membername>')
@path_param('orgname', 'The name of the organization')
@path_param('teamname', 'The name of the team')
@path_param('membername', 'The username of the team member')
class TeamMember(ApiResource): class TeamMember(ApiResource):
""" Resource for managing individual members of a team. """ """ Resource for managing individual members of a team. """
@require_scope(scopes.ORG_ADMIN) @require_scope(scopes.ORG_ADMIN)

View file

@ -8,7 +8,8 @@ from urlparse import urlunparse
from app import app from app import app
from endpoints.api import (RepositoryParamResource, nickname, resource, require_repo_admin, from endpoints.api import (RepositoryParamResource, nickname, resource, require_repo_admin,
log_action, request_error, query_param, parse_args, internal_only, log_action, request_error, query_param, parse_args, internal_only,
validate_json_request, api, Unauthorized, NotFound, InvalidRequest) validate_json_request, api, Unauthorized, NotFound, InvalidRequest,
path_param)
from endpoints.api.build import (build_status_view, trigger_view, RepositoryBuildStatus, from endpoints.api.build import (build_status_view, trigger_view, RepositoryBuildStatus,
get_trigger_config) get_trigger_config)
from endpoints.common import start_build from endpoints.common import start_build
@ -30,6 +31,7 @@ def _prepare_webhook_url(scheme, username, password, hostname, path):
@resource('/v1/repository/<repopath:repository>/trigger/') @resource('/v1/repository/<repopath:repository>/trigger/')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
class BuildTriggerList(RepositoryParamResource): class BuildTriggerList(RepositoryParamResource):
""" Resource for listing repository build triggers. """ """ Resource for listing repository build triggers. """
@ -44,6 +46,8 @@ class BuildTriggerList(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/trigger/<trigger_uuid>') @resource('/v1/repository/<repopath:repository>/trigger/<trigger_uuid>')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('trigger_uuid', 'The UUID of the build trigger')
class BuildTrigger(RepositoryParamResource): class BuildTrigger(RepositoryParamResource):
""" Resource for managing specific build triggers. """ """ Resource for managing specific build triggers. """
@ -90,6 +94,8 @@ class BuildTrigger(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/trigger/<trigger_uuid>/subdir') @resource('/v1/repository/<repopath:repository>/trigger/<trigger_uuid>/subdir')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('trigger_uuid', 'The UUID of the build trigger')
@internal_only @internal_only
class BuildTriggerSubdirs(RepositoryParamResource): class BuildTriggerSubdirs(RepositoryParamResource):
""" Custom verb for fetching the subdirs which are buildable for a trigger. """ """ Custom verb for fetching the subdirs which are buildable for a trigger. """
@ -137,6 +143,8 @@ class BuildTriggerSubdirs(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/trigger/<trigger_uuid>/activate') @resource('/v1/repository/<repopath:repository>/trigger/<trigger_uuid>/activate')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('trigger_uuid', 'The UUID of the build trigger')
@internal_only @internal_only
class BuildTriggerActivate(RepositoryParamResource): class BuildTriggerActivate(RepositoryParamResource):
""" Custom verb for activating a build trigger once all required information has been collected. """ Custom verb for activating a build trigger once all required information has been collected.
@ -237,6 +245,8 @@ class BuildTriggerActivate(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/trigger/<trigger_uuid>/analyze') @resource('/v1/repository/<repopath:repository>/trigger/<trigger_uuid>/analyze')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('trigger_uuid', 'The UUID of the build trigger')
@internal_only @internal_only
class BuildTriggerAnalyze(RepositoryParamResource): class BuildTriggerAnalyze(RepositoryParamResource):
""" Custom verb for analyzing the config for a build trigger and suggesting various changes """ Custom verb for analyzing the config for a build trigger and suggesting various changes
@ -372,6 +382,8 @@ class BuildTriggerAnalyze(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/trigger/<trigger_uuid>/start') @resource('/v1/repository/<repopath:repository>/trigger/<trigger_uuid>/start')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('trigger_uuid', 'The UUID of the build trigger')
class ActivateBuildTrigger(RepositoryParamResource): class ActivateBuildTrigger(RepositoryParamResource):
""" Custom verb to manually activate a build trigger. """ """ Custom verb to manually activate a build trigger. """
@ -408,6 +420,8 @@ class ActivateBuildTrigger(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/trigger/<trigger_uuid>/builds') @resource('/v1/repository/<repopath:repository>/trigger/<trigger_uuid>/builds')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('trigger_uuid', 'The UUID of the build trigger')
class TriggerBuildList(RepositoryParamResource): class TriggerBuildList(RepositoryParamResource):
""" Resource to represent builds that were activated from the specified trigger. """ """ Resource to represent builds that were activated from the specified trigger. """
@require_repo_admin @require_repo_admin
@ -425,6 +439,8 @@ class TriggerBuildList(RepositoryParamResource):
@resource('/v1/repository/<repopath:repository>/trigger/<trigger_uuid>/sources') @resource('/v1/repository/<repopath:repository>/trigger/<trigger_uuid>/sources')
@path_param('repository', 'The full path of the repository. e.g. namespace/name')
@path_param('trigger_uuid', 'The UUID of the build trigger')
@internal_only @internal_only
class BuildTriggerSources(RepositoryParamResource): class BuildTriggerSources(RepositoryParamResource):
""" Custom verb to fetch the list of build sources for the trigger config. """ """ Custom verb to fetch the list of build sources for the trigger config. """

View file

@ -7,7 +7,7 @@ from flask.ext.principal import identity_changed, AnonymousIdentity
from app import app, billing as stripe, authentication from app import app, billing as stripe, authentication
from endpoints.api import (ApiResource, nickname, resource, validate_json_request, request_error, from endpoints.api import (ApiResource, nickname, resource, validate_json_request, request_error,
log_action, internal_only, NotFound, require_user_admin, log_action, internal_only, NotFound, require_user_admin, path_param,
InvalidToken, require_scope, format_date, hide_if, show_if, license_error) InvalidToken, require_scope, format_date, hide_if, show_if, license_error)
from endpoints.api.subscribe import subscribe from endpoints.api.subscribe import subscribe
from endpoints.common import common_login from endpoints.common import common_login
@ -412,6 +412,7 @@ class UserNotificationList(ApiResource):
@resource('/v1/user/notifications/<uuid>') @resource('/v1/user/notifications/<uuid>')
@path_param('uuid', 'The uuid of the user notification')
@internal_only @internal_only
class UserNotification(ApiResource): class UserNotification(ApiResource):
schemas = { schemas = {
@ -482,6 +483,7 @@ class UserAuthorizationList(ApiResource):
@resource('/v1/user/authorizations/<access_token_uuid>') @resource('/v1/user/authorizations/<access_token_uuid>')
@path_param('access_token_uuid', 'The uuid of the access token')
@internal_only @internal_only
class UserAuthorization(ApiResource): class UserAuthorization(ApiResource):
@require_user_admin @require_user_admin