diff --git a/CHANGELOG.md b/CHANGELOG.md index 7154ef8..1de9594 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,17 @@ +## v7.1.0 +* Updates to KubernetesOperators and Bindings (currently in private beta). + +## v7.0.0 +### Breaking Changes +* Renamed `upstream_proto` to `upstream_protocol` for `endpoint` resources + +## v6.2.0 +* Added support for KubernetesOperators and Bindings (currently in private beta). ## v6.1.0 * Added support for Cloud Endpoints (currently in private beta). +* Renamed `principal_id` to `principal` for `endpoint` resources ## v6.0.0 ### Breaking Changes @@ -67,5 +77,5 @@ Hostports: []string `json:"hostports,omitempty"` ### Additions -New clients have been generated for `ApplicationSessions` and `ApplicationUsers`. +New clients have been generated for `ApplicationSessions` and `ApplicationUsers`. diff --git a/agent_ingresses/client.go b/agent_ingresses/client.go index 01ba809..46d866e 100644 --- a/agent_ingresses/client.go +++ b/agent_ingresses/client.go @@ -93,7 +93,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.AgentIngress, error // List all Agent Ingresses owned by this account // // https://ngrok.com/docs/api#api-agent-ingresses-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.AgentIngress] { if paging == nil { paging = new(ngrok.Paging) } @@ -110,16 +110,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterAgentIngress{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterAgentIngress struct { client *Client n int items []ngrok.AgentIngress @@ -130,7 +130,7 @@ type Iter struct { // 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 { +func (it *iterAgentIngress) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -180,14 +180,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the AgentIngress currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.AgentIngress { +func (it *iterAgentIngress) Item() *ngrok.AgentIngress { 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 { +func (it *iterAgentIngress) Err() error { return it.err } diff --git a/api_keys/client.go b/api_keys/client.go index 728be02..207aeab 100644 --- a/api_keys/client.go +++ b/api_keys/client.go @@ -102,7 +102,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.APIKey, error) { // List all API keys owned by this account // // https://ngrok.com/docs/api#api-api-keys-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.APIKey] { if paging == nil { paging = new(ngrok.Paging) } @@ -119,16 +119,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterAPIKey{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterAPIKey struct { client *Client n int items []ngrok.APIKey @@ -139,7 +139,7 @@ type Iter struct { // 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 { +func (it *iterAPIKey) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -189,14 +189,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the APIKey currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.APIKey { +func (it *iterAPIKey) Item() *ngrok.APIKey { 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 { +func (it *iterAPIKey) Err() error { return it.err } diff --git a/application_sessions/client.go b/application_sessions/client.go index 0e84685..a60f768 100644 --- a/application_sessions/client.go +++ b/application_sessions/client.go @@ -70,7 +70,7 @@ func (c *Client) Delete(ctx context.Context, id string) error { // List all application sessions for this account. // // https://ngrok.com/docs/api#api-application-sessions-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.ApplicationSession] { if paging == nil { paging = new(ngrok.Paging) } @@ -87,16 +87,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterApplicationSession{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterApplicationSession struct { client *Client n int items []ngrok.ApplicationSession @@ -107,7 +107,7 @@ type Iter struct { // 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 { +func (it *iterApplicationSession) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -157,13 +157,13 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the ApplicationSession currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.ApplicationSession { +func (it *iterApplicationSession) Item() *ngrok.ApplicationSession { 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 { +func (it *iterApplicationSession) Err() error { return it.err } diff --git a/application_users/client.go b/application_users/client.go index 895b192..e8ad8f0 100644 --- a/application_users/client.go +++ b/application_users/client.go @@ -70,7 +70,7 @@ func (c *Client) Delete(ctx context.Context, id string) error { // List all application users for this account. // // https://ngrok.com/docs/api#api-application-users-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.ApplicationUser] { if paging == nil { paging = new(ngrok.Paging) } @@ -87,16 +87,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterApplicationUser{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterApplicationUser struct { client *Client n int items []ngrok.ApplicationUser @@ -107,7 +107,7 @@ type Iter struct { // 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 { +func (it *iterApplicationUser) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -157,13 +157,13 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the ApplicationUser currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.ApplicationUser { +func (it *iterApplicationUser) Item() *ngrok.ApplicationUser { 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 { +func (it *iterApplicationUser) Err() error { return it.err } diff --git a/backends/failover/client.go b/backends/failover/client.go index 63839e4..9652917 100644 --- a/backends/failover/client.go +++ b/backends/failover/client.go @@ -100,7 +100,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.FailoverBackend, er // List all Failover backends on this account // // https://ngrok.com/docs/api#api-failover-backends-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.FailoverBackend] { if paging == nil { paging = new(ngrok.Paging) } @@ -117,16 +117,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterFailoverBackend{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterFailoverBackend struct { client *Client n int items []ngrok.FailoverBackend @@ -137,7 +137,7 @@ type Iter struct { // 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 { +func (it *iterFailoverBackend) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -187,14 +187,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the FailoverBackend currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.FailoverBackend { +func (it *iterFailoverBackend) Item() *ngrok.FailoverBackend { 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 { +func (it *iterFailoverBackend) Err() error { return it.err } diff --git a/backends/http_response/client.go b/backends/http_response/client.go index 29de365..b39c293 100644 --- a/backends/http_response/client.go +++ b/backends/http_response/client.go @@ -83,7 +83,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.HTTPResponseBackend return &res, nil } -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.HTTPResponseBackend] { if paging == nil { paging = new(ngrok.Paging) } @@ -100,16 +100,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterHTTPResponseBackend{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterHTTPResponseBackend struct { client *Client n int items []ngrok.HTTPResponseBackend @@ -120,7 +120,7 @@ type Iter struct { // 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 { +func (it *iterHTTPResponseBackend) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -170,14 +170,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the HTTPResponseBackend currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.HTTPResponseBackend { +func (it *iterHTTPResponseBackend) Item() *ngrok.HTTPResponseBackend { 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 { +func (it *iterHTTPResponseBackend) Err() error { return it.err } diff --git a/backends/static_address/client.go b/backends/static_address/client.go index 58ef0cc..fb22aec 100644 --- a/backends/static_address/client.go +++ b/backends/static_address/client.go @@ -98,7 +98,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.StaticBackend, erro // List all static backends on this account // // https://ngrok.com/docs/api#api-static-backends-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.StaticBackend] { if paging == nil { paging = new(ngrok.Paging) } @@ -115,16 +115,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterStaticBackend{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterStaticBackend struct { client *Client n int items []ngrok.StaticBackend @@ -135,7 +135,7 @@ type Iter struct { // 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 { +func (it *iterStaticBackend) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -185,14 +185,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the StaticBackend currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.StaticBackend { +func (it *iterStaticBackend) 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 { +func (it *iterStaticBackend) Err() error { return it.err } diff --git a/backends/tunnel_group/client.go b/backends/tunnel_group/client.go index 6008039..97c99df 100644 --- a/backends/tunnel_group/client.go +++ b/backends/tunnel_group/client.go @@ -98,7 +98,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.TunnelGroupBackend, // List all TunnelGroup backends on this account // // https://ngrok.com/docs/api#api-tunnel-group-backends-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.TunnelGroupBackend] { if paging == nil { paging = new(ngrok.Paging) } @@ -115,16 +115,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterTunnelGroupBackend{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterTunnelGroupBackend struct { client *Client n int items []ngrok.TunnelGroupBackend @@ -135,7 +135,7 @@ type Iter struct { // 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 { +func (it *iterTunnelGroupBackend) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -185,14 +185,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the TunnelGroupBackend currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.TunnelGroupBackend { +func (it *iterTunnelGroupBackend) Item() *ngrok.TunnelGroupBackend { 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 { +func (it *iterTunnelGroupBackend) Err() error { return it.err } diff --git a/backends/weighted/client.go b/backends/weighted/client.go index 5bb557b..e0a9524 100644 --- a/backends/weighted/client.go +++ b/backends/weighted/client.go @@ -100,7 +100,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.WeightedBackend, er // List all Weighted backends on this account // // https://ngrok.com/docs/api#api-weighted-backends-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.WeightedBackend] { if paging == nil { paging = new(ngrok.Paging) } @@ -117,16 +117,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterWeightedBackend{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterWeightedBackend struct { client *Client n int items []ngrok.WeightedBackend @@ -137,7 +137,7 @@ type Iter struct { // 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 { +func (it *iterWeightedBackend) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -187,14 +187,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the WeightedBackend currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.WeightedBackend { +func (it *iterWeightedBackend) Item() *ngrok.WeightedBackend { 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 { +func (it *iterWeightedBackend) Err() error { return it.err } diff --git a/bot_users/client.go b/bot_users/client.go index 86062b4..73e202a 100644 --- a/bot_users/client.go +++ b/bot_users/client.go @@ -95,7 +95,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.BotUser, error) { // List all bot users in this account. // // https://ngrok.com/docs/api#api-bot-users-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.BotUser] { if paging == nil { paging = new(ngrok.Paging) } @@ -112,16 +112,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterBotUser{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterBotUser struct { client *Client n int items []ngrok.BotUser @@ -132,7 +132,7 @@ type Iter struct { // 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 { +func (it *iterBotUser) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -182,14 +182,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the BotUser currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.BotUser { +func (it *iterBotUser) Item() *ngrok.BotUser { 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 { +func (it *iterBotUser) Err() error { return it.err } diff --git a/certificate_authorities/client.go b/certificate_authorities/client.go index 3dd87e0..66e87c9 100644 --- a/certificate_authorities/client.go +++ b/certificate_authorities/client.go @@ -98,7 +98,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.CertificateAuthorit // List all Certificate Authority on this account // // https://ngrok.com/docs/api#api-certificate-authorities-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.CertificateAuthority] { if paging == nil { paging = new(ngrok.Paging) } @@ -115,16 +115,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterCertificateAuthority{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterCertificateAuthority struct { client *Client n int items []ngrok.CertificateAuthority @@ -135,7 +135,7 @@ type Iter struct { // 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 { +func (it *iterCertificateAuthority) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -185,14 +185,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the CertificateAuthority currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.CertificateAuthority { +func (it *iterCertificateAuthority) Item() *ngrok.CertificateAuthority { 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 { +func (it *iterCertificateAuthority) Err() error { return it.err } diff --git a/credentials/client.go b/credentials/client.go index 78cf360..214b8ff 100644 --- a/credentials/client.go +++ b/credentials/client.go @@ -103,7 +103,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.Credential, error) // List all tunnel authtoken credentials on this account // // https://ngrok.com/docs/api#api-credentials-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.Credential] { if paging == nil { paging = new(ngrok.Paging) } @@ -120,16 +120,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterCredential{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterCredential struct { client *Client n int items []ngrok.Credential @@ -140,7 +140,7 @@ type Iter struct { // 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 { +func (it *iterCredential) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -190,14 +190,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the Credential currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.Credential { +func (it *iterCredential) Item() *ngrok.Credential { 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 { +func (it *iterCredential) Err() error { return it.err } diff --git a/datatypes.go b/datatypes.go index 0ed4ea4..79ea4d9 100644 --- a/datatypes.go +++ b/datatypes.go @@ -64,6 +64,30 @@ func (x *Paging) GoString() string { return b.String() } +type ItemPaging struct { + // a resource identifier + ID string `json:"id,omitempty"` + BeforeID *string `json:"before_id,omitempty"` + Limit *string `json:"limit,omitempty"` +} + +func (x *ItemPaging) String() string { + return fmt.Sprintf("ItemPaging{ID: %v}", x.ID) + +} + +func (x *ItemPaging) GoString() string { + var b bytes.Buffer + fmt.Fprintf(&b, "ItemPaging {\n") + tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0) + fmt.Fprintf(tw, "\tID\t%v\n", x.ID) + fmt.Fprintf(tw, "\tBeforeID\t%v\n", x.BeforeID) + fmt.Fprintf(tw, "\tLimit\t%v\n", x.Limit) + tw.Flush() + fmt.Fprintf(&b, "}\n") + return b.String() +} + type Error struct { ErrorCode string `json:"error_code,omitempty"` StatusCode int32 `json:"status_code,omitempty"` @@ -4023,13 +4047,11 @@ type Endpoint struct { // the local address the tunnel forwards to UpstreamURL string `json:"upstream_url,omitempty"` // the protocol the agent uses to forward with - UpstreamProto string `json:"upstream_proto,omitempty"` + UpstreamProtocol string `json:"upstream_protocol,omitempty"` // the url of the endpoint URL string `json:"url,omitempty"` // The ID of the owner (bot or user) that owns this endpoint Principal *Ref `json:"principal,omitempty"` - // TODO: deprecate me! - PrincipalID *Ref `json:"principal_id,omitempty"` // The traffic policy attached to this endpoint TrafficPolicy string `json:"traffic_policy,omitempty"` // the bindings associated with this endpoint @@ -4069,10 +4091,9 @@ func (x *Endpoint) GoString() string { fmt.Fprintf(tw, "\tTunnel\t%v\n", x.Tunnel) fmt.Fprintf(tw, "\tEdge\t%v\n", x.Edge) fmt.Fprintf(tw, "\tUpstreamURL\t%v\n", x.UpstreamURL) - fmt.Fprintf(tw, "\tUpstreamProto\t%v\n", x.UpstreamProto) + fmt.Fprintf(tw, "\tUpstreamProtocol\t%v\n", x.UpstreamProtocol) fmt.Fprintf(tw, "\tURL\t%v\n", x.URL) fmt.Fprintf(tw, "\tPrincipal\t%v\n", x.Principal) - fmt.Fprintf(tw, "\tPrincipalID\t%v\n", x.PrincipalID) fmt.Fprintf(tw, "\tTrafficPolicy\t%v\n", x.TrafficPolicy) fmt.Fprintf(tw, "\tBindings\t%v\n", x.Bindings) fmt.Fprintf(tw, "\tTunnelSession\t%v\n", x.TunnelSession) @@ -5206,6 +5227,318 @@ func (x *IPRestrictionList) GoString() string { return b.String() } +type KubernetesOperatorCreate struct { + // human-readable description of this Kubernetes Operator. optional, max 255 bytes. + Description string `json:"description,omitempty"` + // arbitrary user-defined machine-readable data of this Kubernetes Operator. + // optional, max 4096 bytes. + Metadata string `json:"metadata,omitempty"` + // features enabled for this Kubernetes Operator. a subset of {"bindings", + // "ingress", and "gateway"} + EnabledFeatures []string `json:"enabled_features,omitempty"` + // the ngrok region in which the ingress for this operator is served. defaults to + // "global" + Region string `json:"region,omitempty"` + // information about the deployment of this Kubernetes Operator + Deployment KubernetesOperatorDeployment `json:"deployment,omitempty"` + // configuration for the Bindings feature of this Kubernetes Operator. set only if + // enabling the "bindings" feature + Binding *KubernetesOperatorBindingCreate `json:"binding,omitempty"` +} + +func (x *KubernetesOperatorCreate) String() string { + return x.GoString() +} + +func (x *KubernetesOperatorCreate) GoString() string { + var b bytes.Buffer + fmt.Fprintf(&b, "KubernetesOperatorCreate {\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, "\tEnabledFeatures\t%v\n", x.EnabledFeatures) + fmt.Fprintf(tw, "\tRegion\t%v\n", x.Region) + fmt.Fprintf(tw, "\tDeployment\t%v\n", x.Deployment) + fmt.Fprintf(tw, "\tBinding\t%v\n", x.Binding) + tw.Flush() + fmt.Fprintf(&b, "}\n") + return b.String() +} + +type KubernetesOperatorBindingCreate struct { + // the list of cel expressions that filter the k8s bound endpoints for this + // operator + EndpointSelectors []string `json:"endpoint_selectors,omitempty"` + // CSR is supplied during initial creation to enable creating a mutual TLS secured + // connection between ngrok and the operator. This is an internal implementation + // detail and subject to change. + CSR string `json:"csr,omitempty"` + // the public ingress endpoint for this Kubernetes Operator + IngressEndpoint *string `json:"ingress_endpoint,omitempty"` +} + +func (x *KubernetesOperatorBindingCreate) String() string { + return x.GoString() +} + +func (x *KubernetesOperatorBindingCreate) GoString() string { + var b bytes.Buffer + fmt.Fprintf(&b, "KubernetesOperatorBindingCreate {\n") + tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0) + fmt.Fprintf(tw, "\tEndpointSelectors\t%v\n", x.EndpointSelectors) + fmt.Fprintf(tw, "\tCSR\t%v\n", x.CSR) + fmt.Fprintf(tw, "\tIngressEndpoint\t%v\n", x.IngressEndpoint) + tw.Flush() + fmt.Fprintf(&b, "}\n") + return b.String() +} + +type KubernetesOperatorUpdate struct { + // unique identifier for this Kubernetes Operator + ID string `json:"id,omitempty"` + // human-readable description of this Kubernetes Operator. optional, max 255 bytes. + Description *string `json:"description,omitempty"` + // arbitrary user-defined machine-readable data of this Kubernetes Operator. + // optional, max 4096 bytes. + Metadata *string `json:"metadata,omitempty"` + // features enabled for this Kubernetes Operator. a subset of {"bindings", + // "ingress", and "gateway"} + EnabledFeatures []string `json:"enabled_features,omitempty"` + // the ngrok region in which the ingress for this operator is served. defaults to + // "global" + Region *string `json:"region,omitempty"` + // configuration for the Bindings feature of this Kubernetes Operator. set only if + // enabling the "bindings" feature + Binding *KubernetesOperatorBindingUpdate `json:"binding,omitempty"` + // configuration for the Deployment info + Deployment *KubernetesOperatorDeploymentUpdate `json:"deployment,omitempty"` +} + +func (x *KubernetesOperatorUpdate) String() string { + return fmt.Sprintf("KubernetesOperatorUpdate{ID: %v}", x.ID) + +} + +func (x *KubernetesOperatorUpdate) GoString() string { + var b bytes.Buffer + fmt.Fprintf(&b, "KubernetesOperatorUpdate {\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, "\tEnabledFeatures\t%v\n", x.EnabledFeatures) + fmt.Fprintf(tw, "\tRegion\t%v\n", x.Region) + fmt.Fprintf(tw, "\tBinding\t%v\n", x.Binding) + fmt.Fprintf(tw, "\tDeployment\t%v\n", x.Deployment) + tw.Flush() + fmt.Fprintf(&b, "}\n") + return b.String() +} + +type KubernetesOperatorBindingUpdate struct { + // the list of cel expressions that filter the k8s bound endpoints for this + // operator + EndpointSelectors []string `json:"endpoint_selectors,omitempty"` + // CSR is supplied during initial creation to enable creating a mutual TLS secured + // connection between ngrok and the operator. This is an internal implementation + // detail and subject to change. + CSR *string `json:"csr,omitempty"` + // the public ingress endpoint for this Kubernetes Operator + IngressEndpoint *string `json:"ingress_endpoint,omitempty"` +} + +func (x *KubernetesOperatorBindingUpdate) String() string { + return x.GoString() +} + +func (x *KubernetesOperatorBindingUpdate) GoString() string { + var b bytes.Buffer + fmt.Fprintf(&b, "KubernetesOperatorBindingUpdate {\n") + tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0) + fmt.Fprintf(tw, "\tEndpointSelectors\t%v\n", x.EndpointSelectors) + fmt.Fprintf(tw, "\tCSR\t%v\n", x.CSR) + fmt.Fprintf(tw, "\tIngressEndpoint\t%v\n", x.IngressEndpoint) + tw.Flush() + fmt.Fprintf(&b, "}\n") + return b.String() +} + +type KubernetesOperatorDeploymentUpdate struct { + // the deployment name + Name *string `json:"name,omitempty"` +} + +func (x *KubernetesOperatorDeploymentUpdate) String() string { + return x.GoString() +} + +func (x *KubernetesOperatorDeploymentUpdate) GoString() string { + var b bytes.Buffer + fmt.Fprintf(&b, "KubernetesOperatorDeploymentUpdate {\n") + tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0) + fmt.Fprintf(tw, "\tName\t%v\n", x.Name) + tw.Flush() + fmt.Fprintf(&b, "}\n") + return b.String() +} + +type KubernetesOperator struct { + // unique identifier for this Kubernetes Operator + ID string `json:"id,omitempty"` + // URI of this Kubernetes Operator API resource + URI string `json:"uri,omitempty"` + // timestamp when the Kubernetes Operator was created. RFC 3339 format + CreatedAt string `json:"created_at,omitempty"` + // timestamp when the Kubernetes Operator was last updated. RFC 3339 format + UpdatedAt string `json:"updated_at,omitempty"` + // human-readable description of this Kubernetes Operator. optional, max 255 bytes. + Description string `json:"description,omitempty"` + // arbitrary user-defined machine-readable data of this Kubernetes Operator. + // optional, max 4096 bytes. + Metadata string `json:"metadata,omitempty"` + // the principal who created this Kubernetes Operator + Principal Ref `json:"principal,omitempty"` + // features enabled for this Kubernetes Operator. a subset of {"bindings", + // "ingress", and "gateway"} + EnabledFeatures []string `json:"enabled_features,omitempty"` + // the ngrok region in which the ingress for this operator is served. defaults to + // "global" + Region string `json:"region,omitempty"` + // information about the deployment of this Kubernetes Operator + Deployment KubernetesOperatorDeployment `json:"deployment,omitempty"` + // information about the Bindings feature of this Kubernetes Operator, if enabled + Binding *KubernetesOperatorBinding `json:"binding,omitempty"` +} + +func (x *KubernetesOperator) String() string { + return fmt.Sprintf("KubernetesOperator{ID: %v}", x.ID) + +} + +func (x *KubernetesOperator) GoString() string { + var b bytes.Buffer + fmt.Fprintf(&b, "KubernetesOperator {\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, "\tUpdatedAt\t%v\n", x.UpdatedAt) + fmt.Fprintf(tw, "\tDescription\t%v\n", x.Description) + fmt.Fprintf(tw, "\tMetadata\t%v\n", x.Metadata) + fmt.Fprintf(tw, "\tPrincipal\t%v\n", x.Principal) + fmt.Fprintf(tw, "\tEnabledFeatures\t%v\n", x.EnabledFeatures) + fmt.Fprintf(tw, "\tRegion\t%v\n", x.Region) + fmt.Fprintf(tw, "\tDeployment\t%v\n", x.Deployment) + fmt.Fprintf(tw, "\tBinding\t%v\n", x.Binding) + tw.Flush() + fmt.Fprintf(&b, "}\n") + return b.String() +} + +type KubernetesOperatorDeployment struct { + // the deployment name + Name string `json:"name,omitempty"` + // the namespace this Kubernetes Operator is deployed to + Namespace string `json:"namespace,omitempty"` + // the version of this Kubernetes Operator + Version string `json:"version,omitempty"` + // user-given name for the cluster the Kubernetes Operator is deployed to + ClusterName string `json:"cluster_name,omitempty"` +} + +func (x *KubernetesOperatorDeployment) String() string { + return x.GoString() +} + +func (x *KubernetesOperatorDeployment) GoString() string { + var b bytes.Buffer + fmt.Fprintf(&b, "KubernetesOperatorDeployment {\n") + tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0) + fmt.Fprintf(tw, "\tName\t%v\n", x.Name) + fmt.Fprintf(tw, "\tNamespace\t%v\n", x.Namespace) + fmt.Fprintf(tw, "\tVersion\t%v\n", x.Version) + fmt.Fprintf(tw, "\tClusterName\t%v\n", x.ClusterName) + tw.Flush() + fmt.Fprintf(&b, "}\n") + return b.String() +} + +type KubernetesOperatorCert struct { + // the public client certificate generated for this Kubernetes Operator from the + // CSR supplied when enabling the Bindings feature + Cert string `json:"cert,omitempty"` + // timestamp when the certificate becomes valid. RFC 3339 format + NotBefore string `json:"not_before,omitempty"` + // timestamp when the certificate becomes invalid. RFC 3339 format + NotAfter string `json:"not_after,omitempty"` +} + +func (x *KubernetesOperatorCert) String() string { + return x.GoString() +} + +func (x *KubernetesOperatorCert) GoString() string { + var b bytes.Buffer + fmt.Fprintf(&b, "KubernetesOperatorCert {\n") + tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0) + fmt.Fprintf(tw, "\tCert\t%v\n", x.Cert) + fmt.Fprintf(tw, "\tNotBefore\t%v\n", x.NotBefore) + fmt.Fprintf(tw, "\tNotAfter\t%v\n", x.NotAfter) + tw.Flush() + fmt.Fprintf(&b, "}\n") + return b.String() +} + +type KubernetesOperatorBinding struct { + // the list of cel expressions that filter the k8s bound endpoints for this + // operator + EndpointSelectors []string `json:"endpoint_selectors,omitempty"` + // the binding certificate information + Cert KubernetesOperatorCert `json:"cert,omitempty"` + // the public ingress endpoint for this Kubernetes Operator + IngressEndpoint string `json:"ingress_endpoint,omitempty"` +} + +func (x *KubernetesOperatorBinding) String() string { + return x.GoString() +} + +func (x *KubernetesOperatorBinding) GoString() string { + var b bytes.Buffer + fmt.Fprintf(&b, "KubernetesOperatorBinding {\n") + tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0) + fmt.Fprintf(tw, "\tEndpointSelectors\t%v\n", x.EndpointSelectors) + fmt.Fprintf(tw, "\tCert\t%v\n", x.Cert) + fmt.Fprintf(tw, "\tIngressEndpoint\t%v\n", x.IngressEndpoint) + tw.Flush() + fmt.Fprintf(&b, "}\n") + return b.String() +} + +type KubernetesOperatorList struct { + // the list of Kubernetes Operators for this account + Operators []KubernetesOperator `json:"operators,omitempty"` + 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 *KubernetesOperatorList) String() string { + return x.GoString() +} + +func (x *KubernetesOperatorList) GoString() string { + var b bytes.Buffer + fmt.Fprintf(&b, "KubernetesOperatorList {\n") + tw := tabwriter.NewWriter(&b, 0, 4, 0, ' ', 0) + fmt.Fprintf(tw, "\tOperators\t%v\n", x.Operators) + 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 ReservedAddrCreate struct { // human-readable description of what this reserved address will be used for Description string `json:"description,omitempty"` diff --git a/edges/https/client.go b/edges/https/client.go index 50137e1..7f1497f 100644 --- a/edges/https/client.go +++ b/edges/https/client.go @@ -72,7 +72,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.HTTPSEdge, error) { // Returns a list of all HTTPS Edges on this account // // https://ngrok.com/docs/api#api-edges-https-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.HTTPSEdge] { if paging == nil { paging = new(ngrok.Paging) } @@ -89,16 +89,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterHTTPSEdge{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterHTTPSEdge struct { client *Client n int items []ngrok.HTTPSEdge @@ -109,7 +109,7 @@ type Iter struct { // 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 { +func (it *iterHTTPSEdge) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -159,14 +159,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the HTTPSEdge currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.HTTPSEdge { +func (it *iterHTTPSEdge) Item() *ngrok.HTTPSEdge { 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 { +func (it *iterHTTPSEdge) Err() error { return it.err } diff --git a/edges/tcp/client.go b/edges/tcp/client.go index 3dc77ce..ab7d952 100644 --- a/edges/tcp/client.go +++ b/edges/tcp/client.go @@ -72,7 +72,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.TCPEdge, error) { // Returns a list of all TCP Edges on this account // // https://ngrok.com/docs/api#api-edges-tcp-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.TCPEdge] { if paging == nil { paging = new(ngrok.Paging) } @@ -89,16 +89,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterTCPEdge{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterTCPEdge struct { client *Client n int items []ngrok.TCPEdge @@ -109,7 +109,7 @@ type Iter struct { // 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 { +func (it *iterTCPEdge) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -159,14 +159,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the TCPEdge currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.TCPEdge { +func (it *iterTCPEdge) Item() *ngrok.TCPEdge { 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 { +func (it *iterTCPEdge) Err() error { return it.err } diff --git a/edges/tls/client.go b/edges/tls/client.go index 3cb6b0d..55e848d 100644 --- a/edges/tls/client.go +++ b/edges/tls/client.go @@ -72,7 +72,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.TLSEdge, error) { // Returns a list of all TLS Edges on this account // // https://ngrok.com/docs/api#api-edges-tls-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.TLSEdge] { if paging == nil { paging = new(ngrok.Paging) } @@ -89,16 +89,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterTLSEdge{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterTLSEdge struct { client *Client n int items []ngrok.TLSEdge @@ -109,7 +109,7 @@ type Iter struct { // 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 { +func (it *iterTLSEdge) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -159,14 +159,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the TLSEdge currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.TLSEdge { +func (it *iterTLSEdge) Item() *ngrok.TLSEdge { 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 { +func (it *iterTLSEdge) Err() error { return it.err } diff --git a/endpoints/client.go b/endpoints/client.go index a374190..a54f19d 100644 --- a/endpoints/client.go +++ b/endpoints/client.go @@ -28,9 +28,6 @@ func NewClient(cfg *ngrok.ClientConfig) *Client { // // https://ngrok.com/docs/api#api-endpoints-create func (c *Client) Create(ctx context.Context, arg *ngrok.EndpointCreate) (*ngrok.Endpoint, error) { - if arg == nil { - arg = new(ngrok.EndpointCreate) - } var res ngrok.Endpoint var path bytes.Buffer if err := template.Must(template.New("create_path").Parse("/endpoints")).Execute(&path, arg); err != nil { @@ -52,7 +49,7 @@ func (c *Client) Create(ctx context.Context, arg *ngrok.EndpointCreate) (*ngrok. // List all active endpoints on the account // // https://ngrok.com/docs/api#api-endpoints-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.Endpoint] { if paging == nil { paging = new(ngrok.Paging) } @@ -69,16 +66,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterEndpoint{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterEndpoint struct { client *Client n int items []ngrok.Endpoint @@ -89,7 +86,7 @@ type Iter struct { // 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 { +func (it *iterEndpoint) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -139,14 +136,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the Endpoint currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.Endpoint { +func (it *iterEndpoint) Item() *ngrok.Endpoint { 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 { +func (it *iterEndpoint) Err() error { return it.err } diff --git a/event_destinations/client.go b/event_destinations/client.go index 89021a0..eb3ae2b 100644 --- a/event_destinations/client.go +++ b/event_destinations/client.go @@ -97,7 +97,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.EventDestination, e // List all Event Destinations on this account. // // https://ngrok.com/docs/api#api-event-destinations-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.EventDestination] { if paging == nil { paging = new(ngrok.Paging) } @@ -114,16 +114,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterEventDestination{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterEventDestination struct { client *Client n int items []ngrok.EventDestination @@ -134,7 +134,7 @@ type Iter struct { // 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 { +func (it *iterEventDestination) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -184,14 +184,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the EventDestination currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.EventDestination { +func (it *iterEventDestination) Item() *ngrok.EventDestination { 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 { +func (it *iterEventDestination) Err() error { return it.err } diff --git a/event_subscriptions/client.go b/event_subscriptions/client.go index 47ddb70..58f02f7 100644 --- a/event_subscriptions/client.go +++ b/event_subscriptions/client.go @@ -95,7 +95,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.EventSubscription, // List this Account's Event Subscriptions. // // https://ngrok.com/docs/api#api-event-subscriptions-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.EventSubscription] { if paging == nil { paging = new(ngrok.Paging) } @@ -112,16 +112,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterEventSubscription{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterEventSubscription struct { client *Client n int items []ngrok.EventSubscription @@ -132,7 +132,7 @@ type Iter struct { // 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 { +func (it *iterEventSubscription) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -182,14 +182,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the EventSubscription currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.EventSubscription { +func (it *iterEventSubscription) Item() *ngrok.EventSubscription { 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 { +func (it *iterEventSubscription) Err() error { return it.err } diff --git a/ip_policies/client.go b/ip_policies/client.go index e22a6d6..3e45da2 100644 --- a/ip_policies/client.go +++ b/ip_policies/client.go @@ -103,7 +103,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.IPPolicy, error) { // List all IP policies on this account // // https://ngrok.com/docs/api#api-ip-policies-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.IPPolicy] { if paging == nil { paging = new(ngrok.Paging) } @@ -120,16 +120,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterIPPolicy{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterIPPolicy struct { client *Client n int items []ngrok.IPPolicy @@ -140,7 +140,7 @@ type Iter struct { // 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 { +func (it *iterIPPolicy) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -190,14 +190,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the IPPolicy currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.IPPolicy { +func (it *iterIPPolicy) Item() *ngrok.IPPolicy { 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 { +func (it *iterIPPolicy) Err() error { return it.err } diff --git a/ip_policy_rules/client.go b/ip_policy_rules/client.go index a8b9aeb..65c052a 100644 --- a/ip_policy_rules/client.go +++ b/ip_policy_rules/client.go @@ -95,7 +95,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.IPPolicyRule, error // List all IP policy rules on this account // // https://ngrok.com/docs/api#api-ip-policy-rules-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.IPPolicyRule] { if paging == nil { paging = new(ngrok.Paging) } @@ -112,16 +112,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterIPPolicyRule{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterIPPolicyRule struct { client *Client n int items []ngrok.IPPolicyRule @@ -132,7 +132,7 @@ type Iter struct { // 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 { +func (it *iterIPPolicyRule) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -182,14 +182,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the IPPolicyRule currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.IPPolicyRule { +func (it *iterIPPolicyRule) Item() *ngrok.IPPolicyRule { 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 { +func (it *iterIPPolicyRule) Err() error { return it.err } diff --git a/ip_restrictions/client.go b/ip_restrictions/client.go index 1adad28..fe47be9 100644 --- a/ip_restrictions/client.go +++ b/ip_restrictions/client.go @@ -99,7 +99,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.IPRestriction, erro // List all IP restrictions on this account // // https://ngrok.com/docs/api#api-ip-restrictions-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.IPRestriction] { if paging == nil { paging = new(ngrok.Paging) } @@ -116,16 +116,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterIPRestriction{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterIPRestriction struct { client *Client n int items []ngrok.IPRestriction @@ -136,7 +136,7 @@ type Iter struct { // 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 { +func (it *iterIPRestriction) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -186,14 +186,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the IPRestriction currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.IPRestriction { +func (it *iterIPRestriction) Item() *ngrok.IPRestriction { 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 { +func (it *iterIPRestriction) Err() error { return it.err } diff --git a/iter.go b/iter.go new file mode 100644 index 0000000..134cf6d --- /dev/null +++ b/iter.go @@ -0,0 +1,13 @@ +// Code generated for API Clients. DO NOT EDIT. + +package ngrok + +import ( + "context" +) + +type Iter[T any] interface { + Next(context.Context) bool + Item() T + Err() error +} diff --git a/kubernetes_operators/client.go b/kubernetes_operators/client.go new file mode 100644 index 0000000..51db99b --- /dev/null +++ b/kubernetes_operators/client.go @@ -0,0 +1,326 @@ +// Code generated for API Clients. DO NOT EDIT. + +package kubernetes_operators + +import ( + "bytes" + "context" + "net/url" + "text/template" + + "github.com/ngrok/ngrok-api-go/v6" + "github.com/ngrok/ngrok-api-go/v6/internal/api" +) + +// KubernetesOperators is used by the Kubernetes Operator to register and +// manage its own resource, as well as for users to see active kubernetes +// clusters. + +type Client struct { + apiClient *api.Client +} + +func NewClient(cfg *ngrok.ClientConfig) *Client { + return &Client{apiClient: api.NewClient(cfg)} +} + +// Create a new Kubernetes Operator +// +// https://ngrok.com/docs/api#api-kubernetes-operators-create +func (c *Client) Create(ctx context.Context, arg *ngrok.KubernetesOperatorCreate) (*ngrok.KubernetesOperator, error) { + if arg == nil { + arg = new(ngrok.KubernetesOperatorCreate) + } + var res ngrok.KubernetesOperator + var path bytes.Buffer + if err := template.Must(template.New("create_path").Parse("/kubernetes_operators")).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 +} + +// Update an existing Kubernetes operator by ID. +// +// https://ngrok.com/docs/api#api-kubernetes-operators-update +func (c *Client) Update(ctx context.Context, arg *ngrok.KubernetesOperatorUpdate) (*ngrok.KubernetesOperator, error) { + if arg == nil { + arg = new(ngrok.KubernetesOperatorUpdate) + } + var res ngrok.KubernetesOperator + var path bytes.Buffer + if err := template.Must(template.New("update_path").Parse("/kubernetes_operators/{{ .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 +} + +// Delete a Kubernetes Operator +// +// https://ngrok.com/docs/api#api-kubernetes-operators-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("/kubernetes_operators/{{ .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 of a Kubernetes Operator +// +// https://ngrok.com/docs/api#api-kubernetes-operators-get +func (c *Client) Get(ctx context.Context, id string) (*ngrok.KubernetesOperator, error) { + arg := &ngrok.Item{ID: id} + + var res ngrok.KubernetesOperator + var path bytes.Buffer + if err := template.Must(template.New("get_path").Parse("/kubernetes_operators/{{ .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 Kubernetes Operators owned by this account +// +// https://ngrok.com/docs/api#api-kubernetes-operators-list +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.KubernetesOperator] { + if paging == nil { + paging = new(ngrok.Paging) + } + var path bytes.Buffer + if err := template.Must(template.New("list_path").Parse("/kubernetes_operators")).Execute(&path, paging); err != nil { + panic(err) + } + var apiURL = &url.URL{Path: path.String()} + queryVals := make(url.Values) + if paging.BeforeID != nil { + queryVals.Set("before_id", *paging.BeforeID) + } + if paging.Limit != nil { + queryVals.Set("limit", *paging.Limit) + } + apiURL.RawQuery = queryVals.Encode() + return &iterKubernetesOperator{ + client: c, + n: -1, + nextPage: apiURL, + } +} + +// iter allows the caller to iterate through a list of values while +// automatically fetching new pages worth of values from the API. +type iterKubernetesOperator struct { + client *Client + n int + items []ngrok.KubernetesOperator + err error + + nextPage *url.URL +} + +// 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 *iterKubernetesOperator) 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) { + return true + } + + // no more items, do we have a next page? + if it.nextPage == nil { + return false + } + + // fetch the next page + var resp ngrok.KubernetesOperatorList + err := it.client.apiClient.Do(ctx, "GET", it.nextPage, nil, &resp) + if err != nil { + it.err = err + return false + } + + // parse the next page URI as soon as we get it and store it + // so we can use it on the next fetch + if resp.NextPageURI != nil { + it.nextPage, it.err = url.Parse(*resp.NextPageURI) + if it.err != nil { + return false + } + } else { + it.nextPage = nil + } + + // page with zero items means there are no more + if len(resp.Operators) == 0 { + return false + } + + it.n = -1 + it.items = resp.Operators + return it.Next(ctx) +} + +// Item() returns the KubernetesOperator currently +// pointed to by the iterator. +func (it *iterKubernetesOperator) Item() *ngrok.KubernetesOperator { + 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 *iterKubernetesOperator) Err() error { + return it.err +} + +// List Endpoints bound to a Kubernetes Operator +// +// https://ngrok.com/docs/api#api-kubernetes-operators-get-bound-endpoints +func (c *Client) GetBoundEndpoints(id string, paging *ngrok.Paging) ngrok.Iter[*ngrok.Endpoint] { + arg := &ngrok.ItemPaging{ID: id} + if paging == nil { + paging = new(ngrok.Paging) + } + var path bytes.Buffer + if err := template.Must(template.New("get_bound_endpoints_path").Parse("/kubernetes_operators/{{ .ID }}/bound_endpoints")).Execute(&path, arg); err != nil { + panic(err) + } + var apiURL = &url.URL{Path: path.String()} + queryVals := make(url.Values) + if paging.BeforeID != nil { + queryVals.Set("before_id", *paging.BeforeID) + } + if paging.Limit != nil { + queryVals.Set("limit", *paging.Limit) + } + apiURL.RawQuery = queryVals.Encode() + return &iterEndpoint{ + client: c, + n: -1, + nextPage: apiURL, + } +} + +// iter allows the caller to iterate through a list of values while +// automatically fetching new pages worth of values from the API. +type iterEndpoint struct { + client *Client + n int + items []ngrok.Endpoint + err error + + nextPage *url.URL +} + +// 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 *iterEndpoint) 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) { + return true + } + + // no more items, do we have a next page? + if it.nextPage == nil { + return false + } + + // fetch the next page + var resp ngrok.EndpointList + err := it.client.apiClient.Do(ctx, "GET", it.nextPage, nil, &resp) + if err != nil { + it.err = err + return false + } + + // parse the next page URI as soon as we get it and store it + // so we can use it on the next fetch + if resp.NextPageURI != nil { + it.nextPage, it.err = url.Parse(*resp.NextPageURI) + if it.err != nil { + return false + } + } else { + it.nextPage = nil + } + + // page with zero items means there are no more + if len(resp.Endpoints) == 0 { + return false + } + + it.n = -1 + it.items = resp.Endpoints + return it.Next(ctx) +} + +// Item() returns the Endpoint currently +// pointed to by the iterator. +func (it *iterEndpoint) Item() *ngrok.Endpoint { + 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 *iterEndpoint) Err() error { + return it.err +} diff --git a/reserved_addrs/client.go b/reserved_addrs/client.go index 5d8cdba..b0d8a73 100644 --- a/reserved_addrs/client.go +++ b/reserved_addrs/client.go @@ -99,7 +99,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.ReservedAddr, error // List all reserved addresses on this account. // // https://ngrok.com/docs/api#api-reserved-addrs-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.ReservedAddr] { if paging == nil { paging = new(ngrok.Paging) } @@ -116,16 +116,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterReservedAddr{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterReservedAddr struct { client *Client n int items []ngrok.ReservedAddr @@ -136,7 +136,7 @@ type Iter struct { // 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 { +func (it *iterReservedAddr) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -186,14 +186,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the ReservedAddr currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.ReservedAddr { +func (it *iterReservedAddr) Item() *ngrok.ReservedAddr { 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 { +func (it *iterReservedAddr) Err() error { return it.err } diff --git a/reserved_domains/client.go b/reserved_domains/client.go index 0852318..bc5dc44 100644 --- a/reserved_domains/client.go +++ b/reserved_domains/client.go @@ -100,7 +100,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.ReservedDomain, err // List all reserved domains on this account. // // https://ngrok.com/docs/api#api-reserved-domains-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.ReservedDomain] { if paging == nil { paging = new(ngrok.Paging) } @@ -117,16 +117,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterReservedDomain{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterReservedDomain struct { client *Client n int items []ngrok.ReservedDomain @@ -137,7 +137,7 @@ type Iter struct { // 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 { +func (it *iterReservedDomain) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -187,14 +187,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the ReservedDomain currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.ReservedDomain { +func (it *iterReservedDomain) Item() *ngrok.ReservedDomain { 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 { +func (it *iterReservedDomain) Err() error { return it.err } diff --git a/ssh_certificate_authorities/client.go b/ssh_certificate_authorities/client.go index bff67b8..8c27d4d 100644 --- a/ssh_certificate_authorities/client.go +++ b/ssh_certificate_authorities/client.go @@ -98,7 +98,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.SSHCertificateAutho // List all SSH Certificate Authorities on this account // // https://ngrok.com/docs/api#api-ssh-certificate-authorities-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.SSHCertificateAuthority] { if paging == nil { paging = new(ngrok.Paging) } @@ -115,16 +115,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterSSHCertificateAuthority{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterSSHCertificateAuthority struct { client *Client n int items []ngrok.SSHCertificateAuthority @@ -135,7 +135,7 @@ type Iter struct { // 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 { +func (it *iterSSHCertificateAuthority) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -185,14 +185,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the SSHCertificateAuthority currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.SSHCertificateAuthority { +func (it *iterSSHCertificateAuthority) Item() *ngrok.SSHCertificateAuthority { 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 { +func (it *iterSSHCertificateAuthority) Err() error { return it.err } diff --git a/ssh_credentials/client.go b/ssh_credentials/client.go index 73be4a3..81cb306 100644 --- a/ssh_credentials/client.go +++ b/ssh_credentials/client.go @@ -96,7 +96,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.SSHCredential, erro // List all ssh credentials on this account // // https://ngrok.com/docs/api#api-ssh-credentials-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.SSHCredential] { if paging == nil { paging = new(ngrok.Paging) } @@ -113,16 +113,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterSSHCredential{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterSSHCredential struct { client *Client n int items []ngrok.SSHCredential @@ -133,7 +133,7 @@ type Iter struct { // 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 { +func (it *iterSSHCredential) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -183,14 +183,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the SSHCredential currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.SSHCredential { +func (it *iterSSHCredential) Item() *ngrok.SSHCredential { 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 { +func (it *iterSSHCredential) Err() error { return it.err } diff --git a/ssh_host_certificates/client.go b/ssh_host_certificates/client.go index e850a10..a57a0c6 100644 --- a/ssh_host_certificates/client.go +++ b/ssh_host_certificates/client.go @@ -96,7 +96,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.SSHHostCertificate, // List all SSH Host Certificates issued on this account // // https://ngrok.com/docs/api#api-ssh-host-certificates-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.SSHHostCertificate] { if paging == nil { paging = new(ngrok.Paging) } @@ -113,16 +113,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterSSHHostCertificate{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterSSHHostCertificate struct { client *Client n int items []ngrok.SSHHostCertificate @@ -133,7 +133,7 @@ type Iter struct { // 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 { +func (it *iterSSHHostCertificate) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -183,14 +183,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the SSHHostCertificate currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.SSHHostCertificate { +func (it *iterSSHHostCertificate) Item() *ngrok.SSHHostCertificate { 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 { +func (it *iterSSHHostCertificate) Err() error { return it.err } diff --git a/ssh_user_certificates/client.go b/ssh_user_certificates/client.go index d5b06e6..5cbdae7 100644 --- a/ssh_user_certificates/client.go +++ b/ssh_user_certificates/client.go @@ -96,7 +96,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.SSHUserCertificate, // List all SSH User Certificates issued on this account // // https://ngrok.com/docs/api#api-ssh-user-certificates-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.SSHUserCertificate] { if paging == nil { paging = new(ngrok.Paging) } @@ -113,16 +113,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterSSHUserCertificate{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterSSHUserCertificate struct { client *Client n int items []ngrok.SSHUserCertificate @@ -133,7 +133,7 @@ type Iter struct { // 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 { +func (it *iterSSHUserCertificate) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -183,14 +183,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the SSHUserCertificate currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.SSHUserCertificate { +func (it *iterSSHUserCertificate) Item() *ngrok.SSHUserCertificate { 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 { +func (it *iterSSHUserCertificate) Err() error { return it.err } diff --git a/tls_certificates/client.go b/tls_certificates/client.go index e375709..8e5176b 100644 --- a/tls_certificates/client.go +++ b/tls_certificates/client.go @@ -98,7 +98,7 @@ func (c *Client) Get(ctx context.Context, id string) (*ngrok.TLSCertificate, err // List all TLS certificates on this account // // https://ngrok.com/docs/api#api-tls-certificates-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.TLSCertificate] { if paging == nil { paging = new(ngrok.Paging) } @@ -115,16 +115,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterTLSCertificate{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterTLSCertificate struct { client *Client n int items []ngrok.TLSCertificate @@ -135,7 +135,7 @@ type Iter struct { // 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 { +func (it *iterTLSCertificate) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -185,14 +185,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the TLSCertificate currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.TLSCertificate { +func (it *iterTLSCertificate) Item() *ngrok.TLSCertificate { 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 { +func (it *iterTLSCertificate) Err() error { return it.err } diff --git a/tunnel_sessions/client.go b/tunnel_sessions/client.go index c846259..50e4a27 100644 --- a/tunnel_sessions/client.go +++ b/tunnel_sessions/client.go @@ -27,7 +27,7 @@ func NewClient(cfg *ngrok.ClientConfig) *Client { // List all online tunnel sessions running on this account. // // https://ngrok.com/docs/api#api-tunnel-sessions-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.TunnelSession] { if paging == nil { paging = new(ngrok.Paging) } @@ -44,16 +44,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterTunnelSession{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterTunnelSession struct { client *Client n int items []ngrok.TunnelSession @@ -64,7 +64,7 @@ type Iter struct { // 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 { +func (it *iterTunnelSession) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -114,14 +114,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the TunnelSession currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.TunnelSession { +func (it *iterTunnelSession) Item() *ngrok.TunnelSession { 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 { +func (it *iterTunnelSession) Err() error { return it.err } diff --git a/tunnels/client.go b/tunnels/client.go index 72eb355..4997571 100644 --- a/tunnels/client.go +++ b/tunnels/client.go @@ -26,7 +26,7 @@ func NewClient(cfg *ngrok.ClientConfig) *Client { // List all online tunnels currently running on the account. // // https://ngrok.com/docs/api#api-tunnels-list -func (c *Client) List(paging *ngrok.Paging) *Iter { +func (c *Client) List(paging *ngrok.Paging) ngrok.Iter[*ngrok.Tunnel] { if paging == nil { paging = new(ngrok.Paging) } @@ -43,16 +43,16 @@ func (c *Client) List(paging *ngrok.Paging) *Iter { queryVals.Set("limit", *paging.Limit) } apiURL.RawQuery = queryVals.Encode() - return &Iter{ + return &iterTunnel{ client: c, n: -1, nextPage: apiURL, } } -// Iter allows the caller to iterate through a list of values while +// 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 { +type iterTunnel struct { client *Client n int items []ngrok.Tunnel @@ -63,7 +63,7 @@ type Iter struct { // 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 { +func (it *iterTunnel) Next(ctx context.Context) bool { // no more if there is an error if it.err != nil { return false @@ -113,14 +113,14 @@ func (it *Iter) Next(ctx context.Context) bool { // Item() returns the Tunnel currently // pointed to by the iterator. -func (it *Iter) Item() *ngrok.Tunnel { +func (it *iterTunnel) Item() *ngrok.Tunnel { 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 { +func (it *iterTunnel) Err() error { return it.err }