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
38 changes: 24 additions & 14 deletions src/services/cosmosDb/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ const formatRestoreParameters = (
const { restoreTimestampInUtc, databasesToRestore, ...rest } = restoreParameters
return {
restoreTimestampInUtc: restoreTimestampInUtc?.toISOString(),
databasesToRestore: databasesToRestore?.map(db => ({ id: generateUniqueId({
...db
}), ...db })) || [],
databasesToRestore: databasesToRestore?.map(db => ({
id: generateUniqueId({
...db
}), ...db
})) || [],
...rest,
}
}
Expand Down Expand Up @@ -94,6 +96,20 @@ export default ({
tables = [],
} = service

let containersIds: string[] = []
const sqlDatabases = databases?.map(({ id: databaseId, options, data, ...rest }) => {
const containers = new Set(data.map(d => d.id))
containersIds = Array.from(containers)
return ({
id: databaseId,
...rest,
options: {
throughput: options?.throughput,
maxThroughput: options?.autoscaleSettings?.maxThroughput,
},
})
}) || []

return {
id,
name,
Expand Down Expand Up @@ -133,10 +149,10 @@ export default ({
failoverPolicies?.map(fp => ({ id: fp.id, ...fp })) || [],
virtualNetworkRules:
virtualNetworkRules?.map(vn => ({ id: vn.id, ...vn })) || [],
privateEndpointConnections: privateEndpointConnections?.map(({ id: endpointId, privateEndpoint, ...pe}) => ({
id: endpointId,
privateEndpointConnections: privateEndpointConnections?.map(({ id: endpointId, privateEndpoint, ...pe }) => ({
id: endpointId,
privateEndpointId: privateEndpoint?.id,
...pe
...pe
})) || [],
enableMultipleWriteLocations,
enableCassandraConnector,
Expand All @@ -160,14 +176,8 @@ export default ({
disableLocalAuth,
capacityTotalThroughputLimit: capacity?.totalThroughputLimit,
tags: formatTagsFromMap(Tags),
databases: databases?.map(({ id: databaseId, options, ...rest }) => ({
id: databaseId,
...rest,
options: {
throughput: options?.throughput,
maxThroughput: options?.autoscaleSettings?.maxThroughput,
},
})) || [],
databases: sqlDatabases,
azureTables: tables?.map(at => ({ id: at.id, ...at })) || [],
containersIds
}
}
1 change: 1 addition & 0 deletions src/types/generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2497,6 +2497,7 @@ export type AzureCosmosDb = AzureResource & {
capacityTotalThroughputLimit?: Maybe<Scalars['Int']>;
connectorOffer?: Maybe<Scalars['String']>;
consistencyPolicy?: Maybe<AzureCosmosDbConsistencyPolicy>;
containersIds?: Maybe<Array<Maybe<Scalars['String']>>>;
cors?: Maybe<Array<Maybe<AzureCosmosDbCorsPolicy>>>;
createMode?: Maybe<Scalars['String']>;
createdAt?: Maybe<Scalars['String']>;
Expand Down