|
| 1 | +package status |
| 2 | + |
| 3 | +import ( |
| 4 | + "go.mongodb.org/atlas/mongodbatlas" |
| 5 | +) |
| 6 | + |
| 7 | +type CustomZoneMapping struct { |
| 8 | + CustomZoneMapping map[string]string `json:"customZoneMapping,omitempty"` |
| 9 | + ZoneMappingState string `json:"zoneMappingState,omitempty"` |
| 10 | + ZoneMappingErrMessage string `json:"zoneMappingErrMessage,omitempty"` |
| 11 | +} |
| 12 | + |
| 13 | +type ManagedNamespace struct { |
| 14 | + Db string `json:"db"` //nolint:stylecheck // not changing this as is a breaking change |
| 15 | + Collection string `json:"collection"` |
| 16 | + CustomShardKey string `json:"customShardKey,omitempty"` |
| 17 | + NumInitialChunks int `json:"numInitialChunks,omitempty"` |
| 18 | + IsCustomShardKeyHashed *bool `json:"isCustomShardKeyHashed,omitempty"` // Flag that specifies whether the custom shard key for the collection is hashed. |
| 19 | + IsShardKeyUnique *bool `json:"isShardKeyUnique,omitempty"` // Flag that specifies whether the underlying index enforces a unique constraint. |
| 20 | + Status string `json:"status,omitempty"` |
| 21 | + PresplitHashedZones *bool `json:"presplitHashedZones,omitempty"` |
| 22 | + ErrMessage string `json:"errMessage,omitempty"` |
| 23 | +} |
| 24 | + |
| 25 | +func NewFailedToCreateManagedNamespaceStatus(namespace mongodbatlas.ManagedNamespace, err error) ManagedNamespace { |
| 26 | + return ManagedNamespace{ |
| 27 | + Db: namespace.Db, |
| 28 | + Collection: namespace.Collection, |
| 29 | + CustomShardKey: namespace.CustomShardKey, |
| 30 | + IsCustomShardKeyHashed: namespace.IsCustomShardKeyHashed, |
| 31 | + IsShardKeyUnique: namespace.IsShardKeyUnique, |
| 32 | + NumInitialChunks: namespace.NumInitialChunks, |
| 33 | + PresplitHashedZones: namespace.PresplitHashedZones, |
| 34 | + Status: StatusFailed, |
| 35 | + ErrMessage: err.Error(), |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +func NewCreatedManagedNamespaceStatus(namespace mongodbatlas.ManagedNamespace) ManagedNamespace { |
| 40 | + return ManagedNamespace{ |
| 41 | + Db: namespace.Db, |
| 42 | + Collection: namespace.Collection, |
| 43 | + CustomShardKey: namespace.CustomShardKey, |
| 44 | + IsCustomShardKeyHashed: namespace.IsCustomShardKeyHashed, |
| 45 | + IsShardKeyUnique: namespace.IsShardKeyUnique, |
| 46 | + NumInitialChunks: namespace.NumInitialChunks, |
| 47 | + PresplitHashedZones: namespace.PresplitHashedZones, |
| 48 | + Status: StatusReady, |
| 49 | + } |
| 50 | +} |
0 commit comments