azion
Version:
Azion Packages for Edge Computing.
1,664 lines (1,663 loc) • 47 kB
JavaScript
const k = process.env.AZION_DEBUG && process.env.AZION_DEBUG === "true", s = (e) => e ?? process.env.AZION_TOKEN ?? "", i = (e) => e ?? !!k, $ = (e, d, t) => {
let r;
if (e && typeof e == "object") {
const a = Object.keys(e)[0];
if (a && typeof e[a] == "string")
r = e[a];
else if ("detail" in e && typeof e.detail == "string")
r = e.detail;
else if ("message" in e && typeof e.message == "string")
r = e.message;
else if ("error" in e) {
if (typeof e.error == "string")
r = e.error;
else if (typeof e.error == "object" && e.error !== null) {
const u = Object.keys(e.error)[0];
u && typeof e.error[u] == "string" ? r = e.error[u] : "message" in e.error && typeof e.error.message == "string" && (r = e.error.message);
}
}
} else typeof e == "string" && (r = e);
return {
message: r || t,
operation: d
};
};
async function g(e, d, t, r = !0) {
const a = await fetch(e, d);
if (!a.ok) {
const u = `HTTP error! Status: ${a.status} - ${a.statusText}`;
throw t && console.log(`Error in fetch: ${u}`), new Error(u);
}
if (r) {
const u = a.headers.get("content-type");
if (!u || !u.includes("application/json")) {
const o = `Expected JSON response, but got: ${await a.text()}`;
throw t && console.log(`Error in fetch: ${o}`), new Error(o);
}
return await a.json();
} else
return await a.text();
}
const U = "https://api.azionapi.net/edge_applications", ee = async (e, d, t, r) => {
try {
const { page: a = 1, page_size: u = 10, sort: n, order: c } = t || {}, o = new URLSearchParams();
return a && o.append("page", String(a)), u && o.append("page_size", String(u)), n && o.append("sort", n), c && o.append("order", c), await g(
`${U}/${d}/cache_settings${o.toString() ? `?${o.toString()}` : ""}`,
{
method: "GET",
headers: { Accept: "application/json; version=3", Authorization: `Token ${e}` }
},
r
);
} catch (a) {
throw r && console.error("Error getting cache settings:", a), a;
}
}, te = async (e, d, t, r) => {
try {
return await g(
`${U}/${d}/cache_settings/${t}`,
{
method: "GET",
headers: { Accept: "application/json; version=3", Authorization: `Token ${e}` }
},
r
);
} catch (a) {
throw r && console.error("Error getting cache setting by ID:", a), a;
}
}, re = async (e, d, t, r) => {
try {
return await g(
`${U}/${d}/cache_settings`,
{
method: "POST",
headers: {
Accept: "application/json; version=3",
"Content-Type": "application/json",
Authorization: `Token ${e}`
},
body: JSON.stringify(t)
},
r
);
} catch (a) {
throw r && console.error("Error creating cache setting:", a), a;
}
}, ae = async (e, d, t, r, a) => {
try {
return await g(
`${U}/${d}/cache_settings/${t}`,
{
method: "PATCH",
headers: {
Accept: "application/json; version=3",
"Content-Type": "application/json",
Authorization: `Token ${e}`
},
body: JSON.stringify(r)
},
a
);
} catch (u) {
throw a && console.error("Error updating cache setting:", u), u;
}
}, ce = async (e, d, t, r) => {
try {
return await g(
`${U}/${d}/cache_settings/${t}`,
{
method: "DELETE",
headers: { Accept: "application/json; version=3", Authorization: `Token ${e}` }
},
r
);
} catch (a) {
throw r && console.error("Error deleting cache setting:", a), a;
}
}, v = async (e, d, t, r) => {
try {
return { data: (await re(s(e), d, t, i(r?.debug))).results };
} catch (a) {
return {
error: {
message: a instanceof Error ? a.message : "Failed to create cache setting",
operation: "create cache setting"
}
};
}
}, R = async (e, d, t, r) => {
try {
return { data: (await te(s(e), d, t, i(r?.debug))).results };
} catch (a) {
return {
error: {
message: a instanceof Error ? a.message : "Failed to get cache setting",
operation: "get cache setting"
}
};
}
}, A = async (e, d, t, r) => {
try {
const a = await ee(s(e), d, t, i(r?.debug)), u = a.results.map((n) => ({
...n
}));
return {
data: {
count: a.count,
total_pages: a.total_pages,
schema_version: a.schema_version,
links: a.links,
results: u
// results do tipo AzionCacheSetting[]
}
};
} catch (a) {
return {
error: {
message: a instanceof Error ? a.message : "Failed to get cache settings",
operation: "get cache settings"
}
};
}
}, S = async (e, d, t, r, a) => {
try {
return { data: (await ae(
s(e),
d,
t,
r,
i(a?.debug)
)).results };
} catch (u) {
return {
error: {
message: u instanceof Error ? u.message : "Failed to update cache setting",
operation: "update cache setting"
}
};
}
}, m = async (e, d, t, r) => {
try {
return await ce(s(e), d, t, i(r?.debug)), { data: void 0 };
} catch (a) {
return {
error: {
message: a instanceof Error ? a.message : "Failed to delete cache setting",
operation: "delete cache setting"
}
};
}
}, Ce = ({
applicationId: e,
data: d,
options: t
}) => v(s(), e, d, t), je = ({
applicationId: e,
cacheSettingId: d,
options: t
}) => R(s(), e, d, t), qe = ({
applicationId: e,
params: d,
options: t
}) => A(s(), e, d, t), ze = ({
applicationId: e,
cacheSettingId: d,
data: t,
options: r
}) => S(s(), e, d, t, r), De = ({
applicationId: e,
cacheSettingId: d,
options: t
}) => m(s(), e, d, t), K = "https://api.azionapi.net/edge_applications", ne = async (e, d, t, r) => {
try {
const { page: a = 1, page_size: u = 10, sort: n, order: c } = t || {}, o = new URLSearchParams();
return a && o.append("page", String(a)), u && o.append("page_size", String(u)), n && o.append("sort", n), c && o.append("order", c), await g(
`${K}/${d}/device_groups${o.toString() ? `?${o.toString()}` : ""}`,
{
method: "GET",
headers: { Accept: "application/json; version=3", Authorization: `Token ${e}` }
},
r
);
} catch (a) {
throw r && console.error("Error getting device groups:", a), a;
}
}, de = async (e, d, t, r) => {
try {
return await g(
`${K}/${d}/device_groups/${t}`,
{
method: "GET",
headers: { Accept: "application/json; version=3", Authorization: `Token ${e}` }
},
r
);
} catch (a) {
throw r && console.error("Error getting device group by ID:", a), a;
}
}, ue = async (e, d, t, r) => {
try {
return await g(
`${K}/${d}/device_groups`,
{
method: "POST",
headers: {
Accept: "application/json; version=3",
"Content-Type": "application/json",
Authorization: `Token ${e}`
},
body: JSON.stringify(t)
},
r
);
} catch (a) {
throw r && console.error("Error creating device group:", a), a;
}
}, ie = async (e, d, t, r, a) => {
try {
return await g(
`${K}/${d}/device_groups/${t}`,
{
method: "PATCH",
headers: {
Accept: "application/json; version=3",
"Content-Type": "application/json",
Authorization: `Token ${e}`
},
body: JSON.stringify(r)
},
a
);
} catch (u) {
throw a && console.error("Error updating device group:", u), u;
}
}, se = async (e, d, t, r) => {
try {
return await g(
`${K}/${d}/device_groups/${t}`,
{
method: "DELETE",
headers: { Accept: "application/json; version=3", Authorization: `Token ${e}` }
},
r
);
} catch (a) {
throw r && console.error("Error deleting device group:", a), a;
}
}, w = async (e, d, t, r) => {
try {
const { results: a } = await ue(s(e), d, t, i(r?.debug));
return { data: a };
} catch (a) {
return {
error: {
message: a instanceof Error ? a.message : "Failed to create device group",
operation: "create device group"
}
};
}
}, E = async (e, d, t, r) => {
try {
return await se(s(e), d, t, i(r?.debug)), { data: void 0 };
} catch (a) {
return {
error: {
message: a instanceof Error ? a.message : "Failed to delete device group",
operation: "delete device group"
}
};
}
}, T = async (e, d, t, r) => {
try {
const { results: a } = await de(s(e), d, t, i(r?.debug));
return { data: a };
} catch (a) {
return {
error: {
message: a instanceof Error ? a.message : "Failed to get device group",
operation: "get device group"
}
};
}
}, F = async (e, d, t, r) => {
try {
return { data: await ne(s(e), d, t, i(r?.debug)) };
} catch (a) {
return {
error: {
message: a instanceof Error ? a.message : "Failed to get device groups",
operation: "get device groups"
}
};
}
}, G = async (e, d, t, r, a) => {
try {
const { results: u } = await ie(
s(e),
d,
t,
r,
i(a?.debug)
);
return { data: u };
} catch (u) {
return {
error: {
message: u instanceof Error ? u.message : "Failed to update device group",
operation: "update device group"
}
};
}
}, _e = ({
applicationId: e,
data: d,
options: t
}) => w(s(), e, d, t), Me = ({
applicationId: e,
deviceGroupId: d,
options: t
}) => E(s(), e, d, t), We = ({
applicationId: e,
deviceGroupId: d,
options: t
}) => T(s(), e, d, t), Le = ({
applicationId: e,
params: d,
options: t
}) => F(s(), e, d, t), Pe = ({
applicationId: e,
deviceGroupId: d,
data: t,
options: r
}) => G(s(), e, d, t, r), N = "https://api.azionapi.net/edge_applications", ge = async (e, d, t, r) => {
try {
const { page: a = 1, page_size: u = 10, sort: n, order_by: c, filter: o } = t || {}, l = new URLSearchParams();
return a && l.append("page", String(a)), u && l.append("page_size", String(u)), n && l.append("sort", n), c && l.append("order_by", c), o && l.append("filter", o), await g(
`${N}/${d}/functions_instances${l.toString() ? `?${l.toString()}` : ""}`,
{
method: "GET",
headers: { Accept: "application/json; version=3", Authorization: `Token ${e}` }
},
r
);
} catch (a) {
throw r && console.error("Error listing function instances:", a), a;
}
}, oe = async (e, d, t, r) => {
try {
return await g(
`${N}/${d}/functions_instances/${t}`,
{
method: "GET",
headers: { Accept: "application/json; version=3", Authorization: `Token ${e}` }
},
r
);
} catch (a) {
throw r && console.error("Error getting function instance by ID:", a), a;
}
}, le = async (e, d, t, r) => {
try {
const a = await g(
`${N}/${d}/functions_instances`,
{
method: "POST",
headers: {
Accept: "application/json; version=3",
"Content-Type": "application/json",
Authorization: `Token ${e}`
},
body: JSON.stringify(t)
},
r
);
return r && console.log("Response:", a), a;
} catch (a) {
throw r && console.error("Error creating function instance:", a), a;
}
}, pe = async (e, d, t, r, a) => {
try {
return await g(
`${N}/${d}/functions_instances/${t}`,
{
method: "PATCH",
headers: {
Accept: "application/json; version=3",
"Content-Type": "application/json",
Authorization: `Token ${e}`
},
body: JSON.stringify(r)
},
a
);
} catch (u) {
throw a && console.error("Error updating function instance:", u), u;
}
}, he = async (e, d, t, r) => {
try {
return await g(
`${N}/${d}/functions_instances/${t}`,
{
method: "DELETE",
headers: { Accept: "application/json; version=3", Authorization: `Token ${e}` }
},
r
);
} catch (a) {
throw r && console.error("Error deleting function instance:", a), a;
}
}, O = async (e, d, t, r) => {
try {
return { data: (await le(
s(e),
d,
t,
i(r?.debug)
)).results };
} catch (a) {
return {
error: {
message: a instanceof Error ? a.message : "Failed to create function instance",
operation: "create function instance"
}
};
}
}, C = async (e, d, t, r) => {
try {
return await he(s(e), d, t, i(r?.debug)), { data: void 0 };
} catch (a) {
return {
error: {
message: a instanceof Error ? a.message : "Failed to delete function instance",
operation: "delete function instance"
}
};
}
}, j = async (e, d, t, r) => {
try {
const { results: a } = await oe(
s(e),
d,
t,
i(r?.debug)
);
return { data: a };
} catch (a) {
return {
error: {
message: a instanceof Error ? a.message : "Failed to get function instance",
operation: "get function instance"
}
};
}
}, q = async (e, d, t, r) => {
try {
return { data: await ge(s(e), d, t, i(r?.debug)) };
} catch (a) {
return {
error: {
message: a instanceof Error ? a.message : "Failed to get function instances",
operation: "get function instances"
}
};
}
}, z = async (e, d, t, r, a) => {
try {
const { results: u } = await pe(
s(e),
d,
t,
r,
i(a?.debug)
);
return { data: u };
} catch (u) {
return {
error: {
message: u instanceof Error ? u.message : "Failed to update function instance",
operation: "update function instance"
}
};
}
}, Ue = ({
applicationId: e,
data: d,
options: t
}) => O(s(), e, d, t), Ke = ({
applicationId: e,
functionInstanceId: d,
options: t
}) => C(s(), e, d, t), Ne = ({
applicationId: e,
functionInstanceId: d,
options: t
}) => j(s(), e, d, t), Je = ({
applicationId: e,
params: d,
options: t
}) => q(s(), e, d, t), Be = ({
applicationId: e,
functionInstanceId: d,
data: t,
options: r
}) => z(s(), e, d, t, r), J = "https://api.azionapi.net/edge_applications", be = async (e, d, t, r) => {
try {
const { page: a = 1, page_size: u = 10, sort: n, order: c, filter: o } = t || {}, l = new URLSearchParams();
a && l.append("page", String(a)), u && l.append("page_size", String(u)), n && l.append("sort", n), c && l.append("order", c), o && l.append("filter", o);
const I = `${J}/${d}/origins${l.toString() ? `?${l.toString()}` : ""}`;
return r && (console.log("Request URL:", I), console.log("Request headers:", {
Accept: "application/json; version=3",
Authorization: `Token ${e}`
})), await g(
I,
{
method: "GET",
headers: {
Accept: "application/json; version=3",
Authorization: `Token ${e}`
}
},
r
);
} catch (a) {
throw r && console.error("Error listing origins:", a), a;
}
}, ye = async (e, d, t, r) => {
try {
const a = `${J}/${d}/origins/${t}`;
return r && (console.log("Request URL:", a), console.log("Request headers:", {
Accept: "application/json; version=3",
Authorization: `Token ${e}`
})), await g(
a,
{
method: "GET",
headers: {
Accept: "application/json; version=3",
Authorization: `Token ${e}`
}
},
r
);
} catch (a) {
throw r && console.error("Error getting origin by key:", a), a;
}
}, fe = async (e, d, t, r) => {
try {
const a = `${J}/${d}/origins`;
return r && (console.log("Request URL:", a), console.log("Request headers:", {
Accept: "application/json; version=3",
"Content-Type": "application/json",
Authorization: `Token ${e}`
}), console.log("Request body:", t)), await g(
a,
{
method: "POST",
headers: {
Accept: "application/json; version=3",
"Content-Type": "application/json",
Authorization: `Token ${e}`
},
body: JSON.stringify(t)
},
r
);
} catch (a) {
throw r && console.error("Error creating origin:", a), a;
}
}, Ie = async (e, d, t, r, a) => {
try {
const u = `${J}/${d}/origins/${t}`;
return a && (console.log("Request URL:", u), console.log("Request headers:", {
Accept: "application/json; version=3",
"Content-Type": "application/json",
Authorization: `Token ${e}`
}), console.log("Request body:", r)), await g(
u,
{
method: "PATCH",
headers: {
Accept: "application/json; version=3",
"Content-Type": "application/json",
Authorization: `Token ${e}`
},
body: JSON.stringify(r)
},
a
);
} catch (u) {
throw a && console.error("Error updating origin:", u), u;
}
}, $e = async (e, d, t, r) => {
try {
const a = `${J}/${d}/origins/${t}`;
return r && (console.log("Request URL:", a), console.log("Request headers:", {
Accept: "application/json; version=3",
Authorization: `Token ${e}`
})), await g(
a,
{
method: "DELETE",
headers: {
Accept: "application/json; version=3",
Authorization: `Token ${e}`
}
},
r
);
} catch (a) {
throw r && console.error("Error deleting origin:", a), a;
}
}, D = async (e, d, t, r) => {
try {
const { results: a } = await fe(e, d, t, i(r?.debug));
return { data: a };
} catch (a) {
return {
error: {
message: a instanceof Error ? a.message : "Failed to create origin",
operation: "create origin"
}
};
}
}, _ = async (e, d, t, r) => {
try {
return await $e(e, d, t, i(r?.debug)), { data: void 0 };
} catch (a) {
return {
error: {
message: a instanceof Error ? a.message : "Failed to delete origin",
operation: "delete origin"
}
};
}
}, M = async (e, d, t, r) => {
try {
const { results: a } = await ye(e, d, t, i(r?.debug));
return { data: a };
} catch (a) {
return {
error: {
message: a instanceof Error ? a.message : "Failed to get origin",
operation: "get origin"
}
};
}
}, W = async (e, d, t, r) => {
try {
return { data: await be(e, d, t, i(r?.debug)) };
} catch (a) {
return {
error: {
message: a instanceof Error ? a.message : "Failed to get origins",
operation: "get origins"
}
};
}
}, L = async (e, d, t, r, a) => {
try {
const { results: u } = await Ie(e, d, t, r, i(a?.debug));
return { data: u };
} catch (u) {
return {
error: {
message: u instanceof Error ? u.message : "Failed to update origin",
operation: "update origin"
}
};
}
}, He = ({
applicationId: e,
data: d,
options: t
}) => D(s(), e, d, t), xe = ({
applicationId: e,
originKey: d,
options: t
}) => _(s(), e, d, t), Ze = ({
applicationId: e,
originKey: d,
options: t
}) => M(s(), e, d, t), Ve = ({
applicationId: e,
params: d,
options: t
}) => W(s(), e, d, t), Qe = ({
applicationId: e,
originKey: d,
data: t,
options: r
}) => L(s(), e, d, t, r), B = "https://api.azionapi.net/edge_applications", ve = async (e, d, t, r, a) => {
try {
const { page: u = 1, page_size: n = 10, sort: c, order: o } = r || {}, l = new URLSearchParams();
u && l.append("page", String(u)), n && l.append("page_size", String(n)), c && l.append("sort", c), o && l.append("order", o);
const I = `${B}/${d}/rules_engine/${t}/rules${l.toString() ? `?${l.toString()}` : ""}`;
return a && (console.log("Request URL:", I), console.log("Request headers:", {
Accept: "application/json; version=3",
Authorization: `Token ${e}`
})), await g(
I,
{
method: "GET",
headers: {
Accept: "application/json; version=3",
Authorization: `Token ${e}`
}
},
a
);
} catch (u) {
throw a && console.error("Error listing rules:", u), u;
}
}, Re = async (e, d, t, r, a) => {
try {
const u = `${B}/${d}/rules_engine/${t}/rules/${r}`;
return a && (console.log("Request URL:", u), console.log("Request headers:", {
Accept: "application/json; version=3",
Authorization: `Token ${e}`
})), await g(
u,
{
method: "GET",
headers: {
Accept: "application/json; version=3",
Authorization: `Token ${e}`
}
},
a
);
} catch (u) {
throw a && console.error("Error getting rule by ID:", u), u;
}
}, Ae = async (e, d, t, r, a) => {
try {
const u = `${B}/${d}/rules_engine/${t}/rules`;
return a && (console.log("Request URL:", u), console.log("Request headers:", {
Accept: "application/json; version=3",
"Content-Type": "application/json",
Authorization: `Token ${e}`
}), console.log("Request body:", r)), await g(
u,
{
method: "POST",
headers: {
Accept: "application/json; version=3",
"Content-Type": "application/json",
Authorization: `Token ${e}`
},
body: JSON.stringify(r)
},
a
);
} catch (u) {
throw a && console.error("Error creating rule:", u), u;
}
}, Se = async (e, d, t, r, a, u) => {
try {
const n = `${B}/${d}/rules_engine/${t}/rules/${r}`;
return u && (console.log("Request URL:", n), console.log("Request headers:", {
Accept: "application/json; version=3",
"Content-Type": "application/json",
Authorization: `Token ${e}`
}), console.log("Request body:", a)), await g(
n,
{
method: "PATCH",
headers: {
Accept: "application/json; version=3",
"Content-Type": "application/json",
Authorization: `Token ${e}`
},
body: JSON.stringify(a)
},
u
);
} catch (n) {
throw u && console.error("Error updating rule:", n), n;
}
}, me = async (e, d, t, r, a) => {
try {
const u = `${B}/${d}/rules_engine/${t}/rules/${r}`;
a && (console.log("Request URL:", u), console.log("Request headers:", {
Accept: "application/json; version=3",
Authorization: `Token ${e}`
})), await g(
u,
{
method: "DELETE",
headers: {
Accept: "application/json; version=3",
Authorization: `Token ${e}`
}
},
a
);
} catch (u) {
throw a && console.error("Error deleting rule:", u), u;
}
}, Xe = ({
applicationId: e,
phase: d,
data: t,
options: r
}) => p(s(), e, d, t, r), Ye = ({
applicationId: e,
phase: d,
ruleId: t,
options: r
}) => h(s(), e, d, t, r), ke = ({
applicationId: e,
phase: d,
params: t,
options: r
}) => b(s(), e, d, t, r), et = ({
applicationId: e,
phase: d,
ruleId: t,
data: r,
options: a
}) => y(s(), e, d, t, r, a), tt = ({
applicationId: e,
phase: d,
ruleId: t,
options: r
}) => f(s(), e, d, t, r), p = async (e, d, t, r, a) => {
try {
const { results: u } = await Ae(s(e), d, t, r, i(a?.debug));
return { data: u };
} catch (u) {
return {
error: {
message: u instanceof Error ? u.message : "Failed to create rule",
operation: "create rule"
}
};
}
}, h = async (e, d, t, r, a) => {
try {
const { results: u } = await Re(s(e), d, t, r, i(a?.debug));
return { data: u };
} catch (u) {
return {
error: {
message: u instanceof Error ? u.message : "Failed to get rule",
operation: "get rule"
}
};
}
}, b = async (e, d, t, r, a) => {
try {
return { data: await ve(s(e), d, t, r, i(a?.debug)) };
} catch (u) {
return {
error: {
message: u instanceof Error ? u.message : "Failed to get rules",
operation: "get rules"
}
};
}
}, y = async (e, d, t, r, a, u) => {
try {
const { results: n } = await Se(
s(e),
d,
t,
r,
a,
i(u?.debug)
);
return { data: n };
} catch (n) {
return {
error: {
message: n instanceof Error ? n.message : "Failed to update rule",
operation: "update rule"
}
};
}
}, f = async (e, d, t, r, a) => {
try {
return await me(s(e), d, t, r, i(a?.debug)), { data: void 0 };
} catch (u) {
return {
error: {
message: u instanceof Error ? u.message : "Failed to delete rule",
operation: "delete rule"
}
};
}
}, P = "https://api.azionapi.net/edge_applications", we = async (e, d, t) => {
try {
const { order_by: r = "name", sort: a = "asc", page: u = 1, page_size: n = 10 } = d || {}, c = new URLSearchParams({
order_by: r,
sort: a,
page: String(u),
page_size: String(n)
});
return await g(
`${P}?${c.toString()}`,
{
method: "GET",
headers: { Accept: "application/json; version=3", Authorization: `Token ${e}` }
},
t
);
} catch (r) {
throw t && console.error("Error getting all applications:", r), r;
}
}, Ee = async (e, d, t) => {
try {
return await g(
`${P}/${d}`,
{
method: "GET",
headers: { Accept: "application/json; version=3", Authorization: `Token ${e}` }
},
t
);
} catch (r) {
throw t && console.error("Error getting application by ID:", r), r;
}
}, Te = async (e, d, t) => {
try {
return await g(
P,
{
method: "POST",
headers: {
Accept: "application/json; version=3",
"Content-Type": "application/json",
Authorization: `Token ${e}`
},
body: JSON.stringify(d)
},
t
);
} catch (r) {
throw t && console.error("Error creating application:", r), r;
}
}, Fe = async (e, d, t, r) => {
try {
return await g(
`${P}/${d}`,
{
method: "PUT",
headers: {
Accept: "application/json; version=3",
"Content-Type": "application/json",
Authorization: `Token ${e}`
},
body: JSON.stringify(t)
},
r
);
} catch (a) {
throw r && console.error("Error updating application:", a), a;
}
}, Ge = async (e, d, t, r) => {
try {
return await g(
`${P}/${d}`,
{
method: "PATCH",
headers: {
Accept: "application/json; version=3",
"Content-Type": "application/json",
Authorization: `Token ${e}`
},
body: JSON.stringify(t)
},
r
);
} catch (a) {
throw r && console.error("Error patching application:", a), a;
}
}, Oe = async (e, d, t) => {
try {
return await g(
`${P}/${d}`,
{
method: "DELETE",
headers: { Accept: "application/json; version=3", Authorization: `Token ${e}` }
},
t
);
} catch (r) {
throw t && console.error("Error deleting application:", r), r;
}
}, H = async (e, d, t) => {
const r = await Te(s(e), d, i(t?.debug));
if (!r || !r.results)
return {
error: $(r, "post application", "Failed to post application")
};
const a = r.results?.id;
return { data: {
...r.results,
cache: {
createCacheSetting: (n) => v(e, a, n.data, { ...t, debug: i(t?.debug) }),
getCacheSetting: (n) => R(e, a, n.cacheSettingId, {
...t,
debug: i(t?.debug)
}),
getCacheSettings: (n) => A(e, a, n.params, { ...t, debug: i(t?.debug) }),
updateCacheSetting: (n) => S(e, a, n.cacheSettingId, n.data, {
...t,
debug: i(t?.debug)
}),
deleteCacheSetting: (n) => m(e, a, n.cacheSettingId, {
...t,
debug: i(t?.debug)
})
},
origins: {
createOrigin: (n) => D(e, a, n.data, { ...t, debug: i(t?.debug) }),
getOrigin: (n) => M(e, a, n.originKey, { ...t, debug: i(t?.debug) }),
getOrigins: (n) => W(e, a, n.params, { ...t, debug: i(t?.debug) }),
updateOrigin: (n) => L(e, a, n.originKey, n.data, {
...t,
debug: i(t?.debug)
}),
deleteOrigin: (n) => _(e, a, n.originKey, { ...t, debug: i(t?.debug) })
},
rules: {
request: {
createRule: (n) => p(e, a, "request", n.data, { ...t, debug: i(t?.debug) }),
getRule: (n) => h(e, a, "request", n.ruleId, { ...t, debug: i(t?.debug) }),
getRules: (n) => b(e, a, "request", n.params, { ...t, debug: i(t?.debug) }),
updateRule: (n) => y(e, a, "request", n.ruleId, n.data, {
...t,
debug: i(t?.debug)
}),
deleteRule: (n) => f(e, a, "request", n.ruleId, {
...t,
debug: i(t?.debug)
})
},
response: {
createRule: (n) => p(e, a, "response", n.data, {
...t,
debug: i(t?.debug)
}),
getRule: (n) => h(e, a, "response", n.ruleId, { ...t, debug: i(t?.debug) }),
getRules: (n) => b(e, a, "response", n.params, {
...t,
debug: i(t?.debug)
}),
updateRule: (n) => y(e, a, "response", n.ruleId, n.data, {
...t,
debug: i(t?.debug)
}),
deleteRule: (n) => f(e, a, "response", n.ruleId, {
...t,
debug: i(t?.debug)
})
}
},
devices: {
createDeviceGroup: (n) => w(e, a, n.data, { ...t, debug: i(t?.debug) }),
getDeviceGroup: (n) => T(e, a, n.deviceGroupId, { ...t, debug: i(t?.debug) }),
getDeviceGroups: (n) => F(e, a, n.params, { ...t, debug: i(t?.debug) }),
updateDeviceGroup: (n) => G(e, a, n.deviceGroupId, n.data, {
...t,
debug: i(t?.debug)
}),
deleteDeviceGroup: (n) => E(e, a, n.deviceGroupId, {
...t,
debug: i(t?.debug)
})
},
functions: {
createFunctionInstance: (n) => O(e, a, n.data, { ...t, debug: i(t?.debug) }),
getFunctionInstance: (n) => j(e, a, n.functionInstanceId, {
...t,
debug: i(t?.debug)
}),
getFunctionInstances: (n) => q(e, a, n.params, { ...t, debug: i(t?.debug) }),
updateFunctionInstance: (n) => z(e, a, n.functionInstanceId, n.data, {
...t,
debug: i(t?.debug)
}),
deleteFunctionInstance: (n) => C(e, a, n.functionInstanceId, {
...t,
debug: i(t?.debug)
})
}
} };
}, x = async (e, d, t) => {
const r = await Ee(s(e), d, i(t?.debug));
if (!r || !r.results)
return {
error: $(r, "get application", "Failed to get application")
};
const a = r.results.id;
return { data: {
...r.results,
cache: {
createCacheSetting: (n) => v(e, a, n.data, { ...t, debug: i(t?.debug) }),
getCacheSetting: (n) => R(e, a, n.cacheSettingId, {
...t,
debug: i(t?.debug)
}),
getCacheSettings: (n) => A(e, a, n.params, { ...t, debug: i(t?.debug) }),
updateCacheSetting: (n) => S(e, a, n.cacheSettingId, n.data, {
...t,
debug: i(t?.debug)
}),
deleteCacheSetting: (n) => m(e, a, n.cacheSettingId, {
...t,
debug: i(t?.debug)
})
},
origins: {
createOrigin: (n) => D(e, a, n.data, { ...t, debug: i(t?.debug) }),
getOrigin: (n) => M(e, a, n.originKey, { ...t, debug: i(t?.debug) }),
getOrigins: (n) => W(e, a, n.params, { ...t, debug: i(t?.debug) }),
updateOrigin: (n) => L(e, a, n.originKey, n.data, {
...t,
debug: i(t?.debug)
}),
deleteOrigin: (n) => _(e, a, n.originKey, { ...t, debug: i(t?.debug) })
},
rules: {
request: {
createRule: (n) => p(e, a, "request", n.data, { ...t, debug: i(t?.debug) }),
getRule: (n) => h(e, a, "request", n.ruleId, { ...t, debug: i(t?.debug) }),
getRules: (n) => b(e, a, "request", n.params, { ...t, debug: i(t?.debug) }),
updateRule: (n) => y(e, a, "request", n.ruleId, n.data, {
...t,
debug: i(t?.debug)
}),
deleteRule: (n) => f(e, a, "request", n.ruleId, {
...t,
debug: i(t?.debug)
})
},
response: {
createRule: (n) => p(e, a, "response", n.data, {
...t,
debug: i(t?.debug)
}),
getRule: (n) => h(e, a, "response", n.ruleId, { ...t, debug: i(t?.debug) }),
getRules: (n) => b(e, a, "response", n.params, {
...t,
debug: i(t?.debug)
}),
updateRule: (n) => y(e, a, "response", n.ruleId, n.data, {
...t,
debug: i(t?.debug)
}),
deleteRule: (n) => f(e, a, "response", n.ruleId, {
...t,
debug: i(t?.debug)
})
}
},
devices: {
createDeviceGroup: (n) => w(e, a, n.data, { ...t, debug: i(t?.debug) }),
getDeviceGroup: (n) => T(e, a, n.deviceGroupId, { ...t, debug: i(t?.debug) }),
getDeviceGroups: (n) => F(e, a, n.params, { ...t, debug: i(t?.debug) }),
updateDeviceGroup: (n) => G(e, a, n.deviceGroupId, n.data, {
...t,
debug: i(t?.debug)
}),
deleteDeviceGroup: (n) => E(e, a, n.deviceGroupId, {
...t,
debug: i(t?.debug)
})
},
functions: {
createFunctionInstance: (n) => O(e, a, n.data, { ...t, debug: i(t?.debug) }),
getFunctionInstance: (n) => j(e, a, n.functionInstanceId, {
...t,
debug: i(t?.debug)
}),
getFunctionInstances: (n) => q(e, a, n.params, { ...t, debug: i(t?.debug) }),
updateFunctionInstance: (n) => z(e, a, n.functionInstanceId, n.data, {
...t,
debug: i(t?.debug)
}),
deleteFunctionInstance: (n) => C(e, a, n.functionInstanceId, {
...t,
debug: i(t?.debug)
})
}
} };
}, Z = async (e, d, t) => {
const r = await we(s(e), d, i(t?.debug));
if (!r || !r.results)
return {
error: $(r, "get applications", "Failed to get applications")
};
const a = r.results.map((u) => {
const n = u.id;
return {
...u,
cache: {
createCacheSetting: (c) => v(e, n, c.data, { ...t, debug: i(t?.debug) }),
getCacheSetting: (c) => R(e, n, c.cacheSettingId, {
...t,
debug: i(t?.debug)
}),
getCacheSettings: (c) => A(e, n, c.params, { ...t, debug: i(t?.debug) }),
updateCacheSetting: (c) => S(e, n, c.cacheSettingId, c.data, {
...t,
debug: i(t?.debug)
}),
deleteCacheSetting: (c) => m(e, n, c.cacheSettingId, {
...t,
debug: i(t?.debug)
})
},
origins: {
createOrigin: (c) => D(e, n, c.data, { ...t, debug: i(t?.debug) }),
getOrigin: (c) => M(e, n, c.originKey, { ...t, debug: i(t?.debug) }),
getOrigins: (c) => W(e, n, c.params, { ...t, debug: i(t?.debug) }),
updateOrigin: (c) => L(e, n, c.originKey, c.data, {
...t,
debug: i(t?.debug)
}),
deleteOrigin: (c) => _(e, n, c.originKey, { ...t, debug: i(t?.debug) })
},
rules: {
request: {
createRule: (c) => p(e, n, "request", c.data, {
...t,
debug: i(t?.debug)
}),
getRule: (c) => h(e, n, "request", c.ruleId, {
...t,
debug: i(t?.debug)
}),
getRules: (c) => b(e, n, "request", c.params, {
...t,
debug: i(t?.debug)
}),
updateRule: (c) => y(e, n, "request", c.ruleId, c.data, {
...t,
debug: i(t?.debug)
}),
deleteRule: (c) => f(e, n, "request", c.ruleId, {
...t,
debug: i(t?.debug)
})
},
response: {
createRule: (c) => p(e, n, "response", c.data, {
...t,
debug: i(t?.debug)
}),
getRule: (c) => h(e, n, "response", c.ruleId, {
...t,
debug: i(t?.debug)
}),
getRules: (c) => b(e, n, "response", c.params, {
...t,
debug: i(t?.debug)
}),
updateRule: (c) => y(e, n, "response", c.ruleId, c.data, {
...t,
debug: i(t?.debug)
}),
deleteRule: (c) => f(e, n, "response", c.ruleId, {
...t,
debug: i(t?.debug)
})
}
},
devices: {
createDeviceGroup: (c) => w(e, n, c.data, { ...t, debug: i(t?.debug) }),
getDeviceGroup: (c) => T(e, n, c.deviceGroupId, {
...t,
debug: i(t?.debug)
}),
getDeviceGroups: (c) => F(e, n, c.params, { ...t, debug: i(t?.debug) }),
updateDeviceGroup: (c) => G(e, n, c.deviceGroupId, c.data, {
...t,
debug: i(t?.debug)
}),
deleteDeviceGroup: (c) => E(e, n, c.deviceGroupId, {
...t,
debug: i(t?.debug)
})
},
functions: {
createFunctionInstance: (c) => O(e, n, c.data, {
...t,
debug: i(t?.debug)
}),
getFunctionInstance: (c) => j(e, n, c.functionInstanceId, {
...t,
debug: i(t?.debug)
}),
getFunctionInstances: (c) => q(e, n, c.params, {
...t,
debug: i(t?.debug)
}),
updateFunctionInstance: (c) => z(e, n, c.functionInstanceId, c.data, {
...t,
debug: i(t?.debug)
}),
deleteFunctionInstance: (c) => C(e, n, c.functionInstanceId, {
...t,
debug: i(t?.debug)
})
}
};
});
return {
data: {
...r,
results: a
}
};
}, V = async (e, d, t, r) => {
const a = await Fe(
s(e),
d,
t,
i(r?.debug)
);
if (!a || !a.results)
return {
error: $(a, "put application", "Failed to put application")
};
const u = a.results.id;
return { data: {
...a.results,
cache: {
createCacheSetting: (c) => v(e, u, c.data, { ...r, debug: i(r?.debug) }),
getCacheSetting: (c) => R(e, u, c.cacheSettingId, {
...r,
debug: i(r?.debug)
}),
getCacheSettings: (c) => A(e, u, c.params, { ...r, debug: i(r?.debug) }),
updateCacheSetting: (c) => S(e, u, c.cacheSettingId, c.data, {
...r,
debug: i(r?.debug)
}),
deleteCacheSetting: (c) => m(e, u, c.cacheSettingId, {
...r,
debug: i(r?.debug)
})
},
origins: {
createOrigin: (c) => D(e, u, c.data, { ...r, debug: i(r?.debug) }),
getOrigin: (c) => M(e, u, c.originKey, { ...r, debug: i(r?.debug) }),
getOrigins: (c) => W(e, u, c.params, { ...r, debug: i(r?.debug) }),
updateOrigin: (c) => L(e, u, c.originKey, c.data, {
...r,
debug: i(r?.debug)
}),
deleteOrigin: (c) => _(e, u, c.originKey, { ...r, debug: i(r?.debug) })
},
rules: {
request: {
createRule: (c) => p(e, u, "request", c.data, { ...r, debug: i(r?.debug) }),
getRule: (c) => h(e, u, "request", c.ruleId, { ...r, debug: i(r?.debug) }),
getRules: (c) => b(e, u, "request", c.params, { ...r, debug: i(r?.debug) }),
updateRule: (c) => y(e, u, "request", c.ruleId, c.data, {
...r,
debug: i(r?.debug)
}),
deleteRule: (c) => f(e, u, "request", c.ruleId, {
...r,
debug: i(r?.debug)
})
},
response: {
createRule: (c) => p(e, u, "response", c.data, {
...r,
debug: i(r?.debug)
}),
getRule: (c) => h(e, u, "response", c.ruleId, { ...r, debug: i(r?.debug) }),
getRules: (c) => b(e, u, "response", c.params, {
...r,
debug: i(r?.debug)
}),
updateRule: (c) => y(e, u, "response", c.ruleId, c.data, {
...r,
debug: i(r?.debug)
}),
deleteRule: (c) => f(e, u, "response", c.ruleId, {
...r,
debug: i(r?.debug)
})
}
},
devices: {
createDeviceGroup: (c) => w(e, u, c.data, { ...r, debug: i(r?.debug) }),
getDeviceGroup: (c) => T(e, u, c.deviceGroupId, { ...r, debug: i(r?.debug) }),
getDeviceGroups: (c) => F(e, u, c.params, { ...r, debug: i(r?.debug) }),
updateDeviceGroup: (c) => G(e, u, c.deviceGroupId, c.data, {
...r,
debug: i(r?.debug)
}),
deleteDeviceGroup: (c) => E(e, u, c.deviceGroupId, {
...r,
debug: i(r?.debug)
})
},
functions: {
createFunctionInstance: (c) => O(e, u, c.data, { ...r, debug: i(r?.debug) }),
getFunctionInstance: (c) => j(e, u, c.functionInstanceId, {
...r,
debug: i(r?.debug)
}),
getFunctionInstances: (c) => q(e, u, c.params, { ...r, debug: i(r?.debug) }),
updateFunctionInstance: (c) => z(e, u, c.functionInstanceId, c.data, {
...r,
debug: i(r?.debug)
}),
deleteFunctionInstance: (c) => C(e, u, c.functionInstanceId, {
...r,
debug: i(r?.debug)
})
}
} };
}, Q = async (e, d, t, r) => {
const a = await Ge(
s(e),
d,
t,
i(r?.debug)
);
if (!a || !a.results)
return {
error: $(a, "patch application", "Failed to patch application")
};
const u = a.results.id;
return { data: {
...a.results,
cache: {
createCacheSetting: (c) => v(e, u, c.data, { ...r, debug: i(r?.debug) }),
getCacheSetting: (c) => R(e, u, c.cacheSettingId, {
...r,
debug: i(r?.debug)
}),
getCacheSettings: (c) => A(e, u, c.params, { ...r, debug: i(r?.debug) }),
updateCacheSetting: (c) => S(e, u, c.cacheSettingId, c.data, {
...r,
debug: i(r?.debug)
}),
deleteCacheSetting: (c) => m(e, u, c.cacheSettingId, {
...r,
debug: i(r?.debug)
})
},
origins: {
createOrigin: (c) => D(e, u, c.data, { ...r, debug: i(r?.debug) }),
getOrigin: (c) => M(e, u, c.originKey, { ...r, debug: i(r?.debug) }),
getOrigins: (c) => W(e, u, c.params, { ...r, debug: i(r?.debug) }),
updateOrigin: (c) => L(e, u, c.originKey, c.data, {
...r,
debug: i(r?.debug)
}),
deleteOrigin: (c) => _(e, u, c.originKey, { ...r, debug: i(r?.debug) })
},
rules: {
request: {
createRule: (c) => p(e, u, "request", c.data, { ...r, debug: i(r?.debug) }),
getRule: (c) => h(e, u, "request", c.ruleId, { ...r, debug: i(r?.debug) }),
getRules: (c) => b(e, u, "request", c.params, { ...r, debug: i(r?.debug) }),
updateRule: (c) => y(e, u, "request", c.ruleId, c.data, {
...r,
debug: i(r?.debug)
}),
deleteRule: (c) => f(e, u, "request", c.ruleId, {
...r,
debug: i(r?.debug)
})
},
response: {
createRule: (c) => p(e, u, "response", c.data, {
...r,
debug: i(r?.debug)
}),
getRule: (c) => h(e, u, "response", c.ruleId, { ...r, debug: i(r?.debug) }),
getRules: (c) => b(e, u, "response", c.params, {
...r,
debug: i(r?.debug)
}),
updateRule: (c) => y(e, u, "response", c.ruleId, c.data, {
...r,
debug: i(r?.debug)
}),
deleteRule: (c) => f(e, u, "response", c.ruleId, {
...r,
debug: i(r?.debug)
})
}
},
devices: {
createDeviceGroup: (c) => w(e, u, c.data, { ...r, debug: i(r?.debug) }),
getDeviceGroup: (c) => T(e, u, c.deviceGroupId, { ...r, debug: i(r?.debug) }),
getDeviceGroups: (c) => F(e, u, c.params, { ...r, debug: i(r?.debug) }),
updateDeviceGroup: (c) => G(e, u, c.deviceGroupId, c.data, {
...r,
debug: i(r?.debug)
}),
deleteDeviceGroup: (c) => E(e, u, c.deviceGroupId, {
...r,
debug: i(r?.debug)
})
},
functions: {
createFunctionInstance: (c) => O(e, u, c.data, { ...r, debug: i(r?.debug) }),
getFunctionInstance: (c) => j(e, u, c.functionInstanceId, {
...r,
debug: i(r?.debug)
}),
getFunctionInstances: (c) => q(e, u, c.params, { ...r, debug: i(r?.debug) }),
updateFunctionInstance: (c) => z(e, u, c.functionInstanceId, c.data, {
...r,
debug: i(r?.debug)
}),
deleteFunctionInstance: (c) => C(e, u, c.functionInstanceId, {
...r,
debug: i(r?.debug)
})
}
} };
}, X = async (e, d, t) => {
try {
return await Oe(s(e), d, i(t?.debug)), { data: void 0 };
} catch (r) {
return {
error: $(r, "delete application", "Failed to delete application")
};
}
}, rt = ({
data: e,
options: d
}) => H(s(), e, d), at = ({
applicationId: e,
options: d
}) => x(s(), e, d), ct = (e) => Z(s(), e?.params, e?.options), nt = ({
applicationId: e,
data: d,
options: t
}) => V(s(), e, d, t), dt = ({
applicationId: e,
data: d,
options: t
}) => Q(s(), e, d, t), ut = ({
applicationId: e,
options: d
}) => X(s(), e, d), it = (e) => {
const d = s(e?.token), t = i(e?.options?.debug);
return {
createApplication: async ({ data: a }) => H(d, a, { ...e, debug: t }),
deleteApplication: async ({ applicationId: a, options: u }) => X(d, a, {
...e?.options,
...u,
debug: i(e?.options?.debug ?? u?.debug)
}),
getApplication: async ({ applicationId: a, options: u }) => x(d, a, {
...e?.options,
...u,
debug: i(e?.options?.debug ?? u?.debug)
}),
getApplications: async ({
params: a,
options: u
}) => Z(d, a, {
...e?.options,
...u,
debug: i(u?.debug)
}),
putApplication: async ({
applicationId: a,
data: u,
options: n
}) => V(d, a, u, {
...e?.options,
...n,
debug: i(n?.debug)
}),
patchApplication: async ({
applicationId: a,
data: u,
options: n
}) => Q(d, a, u, {
...e?.options,
...n,
debug: i(n?.debug)
})
};
};
export {
rt as createApplication,
it as createAzionApplicationClient,
Ce as createCacheSetting,
_e as createDeviceGroup,
Ue as createFunctionInstance,
He as createOrigin,
Xe as createRule,
it as default,
ut as deleteApplication,
De as deleteCacheSetting,
Me as deleteDeviceGroup,
Ke as deleteFunctionInstance,
xe as deleteOrigin,
tt as deleteRule,
at as getApplication,
ct as getApplications,
je as getCacheSetting,
qe as getCacheSettings,
We as getDeviceGroup,
Le as getDeviceGroups,
Ne as getFunctionInstance,
Je as getFunctionInstances,
Ze as getOrigin,
Ve as getOrigins,
Ye as getRule,
ke as getRules,
dt as patchApplication,
nt as putApplication,
ze as updateCacheSetting,
Pe as updateDeviceGroup,
Be as updateFunctionInstance,
Qe as updateOrigin,
et as updateRule
};