Beispiel #1
0
 def update_func_config(self, func, func_name, func_ns):
     req = models.UpdateFunctionConfigurationRequest()
     req.Namespace = func_ns
     req.FunctionName = func_name
     proper = func.get(tsmacro.Properties, {})
     req.Description = proper.get(tsmacro.Desc)
     req.MemorySize = proper.get(tsmacro.MemSize)
     req.Timeout = proper.get(tsmacro.Timeout)
     req.Environment = self._model_envs(proper.get(tsmacro.Envi, {}))
     req.VpcConfig = self._model_vpc(proper.get(tsmacro.VpcConfig))
     resp = self._client.UpdateFunctionConfiguration(req)
     return resp.to_json_string()
Beispiel #2
0
 def update_func_config(self, func, func_name, func_ns):
     req = models.UpdateFunctionConfigurationRequest()
     req.Namespace = func_ns
     req.FunctionName = func_name
     req.Description = getattr(func, "Description", None)
     req.MemorySize = getattr(func, "MemorySize", None)
     req.Timeout = getattr(func, "Timeout", None)
     req.Runtime = getattr(func, "Runtime", None)
     req.Environment = self._model_envs(getattr(func, "Environment", None))
     req.VpcConfig = self._model_vpc(getattr(func, "VpcConfig", None))
     resp = self._client.UpdateFunctionConfiguration(req)
     return resp.to_json_string()
Beispiel #3
0
def EnvWrite(FunctionName,
             Namespace,
             ms_id,
             ms_secret,
             refresh_token,
             Another=None):
    global SecretId, SecretKey, Region
    try:
        cred = credential.Credential(SecretId, SecretKey)
        client = scf_client.ScfClient(cred, Region)
    except TencentCloudSDKException as err:
        print(err)
    req = models.UpdateFunctionConfigurationRequest()
    params = '{"FunctionName":"' + FunctionName + '",'
    params += '"Namespace":"' + Namespace + '",'
    params += '"Environment":{"Variables":['
    params += '{"Key":"Region","Value":"' + Region + '"},'
    params += '{"Key":"refresh_token","Value":"' + refresh_token + '"},'
    params += '{"Key":"ms_id","Value":"' + ms_id + '"},'
    params += '{"Key":"ms_secret","Value":"' + ms_secret + '"},'
    params += '{"Key":"SecretId","Value":"' + SecretId + '"},'
    params += '{"Key":"SecretKey","Value":"' + SecretKey + '"},'
    if Another:
        for key in Another:
            if Another[key]:
                params += '{"Key":"' + key + '","Value":"' + Another[
                    key] + '"},'
    params = params.rstrip(",")
    params += ']}}'
    #print(params)
    req.from_json_string(params)
    try:
        # 以下照抄腾讯云sdk例程
        resp = client.UpdateFunctionConfiguration(req)
        print(resp.to_json_string())
    except TencentCloudSDKException as err:
        print(err)
    return