Skip to content
MEC application.ipynb 246 KiB
Newer Older
    "    def to_str(self):\n",
    "        return pprint.pformat(self.to_dict())\n",
    "    def __repr__(self):\n",
    "        return self.to_str()\n",
    "    def __eq__(self, other):\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if not isinstance(other, CategoryRef):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
Yann Garcia's avatar
Yann Garcia committed
    "class TransportInfo(object):\n",
    "    swagger_types = {\n",
    "        'id': 'str','name': 'str','description': 'str','type': 'str','protocol': 'str','version': 'str','endpoint': 'OneOfTransportInfoEndpoint','security': 'SecurityInfo','impl_specific_info': 'str'}\n",
    "    attribute_map = {'id': 'id','name': 'name','description': 'description','type': 'type','protocol': 'protocol','version': 'version','endpoint': 'endpoint','security': 'security','impl_specific_info': 'implSpecificInfo'}\n",
    "    def __init__(self, id=None, name=None, description=None, type=None, protocol=None, version=None, endpoint=None, security=None, impl_specific_info=None):  # noqa: E501\n",
    "        self._id = None\n",
    "        self._name = None\n",
    "        self._description = None\n",
    "        self._type = None\n",
    "        self._protocol = None\n",
    "        self._version = None\n",
    "        self._endpoint = None\n",
    "        self._security = None\n",
    "        self._impl_specific_info = None\n",
    "        self.discriminator = None\n",
    "        self.id = id\n",
    "        self.name = name\n",
    "        if description is not None:\n",
    "            self.description = description\n",
    "        self.type = type\n",
    "        self.protocol = protocol\n",
    "        self.version = version\n",
    "        self.endpoint = endpoint\n",
    "        self.security = security\n",
    "        if impl_specific_info is not None:\n",
    "            self.impl_specific_info = impl_specific_info\n",
    "    @property\n",
Yann Garcia's avatar
Yann Garcia committed
    "    def id(self):\n",
    "        return self._id\n",
    "    @id.setter\n",
    "    def id(self, id):\n",
    "        if id is None:\n",
    "            raise ValueError(\"Invalid value for `id`, must not be `None`\")  # noqa: E501\n",
    "        self._id = id\n",
    "    @property\n",
Yann Garcia's avatar
Yann Garcia committed
    "    def name(self):\n",
    "        return self._name\n",
    "    @name.setter\n",
    "    def name(self, name):\n",
    "        if name is None:\n",
    "            raise ValueError(\"Invalid value for `name`, must not be `None`\")  # noqa: E501\n",
    "        self._name = name\n",
    "    @property\n",
    "    def description(self):\n",
    "        return self._description\n",
    "    @description.setter\n",
    "    def description(self, description):\n",
    "        self._description = description\n",
    "    @property\n",
    "    def type(self):\n",
    "        return self._type\n",
    "    @type.setter\n",
    "    def type(self, type):\n",
    "        if type is None:\n",
    "            raise ValueError(\"Invalid value for `type`, must not be `None`\")  # noqa: E501\n",
    "        self._type = type\n",
    "    @property\n",
    "    def protocol(self):\n",
    "        return self._protocol\n",
    "    @protocol.setter\n",
    "    def protocol(self, protocol):\n",
    "        if protocol is None:\n",
    "            raise ValueError(\"Invalid value for `protocol`, must not be `None`\")  # noqa: E501\n",
    "        self._protocol = protocol\n",
    "    @property\n",
    "    def version(self):\n",
    "        return self._version\n",
    "    @version.setter\n",
    "    def version(self, version):\n",
    "        if version is None:\n",
    "            raise ValueError(\"Invalid value for `version`, must not be `None`\")  # noqa: E501\n",
    "        self._version = version\n",
    "    @property\n",
    "    def endpoint(self):\n",
    "        return self._endpoint\n",
    "    @endpoint.setter\n",
    "    def endpoint(self, endpoint):\n",
    "        if endpoint is None:\n",
    "            raise ValueError(\"Invalid value for `endpoint`, must not be `None`\")  # noqa: E501\n",
    "        self._endpoint = endpoint\n",
    "    @property\n",
    "    def security(self):\n",
    "        return self._security\n",
    "    @security.setter\n",
    "    def security(self, security):\n",
    "        if security is None:\n",
    "            raise ValueError(\"Invalid value for `security`, must not be `None`\")  # noqa: E501\n",
    "        self._security = security\n",
    "    @property\n",
    "    def impl_specific_info(self):\n",
    "        return self._impl_specific_info\n",
    "    @impl_specific_info.setter\n",
    "    def impl_specific_info(self, impl_specific_info):\n",
    "        self._impl_specific_info = impl_specific_info\n",
    "    def to_dict(self):\n",
    "        result = {}\n",
    "        for attr, _ in six.iteritems(self.swagger_types):\n",
    "            value = getattr(self, attr)\n",
    "            if isinstance(value, list):\n",
Yann Garcia's avatar
Yann Garcia committed
    "                result[attr] = list(map(\n",
    "                    lambda x: x.to_dict() if hasattr(x, \"to_dict\") else x,\n",
    "                    value\n",
    "                ))\n",
    "            elif hasattr(value, \"to_dict\"):\n",
    "                result[attr] = value.to_dict()\n",
    "            elif isinstance(value, dict):\n",
    "                result[attr] = dict(map(\n",
    "                    lambda item: (item[0], item[1].to_dict())\n",
Yann Garcia's avatar
Yann Garcia committed
    "                    if hasattr(item[1], \"to_dict\") else item,\n",
    "                    value.items()\n",
    "                ))\n",
    "            else:\n",
    "                result[attr] = value\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if issubclass(TransportInfo, dict):\n",
    "            for key, value in self.items():\n",
    "                result[key] = value\n",
    "        return result\n",
    "    def to_str(self):\n",
    "        return pprint.pformat(self.to_dict())\n",
    "    def __repr__(self):\n",
    "        return self.to_str()\n",
    "    def __eq__(self, other):\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if not isinstance(other, TransportInfo):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
Yann Garcia's avatar
Yann Garcia committed
    "class SecurityInfo(object):\n",
    "    swagger_types = {'o_auth2_info': 'SecurityInfoOAuth2Info'}\n",
    "    attribute_map = {'o_auth2_info': 'oAuth2Info'}\n",
    "    def __init__(self, o_auth2_info=None):  # noqa: E501\n",
    "        self._o_auth2_info = None\n",
    "        self.discriminator = None\n",
    "        if o_auth2_info is not None:\n",
    "            self.o_auth2_info = o_auth2_info\n",
    "    @property\n",
Yann Garcia's avatar
Yann Garcia committed
    "    def o_auth2_info(self):\n",
    "        return self._o_auth2_info\n",
    "    @o_auth2_info.setter\n",
    "    def o_auth2_info(self, o_auth2_info):\n",
    "        self._o_auth2_info = o_auth2_info\n",
    "    def to_dict(self):\n",
    "        result = {}\n",
    "        for attr, _ in six.iteritems(self.swagger_types):\n",
    "            value = getattr(self, attr)\n",
    "            if isinstance(value, list):\n",
