mirror of
https://github.com/ngrok/ngrok-api-go.git
synced 2026-05-17 16:50:37 +00:00
92 lines
2.4 KiB
Go
92 lines
2.4 KiB
Go
// Code generated for API Clients. DO NOT EDIT.
|
|
|
|
package https_edge_route_compression
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"fmt"
|
|
"net/url"
|
|
"text/template"
|
|
|
|
"github.com/ngrok/ngrok-api-go/v9"
|
|
"github.com/ngrok/ngrok-api-go/v9/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.EdgeRouteCompressionReplace) (*ngrok.EndpointCompression, error) {
|
|
if arg == nil {
|
|
arg = new(ngrok.EdgeRouteCompressionReplace)
|
|
}
|
|
var res ngrok.EndpointCompression
|
|
var path bytes.Buffer
|
|
if err := template.Must(template.New("replace_path").Parse("/edges/https/{{ .EdgeID }}/routes/{{ .ID }}/compression")).Execute(&path, arg); err != nil {
|
|
return nil, fmt.Errorf("error building path for replace: %w", 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.EndpointCompression, error) {
|
|
if arg == nil {
|
|
arg = new(ngrok.EdgeRouteItem)
|
|
}
|
|
var res ngrok.EndpointCompression
|
|
var path bytes.Buffer
|
|
if err := template.Must(template.New("get_path").Parse("/edges/https/{{ .EdgeID }}/routes/{{ .ID }}/compression")).Execute(&path, arg); err != nil {
|
|
return nil, fmt.Errorf("error building path for get: %w", 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 }}/compression")).Execute(&path, arg); err != nil {
|
|
return fmt.Errorf("error building path for delete: %w", 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
|
|
}
|