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
121 changes: 121 additions & 0 deletions packages/clients/src/api/webhosting/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,29 @@ import type { Region, WaitForOptions } from '../../../bridge'
import { HOSTING_TRANSIENT_STATUSES } from './content.gen'
import {
marshalCheckUserOwnsDomainRequest,
marshalClassicMailApiCreateMailboxRequest,
marshalClassicMailApiUpdateMailboxRequest,
marshalCreateHostingRequest,
marshalUpdateHostingRequest,
unmarshalCheckUserOwnsDomainResponse,
unmarshalDnsRecords,
unmarshalHosting,
unmarshalListControlPanelsResponse,
unmarshalListHostingsResponse,
unmarshalListMailboxesResponse,
unmarshalListOffersResponse,
unmarshalMailbox,
unmarshalResetHostingPasswordResponse,
unmarshalSession,
} from './marshalling.gen'
import type {
CheckUserOwnsDomainRequest,
CheckUserOwnsDomainResponse,
ClassicMailApiCreateMailboxRequest,
ClassicMailApiDeleteMailboxRequest,
ClassicMailApiGetMailboxRequest,
ClassicMailApiListMailboxesRequest,
ClassicMailApiUpdateMailboxRequest,
CreateHostingRequest,
CreateSessionRequest,
DeleteHostingRequest,
Expand All @@ -36,8 +45,10 @@ import type {
ListControlPanelsResponse,
ListHostingsRequest,
ListHostingsResponse,
ListMailboxesResponse,
ListOffersRequest,
ListOffersResponse,
Mailbox,
ResetHostingPasswordRequest,
ResetHostingPasswordResponse,
RestoreHostingRequest,
Expand Down Expand Up @@ -324,3 +335,113 @@ export class API extends ParentAPI {
unmarshalResetHostingPasswordResponse,
)
}

/**
* Web Hosting Classic Mailbox API.
*
* This API allows you to manage your mailboxes for your Web Hosting services.
*/
export class ClassicMailAPI extends ParentAPI {
/** Lists the available regions of the API. */
public static readonly LOCALITIES: Region[] = ['fr-par', 'nl-ams', 'pl-waw']

/**
* Create a new mailbox within your hosting plan.. Create a new mailbox within
* your hosting plan.
*
* @param request - The request {@link ClassicMailApiCreateMailboxRequest}
* @returns A Promise of Mailbox
*/
createMailbox = (request: Readonly<ClassicMailApiCreateMailboxRequest>) =>
this.client.fetch<Mailbox>(
{
body: JSON.stringify(
marshalClassicMailApiCreateMailboxRequest(
request,
this.client.settings,
),
),
headers: jsonContentHeaders,
method: 'POST',
path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/classic-hostings/${validatePathParam('onlineId', request.onlineId)}/mailboxes`,
},
unmarshalMailbox,
)

/**
* Get a mailbox by id within your hosting plan.. Get a mailbox by id within
* your hosting plan.
*
* @param request - The request {@link ClassicMailApiGetMailboxRequest}
* @returns A Promise of Mailbox
*/
getMailbox = (request: Readonly<ClassicMailApiGetMailboxRequest>) =>
this.client.fetch<Mailbox>(
{
method: 'GET',
path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/classic-hostings/${validatePathParam('onlineId', request.onlineId)}/mailboxes/${validatePathParam('mailboxId', request.mailboxId)}`,
},
unmarshalMailbox,
)

protected pageOfListMailboxes = (
request: Readonly<ClassicMailApiListMailboxesRequest>,
) =>
this.client.fetch<ListMailboxesResponse>(
{
method: 'GET',
path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/classic-hostings/${validatePathParam('onlineId', request.onlineId)}/mailboxes`,
urlParams: urlParams(
['domain', request.domain],
['page', request.page],
[
'page_size',
request.pageSize ?? this.client.settings.defaultPageSize,
],
),
},
unmarshalListMailboxesResponse,
)

/**
* List all mailboxes within your hosting plan.. List all mailboxes within
* your hosting plan.
*
* @param request - The request {@link ClassicMailApiListMailboxesRequest}
* @returns A Promise of ListMailboxesResponse
*/
listMailboxes = (request: Readonly<ClassicMailApiListMailboxesRequest>) =>
enrichForPagination('mailboxes', this.pageOfListMailboxes, request)

deleteMailbox = (request: Readonly<ClassicMailApiDeleteMailboxRequest>) =>
this.client.fetch<Mailbox>(
{
method: 'DELETE',
path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/classic-hostings/${validatePathParam('onlineId', request.onlineId)}/mailboxes/${validatePathParam('mailboxId', request.mailboxId)}`,
},
unmarshalMailbox,
)

/**
* Update the mailbox within your hosting plan.. Update the mailbox within
* your hosting plan.
*
* @param request - The request {@link ClassicMailApiUpdateMailboxRequest}
* @returns A Promise of Mailbox
*/
updateMailbox = (request: Readonly<ClassicMailApiUpdateMailboxRequest>) =>
this.client.fetch<Mailbox>(
{
body: JSON.stringify(
marshalClassicMailApiUpdateMailboxRequest(
request,
this.client.settings,
),
),
headers: jsonContentHeaders,
method: 'PATCH',
path: `/webhosting/v1alpha1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/classic-hostings/${validatePathParam('onlineId', request.onlineId)}/mailboxes/${validatePathParam('mailboxId', request.mailboxId)}`,
},
unmarshalMailbox,
)
}
10 changes: 9 additions & 1 deletion packages/clients/src/api/webhosting/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
// 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 { API, ClassicMailAPI } from './api.gen'
export * from './content.gen'
export type {
CheckUserOwnsDomainRequest,
CheckUserOwnsDomainResponse,
ClassicMailApiCreateMailboxRequest,
ClassicMailApiDeleteMailboxRequest,
ClassicMailApiGetMailboxRequest,
ClassicMailApiListMailboxesRequest,
ClassicMailApiUpdateMailboxRequest,
ControlPanel,
CreateHostingRequest,
CreateHostingRequestDomainConfiguration,
Expand All @@ -15,6 +20,7 @@ export type {
DnsRecordType,
DnsRecords,
DnsRecordsStatus,
EmailAddress,
GetDomainDnsRecordsRequest,
GetHostingRequest,
Hosting,
Expand All @@ -27,9 +33,11 @@ export type {
ListHostingsRequest,
ListHostingsRequestOrderBy,
ListHostingsResponse,
ListMailboxesResponse,
ListOffersRequest,
ListOffersRequestOrderBy,
ListOffersResponse,
Mailbox,
Nameserver,
NameserverStatus,
Offer,
Expand Down
72 changes: 72 additions & 0 deletions packages/clients/src/api/webhosting/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,22 @@ import type { DefaultValues } from '../../../bridge'
import type {
CheckUserOwnsDomainRequest,
CheckUserOwnsDomainResponse,
ClassicMailApiCreateMailboxRequest,
ClassicMailApiUpdateMailboxRequest,
ControlPanel,
CreateHostingRequest,
CreateHostingRequestDomainConfiguration,
DnsRecord,
DnsRecords,
EmailAddress,
Hosting,
HostingCpanelUrls,
HostingOption,
ListControlPanelsResponse,
ListHostingsResponse,
ListMailboxesResponse,
ListOffersResponse,
Mailbox,
Nameserver,
Offer,
OfferProduct,
Expand Down Expand Up @@ -92,6 +97,32 @@ export const unmarshalHosting = (data: unknown): Hosting => {
} as Hosting
}

const unmarshalEmailAddress = (data: unknown): EmailAddress => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'EmailAddress' failed as data isn't a dictionary.`,
)
}

return {
domain: data.domain,
login: data.login,
} as EmailAddress
}

export const unmarshalMailbox = (data: unknown): Mailbox => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'Mailbox' failed as data isn't a dictionary.`,
)
}

