|
| 1 | +// Copyright DataStax, Inc. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +import type { AstraDatabaseCloudProvider } from './admin-common.js'; |
| 16 | +import type { CommandOptions } from '@/src/lib/index.js'; |
| 17 | + |
| 18 | +/** |
| 19 | + * ##### Overview |
| 20 | + * |
| 21 | + * The options for {@link AstraAdmin.findAvailableRegions}. |
| 22 | + * |
| 23 | + * @example |
| 24 | + * ```ts |
| 25 | + * const regions = await admin.findAvailableRegions({ |
| 26 | + * onlyOrgEnabledRegions: false, |
| 27 | + * }); |
| 28 | + * ``` |
| 29 | + * |
| 30 | + * @see AstraAdmin.findAvailableRegions |
| 31 | + * @see AstraAvailableRegionInfo |
| 32 | + * |
| 33 | + * @public |
| 34 | + */ |
| 35 | +export interface AstraFindAvailableRegionsOptions extends CommandOptions<{ timeout: 'databaseAdminTimeoutMs' }> { |
| 36 | + /** |
| 37 | + * Whether to only return regions that are enabled for the current organization. |
| 38 | + * |
| 39 | + * - When `true` or unset: only returns regions enabled for the current organization. |
| 40 | + * - When `false`: returns all available regions, including those not enabled for the organization. |
| 41 | + * |
| 42 | + * Note that the organization is determined by the token used to authenticate the request. |
| 43 | + * |
| 44 | + * Defaults to `true`. |
| 45 | + */ |
| 46 | + onlyOrgEnabledRegions?: boolean, |
| 47 | +} |
| 48 | + |
| 49 | +/** |
| 50 | + * ##### Overview |
| 51 | + * |
| 52 | + * Represents the classification tier of an Astra database region. |
| 53 | + * |
| 54 | + * Region availability will depend on the user's account level. |
| 55 | + * |
| 56 | + * @see AstraAvailableRegionInfo |
| 57 | + * |
| 58 | + * @public |
| 59 | + */ |
| 60 | +export type AstraRegionClassification = 'standard' | 'premium' | 'premium_plus'; |
| 61 | + |
| 62 | +/** |
| 63 | + * ##### Overview |
| 64 | + * |
| 65 | + * Represents the geographic zone where an Astra database region is located. |
| 66 | + * |
| 67 | + * - `'na'`: North America |
| 68 | + * - `'emea'`: Europe, Middle East, and Africa |
| 69 | + * - `'apac'`: Asia Pacific |
| 70 | + * - `'sa'`: South America |
| 71 | + * |
| 72 | + * @see AstraAvailableRegionInfo |
| 73 | + * |
| 74 | + * @public |
| 75 | + */ |
| 76 | +export type AstraRegionZone = 'na' | 'apac' | 'emea' | 'sa'; |
| 77 | + |
| 78 | +/** |
| 79 | + * ##### Overview |
| 80 | + * |
| 81 | + * Information about an available region for Astra database deployments. |
| 82 | + * |
| 83 | + * This provides details about each available region including classification, cloud provider, display name, and availability status. |
| 84 | + * |
| 85 | + * @example |
| 86 | + * ```ts |
| 87 | + * // Basic usage |
| 88 | + * const regions = await admin.findAvailableRegions(); |
| 89 | + * console.log(regions[0].displayName); // 'Moncks Corner, South Carolina' |
| 90 | + * |
| 91 | + * // Further filterting & transformation may be done using native list methods |
| 92 | + * const awsRegions = regions.filter(region => region.cloudProvider === 'AWS'); |
| 93 | + * ``` |
| 94 | + * |
| 95 | + * @see AstraAdmin.findAvailableRegions |
| 96 | + * @see AstraFindAvailableRegionsOptions |
| 97 | + * |
| 98 | + * @public |
| 99 | + */ |
| 100 | +export interface AstraAvailableRegionInfo { |
| 101 | + /** |
| 102 | + * Represents the classification tier of an Astra database region. |
| 103 | + * |
| 104 | + * Region availability will depend on the user's account level. |
| 105 | + * |
| 106 | + * @example |
| 107 | + * ```ts |
| 108 | + * 'standard' |
| 109 | + * ``` |
| 110 | + */ |
| 111 | + classification: AstraRegionClassification, |
| 112 | + /** |
| 113 | + * The cloud provider hosting this region. |
| 114 | + * |
| 115 | + * @example |
| 116 | + * ```ts |
| 117 | + * 'GCP' |
| 118 | + * ``` |
| 119 | + */ |
| 120 | + cloudProvider: AstraDatabaseCloudProvider, |
| 121 | + /** |
| 122 | + * A human-readable display name for the region. |
| 123 | + * |
| 124 | + * @example |
| 125 | + * ```ts |
| 126 | + * 'Moncks Corner, South Carolina' |
| 127 | + * ``` |
| 128 | + */ |
| 129 | + displayName: string, |
| 130 | + /** |
| 131 | + * Whether this region is currently enabled for use. |
| 132 | + * |
| 133 | + * > **✏️Note:** If {@link AstraFindAvailableRegionsOptions.onlyOrgEnabledRegions} is `false`, and `enabled` is still `true`, it does not guarantee that the region is usable by the current organization. |
| 134 | + */ |
| 135 | + enabled: boolean, |
| 136 | + /** |
| 137 | + * The unique identifier for the region. |
| 138 | + * |
| 139 | + * @example |
| 140 | + * ```ts |
| 141 | + * 'us-east1' |
| 142 | + * ``` |
| 143 | + */ |
| 144 | + name: string, |
| 145 | + /** |
| 146 | + * Whether this region is reserved for qualified users only, meaning special access is required to use it. |
| 147 | + */ |
| 148 | + reservedForQualifiedUsers: boolean, |
| 149 | + /** |
| 150 | + * The geographic zone where this region is located. |
| 151 | + * |
| 152 | + * @example |
| 153 | + * ```ts |
| 154 | + * 'na' |
| 155 | + * ``` |
| 156 | + */ |
| 157 | + zone: AstraRegionZone, |
| 158 | +} |
0 commit comments