tccli 3.0.1005.1__py2.py3-none-any.whl → 3.0.1006.1__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tccli/__init__.py +1 -1
 - tccli/examples/cdb/v20170320/CloseAuditService.md +20 -0
 - tccli/examples/cdb/v20170320/CreateAuditRuleTemplate.md +31 -0
 - tccli/examples/cdb/v20170320/DeleteAuditRuleTemplates.md +20 -0
 - tccli/examples/cdb/v20170320/DeleteDatabase.md +21 -0
 - tccli/examples/cdb/v20170320/DescribeAuditInstanceList.md +51 -0
 - tccli/examples/cdb/v20170320/DescribeAuditRuleTemplateModifyHistory.md +70 -0
 - tccli/examples/cdb/v20170320/DescribeAuditRuleTemplates.md +61 -0
 - tccli/examples/cdb/v20170320/ModifyAuditRuleTemplates.md +21 -0
 - tccli/examples/cdb/v20170320/ModifyAuditService.md +23 -0
 - tccli/examples/cfg/v20210820/DescribeTaskPolicyTriggerLog.md +38 -0
 - tccli/examples/cfg/v20210820/TriggerPolicy.md +25 -0
 - tccli/examples/config/v20220802/ListAggregateConfigRules.md +79 -0
 - tccli/examples/config/v20220802/ListConfigRules.md +138 -0
 - tccli/examples/tdmq/v20200217/CreateProCluster.md +3 -3
 - tccli/examples/teo/v20220901/DescribeOverviewL7Data.md +4 -2
 - tccli/examples/teo/v20220901/DescribePrefetchTasks.md +2 -1
 - tccli/examples/teo/v20220901/DescribePurgeTasks.md +2 -1
 - tccli/examples/teo/v20220901/DescribeTimingL4Data.md +4 -1
 - tccli/examples/teo/v20220901/DescribeTimingL7AnalysisData.md +6 -3
 - tccli/examples/teo/v20220901/DescribeTimingL7CacheData.md +6 -3
 - tccli/examples/teo/v20220901/DescribeTopL7AnalysisData.md +6 -3
 - tccli/examples/teo/v20220901/DescribeTopL7CacheData.md +8 -4
 - tccli/examples/teo/v20220901/DownloadL4Logs.md +2 -1
 - tccli/examples/teo/v20220901/DownloadL7Logs.md +2 -1
 - tccli/examples/tke/v20180525/DescribeIPAMD.md +6 -3
 - tccli/examples/tse/v20201207/CloseWafProtection.md +21 -0
 - tccli/examples/tse/v20201207/CreateWafDomains.md +21 -0
 - tccli/examples/tse/v20201207/OpenWafProtection.md +21 -0
 - tccli/examples/vod/v20180717/DescribeTaskDetail.md +4 -0
 - tccli/examples/vrs/v20200824/GetVRSVoiceTypes.md +4 -2
 - tccli/services/__init__.py +3 -0
 - tccli/services/cdb/cdb_client.py +497 -20
 - tccli/services/cdb/v20170320/api.json +1174 -51
 - tccli/services/cdb/v20170320/examples.json +72 -0
 - tccli/services/cfg/cfg_client.py +106 -0
 - tccli/services/cfg/v20210820/api.json +199 -0
 - tccli/services/cfg/v20210820/examples.json +16 -0
 - tccli/services/config/__init__.py +4 -0
 - tccli/services/config/config_client.py +247 -0
 - tccli/services/config/v20220802/api.json +767 -0
 - tccli/services/config/v20220802/examples.json +21 -0
 - tccli/services/hai/v20230812/api.json +11 -0
 - tccli/services/tdmq/v20200217/api.json +50 -30
 - tccli/services/tdmq/v20200217/examples.json +2 -2
 - tccli/services/teo/v20220901/api.json +51 -40
 - tccli/services/teo/v20220901/examples.json +24 -24
 - tccli/services/tke/v20180525/api.json +18 -8
 - tccli/services/tke/v20180525/examples.json +2 -2
 - tccli/services/tse/tse_client.py +159 -0
 - tccli/services/tse/v20201207/api.json +147 -0
 - tccli/services/tse/v20201207/examples.json +24 -0
 - tccli/services/vod/v20180717/api.json +278 -24
 - tccli/services/vod/v20180717/examples.json +4 -4
 - tccli/services/vrs/v20200824/examples.json +1 -1
 - tccli/services/waf/v20180125/api.json +3 -3
 - {tccli-3.0.1005.1.dist-info → tccli-3.0.1006.1.dist-info}/METADATA +2 -2
 - {tccli-3.0.1005.1.dist-info → tccli-3.0.1006.1.dist-info}/RECORD +61 -41
 - {tccli-3.0.1005.1.dist-info → tccli-3.0.1006.1.dist-info}/WHEEL +0 -0
 - {tccli-3.0.1005.1.dist-info → tccli-3.0.1006.1.dist-info}/entry_points.txt +0 -0
 - {tccli-3.0.1005.1.dist-info → tccli-3.0.1006.1.dist-info}/license_files/LICENSE +0 -0
 