Yann Garcia's avatar
Yann Garcia committed
    "                result[attr] = list(map(\n",
    "                    lambda x: x.to_dict() if hasattr(x, \"to_dict\") else x,\n",
    "                    value\n",
    "                ))\n",
    "            elif hasattr(value, \"to_dict\"):\n",
    "                result[attr] = value.to_dict()\n",
    "            elif isinstance(value, dict):\n",
    "                result[attr] = dict(map(\n",
    "                    lambda item: (item[0], item[1].to_dict())\n",
Yann Garcia's avatar
Yann Garcia committed
    "                    if hasattr(item[1], \"to_dict\") else item,\n",
    "                    value.items()\n",
    "                ))\n",
    "            else:\n",
    "                result[attr] = value\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if issubclass(SecurityInfo, dict):\n",
    "            for key, value in self.items():\n",
    "                result[key] = value\n",
    "        return result\n",
    "    def to_str(self):\n",
    "        return pprint.pformat(self.to_dict())\n",
    "    def __repr__(self):\n",
    "        return self.to_str()\n",
    "    def __eq__(self, other):\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if not isinstance(other, SecurityInfo):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
Yann Garcia's avatar
Yann Garcia committed
    "class SecurityInfoOAuth2Info(object):\n",
    "    swagger_types = {'grant_types': 'list[str]','token_endpoint': 'str'}\n",
    "    attribute_map = {'grant_types': 'grantTypes','token_endpoint': 'tokenEndpoint'}\n",
    "    def __init__(self, grant_types=None, token_endpoint=None):  # noqa: E501\n",
    "        self._grant_types = None\n",
    "        self._token_endpoint = None\n",
    "        self.discriminator = None\n",
    "        self.grant_types = grant_types\n",
    "        self.token_endpoint = token_endpoint\n",
    "    @property\n",
Yann Garcia's avatar
Yann Garcia committed
    "    def grant_types(self):\n",
    "        return self._grant_types\n",
    "    @grant_types.setter\n",
    "    def grant_types(self, grant_types):\n",
    "        if grant_types is None:\n",
    "            raise ValueError(\"Invalid value for `grant_types`, must not be `None`\")  # noqa: E501\n",
    "        self._grant_types = grant_types\n",
    "    @property\n",
Yann Garcia's avatar
Yann Garcia committed
    "    def token_endpoint(self):\n",
    "        return self._token_endpoint\n",
    "    @token_endpoint.setter\n",
    "    def token_endpoint(self, token_endpoint):\n",
    "        if token_endpoint is None:\n",
    "            raise ValueError(\"Invalid value for `token_endpoint`, must not be `None`\")  # noqa: E501\n",
    "        self._token_endpoint = token_endpoint\n",
    "    def to_dict(self):\n",
    "        result = {}\n",
    "        for attr, _ in six.iteritems(self.swagger_types):\n",
    "            value = getattr(self, attr)\n",
    "            if isinstance(value, list):\n",
Yann Garcia's avatar
Yann Garcia committed
    "                result[attr] = list(map(\n",
    "                    lambda x: x.to_dict() if hasattr(x, \"to_dict\") else x,\n",
    "                    value\n",
    "                ))\n",
    "            elif hasattr(value, \"to_dict\"):\n",
    "                result[attr] = value.to_dict()\n",
    "            elif isinstance(value, dict):\n",
    "                result[attr] = dict(map(\n",
    "                    lambda item: (item[0], item[1].to_dict())\n",
Yann Garcia's avatar
Yann Garcia committed
    "                    if hasattr(item[1], \"to_dict\") else item,\n",
    "                    value.items()\n",
    "                ))\n",
    "            else:\n",
    "                result[attr] = value\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if issubclass(SecurityInfoOAuth2Info, dict):\n",
    "            for key, value in self.items():\n",
    "                result[key] = value\n",
    "        return result\n",
    "    def to_str(self):\n",
    "        return pprint.pformat(self.to_dict())\n",
    "    def __repr__(self):\n",
    "        return self.to_str()\n",
    "    def __eq__(self, other):\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if not isinstance(other, SecurityInfoOAuth2Info):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
Yann Garcia's avatar
Yann Garcia committed
    "class OneOfTransportInfoEndpoint(object):\n",
    "    swagger_types = {}\n",
    "    attribute_map = {}\n",
    "    def __init__(self):  # noqa: E501\n",
    "        self.discriminator = None\n",
    "    @property\n",
Yann Garcia's avatar
Yann Garcia committed
    "    def uris(self):\n",
    "        return self._uris\n",
    "    @uris.setter\n",
    "    def uris(self, uris):\n",
    "        self._uris = uris\n",
    "    def to_dict(self):\n",
    "        result = {}\n",
    "        for attr, _ in six.iteritems(self.swagger_types):\n",
    "            value = getattr(self, attr)\n",
    "            if isinstance(value, list):\n",
Yann Garcia's avatar
Yann Garcia committed
    "                result[attr] = list(map(\n",
    "                    lambda x: x.to_dict() if hasattr(x, \"to_dict\") else x,\n",
    "                    value\n",
    "                ))\n",
    "            elif hasattr(value, \"to_dict\"):\n",
    "                result[attr] = value.to_dict()\n",
    "            elif isinstance(value, dict):\n",
    "                result[attr] = dict(map(\n",
    "                    lambda item: (item[0], item[1].to_dict())\n",
Yann Garcia's avatar
Yann Garcia committed
    "                    if hasattr(item[1], \"to_dict\") else item,\n",
    "                    value.items()\n",
    "                ))\n",
    "            else:\n",
    "                result[attr] = value\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if issubclass(OneOfappInstanceIdServicesBody, dict):\n",
    "            for key, value in self.items():\n",
    "                result[key] = value\n",
    "        return result\n",
    "    def to_str(self):\n",
    "        return pprint.pformat(self.to_dict())\n",
    "    def __repr__(self):\n",
    "        return self.to_str()\n",
    "    def __eq__(self, other):\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if not isinstance(other, OneOfTransportInfoEndpoint):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
Yann Garcia's avatar
Yann Garcia committed
    "class EndPointInfoUris(object):\n",
    "    swagger_types = {'_uris': 'list[str]'}\n",
    "    attribute_map = {'_uris': 'uris'}\n",
    "    def __init__(self, uris:list):  # noqa: E501\n",
    "        self._uris = None\n",
    "        self.uris = uris\n",
    "    @property\n",
