Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/clients/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ export * as Test from './test'
export * as TransactionalEmail from './tem'
export * as VPC from './vpc'
export * as VPCGW from './vpcgw'
export * as Webhosting from './webhosting'
1 change: 1 addition & 0 deletions packages/clients/src/api/webhosting/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * as v1alpha1 from './v1alpha1/index.gen'
243 changes: 243 additions & 0 deletions packages/clients/src/api/webhosting/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
import {
API as ParentAPI,
enrichForPagination,
urlParams,
validatePathParam,
waitForResource,
} from '../../../bridge'
import type { Region, WaitForOptions } from '../../../bridge'
import { HOSTING_TRANSIENT_STATUSES } from './content.gen'
import {
marshalCreateHostingRequest,
marshalUpdateHostingRequest,
unmarshalDnsRecords,
unmarshalHosting,
unmarshalListHostingsResponse,
unmarshalListOffersResponse,
} from './marshalling.gen'
import type {
CreateHostingRequest,
DeleteHostingRequest,
DnsRecords,
GetDomainDnsRecordsRequest,
GetHostingRequest,
Hosting,
ListHostingsRequest,
ListHostingsResponse,
ListOffersRequest,
ListOffersResponse,
RestoreHostingRequest,
UpdateHostingRequest,
} from './types.gen'

const jsonContentHeaders = {
'Content-Type': 'application/json; charset=utf-8',
}