| 
         @@ -0,0 +1,247 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- coding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            import os
         
     | 
| 
      
 3 
     | 
    
         
            +
            import sys
         
     | 
| 
      
 4 
     | 
    
         
            +
            import six
         
     | 
| 
      
 5 
     | 
    
         
            +
            import json
         
     | 
| 
      
 6 
     | 
    
         
            +
            import tccli.options_define as OptionsDefine
         
     | 
| 
      
 7 
     | 
    
         
            +
            import tccli.format_output as FormatOutput
         
     | 
| 
      
 8 
     | 
    
         
            +
            from tccli import __version__
         
     | 
| 
      
 9 
     | 
    
         
            +
            from tccli.utils import Utils
         
     | 
| 
      
 10 
     | 
    
         
            +
            from tccli.exceptions import ConfigurationError, ClientError, ParamError
         
     | 
| 
      
 11 
     | 
    
         
            +
            from tencentcloud.common import credential
         
     | 
| 
      
 12 
     | 
    
         
            +
            from tencentcloud.common.profile.http_profile import HttpProfile
         
     | 
| 
      
 13 
     | 
    
         
            +
            from tencentcloud.common.profile.client_profile import ClientProfile
         
     | 
| 
      
 14 
     | 
    
         
            +
            from tencentcloud.config.v20220802 import config_client as config_client_v20220802
         
     | 
| 
      
 15 
     | 
    
         
            +
            from tencentcloud.config.v20220802 import models as models_v20220802
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            from jmespath import search
         
     | 
| 
      
 18 
     | 
    
         
            +
            import time
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            def doListAggregateConfigRules(args, parsed_globals):
         
     | 
| 
      
 21 
     | 
    
         
            +
                g_param = parse_global_arg(parsed_globals)
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
         
     | 
| 
      
 24 
     | 
    
         
            +
                    cred = credential.CVMRoleCredential()
         
     | 
| 
      
 25 
     | 
    
         
            +
                elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
         
     | 
| 
      
 26 
     | 
    
         
            +
                    cred = credential.STSAssumeRoleCredential(
         
     | 
| 
      
 27 
     | 
    
         
            +
                        g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
         
     | 
| 
      
 28 
     | 
    
         
            +
                        g_param[OptionsDefine.RoleSessionName.replace('-', '_')]
         
     | 
| 
      
 29 
     | 
    
         
            +
                    )
         
     | 
| 
      
 30 
     | 
    
         
            +
                elif os.getenv(OptionsDefine.ENV_TKE_REGION)             and os.getenv(OptionsDefine.ENV_TKE_PROVIDER_ID)             and os.getenv(OptionsDefine.ENV_TKE_WEB_IDENTITY_TOKEN_FILE)             and os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN):
         
     | 
| 
      
 31 
     | 
    
         
            +
                    cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
         
     | 
| 
      
 32 
     | 
    
         
            +
                else:
         
     | 
| 
      
 33 
     | 
    
         
            +
                    cred = credential.Credential(
         
     | 
| 
      
 34 
     | 
    
         
            +
                        g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
         
     | 
| 
      
 35 
     | 
    
         
            +
                    )
         
     | 
