Merge pull request #38 from ngrok/pr/generated-6c60d3c7d0

Update generated files
This commit is contained in:
Rachel Kolavo
2024-02-05 14:20:42 -07:00
committed by GitHub
6 changed files with 784 additions and 0 deletions
+6
View File
@@ -1,4 +1,10 @@
<!-- Code generated for API Clients. DO NOT EDIT. -->
## v5.2.0
ENHANCEMENTS:
* Added support for the Traffic Policy module on TCP edges, TLS edges, and HTTPS edge routes. A Traffic Policy allows traffic to and from your edges to be shaped and influenced by defining rules that contain expression to filter the traffic and actions to take effect.
* Added `static_backend` resource, which defines a static address at which traffic should be forwarded.
## v5.1.0
+233
View File
@@ -0,0 +1,233 @@
// Code generated for API Clients. DO NOT EDIT.
package static_address
import (
"bytes"
"context"
"net/url"
"text/template"
"github.com/ngrok/ngrok-api-go/v5"
"github.com/ngrok/ngrok-api-go/v5/internal/api"
)
// A static backend sends traffic to a TCP address (hostname and port) that
// is reachable on the public internet.
type Client struct {
apiClient *api.Client
}
func NewClient(cfg *ngrok.ClientConfig) *Client {
return &Client{apiClient: api.NewClient(cfg)}
}
// Create a new static backend
//
// https://ngrok.com/docs/api#api-static-backends-create
func (c *Client) Create(ctx context.Context, arg *ngrok.StaticBackendCreate) (*ngrok.StaticBackend, error) {
if arg == nil {
arg = new(ngrok.StaticBackendCreate)
}
var res ngrok.StaticBackend
var path bytes.Buffer
if err := template.Must(template.New("create_path").Parse("/backends/static")).Execute(&path, arg); err != nil {
panic(err)
}
var (
apiURL = &url.URL{Path: path.String()}
bodyArg interface{}
)
apiURL.Path = path.String()
bodyArg = arg
if err := c.apiClient.Do(ctx, "POST", apiURL, bodyArg, &res); err != nil {
return nil, err
}
return &res, nil
}
// Delete a static backend by ID.
//
// https://ngrok.com/docs/api#api-static-backends-delete
func (c *Client) Delete(ctx context.Context, id string) error {
arg := &ngrok.Item{ID: id}
var path bytes.Buffer
if err := template.Must(template.New("delete_path").Parse("/backends/static/{{ .ID }}")).Execute(&path, arg); err != nil {
panic(err)
}
arg.ID = ""
var (
apiURL = &url.URL{Path: path.String()}
bodyArg interface{}
)
apiURL.Path = path.String()
if err := c.apiClient.Do(ctx, "DELETE", apiURL, bodyArg, nil); err != nil {
return err
}
return nil
}
// Get detailed information about a static backend by ID
//
// https://ngrok.com/docs/api#api-static-backends-get
func (c *Client) Get(ctx context.Context, id string) (*ngrok.StaticBackend, error) {
arg := &ngrok.Item{ID: id}
var res ngrok.StaticBackend
var path bytes.Buffer
if err := template.Must(template.New("get_path").Parse("/backends/static/{{ .ID }}")).Execute(&path, arg); err != nil {
panic(err)
}
arg.ID = ""
var (
apiURL = &url.URL{Path: path.String()}
bodyArg interface{}
)
apiURL.Path = path.String()
if err := c.apiClient.Do(ctx, "GET", apiURL, bodyArg, &res); err != nil {
return nil, err
}
return &res, nil
}
// List all static backends on this account
//
// https://ngrok.com/docs/api#api-static-backends-list
func (c *Client) list(ctx context.Context, arg *ngrok.Paging) (*ngrok.StaticBackendList, error) {
if arg == nil {
arg = new(ngrok.Paging)
}
var res ngrok.StaticBackendList
var path bytes.Buffer
if err := template.Must(template.New("list_path").Parse("/backends/static")).Execute(&path, arg); err != nil {
panic(err)
}
var (
apiURL = &url.URL{Path: path.String()}
bodyArg interface{}
)
apiURL.Path = path.String()
queryVals := make(url.Values)
if arg.BeforeID != nil {
queryVals.Set("before_id", *arg.BeforeID)
}
if arg.Limit != nil {
queryVals.Set("limit", *arg.Limit)
}
apiURL.RawQuery = queryVals.Encode()
if err := c.apiClient.Do(ctx, "GET", apiURL, bodyArg, &res); err != nil {
return nil, err
}
return &res, nil
}
// List all static backends on this account
//
// https://ngrok.com/docs/api#api-static-backends-list
func (c *Client) List(paging *ngrok.Paging) *Iter {
if paging == nil {
paging = new(ngrok.Paging)
}
if paging.Limit == nil {
paging.Limit = ngrok.String("100")
}
return &Iter{
client: c,
limit: paging.Limit,
lastItemID: paging.BeforeID,
n: -1,
}
}
// Iter allows the caller to iterate through a list of values while
// automatically fetching new pages worth of values from the API.
type Iter struct {
client *Client
n int
items []ngrok.StaticBackend
err error
limit *string
lastItemID *string
}
// Next returns true if there is another value available in the iterator. If it
// returs true it also advances the iterator to that next available item.
func (it *Iter) Next(ctx context.Context) bool {
// no more if there is an error
if it.err != nil {
return false
}
// advance the iterator
it.n += 1
// is there an available item?
if it.n < len(it.items) {
it.lastItemID = ngrok.String(it.Item().ID)
return true
}
// fetch the next page
resp, err := it.client.list(ctx, &ngrok.Paging{
BeforeID: it.lastItemID,
Limit: it.limit,
})
if err != nil {
it.err = err
return false
}
// page with zero items means there are no more
if len(resp.Backends) == 0 {
return false
}
it.n = -1
it.items = resp.Backends
return it.Next(ctx)
}
// Item() returns the StaticBackend currently
// pointed to by the iterator.
func (it *Iter) Item() *ngrok.StaticBackend {
return &it.items[it.n]
}
// If Next() returned false because an error was encountered while fetching the
// next value Err() will return that error. A caller should always check Err()
// after Next() returns false.
func (it *Iter) Err() error {
return it.err
}
// Update static backend by ID
//
// https://ngrok.com/docs/api#api-static-backends-update
func (c *Client) Update(ctx context.Context, arg *ngrok.StaticBackendUpdate) (*ngrok.StaticBackend, error) {
if arg == nil {
arg = new(ngrok.StaticBackendUpdate)
}
var res ngrok.StaticBackend
var path bytes.Buffer
if err := template.Must(template.New("update_path").Parse("/backends/static/{{ .ID }}")).Execute(&path, arg); err != nil {
panic(err)
}
arg.ID = ""
var (
apiURL = &url.URL{Path: path.String()}
bodyArg interface{}
)
apiURL.Path = path.String()
bodyArg = arg
if err := c.apiClient.Do(ctx, "PATCH", apiURL, bodyArg, &res); err != nil {
return nil, err
}
return &res, nil
}
+285
View File
@@ -1127,6 +1127,147 @@ func (x *HTTPResponseBackendList) GoString() string {
return b.String()
}
type StaticBackend struct {
// unique identifier for this static backend
ID string `json:"id,omitempty"`
// URI of the StaticBackend API resource
URI string `json:"uri,omitempty"`
// timestamp when the backend was created, RFC 3339 format
CreatedAt string `json:"created_at,omitempty"`
// human-readable description of this backend. Optional
Description string `json:"description,omitempty"`
// arbitrary user-defined machine-readable data of this backend. Optional
Metadata string `json:"metadata,omitempty"`
// the address to forward to
Address string `json:"address,omitempty"`
// tls configuration to use
TLS StaticBackendTLS `json:"tls,omitempty"`
}
func (x *StaticBackend) String() string {
return fmt.Sprintf("StaticBackend{ID: %v}", x.ID)
}
func (x *StaticBackend) GoString() string {
var b bytes.Buffer
fmt.Fprintf(&b, "StaticBackend {\n")
tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0)
fmt.Fprintf(tw, "\tID\t%v\n", x.ID)
fmt.Fprintf(tw, "\tURI\t%v\n", x.URI)
fmt.Fprintf(tw, "\tCreatedAt\t%v\n", x.CreatedAt)
fmt.Fprintf(tw, "\tDescription\t%v\n", x.Description)
fmt.Fprintf(tw, "\tMetadata\t%v\n", x.Metadata)
fmt.Fprintf(tw, "\tAddress\t%v\n", x.Address)
fmt.Fprintf(tw, "\tTLS\t%v\n", x.TLS)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
}
type StaticBackendTLS struct {
// if TLS is checked
Enabled bool `json:"enabled,omitempty"`
}
func (x *StaticBackendTLS) String() string {
return x.GoString()
}
func (x *StaticBackendTLS) GoString() string {
var b bytes.Buffer
fmt.Fprintf(&b, "StaticBackendTLS {\n")
tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0)
fmt.Fprintf(tw, "\tEnabled\t%v\n", x.Enabled)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
}
type StaticBackendCreate struct {
// human-readable description of this backend. Optional
Description string `json:"description,omitempty"`
// arbitrary user-defined machine-readable data of this backend. Optional
Metadata string `json:"metadata,omitempty"`
// the address to forward to
Address string `json:"address,omitempty"`
// tls configuration to use
TLS StaticBackendTLS `json:"tls,omitempty"`
}
func (x *StaticBackendCreate) String() string {
return x.GoString()
}
func (x *StaticBackendCreate) GoString() string {
var b bytes.Buffer
fmt.Fprintf(&b, "StaticBackendCreate {\n")
tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0)
fmt.Fprintf(tw, "\tDescription\t%v\n", x.Description)
fmt.Fprintf(tw, "\tMetadata\t%v\n", x.Metadata)
fmt.Fprintf(tw, "\tAddress\t%v\n", x.Address)
fmt.Fprintf(tw, "\tTLS\t%v\n", x.TLS)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
}
type StaticBackendUpdate struct {
ID string `json:"id,omitempty"`
// human-readable description of this backend. Optional
Description *string `json:"description,omitempty"`
// arbitrary user-defined machine-readable data of this backend. Optional
Metadata *string `json:"metadata,omitempty"`
// the address to forward to
Address string `json:"address,omitempty"`
// tls configuration to use
TLS StaticBackendTLS `json:"tls,omitempty"`
}
func (x *StaticBackendUpdate) String() string {
return fmt.Sprintf("StaticBackendUpdate{ID: %v}", x.ID)
}
func (x *StaticBackendUpdate) GoString() string {
var b bytes.Buffer
fmt.Fprintf(&b, "StaticBackendUpdate {\n")
tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0)
fmt.Fprintf(tw, "\tID\t%v\n", x.ID)
fmt.Fprintf(tw, "\tDescription\t%v\n", x.Description)
fmt.Fprintf(tw, "\tMetadata\t%v\n", x.Metadata)
fmt.Fprintf(tw, "\tAddress\t%v\n", x.Address)
fmt.Fprintf(tw, "\tTLS\t%v\n", x.TLS)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
}
type StaticBackendList struct {
// the list of all static backends on this account
Backends []StaticBackend `json:"backends,omitempty"`
// URI of the static backends list API resource
URI string `json:"uri,omitempty"`
// URI of the next page, or null if there is no next page
NextPageURI *string `json:"next_page_uri,omitempty"`
}
func (x *StaticBackendList) String() string {
return x.GoString()
}
func (x *StaticBackendList) GoString() string {
var b bytes.Buffer
fmt.Fprintf(&b, "StaticBackendList {\n")
tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0)
fmt.Fprintf(tw, "\tBackends\t%v\n", x.Backends)
fmt.Fprintf(tw, "\tURI\t%v\n", x.URI)
fmt.Fprintf(tw, "\tNextPageURI\t%v\n", x.NextPageURI)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
}
type TunnelGroupBackend struct {
// unique identifier for this TunnelGroup backend
ID string `json:"id,omitempty"`
@@ -2819,6 +2960,79 @@ func (x *EndpointJWTValidation) GoString() string {
return b.String()
}
type EndpointPolicy struct {
// true if the module will be applied to traffic, false to disable. default true if
// unspecified
Enabled *bool `json:"enabled,omitempty"`
// the inbound rules of the traffic policy.
Inbound []EndpointRule `json:"inbound,omitempty"`
// the outbound rules on the traffic policy.
Outbound []EndpointRule `json:"outbound,omitempty"`
}
func (x *EndpointPolicy) String() string {
return x.GoString()
}
func (x *EndpointPolicy) GoString() string {
var b bytes.Buffer
fmt.Fprintf(&b, "EndpointPolicy {\n")
tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0)
fmt.Fprintf(tw, "\tEnabled\t%v\n", x.Enabled)
fmt.Fprintf(tw, "\tInbound\t%v\n", x.Inbound)
fmt.Fprintf(tw, "\tOutbound\t%v\n", x.Outbound)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
}
type EndpointRule struct {
// cel expressions that filter traffic the policy rule applies to.
Expressions []string `json:"expressions,omitempty"`
// the set of actions on a policy rule.
Actions []EndpointAction `json:"actions,omitempty"`
// the name of the rule that is part of the traffic policy.
Name string `json:"name,omitempty"`
}
func (x *EndpointRule) String() string {
return x.GoString()
}
func (x *EndpointRule) GoString() string {
var b bytes.Buffer
fmt.Fprintf(&b, "EndpointRule {\n")
tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0)
fmt.Fprintf(tw, "\tExpressions\t%v\n", x.Expressions)
fmt.Fprintf(tw, "\tActions\t%v\n", x.Actions)
fmt.Fprintf(tw, "\tName\t%v\n", x.Name)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
}
type EndpointAction struct {
// the type of action on the policy rule.
Type string `json:"type,omitempty"`
// the configuration for the action on the policy rule.
Config any `json:"config,omitempty"`
}
func (x *EndpointAction) String() string {
return x.GoString()
}
func (x *EndpointAction) GoString() string {
var b bytes.Buffer
fmt.Fprintf(&b, "EndpointAction {\n")
tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0)
fmt.Fprintf(tw, "\tType\t%v\n", x.Type)
fmt.Fprintf(tw, "\tConfig\t%v\n", x.Config)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
}
type EdgeRouteItem struct {
// unique identifier of this edge
EdgeID string `json:"edge_id,omitempty"`
@@ -2881,6 +3095,8 @@ type HTTPSEdgeRouteCreate struct {
UserAgentFilter *EndpointUserAgentFilter `json:"user_agent_filter,omitempty"`
// jwt validation module configuration or null
JWTValidation *EndpointJWTValidation `json:"jwt_validation,omitempty"`
// the traffic policy associated with this edge or null
Policy *EndpointPolicy `json:"policy,omitempty"`
}
func (x *HTTPSEdgeRouteCreate) String() string {
@@ -2909,6 +3125,7 @@ func (x *HTTPSEdgeRouteCreate) GoString() string {
fmt.Fprintf(tw, "\tWebsocketTCPConverter\t%v\n", x.WebsocketTCPConverter)
fmt.Fprintf(tw, "\tUserAgentFilter\t%v\n", x.UserAgentFilter)
fmt.Fprintf(tw, "\tJWTValidation\t%v\n", x.JWTValidation)
fmt.Fprintf(tw, "\tPolicy\t%v\n", x.Policy)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
@@ -2955,6 +3172,8 @@ type HTTPSEdgeRouteUpdate struct {
UserAgentFilter *EndpointUserAgentFilter `json:"user_agent_filter,omitempty"`
// jwt validation module configuration or null
JWTValidation *EndpointJWTValidation `json:"jwt_validation,omitempty"`
// the traffic policy associated with this edge or null
Policy *EndpointPolicy `json:"policy,omitempty"`
}
func (x *HTTPSEdgeRouteUpdate) String() string {
@@ -2985,6 +3204,7 @@ func (x *HTTPSEdgeRouteUpdate) GoString() string {
fmt.Fprintf(tw, "\tWebsocketTCPConverter\t%v\n", x.WebsocketTCPConverter)
fmt.Fprintf(tw, "\tUserAgentFilter\t%v\n", x.UserAgentFilter)
fmt.Fprintf(tw, "\tJWTValidation\t%v\n", x.JWTValidation)
fmt.Fprintf(tw, "\tPolicy\t%v\n", x.Policy)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
@@ -3035,6 +3255,8 @@ type HTTPSEdgeRoute struct {
UserAgentFilter *EndpointUserAgentFilter `json:"user_agent_filter,omitempty"`
// jwt validation module configuration or null
JWTValidation *EndpointJWTValidation `json:"jwt_validation,omitempty"`
// the traffic policy associated with this edge or null
Policy *EndpointPolicy `json:"policy,omitempty"`
}
func (x *HTTPSEdgeRoute) String() string {
@@ -3067,6 +3289,7 @@ func (x *HTTPSEdgeRoute) GoString() string {
fmt.Fprintf(tw, "\tWebsocketTCPConverter\t%v\n", x.WebsocketTCPConverter)
fmt.Fprintf(tw, "\tUserAgentFilter\t%v\n", x.UserAgentFilter)
fmt.Fprintf(tw, "\tJWTValidation\t%v\n", x.JWTValidation)
fmt.Fprintf(tw, "\tPolicy\t%v\n", x.Policy)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
@@ -3315,6 +3538,27 @@ func (x *EdgeTLSTerminationAtEdgeReplace) GoString() string {
return b.String()
}
type EdgePolicyReplace struct {
ID string `json:"id,omitempty"`
Module EndpointPolicy `json:"module,omitempty"`
}
func (x *EdgePolicyReplace) String() string {
return fmt.Sprintf("EdgePolicyReplace{ID: %v}", x.ID)
}
func (x *EdgePolicyReplace) GoString() string {
var b bytes.Buffer
fmt.Fprintf(&b, "EdgePolicyReplace {\n")
tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0)
fmt.Fprintf(tw, "\tID\t%v\n", x.ID)
fmt.Fprintf(tw, "\tModule\t%v\n", x.Module)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
}
type EdgeRouteBackendReplace struct {
EdgeID string `json:"edge_id,omitempty"`
ID string `json:"id,omitempty"`
@@ -3614,6 +3858,29 @@ func (x *EdgeRouteJWTValidationReplace) GoString() string {
return b.String()
}
type EdgeRoutePolicyReplace struct {
EdgeID string `json:"edge_id,omitempty"`
ID string `json:"id,omitempty"`
Module EndpointPolicy `json:"module,omitempty"`
}
func (x *EdgeRoutePolicyReplace) String() string {
return fmt.Sprintf("EdgeRoutePolicyReplace{ID: %v}", x.ID)
}
func (x *EdgeRoutePolicyReplace) GoString() string {
var b bytes.Buffer
fmt.Fprintf(&b, "EdgeRoutePolicyReplace {\n")
tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0)
fmt.Fprintf(tw, "\tEdgeID\t%v\n", x.EdgeID)
fmt.Fprintf(tw, "\tID\t%v\n", x.ID)
fmt.Fprintf(tw, "\tModule\t%v\n", x.Module)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
}
type TCPEdgeList struct {
// the list of all TCP Edges on this account
TCPEdges []TCPEdge `json:"tcp_edges,omitempty"`
@@ -3651,6 +3918,8 @@ type TCPEdgeCreate struct {
// edge modules
Backend *EndpointBackendMutate `json:"backend,omitempty"`
IPRestriction *EndpointIPPolicyMutate `json:"ip_restriction,omitempty"`
// the traffic policy associated with this edge or null
Policy *EndpointPolicy `json:"policy,omitempty"`
}
func (x *TCPEdgeCreate) String() string {
@@ -3666,6 +3935,7 @@ func (x *TCPEdgeCreate) GoString() string {
fmt.Fprintf(tw, "\tHostports\t%v\n", x.Hostports)
fmt.Fprintf(tw, "\tBackend\t%v\n", x.Backend)
fmt.Fprintf(tw, "\tIPRestriction\t%v\n", x.IPRestriction)
fmt.Fprintf(tw, "\tPolicy\t%v\n", x.Policy)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
@@ -3685,6 +3955,8 @@ type TCPEdgeUpdate struct {
// edge modules
Backend *EndpointBackendMutate `json:"backend,omitempty"`
IPRestriction *EndpointIPPolicyMutate `json:"ip_restriction,omitempty"`
// the traffic policy associated with this edge or null
Policy *EndpointPolicy `json:"policy,omitempty"`
}
func (x *TCPEdgeUpdate) String() string {
@@ -3702,6 +3974,7 @@ func (x *TCPEdgeUpdate) GoString() string {
fmt.Fprintf(tw, "\tHostports\t%v\n", x.Hostports)
fmt.Fprintf(tw, "\tBackend\t%v\n", x.Backend)
fmt.Fprintf(tw, "\tIPRestriction\t%v\n", x.IPRestriction)
fmt.Fprintf(tw, "\tPolicy\t%v\n", x.Policy)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
@@ -3725,6 +3998,8 @@ type TCPEdge struct {
// edge modules
Backend *EndpointBackend `json:"backend,omitempty"`
IpRestriction *EndpointIPPolicy `json:"ip_restriction,omitempty"`
// the traffic policy associated with this edge or null
Policy *EndpointPolicy `json:"policy,omitempty"`
}
func (x *TCPEdge) String() string {
@@ -3744,6 +4019,7 @@ func (x *TCPEdge) GoString() string {
fmt.Fprintf(tw, "\tHostports\t%v\n", x.Hostports)
fmt.Fprintf(tw, "\tBackend\t%v\n", x.Backend)
fmt.Fprintf(tw, "\tIpRestriction\t%v\n", x.IpRestriction)
fmt.Fprintf(tw, "\tPolicy\t%v\n", x.Policy)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
@@ -3788,6 +4064,8 @@ type TLSEdgeCreate struct {
IPRestriction *EndpointIPPolicyMutate `json:"ip_restriction,omitempty"`
MutualTLS *EndpointMutualTLSMutate `json:"mutual_tls,omitempty"`
TLSTermination *EndpointTLSTermination `json:"tls_termination,omitempty"`
// the traffic policy associated with this edge or null
Policy *EndpointPolicy `json:"policy,omitempty"`
}
func (x *TLSEdgeCreate) String() string {
@@ -3805,6 +4083,7 @@ func (x *TLSEdgeCreate) GoString() string {
fmt.Fprintf(tw, "\tIPRestriction\t%v\n", x.IPRestriction)
fmt.Fprintf(tw, "\tMutualTLS\t%v\n", x.MutualTLS)
fmt.Fprintf(tw, "\tTLSTermination\t%v\n", x.TLSTermination)
fmt.Fprintf(tw, "\tPolicy\t%v\n", x.Policy)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
@@ -3826,6 +4105,8 @@ type TLSEdgeUpdate struct {
IPRestriction *EndpointIPPolicyMutate `json:"ip_restriction,omitempty"`
MutualTLS *EndpointMutualTLSMutate `json:"mutual_tls,omitempty"`
TLSTermination *EndpointTLSTermination `json:"tls_termination,omitempty"`
// the traffic policy associated with this edge or null
Policy *EndpointPolicy `json:"policy,omitempty"`
}
func (x *TLSEdgeUpdate) String() string {
@@ -3845,6 +4126,7 @@ func (x *TLSEdgeUpdate) GoString() string {
fmt.Fprintf(tw, "\tIPRestriction\t%v\n", x.IPRestriction)
fmt.Fprintf(tw, "\tMutualTLS\t%v\n", x.MutualTLS)
fmt.Fprintf(tw, "\tTLSTermination\t%v\n", x.TLSTermination)
fmt.Fprintf(tw, "\tPolicy\t%v\n", x.Policy)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
@@ -3870,6 +4152,8 @@ type TLSEdge struct {
IpRestriction *EndpointIPPolicy `json:"ip_restriction,omitempty"`
MutualTls *EndpointMutualTLS `json:"mutual_tls,omitempty"`
TlsTermination *EndpointTLSTermination `json:"tls_termination,omitempty"`
// the traffic policy associated with this edge or null
Policy *EndpointPolicy `json:"policy,omitempty"`
}
func (x *TLSEdge) String() string {
@@ -3891,6 +4175,7 @@ func (x *TLSEdge) GoString() string {
fmt.Fprintf(tw, "\tIpRestriction\t%v\n", x.IpRestriction)
fmt.Fprintf(tw, "\tMutualTls\t%v\n", x.MutualTls)
fmt.Fprintf(tw, "\tTlsTermination\t%v\n", x.TlsTermination)
fmt.Fprintf(tw, "\tPolicy\t%v\n", x.Policy)
tw.Flush()
fmt.Fprintf(&b, "}\n")
return b.String()
@@ -0,0 +1,90 @@
// Code generated for API Clients. DO NOT EDIT.
package https_edge_route_policy
import (
"bytes"
"context"
"net/url"
"text/template"
"github.com/ngrok/ngrok-api-go/v5"
"github.com/ngrok/ngrok-api-go/v5/internal/api"
)
type Client struct {
apiClient *api.Client
}
func NewClient(cfg *ngrok.ClientConfig) *Client {
return &Client{apiClient: api.NewClient(cfg)}
}
func (c *Client) Replace(ctx context.Context, arg *ngrok.EdgeRoutePolicyReplace) (*ngrok.EndpointPolicy, error) {
if arg == nil {
arg = new(ngrok.EdgeRoutePolicyReplace)
}
var res ngrok.EndpointPolicy
var path bytes.Buffer
if err := template.Must(template.New("replace_path").Parse("/edges/https/{{ .EdgeID }}/routes/{{ .ID }}/policy")).Execute(&path, arg); err != nil {
panic(err)
}
arg.EdgeID = ""
arg.ID = ""
var (
apiURL = &url.URL{Path: path.String()}
bodyArg interface{}
)
apiURL.Path = path.String()
bodyArg = arg.Module
if err := c.apiClient.Do(ctx, "PUT", apiURL, bodyArg, &res); err != nil {
return nil, err
}
return &res, nil
}
func (c *Client) Get(ctx context.Context, arg *ngrok.EdgeRouteItem) (*ngrok.EndpointPolicy, error) {
if arg == nil {
arg = new(ngrok.EdgeRouteItem)
}
var res ngrok.EndpointPolicy
var path bytes.Buffer
if err := template.Must(template.New("get_path").Parse("/edges/https/{{ .EdgeID }}/routes/{{ .ID }}/policy")).Execute(&path, arg); err != nil {
panic(err)
}
arg.EdgeID = ""
arg.ID = ""
var (
apiURL = &url.URL{Path: path.String()}
bodyArg interface{}
)
apiURL.Path = path.String()
if err := c.apiClient.Do(ctx, "GET", apiURL, bodyArg, &res); err != nil {
return nil, err
}
return &res, nil
}
func (c *Client) Delete(ctx context.Context, arg *ngrok.EdgeRouteItem) error {
if arg == nil {
arg = new(ngrok.EdgeRouteItem)
}
var path bytes.Buffer
if err := template.Must(template.New("delete_path").Parse("/edges/https/{{ .EdgeID }}/routes/{{ .ID }}/policy")).Execute(&path, arg); err != nil {
panic(err)
}
arg.EdgeID = ""
arg.ID = ""
var (
apiURL = &url.URL{Path: path.String()}
bodyArg interface{}
)
apiURL.Path = path.String()
if err := c.apiClient.Do(ctx, "DELETE", apiURL, bodyArg, nil); err != nil {
return err
}
return nil
}
+85
View File
@@ -0,0 +1,85 @@
// Code generated for API Clients. DO NOT EDIT.
package tcp_edge_policy
import (
"bytes"
"context"
"net/url"
"text/template"
"github.com/ngrok/ngrok-api-go/v5"
"github.com/ngrok/ngrok-api-go/v5/internal/api"
)
type Client struct {
apiClient *api.Client
}
func NewClient(cfg *ngrok.ClientConfig) *Client {
return &Client{apiClient: api.NewClient(cfg)}
}
func (c *Client) Replace(ctx context.Context, arg *ngrok.EdgePolicyReplace) (*ngrok.EndpointPolicy, error) {
if arg == nil {
arg = new(ngrok.EdgePolicyReplace)
}
var res ngrok.EndpointPolicy
var path bytes.Buffer
if err := template.Must(template.New("replace_path").Parse("/edges/tcp/{{ .ID }}/policy")).Execute(&path, arg); err != nil {
panic(err)
}
arg.ID = ""
var (
apiURL = &url.URL{Path: path.String()}
bodyArg interface{}
)
apiURL.Path = path.String()
bodyArg = arg.Module
if err := c.apiClient.Do(ctx, "PUT", apiURL, bodyArg, &res); err != nil {
return nil, err
}
return &res, nil
}
func (c *Client) Get(ctx context.Context, id string) (*ngrok.EndpointPolicy, error) {
arg := &ngrok.Item{ID: id}
var res ngrok.EndpointPolicy
var path bytes.Buffer
if err := template.Must(template.New("get_path").Parse("/edges/tcp/{{ .ID }}/policy")).Execute(&path, arg); err != nil {
panic(err)
}
arg.ID = ""
var (
apiURL = &url.URL{Path: path.String()}
bodyArg interface{}
)
apiURL.Path = path.String()
if err := c.apiClient.Do(ctx, "GET", apiURL, bodyArg, &res); err != nil {
return nil, err
}
return &res, nil
}
func (c *Client) Delete(ctx context.Context, id string) error {
arg := &ngrok.Item{ID: id}
var path bytes.Buffer
if err := template.Must(template.New("delete_path").Parse("/edges/tcp/{{ .ID }}/policy")).Execute(&path, arg); err != nil {
panic(err)
}
arg.ID = ""
var (
apiURL = &url.URL{Path: path.String()}
bodyArg interface{}
)
apiURL.Path = path.String()
if err := c.apiClient.Do(ctx, "DELETE", apiURL, bodyArg, nil); err != nil {
return err
}
return nil
}
+85
View File
@@ -0,0 +1,85 @@
// Code generated for API Clients. DO NOT EDIT.
package tls_edge_policy
import (
"bytes"
"context"
"net/url"
"text/template"
"github.com/ngrok/ngrok-api-go/v5"
"github.com/ngrok/ngrok-api-go/v5/internal/api"
)
type Client struct {
apiClient *api.Client
}
func NewClient(cfg *ngrok.ClientConfig) *Client {
return &Client{apiClient: api.NewClient(cfg)}
}
func (c *Client) Replace(ctx context.Context, arg *ngrok.EdgePolicyReplace) (*ngrok.EndpointPolicy, error) {
if arg == nil {
arg = new(ngrok.EdgePolicyReplace)
}
var res ngrok.EndpointPolicy
var path bytes.Buffer
if err := template.Must(template.New("replace_path").Parse("/edges/tls/{{ .ID }}/policy")).Execute(&path, arg); err != nil {
panic(err)
}
arg.ID = ""
var (
apiURL = &url.URL{Path: path.String()}
bodyArg interface{}
)
apiURL.Path = path.String()
bodyArg = arg.Module
if err := c.apiClient.Do(ctx, "PUT", apiURL, bodyArg, &res); err != nil {
return nil, err
}
return &res, nil
}
func (c *Client) Get(ctx context.Context, id string) (*ngrok.EndpointPolicy, error) {
arg := &ngrok.Item{ID: id}
var res ngrok.EndpointPolicy
var path bytes.Buffer
if err := template.Must(template.New("get_path").Parse("/edges/tls/{{ .ID }}/policy")).Execute(&path, arg); err != nil {
panic(err)
}
arg.ID = ""
var (
apiURL = &url.URL{Path: path.String()}
bodyArg interface{}
)
apiURL.Path = path.String()
if err := c.apiClient.Do(ctx, "GET", apiURL, bodyArg, &res); err != nil {
return nil, err
}
return &res, nil
}
func (c *Client) Delete(ctx context.Context, id string) error {
arg := &ngrok.Item{ID: id}
var path bytes.Buffer
if err := template.Must(template.New("delete_path").Parse("/edges/tls/{{ .ID }}/policy")).Execute(&path, arg); err != nil {
panic(err)
}
arg.ID = ""
var (
apiURL = &url.URL{Path: path.String()}
bodyArg interface{}
)
apiURL.Path = path.String()
if err := c.apiClient.Do(ctx, "DELETE", apiURL, bodyArg, nil); err != nil {
return err
}
return nil
}