403Webshell
Server IP : 195.134.90.114  /  Your IP : 216.73.216.43
Web Server : Apache/2.4.58
System : Linux nepub 6.8.0-88-generic #89-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 01:02:46 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 8.2.30
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : OFF
Directory :  /usr/lib/python3/dist-packages/uaclient/api/u/pro/attach/magic/revoke/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/uaclient/api/u/pro/attach/magic/revoke/v1.py
from uaclient.api import exceptions
from uaclient.api.api import APIEndpoint
from uaclient.api.data_types import AdditionalInfo
from uaclient.config import UAConfig
from uaclient.contract import UAContractClient
from uaclient.data_types import DataObject, Field, StringDataValue


class MagicAttachRevokeOptions(DataObject):
    fields = [
        Field(
            "magic_token",
            StringDataValue,
            doc="The Token provided by the initiate endpoint.",
        ),
    ]

    def __init__(self, magic_token):
        self.magic_token = magic_token


class MagicAttachRevokeResult(DataObject, AdditionalInfo):
    pass


def revoke(options: MagicAttachRevokeOptions) -> MagicAttachRevokeResult:
    return _revoke(options, UAConfig())


def _revoke(
    options: MagicAttachRevokeOptions, cfg: UAConfig
) -> MagicAttachRevokeResult:
    """
    This endpoint revokes a Magic Attach Token.
    """
    contract = UAContractClient(cfg)
    contract.revoke_magic_attach_token(options.magic_token)

    return MagicAttachRevokeResult()


endpoint = APIEndpoint(
    version="v1",
    name="MagicAttachRevoke",
    fn=_revoke,
    options_cls=MagicAttachRevokeOptions,
)

_doc = {
    "introduced_in": "27.11",
    "requires_network": True,
    "example_python": """
from uaclient.api.u.pro.attach.magic.revoke.v1 import MagicAttachRevokeOptions, revoke

options = MagicAttachWaitOptions(magic_token="<magic_token>")
result = revoke(options)
""",  # noqa: E501
    "result_class": MagicAttachRevokeResult,
    "exceptions": [
        (
            exceptions.ConnectivityError,
            (
                "Raised if it is not possible to connect to the contracts"
                " service."
            ),
        ),
        (
            exceptions.ContractAPIError,
            (
                "Raised if there is an unexpected error in the contracts"
                " service interaction."
            ),
        ),
        (
            exceptions.MagicAttachTokenAlreadyActivated,
            (
                "Raised when trying to revoke a Token which was already"
                " activated through the UI."
            ),
        ),
        (
            exceptions.MagicAttachTokenError,
            "Raised when an invalid/expired Token is sent.",
        ),
        (
            exceptions.MagicAttachUnavailable,
            (
                "Raised if the Magic Attach service is busy or unavailable at"
                " the moment."
            ),
        ),
    ],
    "example_cli": "pro api u.pro.attach.magic.revoke.v1 --args magic_token=<token>",  # noqa: E501
    "example_json": """
{}
""",
}

Youez - 2016 - github.com/yon3zu
LinuXploit