| 
      
 36 
     | 
    
         
            +
                http_profile = HttpProfile(
         
     | 
| 
      
 37 
     | 
    
         
            +
                    reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
         
     | 
| 
      
 38 
     | 
    
         
            +
                    reqMethod="POST",
         
     | 
| 
      
 39 
     | 
    
         
            +
                    endpoint=g_param[OptionsDefine.Endpoint],
         
     | 
| 
      
 40 
     | 
    
         
            +
                    proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
         
     | 
| 
      
 41 
     | 
    
         
            +
                )
         
     | 
| 
      
 42 
     | 
    
         
            +
                profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
         
     | 
| 
      
 43 
     | 
    
         
            +
                if g_param[OptionsDefine.Language]:
         
     | 
| 
      
 44 
     | 
    
         
            +
                    profile.language = g_param[OptionsDefine.Language]
         
     | 
| 
      
 45 
     | 
    
         
            +
                mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
         
     | 
| 
      
 46 
     | 
    
         
            +
                client = mod.ConfigClient(cred, g_param[OptionsDefine.Region], profile)
         
     | 
| 
      
 47 
     | 
    
         
            +
                client._sdkVersion += ("_CLI_" + __version__)
         
     | 
| 
      
 48 
     | 
    
         
            +
                models = MODELS_MAP[g_param[OptionsDefine.Version]]
         
     | 
| 
      
 49 
     | 
    
         
            +
                model = models.ListAggregateConfigRulesRequest()
         
     | 
| 
      
 50 
     | 
    
         
            +
                model.from_json_string(json.dumps(args))
         
     | 
| 
      
 51 
     | 
    
         
            +
                start_time = time.time()
         
     | 
| 
      
 52 
     | 
    
         
            +
                while True:
         
     | 
| 
      
 53 
     | 
    
         
            +
                    rsp = client.ListAggregateConfigRules(model)
         
     | 
| 
      
 54 
     | 
    
         
            +
                    result = rsp.to_json_string()
         
     | 
| 
      
 55 
     | 
    
         
            +
                    try:
         
     | 
| 
      
 56 
     | 
    
         
            +
                        json_obj = json.loads(result)
         
     | 
| 
      
 57 
     | 
    
         
            +
                    except TypeError as e:
         
     | 
| 
      
 58 
     | 
    
         
            +
                        json_obj = json.loads(result.decode('utf-8'))  # python3.3
         
     | 
| 
      
 59 
     | 
    
         
            +
                    if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
         
     | 
| 
      
 60 
     | 
    
         
            +
                        break
         
     | 
| 
      
 61 
     | 
    
         
            +
                    cur_time = time.time()
         
     | 
| 
      
 62 
     | 
    
         
            +
                    if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
         
     | 
| 
      
 63 
     | 
    
         
            +
                        raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
         
     | 
| 
      
 64 
     | 
    
         
            +
                        (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
         
     | 
| 
      
 65 
     | 
    
         
            +
                        search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
         
     | 
| 
      
 66 
     | 
    
         
            +
                    else:
         
     | 
| 
      
 67 
     | 
    
         
            +
                        print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
         
     | 
| 
      
 68 
     | 
    
         
            +
                    time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
         
     | 
| 
      
 69 
     | 
    
         
            +
                FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
            def doListConfigRules(args, parsed_globals):
         
     | 
| 
      
 73 
     | 
    
         
            +
                g_param = parse_global_arg(parsed_globals)
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                if g_param[OptionsDefine.UseCVMRole.replace('-', '_')]:
         
     | 
| 
      
 76 
     | 
    
         
            +
                    cred = credential.CVMRoleCredential()
         
     | 
| 
      
 77 
     | 
    
         
            +
                elif g_param[OptionsDefine.RoleArn.replace('-', '_')] and g_param[OptionsDefine.RoleSessionName.replace('-', '_')]:
         
     | 
| 
      
 78 
     | 
    
         
            +
                    cred = credential.STSAssumeRoleCredential(
         
     | 
| 
      
 79 
     | 
    
         
            +
                        g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.RoleArn.replace('-', '_')],
         
     | 
| 
      
 80 
     | 
    
         
            +
                        g_param[OptionsDefine.RoleSessionName.replace('-', '_')]
         
     | 
| 
      
 81 
     | 
    
         
            +
                    )
         
     | 
