UNPKG

azion

Version:

Azion Packages for Edge Computing.

332 lines (315 loc) 11.9 kB
/** * AzionClientOptions is a type that represents the options of the Azion API client. * @param debug The debug option. * @param force The force option. * @returns An object with the options of the client. */ export declare type AzionClientOptions = { debug?: boolean | undefined; force?: boolean | undefined; }; /** * AzionDomainCollection is a type that represents the domains object in the Azion API. * @param state The state of the response. * @param count The count of the domains. * @param pages The number of pages. * @param results The list of domains. * @returns An object with the domains data. */ export declare type AzionCreateDomain = Omit<AzionDomain, 'id' | 'environment' | 'active' | 'url' | 'state' | 'edgeApplicationId'> & { edgeApplicationId: number; }; /** * AzionDeletedDomain is a type that represents the domain object in the Azion API. * @param id The id of the domain. * @param state The state of the response. * @returns An object with the domain data. */ export declare type AzionDeletedDomain = Pick<AzionDomain, 'id' | 'state'>; /** * AzionDomain is a type that represents the domain object in the Azion API. * @param state The state of the response. * @param id The id of the domain. * @param url The url of the domain. * @param environment The environment of the domain. * @param active The status of the domain. * @param name The name of the domain. * @param cnameAccessOnly The status of the domain. * @param cnames The cnames of the domain. * @param edgeApplicationId The id of the edge application. * @param edgeFirewallId The id of the edge firewall. * @param digitalCertificateId The id of the digital certificate. * @param mtls The mtls object. * @returns An object with the domain data. */ export declare type AzionDomain = { state?: ResponseState; id?: number; url?: string; environment?: string; active?: boolean; name: string; cnameAccessOnly?: boolean; cnames?: string[]; edgeApplicationId?: number; edgeFirewallId?: number; digitalCertificateId?: string | number | null; mtls?: { verification: 'enforce' | 'permissive'; trustedCaCertificateId: number; crlList?: number[]; }; }; /** * AzionDomainCollection is a type that represents the domains object in the Azion API. * @param state The state of the response. * @param count The count of the domains. * @param pages The number of pages. * @param results The list of domains. * @returns An object with the domains data. */ export declare type AzionDomainCollection = { state: ResponseState; count: number; pages: number; results: AzionDomain[]; }; /** * AzionDomainsClient is a type that represents the client of the Azion domains API. * @param createDomain The function to create a domain. * @param getDomains The function to get the domains. * @param getDomain The function to get a domain. * @param updateDomain The function to update a domain. * @param deleteDomain The function to delete a domain. * @returns An object with the client functions. */ export declare interface AzionDomainsClient { /** * createDomain is a function that creates a domain in the Azion API. * @param {AzionCreateDomain} domain The domain object. * @param { AzionClientOptions } options The options of the client. * @returns {Promise<AzionDomainsResponse<AzionDomain>>} The response of the API. * @example * const domain = { * name: 'example.com', * edgeApplicationId: 1, * }; * const { data, error } = await client.createDomain(domain); * if (error) { * console.error(error.message); * } else { * console.log(data); * } */ createDomain: (domain: AzionCreateDomain, options?: AzionClientOptions) => Promise<AzionDomainsResponse<AzionDomain>>; /** * getDomains is a function that gets the domains in the Azion API. * @param {AzionClientOptions} options The options of the client. * @param {{ orderBy?: 'id' | 'name'; page?: number; pageSize?: number; sort?: 'asc' | 'desc' }} queryParams The query parameters of the request. * @returns {Promise<AzionDomainsResponse<AzionDomainCollection>>} The response of the API. * @example * const { data, error } = await client.getDomains(); * if (error) { * console.error(error.message); * } else { * console.log(data.results); * } */ getDomains: (options?: AzionClientOptions, queryParams?: { orderBy?: 'id' | 'name'; page?: number; pageSize?: number; sort?: 'asc' | 'desc'; }) => Promise<AzionDomainsResponse<AzionDomainCollection>>; /** * getDomain is a function that gets a domain in the Azion API. * @param {number} domainId The id of the domain. * @param {AzionClientOptions} options The options of the client. * @returns {Promise<AzionDomainsResponse<AzionDomain>>} The response of the API. * @example * const { data, error } = await client.getDomain(1); * if (error) { * console.error(error.message); * } else { * console.log(data); * } */ getDomain: (domainId: number, options?: AzionClientOptions) => Promise<AzionDomainsResponse<AzionDomain>>; /** * updateDomain is a function that updates a domain in the Azion API. * @param {number} domainId The id of the domain. * @param {AzionUpdateDomain} domain The domain object. * @param {AzionClientOptions} options The options of the client. * @returns {Promise<AzionDomainsResponse<AzionDomain>>} The response of the API. * @example * const domain = { * name: 'example.com', * edgeApplicationId: 1, * }; * const { data, error } = await client.updateDomain(1, domain); * if (error) { * console.error(error.message); * } else { * console.log(data); * } */ updateDomain: (domainId: number, domain: AzionUpdateDomain, options?: AzionClientOptions) => Promise<AzionDomainsResponse<AzionDomain>>; /** * deleteDomain is a function that deletes a domain in the Azion API. * @param {number} domainId The id of the domain. * @param {AzionClientOptions} options The options of the client. * @returns {Promise<AzionDomainsResponse<AzionDeletedDomain>>} The response of the API. * @example * const { data, error } = await client.deleteDomain(1); * if (error) { * console.error(error.message); * } else { * console.log(data.id); * } */ deleteDomain: (domainId: number, options?: AzionClientOptions) => Promise<AzionDomainsResponse<AzionDeletedDomain>>; } /** * AzionDomainsCreateClient is a type that represents the function to create an Azion domains client. * @param config The configuration object. * @returns The Azion domains client. */ export declare type AzionDomainsCreateClient = (config?: Partial<{ token?: string; options?: AzionClientOptions; }>) => AzionDomainsClient; /** * AzionDomainsResponse<T> is a generic type that represents the response of the Azion API. * It can be either a success response with the data or an error response with the error message and operation. * * @param T The type of the data that the response contains. * @returns An object with the data or an error message and operation. */ export declare type AzionDomainsResponse<T> = { data?: T; error?: { message: string; operation: string; }; }; /** * AzionUpdateDomain is a type that represents the domain object in the Azion API. * @param active The status of the domain. * @param name The name of the domain. * @param cnameAccessOnly The status of the domain. * @param cnames The cnames of the domain. * @param edgeApplicationId The id of the edge application. * @param edgeFirewallId The id of the edge firewall. * @param digitalCertificateId The id of the digital certificate. * @param mtls The mtls object. * @returns An object with the domain data. */ export declare type AzionUpdateDomain = Omit<AzionDomain, 'id' | 'environment' | 'url' | 'edgeApplicationId' | 'state'> & { edgeApplicationId: number; }; /** * Creates an Azion client to interact with the Domains. * * @param {Partial<{ token?: string; options?: AzionClientOptions; }>} [config] - Configuration options for the client. * @returns {AzionDomainsClient} An object with methods to interact with the Domains. * * @example * const client = createClient(); // Uses the token from the environment variable process.env.AZION_TOKEN * const domain = { name: 'example.com', edgeApplicationId: 123 }; * const result = await client.createDomain(domain); * console.log(result); */ declare const createClient: AzionDomainsCreateClient; export { createClient } export default createClient; /** * Create a new domain * @param domain Domain to create * @param options Options to create the domain * @returns Domain created with data or error * * @example * const domain = { name: 'example.com', edgeApplicationId: 123 }; * const { data, error } = await createDomain(domain); * if(data) { * console.log(data); * } else { * console.error(error); * * */ export declare const createDomain: (domain: AzionCreateDomain, options?: AzionClientOptions) => Promise<AzionDomainsResponse<AzionDomain>>; /** * Delete a domain * @param domainId Domain ID * @param options Options to delete the domain * @returns Domain deleted with data or error * * @example * const { data, error } = await deleteDomain(123); * if(data) { * console.log(data.id); * } else { * console.error(error); * */ export declare const deleteDomain: (domainId: number, options?: AzionClientOptions) => Promise<AzionDomainsResponse<AzionDeletedDomain>>; /** * Get a domain by ID * @param domainId Domain ID * @param options Options to get the domain * @returns Domain with data or error * * @example * const { data, error } = await getDomain(123); * if(data) { * console.log(data); * } else { * console.error(error); * */ export declare const getDomain: (domainId: number, options?: AzionClientOptions) => Promise<AzionDomainsResponse<AzionDomain>>; /** * List domains * @param options Options to list the domains * @param queryParams Query parameters to list the domains * @returns List of domains with data or error * * @example * const { data, error } = await getDomains(); * if(data) { * console.log(data.results); * } else { * console.error(error); * } */ export declare const getDomains: (options?: AzionClientOptions, queryParams?: { orderBy?: "id" | "name"; page?: number; pageSize?: number; sort?: "asc" | "desc"; }) => Promise<AzionDomainsResponse<AzionDomainCollection>>; /** * ResponseState is a type that represents the state of the response of the Azion API. * It can be either pending, executed or failed. * @returns A string with the state of the response. */ export declare type ResponseState = 'pending' | 'executed' | 'failed'; /** * Update a domain * @param domainId Domain ID * @param domain Domain to update * @param options Options to update the domain * @returns Domain updated with data or error * * @example * const domain = { name: 'example.com', edgeApplicationId: 123 }; * const { data, error } = await updateDomain(123, domain); * if(data) { * console.log(data); * } else { * console.error(error); * } */ export declare const updateDomain: (domainId: number, domain: AzionUpdateDomain, options?: AzionClientOptions) => Promise<AzionDomainsResponse<AzionDomain>>; export { }