Skip to content

Commit

Permalink
feat(mnq): add AMQP credentials (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot authored Jul 26, 2022
1 parent 38905d8 commit bb5eac7
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
39 changes: 39 additions & 0 deletions packages/clients/src/api/mnq/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import type {
CreateCredentialRequest,
CreateNamespaceRequest,
Credential,
CredentialAMQPCreds,
CredentialNATSCredsFile,
CredentialSQSSNSCreds,
CredentialSummary,
CredentialSummaryAMQPCreds,
CredentialSummarySQSSNSCreds,
ListCredentialsResponse,
ListNamespacesResponse,
Expand All @@ -36,6 +38,21 @@ const unmarshalPermissions = (data: unknown) => {
} as Permissions
}

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

return {
permissions: data.permissions
? unmarshalPermissions(data.permissions)
: undefined,
username: data.username,
} as CredentialSummaryAMQPCreds
}

const unmarshalCredentialSummarySQSSNSCreds = (data: unknown) => {
if (!isJSONObject(data)) {
throw new TypeError(
Expand All @@ -51,6 +68,22 @@ const unmarshalCredentialSummarySQSSNSCreds = (data: unknown) => {
} as CredentialSummarySQSSNSCreds
}

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

return {
password: data.password,
permissions: data.permissions
? unmarshalPermissions(data.permissions)
: undefined,
username: data.username,
} as CredentialAMQPCreds
}

const unmarshalCredentialNATSCredsFile = (data: unknown) => {
if (!isJSONObject(data)) {
throw new TypeError(
Expand Down Expand Up @@ -85,6 +118,9 @@ const unmarshalCredentialSummary = (data: unknown) => {
}

return {
amqpCredentials: data.amqp_credentials
? unmarshalCredentialSummaryAMQPCreds(data.amqp_credentials)
: undefined,
id: data.id,
name: data.name,
namespaceId: data.namespace_id,
Expand Down Expand Up @@ -120,6 +156,9 @@ export const unmarshalCredential = (data: unknown) => {
}

return {
amqpCredentials: data.amqp_credentials
? unmarshalCredentialAMQPCreds(data.amqp_credentials)
: undefined,
id: data.id,
name: data.name,
namespaceId: data.namespace_id,
Expand Down
30 changes: 27 additions & 3 deletions packages/clients/src/api/mnq/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,25 @@ export interface Credential {
protocol: NamespaceProtocol
/**
* One-of ('credentialType'): at most one of 'natsCredentials',
* 'sqsSnsCredentials' could be set.
* 'sqsSnsCredentials', 'amqpCredentials' could be set.
*/
natsCredentials?: CredentialNATSCredsFile
/**
* One-of ('credentialType'): at most one of 'natsCredentials',
* 'sqsSnsCredentials' could be set.
* 'sqsSnsCredentials', 'amqpCredentials' could be set.
*/
sqsSnsCredentials?: CredentialSQSSNSCreds
/**
* One-of ('credentialType'): at most one of 'natsCredentials',
* 'sqsSnsCredentials', 'amqpCredentials' could be set.
*/
amqpCredentials?: CredentialAMQPCreds
}

export interface CredentialAMQPCreds {
username: string
password?: string
permissions?: Permissions
}

export interface CredentialNATSCredsFile {
Expand All @@ -50,8 +61,21 @@ export interface CredentialSummary {
name: string
namespaceId: string
protocol: NamespaceProtocol
/** One-of ('credentialType'): at most one of 'sqsSnsCredentials' could be set. */
/**
* One-of ('credentialType'): at most one of 'sqsSnsCredentials',
* 'amqpCredentials' could be set.
*/
sqsSnsCredentials?: CredentialSummarySQSSNSCreds
/**
* One-of ('credentialType'): at most one of 'sqsSnsCredentials',
* 'amqpCredentials' could be set.
*/
amqpCredentials?: CredentialSummaryAMQPCreds
}

export interface CredentialSummaryAMQPCreds {
username: string
permissions?: Permissions
}

export interface CredentialSummarySQSSNSCreds {
Expand Down

0 comments on commit bb5eac7

Please sign in to comment.