{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from ll_sdk.config_api import ConfigApiClient\n", "\n", "username = \"chl20000826@163.com\"\n", "shared_key = \"0f4912881c27a33dcfcf2ab6e2dc286c065a559000926bc9d1fc25d4228bb5cd\"\n", "short_name = \"centtest\"\n", "cl = ConfigApiClient('apis.llnw.com', username, shared_key)" ] }, { "cell_type": "code", "execution_count": 2, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'version': '22.12-RC1', 'timestamp': '2022-11-22T10:24:34+0000', 'mysqlConnection': {'connectionTime': '0'}, 'cfgMgmtConnection': {'available': 'true'}, 'remoteComponentsConnection': {'available': 'true'}, 'serviceDbConnection': {'available': 'true'}}\n" ] } ], "source": [ "print(cl.get_status().json())" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 3, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['OK']\n" ] } ], "source": [ "print(cl.get_health_check().json())" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 4, "outputs": [ { "data": { "text/plain": "{'results': [{'uuid': '9e232e46-89ca-4a08-9186-7a6a7cd45c52',\n 'isLatest': True,\n 'isEnabled': True,\n 'revision': {'createdBy': 'sonoda',\n 'createdDate': 1657529771410,\n 'versionNumber': 1},\n 'meta': {'manifestVersion': '57',\n 'serviceIdentifier': 'deliverysvcinst',\n 'serviceKey': 'delivery'},\n 'status': {'state': 'COMPLETED'},\n 'accounts': [{'shortname': 'centtest'}],\n 'shortname': 'centtest',\n 'body': {'protocolSets': [{'publishedProtocol': 'https',\n 'sourceProtocol': 'https',\n 'options': [{'name': 'agile_backup',\n 'parameters': [],\n 'source': 'direct'}]}],\n 'serviceProfileVersion': 2,\n 'serviceProfileName': 'LLNW-Generic',\n 'publishedHostname': 'centtest.s.llnwi.net',\n 'sourceHostname': 'centtest.mt.lldns.net',\n 'publishedUrlPath': '/v1/',\n 'sourceUrlPath': '/centtest/',\n 'serviceKey': {'name': 'delivery'}}},\n {'uuid': '8a0aae8f-d658-46d7-93af-29fe656e293c',\n 'isLatest': True,\n 'isEnabled': True,\n 'revision': {'createdBy': 'max2022',\n 'createdDate': 1677226134907,\n 'versionNumber': 1},\n 'meta': {'manifestVersion': '57',\n 'serviceIdentifier': 'deliverysvcinst',\n 'serviceKey': 'delivery'},\n 'status': {'state': 'COMPLETED'},\n 'accounts': [{'shortname': 'centtest'}],\n 'shortname': 'centtest',\n 'body': {'protocolSets': [{'publishedProtocol': 'https',\n 'sourceProtocol': 'http',\n 'options': [{'name': 'fivemin_ttl',\n 'parameters': [],\n 'source': 'direct'},\n {'name': 'force_tcphost',\n 'parameters': ['54.255.244.22'],\n 'source': 'direct'}]},\n {'publishedProtocol': 'http',\n 'sourceProtocol': 'http',\n 'options': [{'name': 'fivemin_ttl',\n 'parameters': [],\n 'source': 'direct'},\n {'name': 'force_tcphost',\n 'parameters': ['54.255.244.22'],\n 'source': 'direct'}]}],\n 'serviceProfileVersion': 2,\n 'serviceProfileName': 'LLNW-Generic',\n 'publishedHostname': 'test01.advancecloud.net',\n 'sourceHostname': 'test01.advancecloud.net',\n 'publishedUrlPath': '/',\n 'sourceUrlPath': '/',\n 'serviceKey': {'name': 'delivery'}}},\n {'uuid': 'e4ff684c-c5f5-4caa-aa74-71eaebd93b5d',\n 'isLatest': True,\n 'isEnabled': True,\n 'revision': {'createdBy': 'max2022',\n 'createdDate': 1678871315598,\n 'versionNumber': 1},\n 'meta': {'manifestVersion': '57',\n 'serviceIdentifier': 'deliverysvcinst',\n 'serviceKey': 'delivery'},\n 'status': {'state': 'COMPLETED'},\n 'accounts': [{'shortname': 'centtest'}],\n 'shortname': 'centtest',\n 'body': {'protocolSets': [{'publishedProtocol': 'https',\n 'sourceProtocol': 'https',\n 'options': [{'name': 'req_send_header',\n 'parameters': ['abc', '123'],\n 'source': 'direct'},\n {'name': 'req_send_header',\n 'parameters': ['def', '456'],\n 'source': 'direct'},\n {'name': 'reply_send_header',\n 'parameters': ['123', '456'],\n 'source': 'direct'},\n {'name': 'reply_send_header',\n 'parameters': ['test', 'abc'],\n 'source': 'direct'},\n {'name': 'fivemin_ttl', 'parameters': [], 'source': 'direct'},\n {'name': 'force_tcphost',\n 'parameters': ['www.baidu.com'],\n 'source': 'direct'}]},\n {'publishedProtocol': 'http',\n 'sourceProtocol': 'http',\n 'options': [{'name': 'req_send_header',\n 'parameters': ['abc', '123'],\n 'source': 'direct'},\n {'name': 'req_send_header',\n 'parameters': ['def', '456'],\n 'source': 'direct'},\n {'name': 'reply_send_header',\n 'parameters': ['123', '456'],\n 'source': 'direct'},\n {'name': 'reply_send_header',\n 'parameters': ['test', 'abc'],\n 'source': 'direct'},\n {'name': 'fivemin_ttl', 'parameters': [], 'source': 'direct'},\n {'name': 'force_tcphost',\n 'parameters': ['www.baidu.com'],\n 'source': 'direct'}]}],\n 'serviceProfileVersion': 2,\n 'serviceProfileName': 'LLNW-Generic',\n 'publishedHostname': 'test03.advancecloud.net',\n 'sourceHostname': 'test03.advancecloud.net',\n 'publishedUrlPath': '/',\n 'sourceUrlPath': '/',\n 'serviceKey': {'name': 'delivery'}}},\n {'uuid': 'aa120007-ac20-45f9-9722-b945024cbb5f',\n 'isLatest': True,\n 'isEnabled': True,\n 'revision': {'createdBy': 'max2022',\n 'createdDate': 1678871492617,\n 'versionNumber': 2},\n 'meta': {'manifestVersion': '57',\n 'serviceIdentifier': 'deliverysvcinst',\n 'serviceKey': 'delivery'},\n 'status': {'state': 'COMPLETED'},\n 'accounts': [{'shortname': 'centtest'}],\n 'shortname': 'centtest',\n 'body': {'protocolSets': [{'publishedProtocol': 'https',\n 'sourceProtocol': 'http',\n 'options': [{'name': 'fivemin_ttl',\n 'parameters': [],\n 'source': 'direct'},\n {'name': 'force_tcphost',\n 'parameters': ['54.255.244.11'],\n 'source': 'direct'}]},\n {'publishedProtocol': 'http',\n 'sourceProtocol': 'http',\n 'options': [{'name': 'fivemin_ttl',\n 'parameters': [],\n 'source': 'direct'},\n {'name': 'force_tcphost',\n 'parameters': ['54.255.244.11'],\n 'source': 'direct'}]}],\n 'serviceProfileVersion': 2,\n 'serviceProfileName': 'LLNW-Generic',\n 'publishedHostname': 'test02.advancecloud.net',\n 'sourceHostname': 'test02.advancecloud.net',\n 'publishedUrlPath': '/',\n 'sourceUrlPath': '/',\n 'serviceKey': {'name': 'delivery'}}},\n {'uuid': 'b6cf164a-1022-4d37-b752-bdece0d7f0a5',\n 'isLatest': True,\n 'isEnabled': True,\n 'revision': {'createdBy': 'chl',\n 'createdDate': 1678946758170,\n 'versionNumber': 1},\n 'meta': {'manifestVersion': '57',\n 'serviceIdentifier': 'deliverysvcinst',\n 'serviceKey': 'delivery',\n 'allowManualDuplicate': True},\n 'status': {'state': 'COMPLETED'},\n 'accounts': [{'shortname': 'centtest'}],\n 'shortname': 'centtest',\n 'body': {'protocolSets': [{'publishedProtocol': 'http',\n 'sourceProtocol': 'http',\n 'options': [{'name': 'fivemin_ttl',\n 'parameters': [],\n 'source': 'direct'}]}],\n 'serviceProfileVersion': 2,\n 'description': 'string',\n 'serviceProfileName': 'LLNW-Generic',\n 'publishedHostname': '316.shiqi.tsdb.work',\n 'sourceHostname': '54.255.244.22',\n 'publishedUrlPath': '/',\n 'sourceUrlPath': '/',\n 'serviceKey': {'name': 'delivery'}}}],\n 'size': 'all',\n 'offset': 0,\n 'page': 1,\n 'total': 5,\n 'sort': '_id',\n 'sort.dir': 'ascending'}" }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "res = cl.list_delivery_service_instances(short_name)\n", "t = res.json()\n", "t" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 5, "outputs": [ { "data": { "text/plain": "dict" }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(t)" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 6, "outputs": [ { "data": { "text/plain": "[{'uuid': '9e232e46-89ca-4a08-9186-7a6a7cd45c52',\n 'isLatest': True,\n 'isEnabled': True,\n 'revision': {'createdBy': 'sonoda',\n 'createdDate': 1657529771410,\n 'versionNumber': 1},\n 'meta': {'manifestVersion': '57',\n 'serviceIdentifier': 'deliverysvcinst',\n 'serviceKey': 'delivery'},\n 'status': {'state': 'COMPLETED'},\n 'accounts': [{'shortname': 'centtest'}],\n 'shortname': 'centtest',\n 'body': {'protocolSets': [{'publishedProtocol': 'https',\n 'sourceProtocol': 'https',\n 'options': [{'name': 'agile_backup',\n 'parameters': [],\n 'source': 'direct'}]}],\n 'serviceProfileVersion': 2,\n 'serviceProfileName': 'LLNW-Generic',\n 'publishedHostname': 'centtest.s.llnwi.net',\n 'sourceHostname': 'centtest.mt.lldns.net',\n 'publishedUrlPath': '/v1/',\n 'sourceUrlPath': '/centtest/',\n 'serviceKey': {'name': 'delivery'}}},\n {'uuid': '8a0aae8f-d658-46d7-93af-29fe656e293c',\n 'isLatest': True,\n 'isEnabled': True,\n 'revision': {'createdBy': 'max2022',\n 'createdDate': 1677226134907,\n 'versionNumber': 1},\n 'meta': {'manifestVersion': '57',\n 'serviceIdentifier': 'deliverysvcinst',\n 'serviceKey': 'delivery'},\n 'status': {'state': 'COMPLETED'},\n 'accounts': [{'shortname': 'centtest'}],\n 'shortname': 'centtest',\n 'body': {'protocolSets': [{'publishedProtocol': 'https',\n 'sourceProtocol': 'http',\n 'options': [{'name': 'fivemin_ttl', 'parameters': [], 'source': 'direct'},\n {'name': 'force_tcphost',\n 'parameters': ['54.255.244.22'],\n 'source': 'direct'}]},\n {'publishedProtocol': 'http',\n 'sourceProtocol': 'http',\n 'options': [{'name': 'fivemin_ttl', 'parameters': [], 'source': 'direct'},\n {'name': 'force_tcphost',\n 'parameters': ['54.255.244.22'],\n 'source': 'direct'}]}],\n 'serviceProfileVersion': 2,\n 'serviceProfileName': 'LLNW-Generic',\n 'publishedHostname': 'test01.advancecloud.net',\n 'sourceHostname': 'test01.advancecloud.net',\n 'publishedUrlPath': '/',\n 'sourceUrlPath': '/',\n 'serviceKey': {'name': 'delivery'}}},\n {'uuid': 'e4ff684c-c5f5-4caa-aa74-71eaebd93b5d',\n 'isLatest': True,\n 'isEnabled': True,\n 'revision': {'createdBy': 'max2022',\n 'createdDate': 1678871315598,\n 'versionNumber': 1},\n 'meta': {'manifestVersion': '57',\n 'serviceIdentifier': 'deliverysvcinst',\n 'serviceKey': 'delivery'},\n 'status': {'state': 'COMPLETED'},\n 'accounts': [{'shortname': 'centtest'}],\n 'shortname': 'centtest',\n 'body': {'protocolSets': [{'publishedProtocol': 'https',\n 'sourceProtocol': 'https',\n 'options': [{'name': 'req_send_header',\n 'parameters': ['abc', '123'],\n 'source': 'direct'},\n {'name': 'req_send_header',\n 'parameters': ['def', '456'],\n 'source': 'direct'},\n {'name': 'reply_send_header',\n 'parameters': ['123', '456'],\n 'source': 'direct'},\n {'name': 'reply_send_header',\n 'parameters': ['test', 'abc'],\n 'source': 'direct'},\n {'name': 'fivemin_ttl', 'parameters': [], 'source': 'direct'},\n {'name': 'force_tcphost',\n 'parameters': ['www.baidu.com'],\n 'source': 'direct'}]},\n {'publishedProtocol': 'http',\n 'sourceProtocol': 'http',\n 'options': [{'name': 'req_send_header',\n 'parameters': ['abc', '123'],\n 'source': 'direct'},\n {'name': 'req_send_header',\n 'parameters': ['def', '456'],\n 'source': 'direct'},\n {'name': 'reply_send_header',\n 'parameters': ['123', '456'],\n 'source': 'direct'},\n {'name': 'reply_send_header',\n 'parameters': ['test', 'abc'],\n 'source': 'direct'},\n {'name': 'fivemin_ttl', 'parameters': [], 'source': 'direct'},\n {'name': 'force_tcphost',\n 'parameters': ['www.baidu.com'],\n 'source': 'direct'}]}],\n 'serviceProfileVersion': 2,\n 'serviceProfileName': 'LLNW-Generic',\n 'publishedHostname': 'test03.advancecloud.net',\n 'sourceHostname': 'test03.advancecloud.net',\n 'publishedUrlPath': '/',\n 'sourceUrlPath': '/',\n 'serviceKey': {'name': 'delivery'}}},\n {'uuid': 'aa120007-ac20-45f9-9722-b945024cbb5f',\n 'isLatest': True,\n 'isEnabled': True,\n 'revision': {'createdBy': 'max2022',\n 'createdDate': 1678871492617,\n 'versionNumber': 2},\n 'meta': {'manifestVersion': '57',\n 'serviceIdentifier': 'deliverysvcinst',\n 'serviceKey': 'delivery'},\n 'status': {'state': 'COMPLETED'},\n 'accounts': [{'shortname': 'centtest'}],\n 'shortname': 'centtest',\n 'body': {'protocolSets': [{'publishedProtocol': 'https',\n 'sourceProtocol': 'http',\n 'options': [{'name': 'fivemin_ttl', 'parameters': [], 'source': 'direct'},\n {'name': 'force_tcphost',\n 'parameters': ['54.255.244.11'],\n 'source': 'direct'}]},\n {'publishedProtocol': 'http',\n 'sourceProtocol': 'http',\n 'options': [{'name': 'fivemin_ttl', 'parameters': [], 'source': 'direct'},\n {'name': 'force_tcphost',\n 'parameters': ['54.255.244.11'],\n 'source': 'direct'}]}],\n 'serviceProfileVersion': 2,\n 'serviceProfileName': 'LLNW-Generic',\n 'publishedHostname': 'test02.advancecloud.net',\n 'sourceHostname': 'test02.advancecloud.net',\n 'publishedUrlPath': '/',\n 'sourceUrlPath': '/',\n 'serviceKey': {'name': 'delivery'}}},\n {'uuid': 'b6cf164a-1022-4d37-b752-bdece0d7f0a5',\n 'isLatest': True,\n 'isEnabled': True,\n 'revision': {'createdBy': 'chl',\n 'createdDate': 1678946758170,\n 'versionNumber': 1},\n 'meta': {'manifestVersion': '57',\n 'serviceIdentifier': 'deliverysvcinst',\n 'serviceKey': 'delivery',\n 'allowManualDuplicate': True},\n 'status': {'state': 'COMPLETED'},\n 'accounts': [{'shortname': 'centtest'}],\n 'shortname': 'centtest',\n 'body': {'protocolSets': [{'publishedProtocol': 'http',\n 'sourceProtocol': 'http',\n 'options': [{'name': 'fivemin_ttl',\n 'parameters': [],\n 'source': 'direct'}]}],\n 'serviceProfileVersion': 2,\n 'description': 'string',\n 'serviceProfileName': 'LLNW-Generic',\n 'publishedHostname': '316.shiqi.tsdb.work',\n 'sourceHostname': '54.255.244.22',\n 'publishedUrlPath': '/',\n 'sourceUrlPath': '/',\n 'serviceKey': {'name': 'delivery'}}}]" }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "t['results']\n" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 7, "outputs": [], "source": [ "res = cl.list_delivery_service_profiles(short_name)\n", "\n" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 8, "outputs": [ { "data": { "text/plain": "{'results': [{'uuid': '44041a55-32a0-452e-a52b-258704a47009',\n 'isLatest': True,\n 'isEnabled': True,\n 'revision': {'createdBy': 'cdoehler',\n 'createdDate': 1553296719959,\n 'versionNumber': 2,\n 'notes': 'LLNW Generic serviceProfile - slashes in source and published path removed - MWS-2721'},\n 'meta': {'manifestVersion': '6', 'serviceIdentifier': 'deliverysvcprof'},\n 'status': {'state': 'COMPLETED'},\n 'accounts': [],\n 'body': {'protocolSets': [{'publishedProtocol': 'http',\n 'sourceProtocol': 'http',\n 'allowedOptions': [],\n 'defaultOptions': [],\n 'requiredOptions': []},\n {'publishedProtocol': 'https',\n 'sourceProtocol': 'http',\n 'allowedOptions': [],\n 'defaultOptions': [],\n 'requiredOptions': []},\n {'publishedProtocol': 'http',\n 'sourceProtocol': 'https',\n 'allowedOptions': [],\n 'defaultOptions': [],\n 'requiredOptions': []},\n {'publishedProtocol': 'https',\n 'sourceProtocol': 'https',\n 'allowedOptions': [],\n 'defaultOptions': [],\n 'requiredOptions': []}],\n 'serviceProfileName': 'LLNW-Generic',\n 'useCase': 'Generic',\n 'description': 'General purpose profile allowing all user-accessible options for which the caller/shortname is entitled',\n 'serviceKey': {'name': 'delivery'},\n 'publishedUrlPath': '',\n 'sourceUrlPath': ''}}],\n 'size': 'all',\n 'offset': 0,\n 'page': 1,\n 'total': 1,\n 'sort': '_id',\n 'sort.dir': 'ascending',\n '$prev': '',\n '$next': ''}" }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rj = res.json()\n", "rj\n" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 9, "outputs": [], "source": [ "res = cl.get_delivery_service_instance('9e232e46-89ca-4a08-9186-7a6a7cd45c52').json()" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 10, "outputs": [ { "data": { "text/plain": "{'uuid': '9e232e46-89ca-4a08-9186-7a6a7cd45c52',\n 'isLatest': True,\n 'isEnabled': True,\n 'revision': {'createdBy': 'sonoda',\n 'createdDate': 1657529771410,\n 'versionNumber': 1},\n 'meta': {'manifestVersion': '57',\n 'serviceIdentifier': 'deliverysvcinst',\n 'serviceKey': 'delivery'},\n 'status': {'state': 'COMPLETED'},\n 'accounts': [{'shortname': 'centtest'}],\n 'shortname': 'centtest',\n 'body': {'protocolSets': [{'publishedProtocol': 'https',\n 'sourceProtocol': 'https',\n 'options': [{'name': 'agile_backup',\n 'parameters': [],\n 'source': 'direct'}]}],\n 'serviceProfileVersion': 2,\n 'serviceProfileName': 'LLNW-Generic',\n 'publishedHostname': 'centtest.s.llnwi.net',\n 'sourceHostname': 'centtest.mt.lldns.net',\n 'publishedUrlPath': '/v1/',\n 'sourceUrlPath': '/centtest/',\n 'serviceKey': {'name': 'delivery'}}}" }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "res" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 11, "outputs": [ { "data": { "text/plain": "{'success': False,\n 'errorType': 'validation',\n 'errors': {'body': [{'code': 'validatorInternal.deliverysvcinst.error.deliverySvcInstanceConflict',\n 'message': 'DeliverySvcInstance already exists with uuid [b6cf164a-1022-4d37-b752-bdece0d7f0a5]',\n 'args': ['b6cf164a-1022-4d37-b752-bdece0d7f0a5'],\n 'type': 'validator'}]}}" }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "delivery_config = {\n", " \"accounts\": [\n", " {\n", " \"shortname\": short_name\n", " }\n", " ],\n", " \"body\": {\n", " \"description\": \"string\",\n", " \"protocolSets\": [\n", " {\n", " \"options\": [\n", " {\n", " \"name\": \"fivemin_ttl\",\n", " \"parameters\": []\n", " }\n", " ],\n", " \"publishedProtocol\": \"http\",\n", " \"sourceProtocol\": \"http\"\n", " }\n", " ],\n", " \"publishedHostname\": \"316.shiqi.tsdb.work\",\n", " \"publishedUrlPath\": \"/\",\n", " \"serviceKey\": {\n", " \"name\": \"delivery\"\n", " },\n", " \"serviceProfileName\": \"LLNW-Generic\",\n", " \"serviceProfileVersion\": 2,\n", " \"sourceHostname\": \"54.255.244.22\",\n", " \"sourceUrlPath\": \"/\"\n", " },\n", " \"meta\": {\n", " \"allowManualDuplicate\": True\n", " }\n", "}\n", "cl.validate_delivery_service_instance(delivery_config=delivery_config).json()\n" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 12, "outputs": [ { "data": { "text/plain": "{'success': False,\n 'errorType': 'validation',\n 'errors': {'body': [{'code': 'validatorInternal.deliverysvcinst.error.deliverySvcInstanceConflict',\n 'message': 'DeliverySvcInstance already exists with uuid [b6cf164a-1022-4d37-b752-bdece0d7f0a5]',\n 'args': ['b6cf164a-1022-4d37-b752-bdece0d7f0a5'],\n 'type': 'validator'}]}}" }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cl.create_delivery_service_instance(delivery_config=delivery_config).json()\n" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 13, "outputs": [], "source": [ "import grpc\n", "import llnw_pb2_grpc\n", "from llnw_pb2 import *\n" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 14, "outputs": [], "source": [ "username = \"chl20000826@163.com\"\n", "shared_key = \"0f4912881c27a33dcfcf2ab6e2dc286c065a559000926bc9d1fc25d4228bb5cd\"\n", "short_name = \"centtest\"\n", "base=Base(username=username, key=shared_key)" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 15, "outputs": [], "source": [ "channel = grpc.insecure_channel('localhost:50052')\n", "stub = llnw_pb2_grpc.DeliveryServiceStub(channel)" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 16, "outputs": [ { "data": { "text/plain": "deliveries {\n uuid: \"9e232e46-89ca-4a08-9186-7a6a7cd45c52\"\n isEnabled: true\n shortname: \"centtest\"\n status: \"COMPLETED\"\n sourceHostname: \"centtest.mt.lldns.net\"\n publishedHostname: \"centtest.s.llnwi.net\"\n sourceUrlPath: \"/centtest/\"\n publishedUrlPath: \"/v1/\"\n protocolSets {\n sourceProtocol: \"https\"\n publishedProtocol: \"https\"\n options {\n name: \"agile_backup\"\n source: \"direct\"\n }\n }\n}\ndeliveries {\n uuid: \"8a0aae8f-d658-46d7-93af-29fe656e293c\"\n isEnabled: true\n shortname: \"centtest\"\n status: \"COMPLETED\"\n sourceHostname: \"test01.advancecloud.net\"\n publishedHostname: \"test01.advancecloud.net\"\n sourceUrlPath: \"/\"\n publishedUrlPath: \"/\"\n protocolSets {\n sourceProtocol: \"http\"\n publishedProtocol: \"https\"\n options {\n name: \"fivemin_ttl\"\n source: \"direct\"\n }\n options {\n name: \"force_tcphost\"\n parameters: \"54.255.244.22\"\n source: \"direct\"\n }\n }\n protocolSets {\n sourceProtocol: \"http\"\n publishedProtocol: \"http\"\n options {\n name: \"fivemin_ttl\"\n source: \"direct\"\n }\n options {\n name: \"force_tcphost\"\n parameters: \"54.255.244.22\"\n source: \"direct\"\n }\n }\n}\ndeliveries {\n uuid: \"e4ff684c-c5f5-4caa-aa74-71eaebd93b5d\"\n isEnabled: true\n shortname: \"centtest\"\n status: \"COMPLETED\"\n sourceHostname: \"test03.advancecloud.net\"\n publishedHostname: \"test03.advancecloud.net\"\n sourceUrlPath: \"/\"\n publishedUrlPath: \"/\"\n protocolSets {\n sourceProtocol: \"https\"\n publishedProtocol: \"https\"\n options {\n name: \"req_send_header\"\n parameters: \"abc\"\n parameters: \"123\"\n source: \"direct\"\n }\n options {\n name: \"req_send_header\"\n parameters: \"def\"\n parameters: \"456\"\n source: \"direct\"\n }\n options {\n name: \"reply_send_header\"\n parameters: \"123\"\n parameters: \"456\"\n source: \"direct\"\n }\n options {\n name: \"reply_send_header\"\n parameters: \"test\"\n parameters: \"abc\"\n source: \"direct\"\n }\n options {\n name: \"fivemin_ttl\"\n source: \"direct\"\n }\n options {\n name: \"force_tcphost\"\n parameters: \"www.baidu.com\"\n source: \"direct\"\n }\n }\n protocolSets {\n sourceProtocol: \"http\"\n publishedProtocol: \"http\"\n options {\n name: \"req_send_header\"\n parameters: \"abc\"\n parameters: \"123\"\n source: \"direct\"\n }\n options {\n name: \"req_send_header\"\n parameters: \"def\"\n parameters: \"456\"\n source: \"direct\"\n }\n options {\n name: \"reply_send_header\"\n parameters: \"123\"\n parameters: \"456\"\n source: \"direct\"\n }\n options {\n name: \"reply_send_header\"\n parameters: \"test\"\n parameters: \"abc\"\n source: \"direct\"\n }\n options {\n name: \"fivemin_ttl\"\n source: \"direct\"\n }\n options {\n name: \"force_tcphost\"\n parameters: \"www.baidu.com\"\n source: \"direct\"\n }\n }\n}\ndeliveries {\n uuid: \"aa120007-ac20-45f9-9722-b945024cbb5f\"\n isEnabled: true\n shortname: \"centtest\"\n status: \"COMPLETED\"\n sourceHostname: \"test02.advancecloud.net\"\n publishedHostname: \"test02.advancecloud.net\"\n sourceUrlPath: \"/\"\n publishedUrlPath: \"/\"\n protocolSets {\n sourceProtocol: \"http\"\n publishedProtocol: \"https\"\n options {\n name: \"fivemin_ttl\"\n source: \"direct\"\n }\n options {\n name: \"force_tcphost\"\n parameters: \"54.255.244.11\"\n source: \"direct\"\n }\n }\n protocolSets {\n sourceProtocol: \"http\"\n publishedProtocol: \"http\"\n options {\n name: \"fivemin_ttl\"\n source: \"direct\"\n }\n options {\n name: \"force_tcphost\"\n parameters: \"54.255.244.11\"\n source: \"direct\"\n }\n }\n}\ndeliveries {\n uuid: \"b6cf164a-1022-4d37-b752-bdece0d7f0a5\"\n isEnabled: true\n shortname: \"centtest\"\n status: \"COMPLETED\"\n sourceHostname: \"54.255.244.22\"\n publishedHostname: \"316.shiqi.tsdb.work\"\n sourceUrlPath: \"/\"\n publishedUrlPath: \"/\"\n protocolSets {\n sourceProtocol: \"http\"\n publishedProtocol: \"http\"\n options {\n name: \"fivemin_ttl\"\n source: \"direct\"\n }\n }\n}" }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "e = stub.ListDelivery(ShortNameRequest(base=base, shortName=short_name))\n", "e" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 17, "outputs": [ { "data": { "text/plain": "uuid: \"b6cf164a-1022-4d37-b752-bdece0d7f0a5\"\nisEnabled: true\nshortname: \"centtest\"\nstatus: \"COMPLETED\"\nsourceHostname: \"54.255.244.22\"\npublishedHostname: \"316.shiqi.tsdb.work\"\nsourceUrlPath: \"/\"\npublishedUrlPath: \"/\"\nprotocolSets {\n sourceProtocol: \"http\"\n publishedProtocol: \"http\"\n options {\n name: \"fivemin_ttl\"\n source: \"direct\"\n }\n}" }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "e = stub.GetDelivery(IdRequest(base=base,id=\"b6cf164a-1022-4d37-b752-bdece0d7f0a5\"))\n", "e" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 21, "outputs": [ { "ename": "KeyError", "evalue": "'uuid'", "output_type": "error", "traceback": [ "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m", "\u001B[1;31mKeyError\u001B[0m Traceback (most recent call last)", "Cell \u001B[1;32mIn[21], line 2\u001B[0m\n\u001B[0;32m 1\u001B[0m delivery_config\n\u001B[1;32m----> 2\u001B[0m \u001B[43mdelivery_config\u001B[49m\u001B[43m[\u001B[49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[38;5;124;43muuid\u001B[39;49m\u001B[38;5;124;43m'\u001B[39;49m\u001B[43m]\u001B[49m\u001B[38;5;241m|\u001B[39m\u001B[38;5;28;01mNone\u001B[39;00m\n", "\u001B[1;31mKeyError\u001B[0m: 'uuid'" ] } ], "source": [ "delivery_config\n", "delivery_config['uuid']|None\n" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 24, "outputs": [], "source": [ "import pydash\n" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 31, "outputs": [], "source": [ "pydash.objects.get(delivery_config,\"accounts[0].shortname.a\")\n" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 26, "outputs": [ { "data": { "text/plain": "{'accounts': [{'shortname': 'centtest'}],\n 'body': {'description': 'string',\n 'protocolSets': [{'options': [{'name': 'fivemin_ttl', 'parameters': []}],\n 'publishedProtocol': 'http',\n 'sourceProtocol': 'http'}],\n 'publishedHostname': '316.shiqi.tsdb.work',\n 'publishedUrlPath': '/',\n 'serviceKey': {'name': 'delivery'},\n 'serviceProfileName': 'LLNW-Generic',\n 'serviceProfileVersion': 2,\n 'sourceHostname': '54.255.244.22',\n 'sourceUrlPath': '/'},\n 'meta': {'allowManualDuplicate': True}}" }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "delivery_config\n" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "execution_count": 34, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'results': [], 'size': 'all', 'offset': 0, 'page': 1, 'total': 0, 'sort': '_id', 'sort.dir': 'ascending', '$prev': '', '$next': ''}\n" ] } ], "source": [ "from ll_sdk.config_api import ConfigApiClient\n", "username = \"chl20000826@163.com\"\n", "shared_key = \"0f4912881c27a33dcfcf2ab6e2dc286c065a559000926bc9d1fc25d4228bb5cd\"\n", "short_name = \"centtest\"\n", "cl = ConfigApiClient('apis.llnw.com', username, shared_key)\n", "\n", "storage = {\n", " \"accessKey\": \"AKIASB76IRYZX5KCSXMB\",\n", " \"bucketName\": \"cengcloud-dev\",\n", " \"location\": \"amazon_s3\",\n", " \"path\": \"223-0303.chl.tsdb.work/edgio/\",\n", " \"region\": \"ap-southeast-1\",\n", " \"secretKey\": \"PXgElj+slvVII8H0DKoMtM2rvmr34mxegP+HHRsb\"\n", "}\n", "\n", "config = {\n", " \"compressionType\": \"lz4\",\n", " \"isActive\": \"true\",\n", " \"logFields\": [\"sc-request-id\",\"s-host\",\"datetime\",\"c-country-code\",\"sc-status\",\"c-ip\",\"cs-uri\",\"sc-bytes\"],\n", " \"name\": \"test032101\",\n", " \"serviceType\": \"http\",\n", " \"storage\": storage\n", "}\n", "\n", "uuid = \"97a3db7d-86b2-4302-92cb-3fc7bfa81a60\"\n", "\n", "# print(cl.create_lds(shortname=short_name, config={\"body\":config}).json())\n", "# print(cl.list_lds(shortname=short_name).json())\n", "# print(cl.delete_lds(shortname=short_name, uuid=uuid).json())" ], "metadata": { "collapsed": false } } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 0 }