Skip to content
MEC application.ipynb 192 KiB
Newer Older
    "    def geo_area(self, geo_area):\n",
    "        self._geo_area = geo_area\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",
    "        if issubclass(LocationInfo, dict):\n",
    "            for key, value in self.items():\n",
    "                result[key] = value\n",
3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910
    "    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",
    "        if not isinstance(other, LocationInfo):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
    "class RouteInfo(object):\n",
    "    swagger_types = {'_location': 'LocationInfo', '_time_stamp': 'TimeStamp'}\n",
    "    attribute_map = {'_location': 'location', '_time_stamp': 'time'}\n",
    "    def __init__(self, location:LocationInfo, time_stamp=None):  # noqa: E501\n",
    "        self._location = None\n",
    "        self.location = location\n",
    "        self._time_stamp = None\n",
    "        if time_stamp is not None:\n",
    "            self.time_stamp = time_stamp\n",
    "    @property\n",
    "    def location(self):\n",
    "        return self._location\n",
    "    @location.setter\n",
    "    def location(self, location):\n",
    "        self._location = location\n",
    "    @property\n",
    "    def time_stamp(self):\n",
    "        return self._time_stamp\n",
    "    @time_stamp.setter\n",
    "    def time_stamp(self, time_stamp):\n",
    "        self._time_stamp = time_stamp\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",
    "        if issubclass(RouteInfo, 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",
    "        if not isinstance(other, RouteInfo):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
    "class LocationInfoGeoArea(object):\n",
    "    swagger_types = {'_latitude': 'float', '_longitude': 'float'}\n",
    "    attribute_map = {'_latitude': 'latitude', '_longitude': 'longitude'}\n",
    "    def __init__(self, ecgi=None, geo_area=None):  # noqa: E501\n",
    "        self._latitude = None\n",
    "        self._longitude = None\n",
    "        if latitude is not None:\n",
    "            self.latitude = latitude\n",
    "        if longitude is not None:\n",
    "            self.longitude = longitude\n",
    "    @property\n",
    "    def latitude(self):\n",
    "        return self._latitude\n",
    "    @latitude.setter\n",
    "    def latitude(self, latitude):\n",
    "        self._latitude = latitude\n",
    "    @property\n",
    "    def longitude(self):\n",
    "        return self._longitude\n",
    "    @longitude.setter\n",
    "    def longitude(self, longitude):\n",
    "        self._longitude = longitude\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",
    "        if issubclass(LocationInfoGeoArea, 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",
    "        if not isinstance(other, LocationInfoGeoArea):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
    "class Ecgi(object):\n",
    "    swagger_types = {'_cellId': 'CellId', '_plmn': 'Plmn'}\n",
    "    attribute_map = {'_cellId': 'cellId', '_plmn': 'plmn'}\n",
    "    def __init__(self, cellId=None, plmn=None):  # noqa: E501\n",
    "        self._cellId = None\n",
    "        self._plmn = None\n",
    "        if cellId is not None:\n",
    "            self.cellId = cellId\n",
    "        if plmn is not None:\n",
    "            self.plmn = plmn\n",
    "    @property\n",
    "    def cellId(self):\n",
    "        return self._cellId\n",
    "    @cellId.setter\n",
    "    def cellId(self, cellId):\n",
    "        self._cellId = cellId\n",
    "    @property\n",
    "    def plmn(self):\n",
    "        return self._plmn\n",
    "    @plmn.setter\n",
    "    def plmn(self, plmn):\n",
    "        self._plmn = plmn\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",
    "        if issubclass(Ecgi, 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",
    "        if not isinstance(other, Ecgi):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
    "class CellId(object):\n",
    "    swagger_types = {'_cellId': 'str'}\n",
    "    attribute_map = {'_cellId': 'cellId'}\n",
    "    def __init__(self, cellId):  # noqa: E501\n",
    "        self._cellId = None\n",
    "        self.cellId = cellId\n",
    "    @property\n",
    "    def cellId(self):\n",
    "        return self._cellId\n",
    "    @cellId.setter\n",
    "    def cellId(self, cellId):\n",
    "        self._cellId = cellId\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",
    "        if issubclass(CellId, 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",
    "        if not isinstance(other, CellId):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
    "class Plmn(object):\n",
    "    swagger_types = {'_mcc': 'str', '_mnc': 'str'}\n",
    "    attribute_map = {'_mcc': 'mcc', '_mnc': 'mnc'}\n",
    "    def __init__(self, mcc:str, mnc:str):  # noqa: E501\n",
    "        self._mcc = None\n",
    "        self.mcc = mcc\n",
    "        self._mnc = None\n",
    "        self.mnc = mnc\n",
    "    @property\n",
    "    def mcc(self):\n",
    "        return self._mcc\n",
    "    @mcc.setter\n",
    "    def kpi_nmccame(self, mcc):\n",
    "        self._mcc = mcc\n",
    "    @property\n",
    "    def mnc(self):\n",
    "        return self._mnc\n",
    "    @mnc.setter\n",
    "    def kpi_nmccame(self, mnc):\n",
    "        self._mnc = mnc\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",
    "        if issubclass(Plmn, 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",
    "        if not isinstance(other, Plmn):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
    "class QosKpi(object):\n",
    "    swagger_types = {'_kpi_name': 'str', '_kpi_value': 'str', '_confidence': 'str'}\n",
    "    attribute_map = {'_kpi_name': 'kpiName', '_kpi_value': 'kpiValue', '_confidence': 'Confidence'}\n",
    "    def __init__(self, kpi_name:str, kpi_value:str, confidence=None):  # noqa: E501\n",
    "        self._kpi_name = None\n",
    "        self._kpi_value = None\n",
    "        self._confidence = None\n",
    "        self.kpi_name = kpi_name\n",
    "        self.kpi_value = kpi_value\n",
    "        if confidence is not None:\n",
    "            self.confidences = confidence\n",
    "    @property\n",
    "    def kpi_name(self):\n",
    "        return self._kpi_name\n",
    "    @kpi_name.setter\n",
    "    def kpi_name(self, kpi_name):\n",
    "        self._kpi_name = kpi_name\n",
    "    @property\n",
    "    def kpi_value(self):\n",
    "        return self._kpi_value\n",
    "    @kpi_value.setter\n",
    "    def kpi_value(self, kpi_value):\n",
    "        self._kpi_value = kpi_value\n",
    "    @property\n",
    "    def confidence(self):\n",
    "        return self._confidence\n",
    "    @confidence.setter\n",
    "    def confidence(self, confidence):\n",
    "        self._confidence = confidence\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",
    "        if issubclass(QosKpi, 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",
    "        if not isinstance(other, QosKpi):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
    "class Stream(object):\n",
    "    swagger_types = {'_stream_id': 'str', '_qos_kpi': 'list[QosKpi]'}\n",
    "    attribute_map = {'_stream_id': 'streamId', '_qos_kpi': 'qosKpi'}\n",
    "    def __init__(self, stream_id:str, qos_kpi:list):  # noqa: E501\n",
    "        self._stream_id = None\n",
    "        self._qos_kpi = None\n",
    "        self.stream_id = stream_id\n",
    "        self.qos_kpi = qos_kpi\n",
    "    @property\n",
    "    def stream_id(self):\n",
    "        return self._stream_id\n",
    "    @stream_id.setter\n",
    "    def stream_id(self, stream_id):\n",
    "        self._stream_id = stream_id\n",
    "    @property\n",
    "    def qos_kpi(self):\n",
    "        return self._qos_kpi\n",
    "    @qos_kpi.setter\n",
    "    def qos_kpi(self, qos_kpi):\n",
    "        self._qos_kpi = qos_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",
    "        if issubclass(Stream, 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",
    "        if not isinstance(other, Stream):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
    "class Qos(object):\n",
    "    swagger_types = {'_stream': 'list[Stream]'}\n",
    "    attribute_map = {'_stream': 'stream'}\n",
    "    def __init__(self, stream:list):  # noqa: E501\n",
    "        self._stream = None\n",
    "        self.stream = stream\n",
    "    @property\n",
    "    def stream(self):\n",
    "        return self._stream\n",
    "    @stream.setter\n",
    "    def stream(self, stream):\n",
    "        self._stream = stream\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",
    "        if issubclass(Qos, 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",
    "        if not isinstance(other, Qos):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n",
    "\n",
    "class PredictedQos(object):\n",
    "    swagger_types = {'_location_granularity': 'str', '_notice_period': 'TimeStamp', '_prediction_area': 'PredictionArea', '_predictionTarget': 'str', '_qos': 'Qos', '_routes': 'list[Routes]', '_time_granularity': 'TimeStamp'}\n",
    "    attribute_map = {'_location_granularity': 'locationGranularity', '_notice_period': 'noticePeriod', '_prediction_area': 'predictionArea', '_prediction_target': 'predictionTarget', '_qos': 'qos', '_routes': 'routes', '_time_granularity': 'timeGranularity'}\n",
    "    def __init__(self, prediction_target:str, location_granularity:str, notice_period=None, time_granularity=None, prediction_area=None, routes=None, qos=None):  # noqa: E501\n",
    "        self._prediction_target = None\n",
    "        self._time_granularity = None\n",
    "        self._ = None\n",
    "        self._notice_period = None\n",
    "        self._prediction_area = None\n",
    "        self._routes = None\n",
    "        self._qos = Nonelocation_granularity\n",
    "        self._prediction_target = prediction_target\n",
    "        if time_ranularity is not None:\n",
    "            self.time_granularity = time_granularityg\n",
    "        self.location_granularity = location_granularity\n",
    "        if notice_period is not None:\n",
    "            self.notice_period = notice_period\n",
    "        if prediction_area is not None:\n",
    "            self.prediction_area = prediction_area\n",
    "        if route is not None:\n",
    "            self.routes = routes\n",
    "        if qos is not None:\n",
    "            self.qos = qos\n",
    "    @property\n",
    "    def prediction_target(self):\n",
    "        return self._prediction_target\n",
    "    @prediction_target.setter\n",
    "    def prediction_target(self, prediction_target):\n",
    "        self._prediction_target = prediction_target\n",
    "    @property\n",
    "    def time_granularity(self):\n",
    "        return self._time_granularity\n",
    "    @time_granularity.setter\n",
    "    def time_granularity(self, time_granularity):\n",
    "        self._time_granularity = time_granularity\n",
    "    @property\n",
    "    def location_granularity(self):\n",
    "        return self._location_granularity\n",
    "    @location_granularity.setter\n",
    "    def location_granularity(self, location_granularity):\n",
    "        self._location_granularity = location_granularity\n",
    "    @property\n",
    "    def notice_period(self):\n",
    "        return self._notice_period\n",
    "    @notice_period.setter\n",
    "    def notice_period(self, notice_period):\n",
    "        self._notice_period = notice_period\n",
    "    @property\n",
    "    def prediction_area(self):\n",
    "        return self._prediction_area\n",
    "    @prediction_area.setter\n",
    "    def prediction_area(self, prediction_area):\n",
    "        self._prediction_area = prediction_area\n",
    "    @property\n",
    "    def routes(self):\n",
    "        return self._routes\n",
    "    @routes.setter\n",
    "    def routes(self, routes):\n",
    "        self._routes = routes\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",
    "        if issubclass(PredictedQos, 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",
    "        if not isinstance(other, PredictedQos):\n",
    "            return False\n",
    "        return self.__dict__ == other.__dict__\n",
    "    def __ne__(self, other):\n",
    "        return not self == other\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here is the V2X Prediscted QoS:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_qos_prediction(sandbox_name: str) -> int:\n",
    "    global MEC_PLTF, logger\n",
    "\n",
    "    logger.debug('>>> get_qos_prediction: latitude: ' + sandbox_name)\n",
    "    try:\n",
    "        url = '/{sandbox_name}/{mec_pltf}/vis/v2//provide_predicted_qos'\n",
    "        logger.debug('send_uu_unicast_provisioning_info: url: ' + url)\n",
    "        path_params = {}\n",
    "        path_params['sandbox_name'] = sandbox_name\n",
    "        path_params['mec_pltf'] = MEC_PLTF\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",
    "        # Body request\n",
    "        loc1 = LocationInfo(LocationInfoGeoArea(latitude=43.729416, longitude=7.414853))\n",
    "        loc2 = LocationInfo(LocationInfoGeoArea(latitude=43.732456, longitude=7.418417))\n",
    "        routeInfo1 = RoutesInfo(loc1, TimeStamp(nanoSeconds=0, seconds=1653295620))\n",
    "        routeInfo2 = RoutesInfo(loc2, TimeStamp(nanoSeconds=0, seconds=1653299220))\n",
    "        routes = [routeInfo1, routeInfo2]\n",
    "        predictedQos = PredictedQos(prediction_target=\"SINGLE_UE_PREDICTION\", location_granularity=\"30\", routes=routes)\n",
    "        result = service_api.call_api(url, 'GET', header_params=header_params, path_params=path_params, body=predictedQos, async_req=False)\n",
    "        return result\n",
    "    except ApiException as e:\n",
    "        logger.error('Exception when calling call_api: %s\\n' % e)\n",
    "    return None\n",
    "    # End of function send_uu_unicast_provisioning_info"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Grouping all together provides the process_main funtion.. The sequence is the following:\n",
    "- Mec application setup\n",
    "- V2X QoS request\n",
    "- Mec application termination\n",
    "\n",
    "The expected response should be:\n",
    "- RSRP: 55\n",
    "- RSRQ: 13"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-10-04 11:41:34,129 - __main__ - DEBUG - Starting at 20241004-114134\n",
      "2024-10-04 11:41:34,129 - __main__ - DEBUG - Starting at 20241004-114134\n",
      "2024-10-04 11:41:34,134 - __main__ - DEBUG - \t pwd= /home/yann/dev/jupyter/Sandbox/mecapp\n",
      "2024-10-04 11:41:34,134 - __main__ - DEBUG - \t pwd= /home/yann/dev/jupyter/Sandbox/mecapp\n",
      "2024-10-04 11:41:34,163 - __main__ - DEBUG - >>> process_login\n",
      "2024-10-04 11:41:34,163 - __main__ - DEBUG - >>> process_login\n",
      "2024-10-04 11:41:34,194 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
      "2024-10-04 11:41:34,373 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/login?provider=Jupyter2024 HTTP/1.1\" 201 48\n",
      "2024-10-04 11:41:34,375 DEBUG response body: b'{\"user_code\":\"sbxj1uzhkb\",\"verification_uri\":\"\"}'\n",
      "2024-10-04 11:41:34,380 - __main__ - DEBUG - process_login (step1): oauth: {'user_code': 'sbxj1uzhkb', 'verification_uri': ''}\n",
      "2024-10-04 11:41:34,380 - __main__ - DEBUG - process_login (step1): oauth: {'user_code': 'sbxj1uzhkb', 'verification_uri': ''}\n",
      "2024-10-04 11:41:34,385 - __main__ - DEBUG - =======================> DO AUTHORIZATION WITH CODE : sbxj1uzhkb\n",
      "2024-10-04 11:41:34,385 - __main__ - DEBUG - =======================> DO AUTHORIZATION WITH CODE : sbxj1uzhkb\n",
      "2024-10-04 11:41:34,391 - __main__ - DEBUG - =======================> DO AUTHORIZATION HERE :      \n",
      "2024-10-04 11:41:34,391 - __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",
      "header: Date: Fri, 04 Oct 2024 09:41:34 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": [
      "2024-10-04 11:41:37,424 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/namespace?user_code=sbxj1uzhkb HTTP/1.1\" 200 29\n",
      "2024-10-04 11:41:37,427 DEBUG response body: b'{\"sandbox_name\":\"sbxj1uzhkb\"}'\n",
      "2024-10-04 11:41:37,431 - __main__ - DEBUG - process_login (step2): result: {'sandbox_name': 'sbxj1uzhkb'}\n",
      "2024-10-04 11:41:37,431 - __main__ - DEBUG - process_login (step2): result: {'sandbox_name': 'sbxj1uzhkb'}\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'GET /sandbox-api/v1/namespace?user_code=sbxj1uzhkb 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",
      "header: Date: Fri, 04 Oct 2024 09:41:37 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": [
      "2024-10-04 11:41:43,441 - __main__ - DEBUG - >>> get_network_scenarios: sandbox=sbxj1uzhkb\n",
      "2024-10-04 11:41:43,441 - __main__ - DEBUG - >>> get_network_scenarios: sandbox=sbxj1uzhkb\n",
      "2024-10-04 11:41:43,448 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n",
      "2024-10-04 11:41:43,656 DEBUG https://mec-platform2.etsi.org:443 \"GET /sandbox-api/v1/sandboxNetworkScenarios?sandbox_name=sbxj1uzhkb HTTP/1.1\" 200 157\n",
      "2024-10-04 11:41:43,659 DEBUG response body: b'[{\"id\":\"4g-5g-macro-v2x\"},{\"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-04 11:41:43,663 - __main__ - DEBUG - get_network_scenarios: result: [{'id': '4g-5g-macro-v2x'}, {'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-04 11:41:43,663 - __main__ - DEBUG - get_network_scenarios: result: [{'id': '4g-5g-macro-v2x'}, {'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": [
      "send: b'GET /sandbox-api/v1/sandboxNetworkScenarios?sandbox_name=sbxj1uzhkb 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",
      "header: Date: Fri, 04 Oct 2024 09:41:43 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Content-Length: 157\n",
      "header: Connection: keep-alive\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-10-04 11:41:49,674 - __main__ - DEBUG - >>> activate_network_scenario: sbxj1uzhkb\n",
      "2024-10-04 11:41:49,674 - __main__ - DEBUG - >>> activate_network_scenario: sbxj1uzhkb\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'POST /sandbox-api/v1/sandboxNetworkScenarios/sbxj1uzhkb?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": [
      "2024-10-04 11:41:49,738 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxNetworkScenarios/sbxj1uzhkb?network_scenario_id=4g-5g-macro-v2x HTTP/1.1\" 204 0\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "reply: 'HTTP/1.1 204 No Content\\r\\n'\n",
      "header: Date: Fri, 04 Oct 2024 09:41:49 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-04 11:41:49,748 DEBUG response body: b''\n",
      "2024-10-04 11:42:01,768 - __main__ - DEBUG - >>> request_application_instance_id: sbxj1uzhkb\n",
      "2024-10-04 11:42:01,768 - __main__ - DEBUG - >>> request_application_instance_id: sbxj1uzhkb\n",
      "2024-10-04 11:42:01,778 DEBUG Resetting dropped connection: mec-platform2.etsi.org\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'id': '9fd5e0c9-c00c-4b7c-845b-ac91056d0482',\n",
      " 'name': 'JupyterMecApp',\n",
      " 'node_name': 'mep1',\n",
      " 'persist': None,\n",
      " 'type': 'USER'}\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-10-04 11:42:01,939 DEBUG https://mec-platform2.etsi.org:443 \"POST /sandbox-api/v1/sandboxAppInstances/sbxj1uzhkb HTTP/1.1\" 201 100\n",
      "2024-10-04 11:42:01,940 DEBUG response body: b'{\"id\":\"9fd5e0c9-c00c-4b7c-845b-ac91056d0482\",\"name\":\"JupyterMecApp\",\"nodeName\":\"mep1\",\"type\":\"USER\"}'\n",
      "2024-10-04 11:42:01,942 - __main__ - DEBUG - request_application_instance_id: result: {'id': '9fd5e0c9-c00c-4b7c-845b-ac91056d0482',\n",
      " 'name': 'JupyterMecApp',\n",
      " 'node_name': 'mep1',\n",
      " 'persist': None,\n",
      " 'type': 'USER'}\n",
      "2024-10-04 11:42:01,942 - __main__ - DEBUG - request_application_instance_id: result: {'id': '9fd5e0c9-c00c-4b7c-845b-ac91056d0482',\n",
      " 'name': 'JupyterMecApp',\n",
      " 'node_name': 'mep1',\n",
      " 'persist': None,\n",
      " 'type': 'USER'}\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'POST /sandbox-api/v1/sandboxAppInstances/sbxj1uzhkb 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\": \"9fd5e0c9-c00c-4b7c-845b-ac91056d0482\", \"name\": \"JupyterMecApp\", \"nodeName\": \"mep1\", \"type\": \"USER\"}'\n",
      "reply: 'HTTP/1.1 201 Created\\r\\n'\n",
      "header: Date: Fri, 04 Oct 2024 09:42:01 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": [
      "2024-10-04 11:42:07,950 - __main__ - DEBUG - >>> send_ready_confirmation: 9fd5e0c9-c00c-4b7c-845b-ac91056d0482\n",
      "2024-10-04 11:42:07,950 - __main__ - DEBUG - >>> send_ready_confirmation: 9fd5e0c9-c00c-4b7c-845b-ac91056d0482\n",
      "2024-10-04 11:42:07,954 - __main__ - DEBUG - send_ready_confirmation: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/confirm_ready\n",
      "2024-10-04 11:42:07,954 - __main__ - DEBUG - send_ready_confirmation: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/confirm_ready\n",
      "2024-10-04 11:42:07,966 DEBUG Starting new HTTPS connection (1): mec-platform2.etsi.org:443\n",
      "2024-10-04 11:42:08,099 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxj1uzhkb/mep1/mec_app_support/v2/applications/9fd5e0c9-c00c-4b7c-845b-ac91056d0482/confirm_ready HTTP/1.1\" 204 0\n",
      "2024-10-04 11:42:08,099 DEBUG response body: b''\n",
      "2024-10-04 11:42:08,100 - __main__ - DEBUG - >>> send_subscribe_termination: 9fd5e0c9-c00c-4b7c-845b-ac91056d0482\n",
      "2024-10-04 11:42:08,100 - __main__ - DEBUG - >>> send_subscribe_termination: 9fd5e0c9-c00c-4b7c-845b-ac91056d0482\n",
      "2024-10-04 11:42:08,101 - __main__ - DEBUG - send_subscribe_termination: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions\n",
      "2024-10-04 11:42:08,101 - __main__ - DEBUG - send_subscribe_termination: url: /{sandbox_name}/{mec_pltf}/mec_app_support/v2/applications/{app_inst_id}/subscriptions\n",
      "2024-10-04 11:42:08,146 DEBUG https://mec-platform2.etsi.org:443 \"POST /sbxj1uzhkb/mep1/mec_app_support/v2/applications/9fd5e0c9-c00c-4b7c-845b-ac91056d0482/subscriptions HTTP/1.1\" 201 367\n",
      "2024-10-04 11:42:08,159 DEBUG response body: b'{\"subscriptionType\":\"AppTerminationNotificationSubscription\",\"callbackReference\":\"http://yanngarcia.ddns.net/mec011/v2/termination\",\"_links\":{\"self\":{\"href\":\"https://mec-platform2.etsi.org/sbxj1uzhkb/mep1/mec_app_support/v2/applications/9fd5e0c9-c00c-4b7c-845b-ac91056d0482/subscriptions/sub-VICy0s72InscM1yP\"}},\"appInstanceId\":\"9fd5e0c9-c00c-4b7c-845b-ac91056d0482\"}'\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "send: b'POST /sbxj1uzhkb/mep1/mec_app_support/v2/applications/9fd5e0c9-c00c-4b7c-845b-ac91056d0482/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: Fri, 04 Oct 2024 09:42:08 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 /sbxj1uzhkb/mep1/mec_app_support/v2/applications/9fd5e0c9-c00c-4b7c-845b-ac91056d0482/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\": \"9fd5e0c9-c00c-4b7c-845b-ac91056d0482\"}'\n",
      "reply: 'HTTP/1.1 201 Created\\r\\n'\n",
      "header: Date: Fri, 04 Oct 2024 09:42:08 GMT\n",
      "header: Content-Type: application/json; charset=UTF-8\n",
      "header: Content-Length: 367\n",
      "header: Connection: keep-alive\n",
      "header: Location: https://mec-platform2.etsi.org/sbxj1uzhkb/mep1/mec_app_support/v2/applications/9fd5e0c9-c00c-4b7c-845b-ac91056d0482/subscriptions/sub-VICy0s72InscM1yP\n",
      "header: Strict-Transport-Security: max-age=15724800; includeSubDomains\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-10-04 11:42:08,165 - __main__ - DEBUG - >>> extract_sub_id: resource_url: https://mec-platform2.etsi.org/sbxj1uzhkb/mep1/mec_app_support/v2/applications/9fd5e0c9-c00c-4b7c-845b-ac91056d0482/subscriptions/sub-VICy0s72InscM1yP\n",
      "2024-10-04 11:42:08,165 - __main__ - DEBUG - >>> extract_sub_id: resource_url: https://mec-platform2.etsi.org/sbxj1uzhkb/mep1/mec_app_support/v2/applications/9fd5e0c9-c00c-4b7c-845b-ac91056d0482/subscriptions/sub-VICy0s72InscM1yP\n"
     ]
    },
    {
     "ename": "TypeError",
     "evalue": "get_qos_prediction() missing 2 required positional arguments: 'latitude' and 'longitude'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[82], line 33\u001b[0m\n\u001b[1;32m     30\u001b[0m     \u001b[38;5;66;03m# End of function process_main\u001b[39;00m\n\u001b[1;32m     32\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;18m__name__\u001b[39m \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m__main__\u001b[39m\u001b[38;5;124m'\u001b[39m:\n\u001b[0;32m---> 33\u001b[0m     \u001b[43mprocess_main\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
      "Cell \u001b[0;32mIn[82], line 17\u001b[0m, in \u001b[0;36mprocess_main\u001b[0;34m()\u001b[0m\n\u001b[1;32m     14\u001b[0m (sandbox_name, app_inst_id, sub_id) \u001b[38;5;241m=\u001b[39m mec_app_setup()\n\u001b[1;32m     16\u001b[0m \u001b[38;5;66;03m# QoS Prediction\u001b[39;00m\n\u001b[0;32m---> 17\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[43mget_qos_prediction\u001b[49m\u001b[43m(\u001b[49m\u001b[43msandbox_name\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m     18\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m result \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m     19\u001b[0m     logger\u001b[38;5;241m.\u001b[39merror(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mFailed to get UU unicast provisioning information\u001b[39m\u001b[38;5;124m'\u001b[39m)\n",
      "\u001b[0;31mTypeError\u001b[0m: get_qos_prediction() missing 2 required positional arguments: 'latitude' and 'longitude'"
     ]
    }
   ],
   "source": [
    "def process_main():\n",
    "    \"\"\"\n",
    "    This is the second sprint of our skeleton of our MEC application:\n",
    "        - Mec application setup\n",
    "        - V2X QoS request\n",
    "        - Mec application termination\n",
    "    \"\"\" \n",
    "    global logger\n",
    "\n",
    "    logger.debug('Starting at ' + time.strftime('%Y%m%d-%H%M%S'))\n",
    "    logger.debug('\\t pwd= ' + os.getcwd())\n",
    "\n",
    "    # Setup the MEC application\n",
    "    (sandbox_name, app_inst_id, sub_id) = mec_app_setup()\n",
    "\n",
    "    # QoS Prediction\n",
    "    result = get_qos_prediction(sandbox_name)\n",
    "    if result is None:\n",
    "        logger.error('Failed to get UU unicast provisioning information')\n",
    "    else:\n",
    "        logger.info('UU unicast provisioning information: ', str(result))\n",
    "    \n",
    "    # Delete the V2X message subscritpion\n",
    "    delete_mec_subscription(v2x_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"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Our third MEC application: how to create a new MEC Services\n",
    "\n",
    "<b>The cells below are under develpment</b>\n",
    "\n",
    "The purpose of this MEC Service application is to provide a custom MEC service that can be use by other MEC applications. For the purpose of this tutorial, our MEC service is simulating some complex calculation based on a set of data provided by the MEC use.   \n",
    "We will use a second MEC application to exploit the features of our new MEC services.\n",
    "\n",
    "In this clause, we use the following functionalities provided by MEC-011:\n",
    "- Register a new service\n",
    "- Retrieve the list of the MEC services exposed by the MEC platform\n",
    "- Check that our new MEC service is present in the list\n",
    "- Delete a created service\n",
    "\n",
    "<b>Note:</b> We will use a second MEC application to exploit the features of our new MEC services.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Bases of the creation of a MEC service\n",
    "\n",
    "From the user perspective, a MEC service provides a set of endpoints which describe the interface of the MEC service (see [HTTP REST APIs \n",
    "concepts](https://blog.postman.com/rest-api-examples/)). These endpoints come usually with a set of data structures used by the one or more endpoints.\n",
    "\n",
    "Our service is really basic: it provide one endpoint:\n",
    "- GET /statistic/v1/quantity: it computes statistical quantities of a set of data (such as average, max, min, standard deviation)\n",
    "\n",
    "The body of this GET method is a list of datas:\n",
    "```json\n",
    "{\"time\":20180124,\"data1\":\"[1516752000,11590.6,11616.9,11590.4,11616.9,0.25202387,1516752060,11622.4,11651.7,11622.4,11644.6,1.03977764]\"}\n",
    "```\n",
    "\n",
    "The response body is the list of statistical quantities:\n",
    "```json\n",
    "{\"time\":20180124,\"avg\": 0.0,\"max\": 0.0,\"min\": 0.0,\"stddev\": 0.0 }\n",
    "```\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
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}