Yann Garcia's avatar
Yann Garcia committed
    "    def uris(self):\n",
    "        return self._uris\n",
    "    @uris.setter\n",
    "    def uris(self, uris):\n",
    "        self._uris = uris\n",
    "    def to_dict(self):\n",
    "        result = {}\n",
    "        for attr, _ in six.iteritems(self.swagger_types):\n",
    "            value = getattr(self, attr)\n",
    "            if isinstance(value, list):\n",
    "                result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, 'to_dict') else x,value))\n",
    "            elif hasattr(value, 'to_dict'):\n",
    "                result[attr] = value.to_dict()\n",
    "            elif isinstance(value, dict):\n",
    "                result[attr] = dict(map(\n",
    "                    lambda item: (item[0], item[1].to_dict())\n",
    "                    if hasattr(item[1], 'to_dict') else item,\n",
    "                    value.items()\n",
    "                ))\n",
    "            else:\n",
    "                result[attr] = value\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if issubclass(EndPointInfoUris, dict):\n",
    "            for key, value in self.items():\n",
    "                result[key] = value\n",
    "        return result\n",
    "    def to_str(self):\n",
    "        return pprint.pformat(self.to_dict())\n",
    "    def __repr__(self):\n",
    "        return self.to_str()\n",
    "    def __eq__(self, other):\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if not isinstance(other, EndPointInfoUris):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
Yann Garcia's avatar
Yann Garcia committed
    "class EndPointInfoFqdn(object):\n",
    "    swagger_types = {'_fqdn': 'list[str]'}\n",
    "    attribute_map = {'_fqdn': 'fqdn'}\n",
    "    def __init__(self, fqdn:list):  # noqa: E501\n",
    "        self._fqdn = None\n",
    "        self.fqdn = fqdn\n",
    "    @property\n",
Yann Garcia's avatar
Yann Garcia committed
    "    def fqdn(self):\n",
    "        return self._fqdn\n",
    "    @fqdn.setter\n",
    "    def fqdn(self, fqdn):\n",
    "        self._fqdn = fqdn\n",
    "    def to_dict(self):\n",
    "        result = {}\n",
    "        for attr, _ in six.iteritems(self.swagger_types):\n",
    "            value = getattr(self, attr)\n",
    "            if isinstance(value, list):\n",
    "                result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, 'to_dict') else x,value))\n",
    "            elif hasattr(value, 'to_dict'):\n",
    "                result[attr] = value.to_dict()\n",
    "            elif isinstance(value, dict):\n",
    "                result[attr] = dict(map(\n",
    "                    lambda item: (item[0], item[1].to_dict())\n",
    "                    if hasattr(item[1], 'to_dict') else item,\n",
    "                    value.items()\n",
    "                ))\n",
    "            else:\n",
    "                result[attr] = value\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if issubclass(EndPointInfoFqdn, dict):\n",
    "            for key, value in self.items():\n",
    "                result[key] = value\n",
    "        return result\n",
    "    def to_str(self):\n",
    "        return pprint.pformat(self.to_dict())\n",
    "    def __repr__(self):\n",
    "        return self.to_str()\n",
    "    def __eq__(self, other):\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if not isinstance(other, EndPointInfoFqdn):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
Yann Garcia's avatar
Yann Garcia committed
    "class EndPointInfoAddress(object):\n",
    "    swagger_types = {'_host': 'str', '_port': 'int'}\n",
    "    attribute_map = {'_host': 'host', '_port': 'port'}\n",
    "    def __init__(self, host:str, port:list):  # noqa: E501\n",
    "        self._host = None\n",
    "        self._port = None\n",
    "        self.host = host\n",
    "        self.port = port\n",
    "    @property\n",
Yann Garcia's avatar
Yann Garcia committed
    "    def host(self):\n",
    "        return self.host\n",
    "    @host.setter\n",
    "    def host(self, host):\n",
    "        self._host = host\n",
    "    @property\n",
Yann Garcia's avatar
Yann Garcia committed
    "    def port(self):\n",
    "        return self._port\n",
    "    @port.setter\n",
    "    def port(self, port):\n",
    "        self._port = qosport_kpi\n",
    "    def to_dict(self):\n",
    "        result = {}\n",
    "        for attr, _ in six.iteritems(self.swagger_types):\n",
    "            value = getattr(self, attr)\n",
    "            if isinstance(value, list):\n",
    "                result[attr] = list(map(\n",
    "                    lambda x: x.to_dict() if hasattr(x, 'to_dict') else x,\n",
    "                    value\n",
    "                ))\n",
    "            elif hasattr(value, 'to_dict'):\n",
    "                result[attr] = value.to_dict()\n",
    "            elif isinstance(value, dict):\n",
    "                result[attr] = dict(map(\n",
    "                    lambda item: (item[0], item[1].to_dict())\n",
    "                    if hasattr(item[1], 'to_dict') else item,\n",
    "                    value.items()\n",
    "                ))\n",
    "            else:\n",
    "                result[attr] = value\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if issubclass(EndPointInfoAddress, dict):\n",
    "            for key, value in self.items():\n",
    "                result[key] = value\n",
    "        return result\n",
    "    def to_str(self):\n",
    "        return pprint.pformat(self.to_dict())\n",
    "    def __repr__(self):\n",
    "        return self.to_str()\n",
    "    def __eq__(self, other):\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if not isinstance(other, EndPointInfoAddress):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
Yann Garcia's avatar
Yann Garcia committed
    "class EndPointInfoAddresses(object):\n",
    "    swagger_types = {'_addresses': 'list[EndPointInfoAddress]'}\n",
    "    attribute_map = {'_addresses': 'addresses'}\n",
    "    def __init__(self, addresses:list):  # noqa: E501\n",
    "        self._addresses = None\n",
    "        self.addresses = addresses\n",
    "    @property\n",
Yann Garcia's avatar
Yann Garcia committed
    "    def addresses(self):\n",
    "        return self._addresses\n",
    "    @addresses.setter\n",
    "    def addresses(self, addresses):\n",
    "        self._addresses = addresses\n",
    "    def to_dict(self):\n",
    "        result = {}\n",
Yann Garcia's avatar
Yann Garcia committed
    "        for attr, _ in six.iteritems(self.swagger_types):\n",
    "            value = getattr(self, attr)\n",
    "            if isinstance(value, list):\n",
    "                result[attr] = list(map(lambda x: x.to_dict() if hasattr(x, 'to_dict') else x,value))\n",
    "            elif hasattr(value, 'to_dict'):\n",
    "                result[attr] = value.to_dict()\n",
    "            elif isinstance(value, dict):\n",
    "                result[attr] = dict(map(\n",
    "                    lambda item: (item[0], item[1].to_dict())\n",
    "                    if hasattr(item[1], 'to_dict') else item,\n",
    "                    value.items()\n",
    "                ))\n",
    "            else:\n",
    "                result[attr] = value\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if issubclass(EndPointInfoAddresses, dict):\n",
    "            for key, value in self.items():\n",
    "                result[key] = value\n",
    "        return result\n",
    "    def to_str(self):\n",
    "        return pprint.pformat(self.to_dict())\n",
    "    def __repr__(self):\n",
    "        return self.to_str()\n",
    "    def __eq__(self, other):\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if not isinstance(other, EndPointInfoAddresses):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
Yann Garcia's avatar
Yann Garcia committed
    "class EndPointInfoAlternative(object):\n",
    "    swagger_types = {'alternative': 'object'}\n",
    "    attribute_map = {'alternative': 'alternative'}\n",
    "    def __init__(self, alternative=None):  # noqa: E501\n",
    "        self._alternative = None\n",
    "        self.discriminator = None\n",
    "        self.alternative = alternative\n",
    "    @property\n",
