From af27a1b6dc50adb358593f44d07218014d6cb995 Mon Sep 17 00:00:00 2001 From: Evan Cordell Date: Thu, 20 Jul 2017 14:24:43 -0400 Subject: [PATCH 1/2] Add a data interface for manifest labels API --- endpoints/api/manifest.py | 92 +++++++++------------- endpoints/api/manifest_models_interface.py | 42 ++++++++++ endpoints/api/manifest_models_pre_oci.py | 50 ++++++++++++ 3 files changed, 128 insertions(+), 56 deletions(-) create mode 100644 endpoints/api/manifest_models_interface.py create mode 100644 endpoints/api/manifest_models_pre_oci.py diff --git a/endpoints/api/manifest.py b/endpoints/api/manifest.py index 66716da3f..7eaad827b 100644 --- a/endpoints/api/manifest.py +++ b/endpoints/api/manifest.py @@ -4,10 +4,11 @@ from app import label_validator from flask import request from endpoints.api import (resource, nickname, require_repo_read, require_repo_write, RepositoryParamResource, log_action, validate_json_request, - path_param, parse_args, query_param, truthy_bool, abort, api, + path_param, parse_args, query_param, abort, api, disallow_for_app_repositories) from endpoints.exception import NotFound -from data import model +from manifest_models_pre_oci import pre_oci_model as model +from data.model import InvalidLabelKeyException, InvalidMediaTypeException from digest import digest_tools from util.validation import VALID_LABEL_KEY_REGEX @@ -16,16 +17,6 @@ BASE_MANIFEST_ROUTE = '/v1/repository//manifest/ Date: Wed, 26 Jul 2017 14:21:51 -0400 Subject: [PATCH 2/2] Add doc comments to data interface for manifest labels --- endpoints/api/manifest_models_interface.py | 65 ++++++++++++++++++++-- endpoints/api/manifest_models_pre_oci.py | 2 +- 2 files changed, 61 insertions(+), 6 deletions(-) diff --git a/endpoints/api/manifest_models_interface.py b/endpoints/api/manifest_models_interface.py index 5157fb0da..618e434b7 100644 --- a/endpoints/api/manifest_models_interface.py +++ b/endpoints/api/manifest_models_interface.py @@ -12,7 +12,14 @@ class ManifestLabel( 'source_type_name', 'media_type_name', ])): - + """ + ManifestLabel represents a label on a manifest + :type uuid: string + :type key: string + :type value: string + :type source_type_name: string + :type media_type_name: string + """ def to_dict(self): return { 'id': self.uuid, @@ -25,18 +32,66 @@ class ManifestLabel( @add_metaclass(ABCMeta) class ManifestLabelInterface(object): + """ + Data interface that the manifest labels API uses + """ + @abstractmethod def get_manifest_labels(self, namespace_name, repository_name, manifestref, filter=None): - pass + """ + + Args: + namespace_name: string + repository_name: string + manifestref: string + filter: string + + Returns: + list(ManifestLabel) or None + + """ @abstractmethod def create_manifest_label(self, namespace_name, repository_name, manifestref, key, value, source_type_name, media_type_name): - pass + """ + + Args: + namespace_name: string + repository_name: string + manifestref: string + key: string + value: string + source_type_name: string + media_type_name: string + + Returns: + ManifestLabel or None + """ @abstractmethod def get_manifest_label(self, namespace_name, repository_name, manifestref, label_uuid): - pass + """ + + Args: + namespace_name: string + repository_name: string + manifestref: string + label_uuid: string + + Returns: + ManifestLabel or None + """ @abstractmethod def delete_manifest_label(self, namespace_name, repository_name, manifestref, label_uuid): - pass + """ + + Args: + namespace_name: string + repository_name: string + manifestref: string + label_uuid: string + + Returns: + ManifestLabel or None + """ diff --git a/endpoints/api/manifest_models_pre_oci.py b/endpoints/api/manifest_models_pre_oci.py index 5d0c7cbdd..9cc44ce93 100644 --- a/endpoints/api/manifest_models_pre_oci.py +++ b/endpoints/api/manifest_models_pre_oci.py @@ -47,4 +47,4 @@ class ManifestLabelPreOCI(ManifestLabelInterface): media_type_name=label_obj.media_type.name, ) -pre_oci_model = ManifestLabelPreOCI() \ No newline at end of file +pre_oci_model = ManifestLabelPreOCI()