|
| 1 | +package status |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + |
| 6 | + "go.mongodb.org/atlas/mongodbatlas" |
| 7 | +) |
| 8 | + |
| 9 | +type ServerlessPrivateEndpoint struct { |
| 10 | + // ID is the identifier of the Serverless PrivateLink Service. |
| 11 | + ID string `json:"_id,omitempty"` |
| 12 | + // CloudProviderEndpointID is the identifier of the cloud provider endpoint. |
| 13 | + CloudProviderEndpointID string `json:"cloudProviderEndpointId,omitempty"` |
| 14 | + // Name is the name of the Serverless PrivateLink Service. Should be unique. |
| 15 | + Name string `json:"name,omitempty"` |
| 16 | + // EndpointServiceName is the name of the PrivateLink endpoint service in AWS. Returns null while the endpoint service is being created. |
| 17 | + EndpointServiceName string `json:"endpointServiceName,omitempty"` |
| 18 | + // ErrorMessage is the error message if the Serverless PrivateLink Service failed to create or connect. |
| 19 | + ErrorMessage string `json:"errorMessage,omitempty"` |
| 20 | + // Status of the AWS Serverless PrivateLink connection. |
| 21 | + Status string `json:"status,omitempty"` |
| 22 | + // ProviderName is human-readable label that identifies the cloud provider. Values include AWS or AZURE. |
| 23 | + ProviderName string `json:"providerName,omitempty"` |
| 24 | + // PrivateEndpointIPAddress is the IPv4 address of the private endpoint in your Azure VNet that someone added to this private endpoint service. |
| 25 | + PrivateEndpointIPAddress string `json:"privateEndpointIpAddress,omitempty"` |
| 26 | + // PrivateLinkServiceResourceID is the root-relative path that identifies the Azure Private Link Service that MongoDB Cloud manages. MongoDB Cloud returns null while it creates the endpoint service. |
| 27 | + PrivateLinkServiceResourceID string `json:"privateLinkServiceResourceId,omitempty"` |
| 28 | +} |
| 29 | + |
| 30 | +func SPEFromAtlas(in mongodbatlas.ServerlessPrivateEndpointConnection) ServerlessPrivateEndpoint { |
| 31 | + return ServerlessPrivateEndpoint{ |
| 32 | + ID: in.ID, |
| 33 | + CloudProviderEndpointID: in.CloudProviderEndpointID, |
| 34 | + Name: in.Comment, |
| 35 | + EndpointServiceName: in.EndpointServiceName, |
| 36 | + ErrorMessage: in.ErrorMessage, |
| 37 | + Status: in.Status, |
| 38 | + ProviderName: in.ProviderName, |
| 39 | + PrivateEndpointIPAddress: in.PrivateEndpointIPAddress, |
| 40 | + PrivateLinkServiceResourceID: in.PrivateLinkServiceResourceID, |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +func FailedToCreateSPE(comment, message string) ServerlessPrivateEndpoint { |
| 45 | + return ServerlessPrivateEndpoint{ |
| 46 | + ErrorMessage: message, |
| 47 | + Name: comment, |
| 48 | + Status: StatusFailed, |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +func FailedDuplicationSPE(name, cloudProviderEndpointID, privateEndpointIPAddress string) ServerlessPrivateEndpoint { |
| 53 | + return ServerlessPrivateEndpoint{ |
| 54 | + CloudProviderEndpointID: cloudProviderEndpointID, |
| 55 | + PrivateEndpointIPAddress: privateEndpointIPAddress, |
| 56 | + ErrorMessage: fmt.Sprintf("The SPE with same name exists: %s. Please use unique names", name), |
| 57 | + Name: name, |
| 58 | + Status: StatusFailed, |
| 59 | + } |
| 60 | +} |
| 61 | + |
| 62 | +func FailedToConnectSPE(pe mongodbatlas.ServerlessPrivateEndpointConnection, message string) ServerlessPrivateEndpoint { |
| 63 | + return ServerlessPrivateEndpoint{ |
| 64 | + ID: pe.ID, |
| 65 | + CloudProviderEndpointID: pe.CloudProviderEndpointID, |
| 66 | + Name: pe.Comment, |
| 67 | + EndpointServiceName: pe.EndpointServiceName, |
| 68 | + ErrorMessage: message, |
| 69 | + Status: StatusFailed, |
| 70 | + ProviderName: pe.ProviderName, |
| 71 | + PrivateEndpointIPAddress: pe.PrivateEndpointIPAddress, |
| 72 | + PrivateLinkServiceResourceID: pe.PrivateLinkServiceResourceID, |
| 73 | + } |
| 74 | +} |
0 commit comments