| 
      
 82 
     | 
    
         
            +
                elif os.getenv(OptionsDefine.ENV_TKE_REGION)             and os.getenv(OptionsDefine.ENV_TKE_PROVIDER_ID)             and os.getenv(OptionsDefine.ENV_TKE_WEB_IDENTITY_TOKEN_FILE)             and os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN):
         
     | 
| 
      
 83 
     | 
    
         
            +
                    cred = credential.DefaultTkeOIDCRoleArnProvider().get_credentials()
         
     | 
| 
      
 84 
     | 
    
         
            +
                else:
         
     | 
| 
      
 85 
     | 
    
         
            +
                    cred = credential.Credential(
         
     | 
| 
      
 86 
     | 
    
         
            +
                        g_param[OptionsDefine.SecretId], g_param[OptionsDefine.SecretKey], g_param[OptionsDefine.Token]
         
     | 
| 
      
 87 
     | 
    
         
            +
                    )
         
     | 
| 
      
 88 
     | 
    
         
            +
                http_profile = HttpProfile(
         
     | 
| 
      
 89 
     | 
    
         
            +
                    reqTimeout=60 if g_param[OptionsDefine.Timeout] is None else int(g_param[OptionsDefine.Timeout]),
         
     | 
| 
      
 90 
     | 
    
         
            +
                    reqMethod="POST",
         
     | 
| 
      
 91 
     | 
    
         
            +
                    endpoint=g_param[OptionsDefine.Endpoint],
         
     | 
| 
      
 92 
     | 
    
         
            +
                    proxy=g_param[OptionsDefine.HttpsProxy.replace('-', '_')]
         
     | 
| 
      
 93 
     | 
    
         
            +
                )
         
     | 
| 
      
 94 
     | 
    
         
            +
                profile = ClientProfile(httpProfile=http_profile, signMethod="HmacSHA256")
         
     | 
| 
      
 95 
     | 
    
         
            +
                if g_param[OptionsDefine.Language]:
         
     | 
| 
      
 96 
     | 
    
         
            +
                    profile.language = g_param[OptionsDefine.Language]
         
     | 
| 
      
 97 
     | 
    
         
            +
                mod = CLIENT_MAP[g_param[OptionsDefine.Version]]
         
     | 
| 
      
 98 
     | 
    
         
            +
                client = mod.ConfigClient(cred, g_param[OptionsDefine.Region], profile)
         
     | 
| 
      
 99 
     | 
    
         
            +
                client._sdkVersion += ("_CLI_" + __version__)
         
     | 
| 
      
 100 
     | 
    
         
            +
                models = MODELS_MAP[g_param[OptionsDefine.Version]]
         
     | 
| 
      
 101 
     | 
    
         
            +
                model = models.ListConfigRulesRequest()
         
     | 
| 
      
 102 
     | 
    
         
            +
                model.from_json_string(json.dumps(args))
         
     | 
| 
      
 103 
     | 
    
         
            +
                start_time = time.time()
         
     | 
| 
      
 104 
     | 
    
         
            +
                while True:
         
     | 
| 
      
 105 
     | 
    
         
            +
                    rsp = client.ListConfigRules(model)
         
     | 
| 
      
 106 
     | 
    
         
            +
                    result = rsp.to_json_string()
         
     | 
| 
      
 107 
     | 
    
         
            +
                    try:
         
     | 
| 
      
 108 
     | 
    
         
            +
                        json_obj = json.loads(result)
         
     | 
| 
      
 109 
     | 
    
         
            +
                    except TypeError as e:
         
     | 
| 
      
 110 
     | 
    
         
            +
                        json_obj = json.loads(result.decode('utf-8'))  # python3.3
         
     | 
| 
      
 111 
     | 
    
         
            +
                    if not g_param[OptionsDefine.Waiter] or search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj) == g_param['OptionsDefine.WaiterInfo']['to']:
         
     | 
| 
      
 112 
     | 
    
         
            +
                        break
         
     | 
| 
      
 113 
     | 
    
         
            +
                    cur_time = time.time()
         
     | 
| 
      
 114 
     | 
    
         
            +
                    if cur_time - start_time >= g_param['OptionsDefine.WaiterInfo']['timeout']:
         
     | 
