Skip to content

Commit 531d3d9

Browse files
committed
Get Account Usage improvements and error handling
1 parent b049151 commit 531d3d9

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

components/cloudinary/actions/get-account-usage-details/get-account-usage-details.mjs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@ import cloudinary from "../../cloudinary.app.mjs";
33
export default {
44
key: "cloudinary-get-account-usage-details",
55
name: "Get Account Usage Details",
6-
description: "Enables you to get a report on the status of your Cloudinary account usage details, including storage, credits, bandwidth, requests, number of resources, and add-on usage. [See the documentation](https://cloudinary.com/documentation/admin_api#usage)",
7-
version: "0.1.2",
6+
description: "Gets a report of your Cloudinary account usage details, including storage, credits, bandwidth, requests, number of resources, and add-on usage. [See the documentation](https://cloudinary.com/documentation/admin_api#usage)",
7+
version: "0.2.{{ts}}",
88
type: "action",
99
props: {
1010
cloudinary,
11+
dateInfo: {
12+
type: "alert",
13+
alertType: "info",
14+
content: "If `Date` is not specified, it defaults to the current date."
15+
},
1116
date: {
1217
type: "string",
1318
label: "Date",
14-
description: "The date for the usage report. Must be within the last 3 months and given in the format: `dd-mm-yyyy`. Default: the current date",
19+
description: "The date for the usage report, in the `yyyy-mm-dd` format, e.g. `2019-07-21`. Must be between yesterday and the last 3 months.",
1520
optional: true,
1621
},
1722
},
@@ -20,12 +25,17 @@ export default {
2025
date: this.date,
2126
};
2227

28+
try {
2329
const response = await this.cloudinary.getUsage(options);
2430

2531
if (response) {
26-
$.export("$summary", "Successfully retrieved usage details.");
32+
$.export("$summary", "Successfully retrieved usage details");
2733
}
2834

2935
return response;
36+
}
37+
catch (err) {
38+
throw new Error(`Cloudinary error response: ${err.error?.message ?? JSON.stringify(err)}`);
39+
}
3040
},
3141
};

0 commit comments

Comments
 (0)