/** Webhosting API. */
export class API extends ParentAPI {
/** Lists the available regions of the API. */
public static readonly LOCALITIES: Region[] = ['fr-par']

/**
* Create a hosting
*
* @param request - The request {@link CreateHostingRequest}
* @returns A Promise of Hosting
*/
createHosting = (request: Readonly<CreateHostingRequest>) =>
this.client.fetch<Hosting>(
{
body: JSON.stringify(
marshalCreateHostingRequest(request, this.client.settings),
),
headers: jsonContentHeaders,
method: 'POST',
path: `/webhosting/v1alpha1/regions/${validatePathParam(
'region',
request.region ?? this.client.settings.defaultRegion,
)}/hostings`,
},
unmarshalHosting,
)

protected pageOfListHostings = (
request: Readonly<ListHostingsRequest> = {},
) =>
this.client.fetch<ListHostingsResponse>(
{
method: 'GET',
path: `/webhosting/v1alpha1/regions/${validatePathParam(
'region',
request.region ?? this.client.settings.defaultRegion,
)}/hostings`,
urlParams: urlParams(
['domain', request.domain],
['order_by', request.orderBy ?? 'created_at_asc'],
['organization_id', request.organizationId],
['page', request.page],
[
'page_size',
request.pageSize ?? this.client.settings.defaultPageSize,
],
['project_id', request.projectId],
['statuses', request.statuses],
['tags', request.tags],
),
},
unmarshalListHostingsResponse,
)

/**
* List all hostings
*
* @param request - The request {@link ListHostingsRequest}
* @returns A Promise of ListHostingsResponse
*/
listHostings = (request: Readonly<ListHostingsRequest> = {}) =>
enrichForPagination('hostings', this.pageOfListHostings, request)

/**
* Get the details of a Hosting with the given ID.
*
* @param request - The request {@link GetHostingRequest}
* @returns A Promise of Hosting
*/
getHosting = (request: Readonly<GetHostingRequest>) =>
this.client.fetch<Hosting>(
{
method: 'GET',
path: `/webhosting/v1alpha1/regions/${validatePathParam(
'region',
request.region ?? this.client.settings.defaultRegion,
)}/hostings/${validatePathParam('hostingId', request.hostingId)}`,
},
unmarshalHosting,
)

/**
* Waits for {@link Hosting} to be in a final state.
*
* @param request - The request {@link GetHostingRequest}
* @param options - The waiting options
* @returns A Promise of Hosting
*/
waitForHosting = (
request: Readonly<GetHostingRequest>,
options?: Readonly<WaitForOptions<Hosting>>,
) =>
waitForResource(
options?.stop ??
(res =>
Promise.resolve(!HOSTING_TRANSIENT_STATUSES.includes(res.status))),
this.getHosting,
request,
options,
)

/**
* Update a hosting
*
* @param request - The request {@link UpdateHostingRequest}
* @returns A Promise of Hosting
*/
updateHosting = (request: Readonly<UpdateHostingRequest>) =>
this.client.fetch<Hosting>(
{
body: JSON.stringify(
marshalUpdateHostingRequest(request, this.client.settings),
),
headers: jsonContentHeaders,
method: 'PATCH',
path: `/webhosting/v1alpha1/regions/${validatePathParam(
'region',
request.region ?? this.client.settings.defaultRegion,
)}/hostings/${validatePathParam('hostingId', request.hostingId)}`,
},
unmarshalHosting,
)

/**
* Delete a hosting with the given ID.
*
* @param request - The request {@link DeleteHostingRequest}
* @returns A Promise of Hosting
*/
deleteHosting = (request: Readonly<DeleteHostingRequest>) =>
this.client.fetch<Hosting>(
{
method: 'DELETE',
path: `/webhosting/v1alpha1/regions/${validatePathParam(
'region',
request.region ?? this.client.settings.defaultRegion,
)}/hostings/${validatePathParam('hostingId', request.hostingId)}`,
},
unmarshalHosting,
)

/**
* Restore a hosting with the given ID.
*
* @param request - The request {@link RestoreHostingRequest}
* @returns A Promise of Hosting
*/
restoreHosting = (request: Readonly<RestoreHostingRequest>) =>
this.client.fetch<Hosting>(
{
body: '{}',
headers: jsonContentHeaders,
method: 'POST',
path: `/webhosting/v1alpha1/regions/${validatePathParam(
'region',
request.region ?? this.client.settings.defaultRegion,
)}/hostings/${validatePathParam(
'hostingId',
request.hostingId,
)}/restore`,
},
unmarshalHosting,
)

/**
* Get the DNS records of a specified domain.
*
* @param request - The request {@link GetDomainDnsRecordsRequest}
* @returns A Promise of DnsRecords
*/
getDomainDnsRecords = (request: Readonly<GetDomainDnsRecordsRequest>) =>
this.client.fetch<DnsRecords>(
{
method: 'GET',
path: `/webhosting/v1alpha1/regions/${validatePathParam(
'region',
request.region ?? this.client.settings.defaultRegion,
)}/domains/${validatePathParam('domain', request.domain)}/dns-records`,
},
unmarshalDnsRecords,
)

/**
* List all offers
*
* @param request - The request {@link ListOffersRequest}
* @returns A Promise of ListOffersResponse
*/
listOffers = (request: Readonly<ListOffersRequest>) =>
this.client.fetch<ListOffersResponse>(
{
method: 'GET',
path: `/webhosting/v1alpha1/regions/${validatePathParam(
'region',
request.region ?? this.client.settings.defaultRegion,
)}/offers`,
urlParams: urlParams(
['only_options', request.onlyOptions],
['order_by', request.orderBy ?? 'price_asc'],
['without_options', request.withoutOptions],
),
},
unmarshalListOffersResponse,
)
}
9 changes: 9 additions & 0 deletions packages/clients/src/api/webhosting/v1alpha1/content.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
import type { HostingStatus } from './types.gen'

/** Lists transient statutes of the enum {@link HostingStatus}. */
export const HOSTING_TRANSIENT_STATUSES: HostingStatus[] = [
'delivering',
'deleting',
]
33 changes: 33 additions & 0 deletions packages/clients/src/api/webhosting/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
export { API } from './api.gen'
export * from './content.gen'
export type {
CreateHostingRequest,
DeleteHostingRequest,
DnsRecord,
DnsRecordStatus,
DnsRecordType,
DnsRecords,
DnsRecordsStatus,
GetDomainDnsRecordsRequest,
GetHostingRequest,
Hosting,
HostingCpanelUrls,
HostingDnsStatus,
HostingOption,
HostingStatus,
ListHostingsRequest,
ListHostingsRequestOrderBy,
ListHostingsResponse,
ListOffersRequest,
ListOffersRequestOrderBy,
ListOffersResponse,
Nameserver,
NameserverStatus,
Offer,
OfferProduct,
RestoreHostingRequest,
UpdateHostingRequest,
} from './types.gen'
export * as ValidationRules from './validation-rules.gen'
Loading