| 
      
 115 
     | 
    
         
            +
                        raise ClientError('Request timeout, wait `%s` to `%s` timeout, last request is %s' %
         
     | 
| 
      
 116 
     | 
    
         
            +
                        (g_param['OptionsDefine.WaiterInfo']['expr'], g_param['OptionsDefine.WaiterInfo']['to'],
         
     | 
| 
      
 117 
     | 
    
         
            +
                        search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj)))
         
     | 
| 
      
 118 
     | 
    
         
            +
                    else:
         
     | 
| 
      
 119 
     | 
    
         
            +
                        print('Inquiry result is %s.' % search(g_param['OptionsDefine.WaiterInfo']['expr'], json_obj))
         
     | 
| 
      
 120 
     | 
    
         
            +
                    time.sleep(g_param['OptionsDefine.WaiterInfo']['interval'])
         
     | 
| 
      
 121 
     | 
    
         
            +
                FormatOutput.output("action", json_obj, g_param[OptionsDefine.Output], g_param[OptionsDefine.Filter])
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
            CLIENT_MAP = {
         
     | 
| 
      
 125 
     | 
    
         
            +
                "v20220802": config_client_v20220802,
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
            }
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
            MODELS_MAP = {
         
     | 
| 
      
 130 
     | 
    
         
            +
                "v20220802": models_v20220802,
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
            }
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
            ACTION_MAP = {
         
     | 
| 
      
 135 
     | 
    
         
            +
                "ListAggregateConfigRules": doListAggregateConfigRules,
         
     | 
| 
      
 136 
     | 
    
         
            +
                "ListConfigRules": doListConfigRules,
         
     | 
| 
      
 137 
     | 
    
         
            +
             
     | 
| 
      
 138 
     | 
    
         
            +
            }
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
            AVAILABLE_VERSION_LIST = [
         
     | 
| 
      
 141 
     | 
    
         
            +
                "v20220802",
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
            ]
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
             
     | 
| 
      
 146 
     | 
    
         
            +
            def action_caller():
         
     | 
| 
      
 147 
     | 
    
         
            +
                return ACTION_MAP
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
            def parse_global_arg(parsed_globals):
         
     | 
| 
      
 151 
     | 
    
         
            +
                g_param = parsed_globals
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
                is_exist_profile = True
         
     | 
| 
      
 154 
     | 
    
         
            +
                if not parsed_globals["profile"]:
         
     | 
| 
      
 155 
     | 
    
         
            +
                    is_exist_profile = False
         
     | 
| 
      
 156 
     | 
    
         
            +
                    g_param["profile"] = os.environ.get("TCCLI_PROFILE", "default")
         
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
      
 158 
     | 
    
         
            +
                configure_path = os.path.join(os.path.expanduser("~"), ".tccli")
         
     | 
| 
      
 159 
     | 
    
         
            +
                is_conf_exist, conf_path = Utils.file_existed(configure_path, g_param["profile"] + ".configure")
         
     | 
| 
      
 160 
     | 
    
         
            +
                is_cred_exist, cred_path = Utils.file_existed(configure_path, g_param["profile"] + ".credential")
         
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
      
 162 
     | 
    
         
            +
                conf = {}
         
     | 
| 
      
 163 
     | 
    
         
            +
                cred = {}
         
     | 
| 
      
 164 
     | 
    
         
            +
             
     | 
| 
      
 165 
     | 
    
         
            +
                if is_conf_exist:
         
     | 
| 
      
 166 
     | 
    
         
            +
                    conf = Utils.load_json_msg(conf_path)
         
     | 
| 
      
 167 
     | 
    
         
            +
                if is_cred_exist:
         
     | 
| 
      
 168 
     | 
    
         
            +
                    cred = Utils.load_json_msg(cred_path)
         
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
                if not (isinstance(conf, dict) and isinstance(cred, dict)):
         
     | 
| 
      
 171 
     | 
    
         
            +
                    raise ConfigurationError(
         
     | 
| 
      
 172 
     | 
    
         
            +
                        "file: %s or %s is not json format"
         
     | 
| 
      
 173 
     | 
    
         
            +
                        % (g_param["profile"] + ".configure", g_param["profile"] + ".credential"))
         
     | 
| 
      
 174 
     | 
    
         
            +
             
     | 
| 
      
 175 
     | 
    
         
            +
                if OptionsDefine.Token not in cred:
         
     | 
