diff options
Diffstat (limited to 'acme/acme/messages.py')
-rw-r--r-- | acme/acme/messages.py | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/acme/acme/messages.py b/acme/acme/messages.py index 9b9ef5de2..fbb7738d0 100644 --- a/acme/acme/messages.py +++ b/acme/acme/messages.py @@ -14,6 +14,7 @@ from typing import Type from typing import TYPE_CHECKING from typing import TypeVar from typing import Union +import warnings import josepy as jose @@ -22,7 +23,9 @@ from acme import errors from acme import fields from acme import jws from acme import util -from acme.mixins import ResourceMixin +with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=DeprecationWarning) + from acme.mixins import ResourceMixin if TYPE_CHECKING: from typing_extensions import Protocol # pragma: no cover @@ -573,14 +576,14 @@ class Authorization(ResourceBody): :ivar acme.messages.Identifier identifier: :ivar list challenges: `list` of `.ChallengeBody` :ivar tuple combinations: Challenge combinations (`tuple` of `tuple` - of `int`, as opposed to `list` of `list` from the spec). + of `int`, as opposed to `list` of `list` from the spec). (deprecated since 1.30.0) :ivar acme.messages.Status status: :ivar datetime.datetime expires: """ identifier: Identifier = jose.field('identifier', decoder=Identifier.from_json, omitempty=True) challenges: List[ChallengeBody] = jose.field('challenges', omitempty=True) - combinations: Tuple[Tuple[int, ...], ...] = jose.field('combinations', omitempty=True) + _combinations: Tuple[Tuple[int, ...], ...] = jose.field('combinations', omitempty=True) status: Status = jose.field('status', omitempty=True, decoder=Status.from_json) # TODO: 'expires' is allowed for Authorization Resources in @@ -590,6 +593,13 @@ class Authorization(ResourceBody): expires: datetime.datetime = fields.rfc3339('expires', omitempty=True) wildcard: bool = jose.field('wildcard', omitempty=True) + # combinations is temporarily renamed to _combinations during its deprecation + # period. See https://github.com/certbot/certbot/pull/9369#issuecomment-1199849262. + def __init__(self, **kwargs: Any) -> None: + if 'combinations' in kwargs: + kwargs['_combinations'] = kwargs.pop('combinations') + super().__init__(**kwargs) + # Mypy does not understand the josepy magic happening here, and falsely claims # that challenge is redefined. Let's ignore the type check here. @challenges.decoder # type: ignore @@ -597,8 +607,35 @@ class Authorization(ResourceBody): return tuple(ChallengeBody.from_json(chall) for chall in value) @property + def combinations(self) -> Tuple[Tuple[int, ...], ...]: + """Challenge combinations. + (`tuple` of `tuple` of `int`, as opposed to `list` of `list` from the spec). + + .. deprecated: 1.30.0 + + """ + warnings.warn( + "acme.messages.Authorization.combinations is deprecated and will be " + "removed in a future release.", DeprecationWarning) + return self._combinations + + @combinations.setter + def combinations(self, combos: Tuple[Tuple[int, ...], ...]) -> None: # pragma: no cover + warnings.warn( + "acme.messages.Authorization.combinations is deprecated and will be " + "removed in a future release.", DeprecationWarning) + self._combinations = combos + + @property def resolved_combinations(self) -> Tuple[Tuple[ChallengeBody, ...], ...]: - """Combinations with challenges instead of indices.""" + """Combinations with challenges instead of indices. + + .. deprecated: 1.30.0 + + """ + warnings.warn( + "acme.messages.Authorization.resolved_combinations is deprecated and will be " + "removed in a future release.", DeprecationWarning) return tuple(tuple(self.challenges[idx] for idx in combo) for combo in self.combinations) # pylint: disable=not-an-iterable |