File tree Expand file tree Collapse file tree 5 files changed +18
-8
lines changed
authorized_storage_account Expand file tree Collapse file tree 5 files changed +18
-8
lines changed Original file line number Diff line number Diff line change 77 get_imp_name ,
88)
99from addon_service .common .static_dataclass_model import StaticDataclassModel
10- from addon_toolkit import AddonOperationImp
10+ from addon_toolkit import (
11+ AddonCapabilities ,
12+ AddonOperationImp ,
13+ )
1114from addon_toolkit .json_arguments import jsonschema_for_signature_params
1215from addon_toolkit .operation import AddonOperationType
1316
1417
1518# dataclass wrapper for addon_toolkit.AddonOperationImp that sufficiently
1619# meets rest_framework_json_api expectations on a model class
17- @dataclasses .dataclass (frozen = True , kw_only = True )
20+ @dataclasses .dataclass (frozen = True )
1821class AddonOperationModel (StaticDataclassModel ):
1922 operation_imp : AddonOperationImp
2023
@@ -42,7 +45,7 @@ def implementation_docstring(self) -> str:
4245 return self .operation_imp .imp_function .__doc__ or ""
4346
4447 @cached_property
45- def capability (self ) -> str :
48+ def capability (self ) -> AddonCapabilities :
4649 return self .operation_imp .declaration .capability
4750
4851 @cached_property
Original file line number Diff line number Diff line change 11from rest_framework_json_api import serializers
22from rest_framework_json_api .utils import get_resource_type_from_model
33
4- from addon_service .addon_imp .models import AddonImp
54from addon_service .common import view_names
65from addon_service .common .enums .serializers import EnumNameChoiceField
76from addon_service .common .serializer_fields import DataclassRelatedDataField
87from addon_toolkit import AddonCapabilities
8+ from addon_toolkit .imp import AddonImp
99
1010from .models import AddonOperationModel
1111
Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ def authorized_operation_names(self):
121121 ]
122122
123123 @property
124- def auth_url (self ) -> str :
124+ def auth_url (self ) -> str | None :
125125 """Generates the url required to initiate OAuth2 credentials exchange.
126126
127127 Returns None if the ExternalStorageService does not support OAuth2
Original file line number Diff line number Diff line change 77 Iterator ,
88)
99
10+ from .capabilities import AddonCapabilities
1011from .declarator import Declarator
1112
1213
@@ -35,7 +36,7 @@ class AddonOperationDeclaration:
3536 """
3637
3738 operation_type : AddonOperationType
38- capability : enum . Enum
39+ capability : AddonCapabilities
3940 operation_fn : Callable # the decorated function
4041 return_type : type = dataclasses .field (
4142 default = type (None ), # if not provided, inferred by __post_init__
@@ -99,7 +100,13 @@ def param_dataclasses(self) -> Iterator[type]:
99100@dataclasses .dataclass
100101class RedirectResult :
101102 url : str
102- method : HTTPMethod = HTTPMethod .GET
103+ method : str = HTTPMethod .GET
104+
105+ def __post_init__ (self ):
106+ try :
107+ HTTPMethod (self .method )
108+ except ValueError :
109+ raise ValueError (f'invalid http method "{ self .method } "' )
103110
104111
105112# decorator for operations that may be performed by a client request (e.g. redirect to waterbutler)
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ class _MyCapability(enum.Enum):
2525 UNUSED = "unused" # for testing when a capability has no operations
2626
2727 ###
28- # shared test env (on `self` )
28+ # shared test env (initialized by setUpClass )
2929 _MyProtocol : type # typing.Protocol subclass decorated with `@addon_protocol`
3030 _MyImplementation : type # subclass of _MyProtocol
3131 _my_imp : AddonImp
You can’t perform that action at this time.
0 commit comments