| 
      
 176 
     | 
    
         
            +
                    cred[OptionsDefine.Token] = None
         
     | 
| 
      
 177 
     | 
    
         
            +
             
     | 
| 
      
 178 
     | 
    
         
            +
                if not is_exist_profile:
         
     | 
| 
      
 179 
     | 
    
         
            +
                    if os.environ.get(OptionsDefine.ENV_SECRET_ID) and os.environ.get(OptionsDefine.ENV_SECRET_KEY):
         
     | 
| 
      
 180 
     | 
    
         
            +
                        cred[OptionsDefine.SecretId] = os.environ.get(OptionsDefine.ENV_SECRET_ID)
         
     | 
| 
      
 181 
     | 
    
         
            +
                        cred[OptionsDefine.SecretKey] = os.environ.get(OptionsDefine.ENV_SECRET_KEY)
         
     | 
| 
      
 182 
     | 
    
         
            +
                        cred[OptionsDefine.Token] = os.environ.get(OptionsDefine.ENV_TOKEN)
         
     | 
| 
      
 183 
     | 
    
         
            +
             
     | 
| 
      
 184 
     | 
    
         
            +
                    if os.environ.get(OptionsDefine.ENV_REGION):
         
     | 
| 
      
 185 
     | 
    
         
            +
                        conf[OptionsDefine.SysParam][OptionsDefine.Region] = os.environ.get(OptionsDefine.ENV_REGION)
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
                    if os.environ.get(OptionsDefine.ENV_ROLE_ARN) and os.environ.get(OptionsDefine.ENV_ROLE_SESSION_NAME):
         
     | 
| 
      
 188 
     | 
    
         
            +
                        cred[OptionsDefine.RoleArn] = os.environ.get(OptionsDefine.ENV_ROLE_ARN)
         
     | 
| 
      
 189 
     | 
    
         
            +
                        cred[OptionsDefine.RoleSessionName] = os.environ.get(OptionsDefine.ENV_ROLE_SESSION_NAME)
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
      
 191 
     | 
    
         
            +
                for param in g_param.keys():
         
     | 
| 
      
 192 
     | 
    
         
            +
                    if g_param[param] is None:
         
     | 
| 
      
 193 
     | 
    
         
            +
                        if param in [OptionsDefine.SecretKey, OptionsDefine.SecretId, OptionsDefine.Token]:
         
     | 
| 
      
 194 
     | 
    
         
            +
                            if param in cred:
         
     | 
| 
      
 195 
     | 
    
         
            +
                                g_param[param] = cred[param]
         
     | 
| 
      
 196 
     | 
    
         
            +
                            elif not (g_param[OptionsDefine.UseCVMRole.replace('-', '_')]
         
     | 
| 
      
 197 
     | 
    
         
            +
                                      or os.getenv(OptionsDefine.ENV_TKE_ROLE_ARN)):
         
     | 
| 
      
 198 
     | 
    
         
            +
                                raise ConfigurationError("%s is invalid" % param)
         
     | 
| 
      
 199 
     | 
    
         
            +
                        elif param in [OptionsDefine.Region, OptionsDefine.Output, OptionsDefine.Language]:
         
     | 
| 
      
 200 
     | 
    
         
            +
                            if param in conf[OptionsDefine.SysParam]:
         
     | 
| 
      
 201 
     | 
    
         
            +
                                g_param[param] = conf[OptionsDefine.SysParam][param]
         
     | 
| 
      
 202 
     | 
    
         
            +
                            elif param != OptionsDefine.Language:
         
     | 
| 
      
 203 
     | 
    
         
            +
                                raise ConfigurationError("%s is invalid" % param)
         
     | 
| 
      
 204 
     | 
    
         
            +
                        elif param.replace('_', '-') in [OptionsDefine.RoleArn, OptionsDefine.RoleSessionName]:
         
     | 
| 
      
 205 
     | 
    
         
            +
                            if param.replace('_', '-') in cred:
         
     | 
| 
      
 206 
     | 
    
         
            +
                                g_param[param] = cred[param.replace('_', '-')]
         
     | 
| 
      
 207 
     | 
    
         
            +
             
     | 
| 
      
 208 
     | 
    
         
            +
                try:
         
     | 
