@routr/sdk is a Node.js client for the Routr API server. It exposes one client class per Connect resource. Each class wraps the gRPC API and returns promises. rctl is built on the same SDK.
Install
Add the SDK to your project.Import
The package has a default export that holds the seven client classes. In TypeScript, or any setup with ES module interop, import it like this.default property.
Privacy, Transport, LoadBalancingAlgorithm) come from @routr/common.
Client classes
Client options
Every class takes the sameClientOptions object.
string
required
Address of the API server, as
host:port. The API server’s external port defaults to 51908.boolean
default:"false"
Use a plaintext connection. When
false, the client opens a TLS connection. Setting the environment variable ALLOW_INSECURE=true has the same effect.string
Path to a CA certificate used to verify the server’s TLS certificate. The client throws if the file does not exist. When omitted, the system CA store is used.
string
Username for Basic authentication. When you set both
username and password, the client sends an authorization: Basic <base64(username:password)> gRPC metadata entry with every call.string
Password for Basic authentication.
Common behavior
Every client has the same five methods, named after its resource.List request and response
number
required
Number of items to return.
string
required
Token from the previous page. Use
"" for the first page.Resource[]
The resources in this page.
string
Token for the next page. Empty when there are no more pages.
Fields on every resource
Every response object carries these fields in addition to the resource fields.string
Unique reference. The API server generates a UUID on create.
string
v2beta1 or v2. Resources created through the PostgreSQL-backed API server are stored as v2.string
Friendly name.
number
Creation time, as a Unix timestamp in seconds.
number
Last update time, as a Unix timestamp in seconds.
object
Free-form attributes you attach to the resource, such as an external ID.
Errors
Methods reject with gRPC errors. Checkerror.code against @grpc/grpc-js status codes.
The following snippet handles a duplicate Agent.
Acls
Manages AccessControlList resources.CreateAclRequest fields:
UpdateAclRequest takes ref (required) plus any of the fields above.
Agents
Manages Agent resources.CreateAgentRequest fields:
UpdateAgentRequest takes ref (required) plus any field above except username, which you can’t change.
Responses include domain and credentials: the referenced Domain and Credentials objects, when set.
Credentials
Manages Credentials resources.CreateCredentialsRequest fields:
UpdateCredentialsRequest takes ref (required) plus any of the fields above.
Domains
Manages Domain resources.CreateDomainRequest fields:
UpdateDomainRequest takes ref (required) plus any field above except domainUri, which you can’t change.
Responses include accessControlList and, inside each egress policy, number: the referenced objects, when set.
Numbers
Manages Number resources.CreateNumberRequest fields:
UpdateNumberRequest takes ref (required) plus any field above except telUrl, city, country, and countryIsoCode.
Responses include trunk: the referenced Trunk, when set.
Peers
Manages Peer resources.CreatePeerRequest fields:
UpdatePeerRequest takes ref (required) plus any field above except username, which you can’t change.
Responses include accessControlList and credentials: the referenced objects, when set.
Trunks
Manages Trunk resources.CreateTrunkRequest fields:
TrunkURI fields:
UpdateTrunkRequest takes ref (required) plus any of the fields above.
Responses include accessControlList, inboundCredentials, and outboundCredentials: the referenced objects, when set.
Related
Manage resources with the SDK
Build a small script that provisions a Domain and Agents.
Connect resources
Field constraints and the YAML form of each resource.