Yann Garcia's avatar
Yann Garcia committed
    "    def alternative(self):\n",
    "        return self._alternative\n",
    "    @alternative.setter\n",
    "    def alternative(self, alternative):\n",
    "        if alternative is None:\n",
    "            raise ValueError(\"Invalid value for `alternative`, must not be `None`\")  # noqa: E501\n",
    "        self._alternative = alternative\n",
    "    def to_dict(self):\n",
    "        result = {}\n",
    "        for attr, _ in six.iteritems(self.swagger_types):\n",
    "            value = getattr(self, attr)\n",
    "            if isinstance(value, list):\n",
    "                result[attr] = list(map(\n",
Yann Garcia's avatar
Yann Garcia committed
    "                    lambda x: x.to_dict() if hasattr(x, \"to_dict\") else x,\n",
    "                    value\n",
    "                ))\n",
Yann Garcia's avatar
Yann Garcia committed
    "            elif hasattr(value, \"to_dict\"):\n",
    "                result[attr] = value.to_dict()\n",
    "            elif isinstance(value, dict):\n",
    "                result[attr] = dict(map(\n",
    "                    lambda item: (item[0], item[1].to_dict())\n",
Yann Garcia's avatar
Yann Garcia committed
    "                    if hasattr(item[1], \"to_dict\") else item,\n",
    "                    value.items()\n",
    "                ))\n",
    "            else:\n",
    "                result[attr] = value\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if issubclass(EndPointInfoAlternative, dict):\n",
    "            for key, value in self.items():\n",
    "                result[key] = value\n",
    "        return result\n",
    "    def to_str(self):\n",
    "        return pprint.pformat(self.to_dict())\n",
    "    def __repr__(self):\n",
    "        return self.to_str()\n",
    "    def __eq__(self, other):\n",
