-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
88 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
'use strict'; | ||
// This file is auto-generated, don't edit it | ||
// 依赖的模块可通过下载工程中的模块依赖文件或右上角的获取 SDK 依赖信息查看 | ||
const ESA20240910 = require('@alicloud/esa20240910'); | ||
const OpenApi = require('@alicloud/openapi-client'); | ||
const Console = require('@alicloud/tea-console'); | ||
const Util = require('@alicloud/tea-util'); | ||
const Tea = require('@alicloud/tea-typescript'); | ||
|
||
class Client { | ||
|
||
/** | ||
* 使用 AK&SK 初始化账号 Client | ||
* @return Client | ||
* @throws Exception | ||
*/ | ||
static createClient() { | ||
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。 | ||
// 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378664.html。 | ||
let config = new OpenApi.Config({ | ||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。 | ||
accessKeyId: process.env['ACCESS_KEY_ID'], | ||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。 | ||
accessKeySecret: process.env['ACCESS_KEY_SECRET'], | ||
}); | ||
// Endpoint 请参考 https://api.aliyun.com/product/ESA | ||
config.endpoint = `esa.cn-hangzhou.aliyuncs.com`; | ||
return new ESA20240910.default(config); | ||
} | ||
|
||
static async main(args) { | ||
let client = Client.createClient(); | ||
let content = new ESA20240910.PurgeCachesRequestContent({ | ||
// Array, 可选,目录刷新列表,类型为 directory 时需要指定。 > 每次最多 100 条,每次最多包含 10 个不同域名。 | ||
directories: [ | ||
'https://www.eallion.com/' | ||
], | ||
}); | ||
let purgeCachesRequest = new ESA20240910.PurgeCachesRequest({ | ||
type: 'directory', | ||
siteId: process.env['ESA_SITE_ID'], | ||
// Object, 可选 | ||
content: content, | ||
}); | ||
let runtime = new Util.RuntimeOptions({ }); | ||
try { | ||
let resp = await client.purgeCachesWithOptions(purgeCachesRequest, runtime); | ||
Console.default.log(Util.default.toJSONString(resp)); | ||
} catch (error) { | ||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。 | ||
// 错误 message | ||
console.log(error.message); | ||
// 诊断地址 | ||
console.log(error.data["Recommend"]); | ||
Util.default.assertAsString(error.message); | ||
} | ||
} | ||
|
||
} | ||
|
||
exports.Client = Client; | ||
Client.main(process.argv.slice(2)); |