| 
      
 209 
     | 
    
         
            +
                    if g_param[OptionsDefine.ServiceVersion]:
         
     | 
| 
      
 210 
     | 
    
         
            +
                        g_param[OptionsDefine.Version] = "v" + g_param[OptionsDefine.ServiceVersion].replace('-', '')
         
     | 
| 
      
 211 
     | 
    
         
            +
                    else:
         
     | 
| 
      
 212 
     | 
    
         
            +
                        version = conf["config"][OptionsDefine.Version]
         
     | 
| 
      
 213 
     | 
    
         
            +
                        g_param[OptionsDefine.Version] = "v" + version.replace('-', '')
         
     | 
| 
      
 214 
     | 
    
         
            +
             
     | 
| 
      
 215 
     | 
    
         
            +
                    if g_param[OptionsDefine.Endpoint] is None:
         
     | 
| 
      
 216 
     | 
    
         
            +
                        g_param[OptionsDefine.Endpoint] = conf["config"][OptionsDefine.Endpoint]
         
     | 
| 
      
 217 
     | 
    
         
            +
                except Exception as err:
         
     | 
| 
      
 218 
     | 
    
         
            +
                    raise ConfigurationError("config file:%s error, %s" % (conf_path, str(err)))
         
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
                if g_param[OptionsDefine.Version] not in AVAILABLE_VERSION_LIST:
         
     | 
| 
      
 221 
     | 
    
         
            +
                    raise Exception("available versions: %s" % " ".join(AVAILABLE_VERSION_LIST))
         
     | 
| 
      
 222 
     | 
    
         
            +
             
     | 
| 
      
 223 
     | 
    
         
            +
                if g_param[OptionsDefine.Waiter]:
         
     | 
| 
      
 224 
     | 
    
         
            +
                    param = eval(g_param[OptionsDefine.Waiter])
         
     | 
| 
      
 225 
     | 
    
         
            +
                    if 'expr' not in param:
         
     | 
| 
      
 226 
     | 
    
         
            +
                        raise Exception('`expr` in `--waiter` must be defined')
         
     | 
| 
      
 227 
     | 
    
         
            +
                    if 'to' not in param:
         
     | 
| 
      
 228 
     | 
    
         
            +
                        raise Exception('`to` in `--waiter` must be defined')
         
     | 
| 
      
 229 
     | 
    
         
            +
                    if 'timeout' not in param:
         
     | 
| 
      
 230 
     | 
    
         
            +
                        if 'waiter' in conf and 'timeout' in conf['waiter']:
         
     | 
| 
      
 231 
     | 
    
         
            +
                            param['timeout'] = conf['waiter']['timeout']
         
     | 
| 
      
 232 
     | 
    
         
            +
                        else:
         
     | 
| 
      
 233 
     | 
    
         
            +
                            param['timeout'] = 180
         
     | 
| 
      
 234 
     | 
    
         
            +
                    if 'interval' not in param:
         
     | 
| 
      
 235 
     | 
    
         
            +
                        if 'waiter' in conf and 'interval' in conf['waiter']:
         
     | 
| 
      
 236 
     | 
    
         
            +
                            param['interval'] = conf['waiter']['interval']
         
     | 
| 
      
 237 
     | 
    
         
            +
                        else:
         
     | 
| 
      
 238 
     | 
    
         
            +
                            param['interval'] = 5
         
     | 
| 
      
 239 
     | 
    
         
            +
                    param['interval'] = min(param['interval'], param['timeout'])
         
     | 
| 
      
 240 
     | 
    
         
            +
                    g_param['OptionsDefine.WaiterInfo'] = param
         
     | 
| 
      
 241 
     | 
    
         
            +
             
     | 
| 
      
 242 
     | 
    
         
            +
                if six.PY2:
         
     | 
| 
      
 243 
     | 
    
         
            +
                    for key, value in g_param.items():
         
     | 
| 
      
 244 
     | 
    
         
            +
                        if isinstance(value, six.text_type):
         
     | 
| 
      
 245 
     | 
    
         
            +
                            g_param[key] = value.encode('utf-8')
         
     | 
| 
      
 246 
     | 
    
         
            +
                return g_param
         
     | 
| 
      
 247 
     | 
    
         
            +
             
     |