Yann Garcia's avatar
Yann Garcia committed
    "        if not isinstance(other, EndPointInfoAlternative):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n"
   ]
  },
  {
   "cell_type": "code",
Yann Garcia's avatar
Yann Garcia committed
   "execution_count": 39,
   "metadata": {},
   "outputs": [],
   "source": [
Yann Garcia's avatar
Yann Garcia committed
    "def create_mec_service(sandbox_name: str, app_inst_id: swagger_client.models.application_info.ApplicationInfo) -> object:\n",
    "    global MEC_PLTF, CALLBACK_URI, logger\n",
    "\n",
Yann Garcia's avatar
Yann Garcia committed
    "    logger.debug('>>> create_mec_service')\n",
    "    try:\n",
Yann Garcia's avatar
Yann Garcia committed
    "        url = '/{sandbox_name}/{mec_pltf}/mec_service_mgmt/v1/applications/{app_inst_id}/services'\n",
    "        logger.debug('create_mec_service: url: ' + url)\n",
    "        path_params = {}\n",
    "        path_params['sandbox_name'] = sandbox_name\n",
    "        path_params['mec_pltf'] = MEC_PLTF\n",
Yann Garcia's avatar
Yann Garcia committed
    "        path_params['app_inst_id'] = app_inst_id.id\n",
    "        # HTTP header `Accept`\n",
Yann Garcia's avatar
Yann Garcia committed
    "        header_params = {}\n",
    "        header_params['Accept'] = 'application/json'  # noqa: E501\n",
    "        # HTTP header `Content-Type`\n",
    "        header_params['Content-Type'] = 'application/json'  # noqa: E501\n",
    "        # Body request\n",
Yann Garcia's avatar
Yann Garcia committed
    "        callback = CALLBACK_URI + '/statistic/v1/quantity'\n",
    "        transport_info = TransportInfo(id=str(uuid.uuid4()), name='HTTP REST API', type='REST_HTTP', protocol='HTTP', version='2.0', security=SecurityInfo(), endpoint=OneOfTransportInfoEndpoint())\n",
    "        transport_info.endpoint.uris=[EndPointInfoUris(callback)]\n",
    "        category_ref = CategoryRef(href=callback, id=str(uuid.uuid4()), name='Demo', version='1.0.0')\n",
    "        appServiceInfo = ServiceInfo(ser_name='demo6 MEC Service', ser_category=category_ref, version='1.0.0', state='ACTIVE',transport_info=transport_info, serializer='JSON')\n",
    "        (result, status, headers) = service_api.call_api(url, 'POST', header_params=header_params, path_params=path_params, body=appServiceInfo, async_req=False)\n",
    "        return (result, status, headers['Location'])\n",
    "    except ApiException as e:\n",
    "        logger.error('Exception when calling call_api: %s\\n' % e)\n",
    "    return None\n",
Yann Garcia's avatar
Yann Garcia committed
    "    # End of function create_mec_service"
Yann Garcia's avatar
Yann Garcia committed
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
Yann Garcia's avatar
Yann Garcia committed
   "outputs": [],
   "source": [
Yann Garcia's avatar
Yann Garcia committed
    "def delete_mec_service(resource_url: str) -> int:\n",
    "    global logger\n",
    "\n",
Yann Garcia's avatar
Yann Garcia committed
    "    logger.debug('>>> delete_mec_subscription: resource_url: ' + resource_url)\n",
    "    try:\n",
    "        res = urllib3.util.parse_url(resource_url)\n",
    "        if res is None:\n",
    "            logger.error('delete_mec_subscription: Failed to paerse URL')\n",
    "            return -1\n",
    "        header_params = {}\n",
    "        # HTTP header `Accept`\n",
    "        header_params['Accept'] = 'application/json'  # noqa: E501\n",
    "        # HTTP header `Content-Type`\n",
    "        header_params['Content-Type'] = 'application/json'  # noqa: E501\n",
    "        service_api.call_api(res.path, 'DELETE', header_params=header_params, async_req=False)\n",
    "        return 0\n",
    "    except ApiException as e:\n",
    "        logger.error('Exception when calling call_api: %s\\n' % e)\n",
    "    return -1\n",
    "    # End of function delete_mec_service"
   ]
  },
  {
   "cell_type": "code",
Yann Garcia's avatar
Yann Garcia committed
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
Yann Garcia's avatar
Yann Garcia committed
      "2024-10-10 15:48:24,836 - __main__ - DEBUG - Starting at 20241010-154824\n",
      "2024-10-10 15:48:24,839 - __main__ - DEBUG - \t pwd= /home/yann/dev/jupyter/Sandbox/mecapp\n",
      "/tmp/ipykernel_3112397/3246377199.py:17: DeprecationWarning: setDaemon() is deprecated, set the daemon attribute instead\n",
      "  notification_server.setDaemon(True) # Set as a daemon so it will be killed once the main thread is dead.\n",
      "Exception in thread notification_server:\n",
      "Traceback (most recent call last):\n",
      "  File \"/usr/lib/python3.10/threading.py\", line 1016, in _bootstrap_inner\n",
      "2024-10-10 15:48:24,843 - __main__ - DEBUG - >>> process_login\n",
      "    self.run()\n",
      "  File \"/home/yann/.local/lib/python3.10/site-packages/ipykernel/ipkernel.py\", line 761, in run_closure\n",
      "2024-10-10 15:48:24,846 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
      "    _threading_Thread_run(self)\n",
      "  File \"/usr/lib/python3.10/threading.py\", line 953, in run\n",
      "    self._target(*self._args, **self._kwargs)\n",
      "TypeError: BaseRequestHandler.__init__() missing 1 required positional argument: 'server'\n",
      "2024-10-10 15:48:25,047 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/login?provider=Jupyter2024 HTTP/1.1\" 201 48\n",
      "2024-10-10 15:48:25,048 DEBUG response body: b'{\"user_code\":\"sbxulje0su\",\"verification_uri\":\"\"}'\n",
      "2024-10-10 15:48:25,049 - __main__ - DEBUG - process_login (step1): oauth: {'user_code': 'sbxulje0su', 'verification_uri': ''}\n",
      "2024-10-10 15:48:25,050 - __main__ - DEBUG - =======================> DO AUTHORIZATION WITH CODE : sbxulje0su\n",
      "2024-10-10 15:48:25,051 - __main__ - DEBUG - =======================> DO AUTHORIZATION HERE :      \n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'POST /sandbox-api/v1/login?provider=Jupyter2024 HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n",
      "send: b'{}'\n",
      "reply: 'HTTP/1.1 201 Created\\r\\n'\n",
Yann Garcia's avatar
Yann Garcia committed
      "header: Date: Thu, 10 Oct 2024 13:48:24 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Content-Length: 48\n",
      "header: Connection: keep-alive\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
Yann Garcia's avatar
Yann Garcia committed
      "2024-10-10 15:48:28,118 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/namespace?user_code=sbxulje0su HTTP/1.1\" 200 29\n",
      "2024-10-10 15:48:28,120 DEBUG response body: b'{\"sandbox_name\":\"sbxulje0su\"}'\n",
      "2024-10-10 15:48:28,122 - __main__ - DEBUG - process_login (step2): result: {'sandbox_name': 'sbxulje0su'}\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
Yann Garcia's avatar
Yann Garcia committed
      "send: b'GET /sandbox-api/v1/namespace?user_code=sbxulje0su HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n",
      "reply: 'HTTP/1.1 200 OK\\r\\n'\n",
Yann Garcia's avatar
Yann Garcia committed
      "header: Date: Thu, 10 Oct 2024 13:48:28 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Content-Length: 29\n",
      "header: Connection: keep-alive\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
Yann Garcia's avatar
Yann Garcia committed
      "2024-10-10 15:48:34,130 - __main__ - DEBUG - >>> get_network_scenarios: sandbox=sbxulje0su\n",
      "2024-10-10 15:48:34,133 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'GET /sandbox-api/v1/sandboxNetworkScenarios?sandbox_name=sbxulje0su HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-10-10 15:48:34,578 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/sandboxNetworkScenarios?sandbox_name=sbxulje0su HTTP/1.1\" 200 186\n",
      "2024-10-10 15:48:34,580 DEBUG response body: b'[{\"id\":\"4g-5g-macro-v2x\"},{\"id\":\"4g-5g-macro-v2x-fed\"},{\"id\":\"4g-5g-wifi-macro\"},{\"id\":\"4g-macro\"},{\"id\":\"4g-wifi-macro\"},{\"id\":\"dual-mep-4g-5g-wifi-macro\"},{\"id\":\"dual-mep-short-path\"}]'\n",
      "2024-10-10 15:48:34,583 - __main__ - DEBUG - get_network_scenarios: result: [{'id': '4g-5g-macro-v2x'}, {'id': '4g-5g-macro-v2x-fed'}, {'id': '4g-5g-wifi-macro'}, {'id': '4g-macro'}, {'id': '4g-wifi-macro'}, {'id': 'dual-mep-4g-5g-wifi-macro'}, {'id': 'dual-mep-short-path'}]\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "reply: 'HTTP/1.1 200 OK\\r\\n'\n",
Yann Garcia's avatar
Yann Garcia committed
      "header: Date: Thu, 10 Oct 2024 13:48:34 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
Yann Garcia's avatar
Yann Garcia committed
      "header: Content-Length: 186\n",
      "header: Connection: keep-alive\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
Yann Garcia's avatar
Yann Garcia committed
      "2024-10-10 15:48:40,591 - __main__ - DEBUG - >>> activate_network_scenario: sbxulje0su\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
Yann Garcia's avatar
Yann Garcia committed
      "send: b'POST /sandbox-api/v1/sandboxNetworkScenarios/sbxulje0su?network_scenario_id=4g-5g-macro-v2x HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n",
      "send: b'{}'\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
Yann Garcia's avatar
Yann Garcia committed
      "2024-10-10 15:48:40,948 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxNetworkScenarios/sbxulje0su?network_scenario_id=4g-5g-macro-v2x HTTP/1.1\" 204 0\n",
      "2024-10-10 15:48:40,950 DEBUG response body: b''\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "reply: 'HTTP/1.1 204 No Content\\r\\n'\n",
Yann Garcia's avatar
Yann Garcia committed
      "header: Date: Thu, 10 Oct 2024 13:48:40 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Connection: keep-alive\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
Yann Garcia's avatar
Yann Garcia committed
      "2024-10-10 15:48:52,964 - __main__ - DEBUG - >>> request_application_instance_id: sbxulje0su\n",
      "2024-10-10 15:48:52,968 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
      "2024-10-10 15:48:53,151 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxAppInstances/sbxulje0su HTTP/1.1\" 201 100\n",
      "2024-10-10 15:48:53,154 DEBUG response body: b'{\"id\":\"a3353a39-6e9e-440a-a34c-1eeeb2973404\",\"name\":\"JupyterMecApp\",\"nodeName\":\"mep1\",\"type\":\"USER\"}'\n",
      "2024-10-10 15:48:53,156 - __main__ - DEBUG - request_application_instance_id: result: {'id': 'a3353a39-6e9e-440a-a34c-1eeeb2973404',\n",
      " 'name': 'JupyterMecApp',\n",
      " 'node_name': 'mep1',\n",
      " 'persist': None,\n",
      " 'type': 'USER'}\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
Yann Garcia's avatar
Yann Garcia committed
      "{'id': 'a3353a39-6e9e-440a-a34c-1eeeb2973404',\n",
      " 'name': 'JupyterMecApp',\n",
      " 'node_name': 'mep1',\n",
      " 'persist': None,\n",
Yann Garcia's avatar
Yann Garcia committed
      " 'type': 'USER'}\n",
      "send: b'POST /sandbox-api/v1/sandboxAppInstances/sbxulje0su HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 107\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n",
      "send: b'{\"id\": \"a3353a39-6e9e-440a-a34c-1eeeb2973404\", \"name\": \"JupyterMecApp\", \"nodeName\": \"mep1\", \"type\": \"USER\"}'\n",
      "reply: 'HTTP/1.1 201 Created\\r\\n'\n",
      "header: Date: Thu, 10 Oct 2024 13:48:53 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Content-Length: 100\n",
      "header: Connection: keep-alive\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
Yann Garcia's avatar
Yann Garcia committed
      "2024-10-10 15:48:59,163 - __main__ - DEBUG - >>> send_ready_confirmation: a3353a39-6e9e-440a-a34c-1eeeb2973404\n",
      "2024-10-10 15:48:59,166 - __main__ - DEBUG - send_ready_confirmation: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/confirm_ready\n",
      "2024-10-10 15:48:59,169 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
      "2024-10-10 15:48:59,297 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxulje0su/mep1/mec_app_support/v2/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/confirm_ready HTTP/1.1\" 204 0\n",
      "2024-10-10 15:48:59,298 DEBUG response body: b''\n",
      "2024-10-10 15:48:59,298 - __main__ - DEBUG - >>> send_subscribe_termination: a3353a39-6e9e-440a-a34c-1eeeb2973404\n",
      "2024-10-10 15:48:59,299 - __main__ - DEBUG - send_subscribe_termination: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions\n",
      "2024-10-10 15:48:59,315 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxulje0su/mep1/mec_app_support/v2/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/subscriptions HTTP/1.1\" 201 367\n",
      "2024-10-10 15:48:59,315 DEBUG response body: b'{\"subscriptionType\":\"AppTerminationNotificationSubscription\",\"callbackReference\":\"http://yanngarcia.ddns.net/mec011/v2/termination\",\"_links\":{\"self\":{\"href\":\"https://mec-platform2.etsi.org/sbxulje0su/mep1/mec_app_support/v2/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/subscriptions/sub-r-7lG6iLd34rwhiT\"}},\"appInstanceId\":\"a3353a39-6e9e-440a-a34c-1eeeb2973404\"}'\n",
      "2024-10-10 15:48:59,316 - __main__ - DEBUG - >>> extract_sub_id: resource_url: https://mec-platform2.etsi.org/sbxulje0su/mep1/mec_app_support/v2/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/subscriptions/sub-r-7lG6iLd34rwhiT\n",
      "2024-10-10 15:48:59,317 - __main__ - DEBUG - >>> create_mec_service\n",
      "2024-10-10 15:48:59,317 - __main__ - DEBUG - create_mec_service: url: /{sandbox_name}/{mec_pltf}/mec_service_mgmt/v1/applications/{app_inst_id}/services\n",
      "2024-10-10 15:48:59,337 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxulje0su/mep1/mec_service_mgmt/v1/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/services HTTP/1.1\" 201 809\n",
      "2024-10-10 15:48:59,339 DEBUG response body: b'{\"serInstanceId\":\"10724851-5fde-41b4-af03-edf9630a5b8b\",\"serName\":\"demo6 MEC Service\",\"serCategory\":{\"href\":\"http://yanngarcia.ddns.net:36001/jupyter/sandbox/demo6/v1//statistic/v1/quantity\",\"id\":\"5ce299e8-5651-462a-9eb8-de1397a07257\",\"name\":\"Demo\",\"version\":\"1.0.0\"},\"version\":\"1.0.0\",\"state\":\"ACTIVE\",\"transportInfo\":{\"id\":\"fbd09b4a-9a12-4c73-95b0-7246e458dd04\",\"name\":\"HTTP REST API\",\"type\":\"REST_HTTP\",\"protocol\":\"HTTP\",\"version\":\"2.0\",\"endpoint\":{\"uris\":null,\"fqdn\":null,\"addresses\":null,\"alternative\":null},\"security\":{}},\"serializer\":\"JSON\",\"scopeOfLocality\":\"MEC_HOST\",\"consumedLocalOnly\":true,\"isLocal\":true,\"_links\":{\"self\":{\"href\":\"https://mec-platform2.etsi.org/sbxulje0su/mep1/mec_service_mgmt/v1/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/services/10724851-5fde-41b4-af03-edf9630a5b8b\"}}}'\n",
      "2024-10-10 15:48:59,340 - __main__ - INFO - mec_service_resource: https://mec-platform2.etsi.org/sbxulje0su/mep1/mec_service_mgmt/v1/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/services/10724851-5fde-41b4-af03-edf9630a5b8b\n",
      "2024-10-10 15:48:59,341 - __main__ - INFO - body: b'{\"serInstanceId\":\"10724851-5fde-41b4-af03-edf9630a5b8b\",\"serName\":\"demo6 MEC Service\",\"serCategory\":{\"href\":\"http://yanngarcia.ddns.net:36001/jupyter/sandbox/demo6/v1//statistic/v1/quantity\",\"id\":\"5ce299e8-5651-462a-9eb8-de1397a07257\",\"name\":\"Demo\",\"version\":\"1.0.0\"},\"version\":\"1.0.0\",\"state\":\"ACTIVE\",\"transportInfo\":{\"id\":\"fbd09b4a-9a12-4c73-95b0-7246e458dd04\",\"name\":\"HTTP REST API\",\"type\":\"REST_HTTP\",\"protocol\":\"HTTP\",\"version\":\"2.0\",\"endpoint\":{\"uris\":null,\"fqdn\":null,\"addresses\":null,\"alternative\":null},\"security\":{}},\"serializer\":\"JSON\",\"scopeOfLocality\":\"MEC_HOST\",\"consumedLocalOnly\":true,\"isLocal\":true,\"_links\":{\"self\":{\"href\":\"https://mec-platform2.etsi.org/sbxulje0su/mep1/mec_service_mgmt/v1/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/services/10724851-5fde-41b4-af03-edf9630a5b8b\"}}}'\n",
      "2024-10-10 15:48:59,342 - __main__ - INFO - data: {'serInstanceId': '10724851-5fde-41b4-af03-edf9630a5b8b', 'serName': 'demo6 MEC Service', 'serCategory': {'href': 'http://yanngarcia.ddns.net:36001/jupyter/sandbox/demo6/v1//statistic/v1/quantity', 'id': '5ce299e8-5651-462a-9eb8-de1397a07257', 'name': 'Demo', 'version': '1.0.0'}, 'version': '1.0.0', 'state': 'ACTIVE', 'transportInfo': {'id': 'fbd09b4a-9a12-4c73-95b0-7246e458dd04', 'name': 'HTTP REST API', 'type': 'REST_HTTP', 'protocol': 'HTTP', 'version': '2.0', 'endpoint': {'uris': None, 'fqdn': None, 'addresses': None, 'alternative': None}, 'security': {}}, 'serializer': 'JSON', 'scopeOfLocality': 'MEC_HOST', 'consumedLocalOnly': True, 'isLocal': True, '_links': {'self': {'href': 'https://mec-platform2.etsi.org/sbxulje0su/mep1/mec_service_mgmt/v1/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/services/10724851-5fde-41b4-af03-edf9630a5b8b'}}}\n",
      "2024-10-10 15:48:59,343 - __main__ - INFO - =============> Execute the command: curl http://yanngarcia.ddns.net:36001/jupyter/sandbox/demo6/v1//statistic/v1/quantity\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
Yann Garcia's avatar
Yann Garcia committed
      "send: b'POST /sbxulje0su/mep1/mec_app_support/v2/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/confirm_ready HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 23\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n",
      "send: b'{\"indication\": \"READY\"}'\n",
      "reply: 'HTTP/1.1 204 No Content\\r\\n'\n",
      "header: Date: Thu, 10 Oct 2024 13:48:59 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Connection: keep-alive\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n",
      "send: b'POST /sbxulje0su/mep1/mec_app_support/v2/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/subscriptions HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 192\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n",
      "send: b'{\"subscriptionType\": \"AppTerminationNotificationSubscription\", \"callbackReference\": \"http://yanngarcia.ddns.net/mec011/v2/termination\", \"appInstanceId\": \"a3353a39-6e9e-440a-a34c-1eeeb2973404\"}'\n",
      "reply: 'HTTP/1.1 201 Created\\r\\n'\n",
Yann Garcia's avatar
Yann Garcia committed
      "header: Date: Thu, 10 Oct 2024 13:48:59 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
Yann Garcia's avatar
Yann Garcia committed
      "header: Content-Length: 367\n",
      "header: Connection: keep-alive\n",
      "header: Location: https://mec-platform2.etsi.org/sbxulje0su/mep1/mec_app_support/v2/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/subscriptions/sub-r-7lG6iLd34rwhiT\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n",
      "send: b'POST /sbxulje0su/mep1/mec_service_mgmt/v1/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/services HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 465\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n",
      "send: b'{\"serName\": \"demo6 MEC Service\", \"serCategory\": {\"href\": \"http://yanngarcia.ddns.net:36001/jupyter/sandbox/demo6/v1//statistic/v1/quantity\", \"id\": \"5ce299e8-5651-462a-9eb8-de1397a07257\", \"name\": \"Demo\", \"version\": \"1.0.0\"}, \"version\": \"1.0.0\", \"state\": \"ACTIVE\", \"transportInfo\": {\"id\": \"fbd09b4a-9a12-4c73-95b0-7246e458dd04\", \"name\": \"HTTP REST API\", \"type\": \"REST_HTTP\", \"protocol\": \"HTTP\", \"version\": \"2.0\", \"endpoint\": {}, \"security\": {}}, \"serializer\": \"JSON\"}'\n",
      "reply: 'HTTP/1.1 201 Created\\r\\n'\n",
      "header: Date: Thu, 10 Oct 2024 13:48:59 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Content-Length: 809\n",
      "header: Connection: keep-alive\n",
Yann Garcia's avatar
Yann Garcia committed
      "header: Location: https://mec-platform2.etsi.org/sbxulje0su/mep1/mec_service_mgmt/v1/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/services/10724851-5fde-41b4-af03-edf9630a5b8b\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
Yann Garcia's avatar
Yann Garcia committed
      "2024-10-10 15:49:29,369 - __main__ - DEBUG - >>> delete_mec_subscription: resource_url: https://mec-platform2.etsi.org/sbxulje0su/mep1/mec_service_mgmt/v1/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/services/10724851-5fde-41b4-af03-edf9630a5b8b\n",
      "2024-10-10 15:49:29,391 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sbxulje0su/mep1/mec_service_mgmt/v1/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/services/10724851-5fde-41b4-af03-edf9630a5b8b HTTP/1.1\" 204 0\n",
      "2024-10-10 15:49:29,394 DEBUG response body: b''\n",
      "2024-10-10 15:49:29,396 - __main__ - DEBUG - >>> delete_subscribe_termination: a3353a39-6e9e-440a-a34c-1eeeb2973404\n",
      "2024-10-10 15:49:29,397 - __main__ - DEBUG - delete_subscribe_termination: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions/{sub_id}\n",
      "2024-10-10 15:49:29,417 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sbxulje0su/mep1/mec_app_support/v2/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/subscriptions/sub-r-7lG6iLd34rwhiT HTTP/1.1\" 204 0\n",
      "2024-10-10 15:49:29,419 DEBUG response body: b''\n",
      "2024-10-10 15:49:29,421 - __main__ - DEBUG - >>> delete_application_instance_id: sbxulje0su\n",
      "2024-10-10 15:49:29,424 - __main__ - DEBUG - >>> delete_application_instance_id: a3353a39-6e9e-440a-a34c-1eeeb2973404\n",
      "2024-10-10 15:49:29,474 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sandbox-api/v1/sandboxAppInstances/sbxulje0su/a3353a39-6e9e-440a-a34c-1eeeb2973404 HTTP/1.1\" 204 0\n",
      "2024-10-10 15:49:29,478 DEBUG response body: b''\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
Yann Garcia's avatar
Yann Garcia committed
      "send: b'DELETE /sbxulje0su/mep1/mec_service_mgmt/v1/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/services/10724851-5fde-41b4-af03-edf9630a5b8b HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n",
      "send: b'{}'\n",
      "reply: 'HTTP/1.1 204 No Content\\r\\n'\n",
Yann Garcia's avatar
Yann Garcia committed
      "header: Date: Thu, 10 Oct 2024 13:49:29 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Connection: keep-alive\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n",
Yann Garcia's avatar
Yann Garcia committed
      "send: b'DELETE /sbxulje0su/mep1/mec_app_support/v2/applications/a3353a39-6e9e-440a-a34c-1eeeb2973404/subscriptions/sub-r-7lG6iLd34rwhiT HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nAccept: application/json\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n",
      "send: b'{}'\n",
      "reply: 'HTTP/1.1 204 No Content\\r\\n'\n",
      "header: Date: Thu, 10 Oct 2024 13:49:29 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Connection: keep-alive\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n",
      "send: b'DELETE /sandbox-api/v1/sandboxAppInstances/sbxulje0su/a3353a39-6e9e-440a-a34c-1eeeb2973404 HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n",
      "send: b'{}'\n",
      "reply: 'HTTP/1.1 204 No Content\\r\\n'\n",
      "header: Date: Thu, 10 Oct 2024 13:49:29 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Connection: keep-alive\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
Yann Garcia's avatar
Yann Garcia committed
      "2024-10-10 15:49:35,486 - __main__ - DEBUG - >>> deactivate_network_scenario: sbxulje0su\n",
      "2024-10-10 15:49:35,536 DEBUG https://mec-platform2.etsi.org:443 \"DELETE /sandbox-api/v1/sandboxNetworkScenarios/sbxulje0su/4g-5g-macro-v2x HTTP/1.1\" 204 0\n",
      "2024-10-10 15:49:35,539 DEBUG response body: b''\n"
Yann Garcia's avatar
Yann Garcia committed
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'DELETE /sandbox-api/v1/sandboxNetworkScenarios/sbxulje0su/4g-5g-macro-v2x HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n",
      "send: b'{}'\n",
      "reply: 'HTTP/1.1 204 No Content\\r\\n'\n",
      "header: Date: Thu, 10 Oct 2024 13:49:35 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Connection: keep-alive\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-10-10 15:49:47,545 - __main__ - DEBUG - >>> process_logout: sandbox=sbxulje0su\n",
      "2024-10-10 15:49:47,549 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
      "2024-10-10 15:49:47,752 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/logout?sandbox_name=sbxulje0su HTTP/1.1\" 204 0\n",
      "2024-10-10 15:49:47,754 DEBUG response body: b''\n",
      "2024-10-10 15:49:47,757 - __main__ - DEBUG - Stopped at 20241010-154947\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'POST /sandbox-api/v1/logout?sandbox_name=sbxulje0su HTTP/1.1\\r\\nHost: mec-platform2.etsi.org\\r\\nAccept-Encoding: identity\\r\\nContent-Length: 2\\r\\nContent-Type: application/json\\r\\nUser-Agent: Swagger-Codegen/1.0.0/python\\r\\n\\r\\n'\n",
      "send: b'{}'\n",
      "reply: 'HTTP/1.1 204 No Content\\r\\n'\n",
      "header: Date: Thu, 10 Oct 2024 13:49:47 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Connection: keep-alive\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n"
     ]
    }
   ],
   "source": [
    "def process_main():\n",
    "    \"\"\"\n",
    "    This is the second sprint of our skeleton of our MEC application:\n",
    "        - Mec application setup\n",
Yann Garcia's avatar
Yann Garcia committed
    "        - Create new MEC service\n",
    "        - Send a request to our MEC service\n",
    "        - Delete newly created MEC service\n",
    "        - Mec application termination\n",
    "    \"\"\" \n",
Yann Garcia's avatar
Yann Garcia committed
    "    global LISTENER_IP, LISTENER_PORT, CALLBACK_URI, logger\n",
    "\n",
    "    logger.debug('Starting at ' + time.strftime('%Y%m%d-%H%M%S'))\n",
    "    logger.debug('\\t pwd= ' + os.getcwd())\n",
    "\n",
Yann Garcia's avatar
Yann Garcia committed
    "    # Start notification server in a daemonized thread\n",
    "    notification_server = threading.Thread(name='notification_server', target=HTTPRequestHandler, args=(LISTENER_IP, LISTENER_PORT))\n",
    "    notification_server.setDaemon(True) # Set as a daemon so it will be killed once the main thread is dead.\n",
    "    notification_server.start()\n",
    "    # Continue\n",
    "\n",
    "\n",
    "    # Setup the MEC application\n",
Yann Garcia's avatar
Yann Garcia committed
    "    sandbox_name, app_inst_id, sub_id = mec_app_setup()\n",
    "\n",
Yann Garcia's avatar
Yann Garcia committed
    "    # Create the MEC service\n",
    "    result, status, mec_service_resource = create_mec_service(sandbox_name, app_inst_id)\n",
    "    if status != 201:\n",
    "        logger.error('Failed to create MEC service')\n",
    "    else:\n",
Yann Garcia's avatar
Yann Garcia committed
    "        logger.info('mec_service_resource: %s', mec_service_resource)\n",
    "\n",
    "    # Any processing here\n",
    "    logger.info('body: ' + str(result.data))\n",
    "    data = json.loads(result.data)\n",
    "    logger.info('data: %s', str(data))\n",
    "    logger.info('=============> Execute the command: curl %s/statistic/v1/quantity', CALLBACK_URI)\n",
    "    time.sleep(30)\n",
    "\n",
    "    # Delete the MEC servce\n",
    "    delete_mec_service(mec_service_resource)\n",
    "\n",
    "    # Terminate the MEC application\n",
    "    mec_app_termination(sandbox_name, app_inst_id, sub_id)\n",
    "\n",
    "    logger.debug('Stopped at ' + time.strftime('%Y%m%d-%H%M%S'))\n",
    "    # End of function process_main\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    process_main()\n"
   ]
  },
