|
22 | 22 | from otcextensions.sdk.apig.v2 import api as _api |
23 | 23 | from otcextensions.sdk.apig.v2 import api_supplements as _supp |
24 | 24 | from otcextensions.sdk.apig.v2 import signature as _sign |
| 25 | +from otcextensions.sdk.apig.v2 import signature_binding as _sign_bind |
25 | 26 |
|
26 | 27 |
|
27 | 28 | class Proxy(proxy.Proxy): |
@@ -981,3 +982,92 @@ def signatures(self, gateway, **attrs): |
981 | 982 | gateway_id=gateway.id, |
982 | 983 | **attrs |
983 | 984 | ) |
| 985 | + |
| 986 | + # ======== Signature Binding Methods ======== |
| 987 | + |
| 988 | + def bind_signature(self, gateway, **attrs): |
| 989 | + """Bind a Signature for a specific API. |
| 990 | +
|
| 991 | + :param gateway: The ID of the gateway or an instance of |
| 992 | + :class:`~otcextensions.sdk.apig.v2.gateway.Gateway` |
| 993 | + :param attrs: Additional attributes for the Signature bind. |
| 994 | +
|
| 995 | + :returns: An instance of SignatureBind |
| 996 | + """ |
| 997 | + gateway = self._get_resource(_gateway.Gateway, gateway) |
| 998 | + return self._create( |
| 999 | + _sign_bind.SignatureBind, |
| 1000 | + gateway_id=gateway.id, |
| 1001 | + **attrs) |
| 1002 | + |
| 1003 | + def unbind_signature(self, gateway, bind, ignore_missing=False): |
| 1004 | + """Unbind a bound Signature from a specific API. |
| 1005 | +
|
| 1006 | + :param gateway: The ID of the gateway or an instance of |
| 1007 | + :class:`~otcextensions.sdk.apig.v2.gateway.Gateway` |
| 1008 | + :param bind: The ID of the SignatureBind or an instance |
| 1009 | + of SignatureBind |
| 1010 | +
|
| 1011 | + :returns: None |
| 1012 | + """ |
| 1013 | + gateway = self._get_resource(_gateway.Gateway, gateway) |
| 1014 | + bind = self._get_resource(_sign_bind.SignatureBind, bind) |
| 1015 | + return self._delete( |
| 1016 | + _sign_bind.SignatureBind, |
| 1017 | + bind, |
| 1018 | + gateway_id=gateway.id, |
| 1019 | + ignore_missing=ignore_missing |
| 1020 | + ) |
| 1021 | + |
| 1022 | + def bound_signatures(self, gateway, **query): |
| 1023 | + """List all Signatures bound a specific API. |
| 1024 | +
|
| 1025 | + :param gateway: The ID of the gateway or an instance of |
| 1026 | + :class:`~otcextensions.sdk.apig.v2.gateway.Gateway` |
| 1027 | + :param query: Additional filters for listing SignatureBind. |
| 1028 | +
|
| 1029 | + :returns: A list of instances of SignatureBind |
| 1030 | + """ |
| 1031 | + gateway = self._get_resource(_gateway.Gateway, gateway) |
| 1032 | + bp = '/apigw/instances/%(gateway_id)s/sign-bindings/binded-signs' |
| 1033 | + return self._list( |
| 1034 | + _sign_bind.SignatureBind, |
| 1035 | + paginated=False, |
| 1036 | + gateway_id=gateway.id, |
| 1037 | + base_path=bp, |
| 1038 | + **query |
| 1039 | + ) |
| 1040 | + |
| 1041 | + def not_bound_apis(self, gateway, **query): |
| 1042 | + """List all APIs to which a signature key has not been bound. |
| 1043 | +
|
| 1044 | + :param gateway: The ID of the gateway or an instance of |
| 1045 | + :class:`~otcextensions.sdk.apig.v2.gateway.Gateway` |
| 1046 | + :param query: Additional filters for listing NotBoundApi. |
| 1047 | +
|
| 1048 | + :returns: A list of instances of NotBoundApi |
| 1049 | + """ |
| 1050 | + gateway = self._get_resource(_gateway.Gateway, gateway) |
| 1051 | + return self._list( |
| 1052 | + _sign_bind.NotBoundApi, |
| 1053 | + paginated=False, |
| 1054 | + gateway_id=gateway.id, |
| 1055 | + **query |
| 1056 | + ) |
| 1057 | + |
| 1058 | + def bound_apis(self, gateway, **query): |
| 1059 | + """List all APIs to which a signature key has been bound. |
| 1060 | +
|
| 1061 | + :param gateway: The ID of the gateway or an instance of |
| 1062 | + :class:`~otcextensions.sdk.apig.v2.gateway.Gateway` |
| 1063 | + :param query: Additional filters for listing BoundApi. |
| 1064 | +
|
| 1065 | + :returns: A list of instances of BoundApi |
| 1066 | + """ |
| 1067 | + gateway = self._get_resource(_gateway.Gateway, gateway) |
| 1068 | + return self._list( |
| 1069 | + _sign_bind.BoundApi, |
| 1070 | + paginated=False, |
| 1071 | + gateway_id=gateway.id, |
| 1072 | + **query |
| 1073 | + ) |
0 commit comments