return {
email: data.email ? unmarshalEmailAddress(data.email) : undefined,
mailboxId: data.mailbox_id,
} as Mailbox
}

export const unmarshalCheckUserOwnsDomainResponse = (
data: unknown,
): CheckUserOwnsDomainResponse => {
Expand Down Expand Up @@ -199,6 +230,21 @@ export const unmarshalListHostingsResponse = (
} as ListHostingsResponse
}

export const unmarshalListMailboxesResponse = (
data: unknown,
): ListMailboxesResponse => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'ListMailboxesResponse' failed as data isn't a dictionary.`,
)
}

return {
mailboxes: unmarshalArrayOfObject(data.mailboxes, unmarshalMailbox),
totalCount: data.total_count,
} as ListMailboxesResponse
}

const unmarshalOfferProduct = (data: unknown): OfferProduct => {
if (!isJSONObject(data)) {
throw new TypeError(
Expand Down Expand Up @@ -286,6 +332,32 @@ export const marshalCheckUserOwnsDomainRequest = (
project_id: request.projectId ?? defaults.defaultProjectId,
})

const marshalEmailAddress = (
request: EmailAddress,
defaults: DefaultValues,
): Record<string, unknown> => ({
domain: request.domain,
login: request.login,
})

export const marshalClassicMailApiCreateMailboxRequest = (
request: ClassicMailApiCreateMailboxRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
email:
request.email !== undefined
? marshalEmailAddress(request.email, defaults)
: undefined,
password: request.password,
})

export const marshalClassicMailApiUpdateMailboxRequest = (
request: ClassicMailApiUpdateMailboxRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
password: request.password,
})

const marshalCreateHostingRequestDomainConfiguration = (
request: CreateHostingRequestDomainConfiguration,
defaults: DefaultValues,
Expand Down
Loading