# Endpoint

Connection endpoint of a database cluster or instance.

Consists of a combination of hostname and port.

- Source: [`aws-docdb/lib/endpoint.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-docdb/lib/endpoint.ts#L9)

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_docdb as docdb } from 'aws-cdk-lib';
const endpoint = new docdb.Endpoint('address', 123);
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_docdb as docdb

endpoint = docdb.Endpoint("address", 123)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.docdb.*;

Endpoint endpoint = new Endpoint("address", 123);
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.DocDB;

var endpoint = new Endpoint("address", 123);
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

endpoint := awscdk.Aws_docdb.NewEndpoint(jsii.String("address"), jsii.Number(123))
```

## Initializer

TypeScript:

```ts
new Endpoint(address: string, port: number)
```

Python:

```python
Endpoint(address: str, port: int | float)
```

Java:

```java
new Endpoint(String address, Number port)
```

C# / .NET:

```csharp
new Endpoint(string address, double port)
```

Golang:

```go
NewEndpoint(Address *string, Port *float64)
```

## Properties

- `hostname`: string — The hostname of the endpoint.

- `port`: number — The port number of the endpoint.

  This can potentially be a CDK token. If you need to embed the port in a string (e.g. instance user data script),
  use `Endpoint.portAsString`.

- `socketAddress`: string — The combination of ``HOSTNAME:PORT`` for this endpoint.

## Methods

- `portAsString(): string` — Returns the port number as a string representation that can be used for embedding within other strings.

  This is intended to deal with CDK's token system. Numeric CDK tokens are not expanded when their string
  representation is embedded in a string. This function returns the port either as an unresolved string token or
  as a resolved string representation of the port value.

  **Returns:** An (un)resolved string representation of the endpoint's port number