Yann Garcia's avatar
Yann Garcia committed
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Annexes\n",
    "\n",
    "## Annex A: How to use an existing MEC sandbox instance\n",
    "\n",
    "This case is used when the MEC Sandbox API is not used. The procedure is the following:\n",
    "- Log to the MEC Sandbox using a WEB browser\n",
    "- Select a network scenario\n",
    "- Create a new application instance\n",
    "\n",
    "When it is done, the newly created application instance is used by your application when required. This application instance is usually passed to your application in the command line or using a configuration file\n"
Yann Garcia's avatar
Yann Garcia committed
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Bibliography\n",
Yann Garcia's avatar
Yann Garcia committed
    "\n",
    "1. ETSI GS MEC 002 (V2.2.1) (01-2022): \"Multi-access Edge Computing (MEC); Phase 2: Use Cases and Requirements\".\n",
    "2. ETSI GS MEC 010-1 (V1.1.1) (10-2017): \"Mobile Edge Computing (MEC); Mobile Edge Management; Part 1: System, host and platform management\".\n",
    "3. ETSI GS MEC 010-2 (V2.2.1) (02-2022): \"Multi-access Edge Computing (MEC); MEC Management; Part 2: Application lifecycle, rules and requirements management\".\n",
    "4. ETSI GS MEC 011 (V3.1.1) (09-2022): \"Multi-access Edge Computing (MEC); Edge Platform Application Enablement\".\n",
    "5. ETSI GS MEC 012 (V2.2.1) (02-2022): \"Multi-access Edge Computing (MEC); Radio Network Information API\".\n",
    "6. ETSI GS MEC 013 (V2.2.1) (01-2022): \"Multi-access Edge Computing (MEC); Location API\".\n",
    "7. ETSI GS MEC 014 (V2.1.1) (03-2021): \"Multi-access Edge Computing (MEC); UE Identity API\".\n",
    "8. ETSI GS MEC 015 (V2.1.1) (06-2020): \"Multi-Access Edge Computing (MEC); Traffic Management APIs\".\n",
    "9. ETSI GS MEC 016 (V2.2.1) (04-2020): \"Multi-access Edge Computing (MEC); Device application interface\".\n",
    "10. ETSI GS MEC 021 (V2.2.1) (02-2022): \"Multi-access Edge Computing (MEC); Application Mobility Service API\".\n",
    "11. ETSI GS MEC 028 (V2.3.1) (07-2022): \"Multi-access Edge Computing (MEC); WLAN Access Information API\".\n",
    "12. ETSI GS MEC 029 (V2.2.1) (01-2022): \"Multi-access Edge Computing (MEC); Fixed Access Information API\".\n",
    "13. ETSI GS MEC 030 (V3.2.1) (05-2022): \"Multi-access Edge Computing (MEC); V2X Information Service API\".\n",
Yann Garcia's avatar
Yann Garcia committed
    "14. ETSI GR MEC-DEC 025 (V2.1.1) (06-2019): \"Multi-access Edge Computing (MEC); MEC Testing Framework\".\n",
    "15. ETSI GR MEC 001 (V3.1.1) (01-2022): \"Multi-access Edge Computing (MEC); Terminology\".\n",
    "16. ETSI GR MEC 003 (V3.1.1): Multi-access Edge Computing (MEC); \n",
    "Framework and Reference Architecture\n",
    "17. [The Wiki MEC web site](https://www.etsi.org/technologies/multi-access-edge-computing)\n"
Yann Garcia's avatar
Yann Garcia committed
   ]
  }