Documentation
¶
Index ¶
- func IsConflict(err error) bool
- func IsForbidden(err error) bool
- func IsNotFound(err error) bool
- type APIError
- type AccessList
- type AuditEntry
- type Bool
- type Certificate
- type Client
- func (c *Client) ChangePassword(ctx context.Context, id int, body interface{}) error
- func (c *Client) CreateAccessList(ctx context.Context, body interface{}) (*AccessList, error)
- func (c *Client) CreateCertificate(ctx context.Context, body interface{}) (*Certificate, error)
- func (c *Client) CreateDeadHost(ctx context.Context, body interface{}) (*DeadHost, error)
- func (c *Client) CreateProxyHost(ctx context.Context, body interface{}) (*ProxyHost, error)
- func (c *Client) CreateRedirectHost(ctx context.Context, body interface{}) (*RedirectHost, error)
- func (c *Client) CreateStream(ctx context.Context, body interface{}) (*Stream, error)
- func (c *Client) CreateUser(ctx context.Context, body interface{}) (*User, error)
- func (c *Client) Delete(ctx context.Context, path string) (*Response, error)
- func (c *Client) DeleteAccessList(ctx context.Context, id int) error
- func (c *Client) DeleteCertificate(ctx context.Context, id int) error
- func (c *Client) DeleteDeadHost(ctx context.Context, id int) error
- func (c *Client) DeleteProxyHost(ctx context.Context, id int) error
- func (c *Client) DeleteRedirectHost(ctx context.Context, id int) error
- func (c *Client) DeleteStream(ctx context.Context, id int) error
- func (c *Client) DeleteUser(ctx context.Context, id int) error
- func (c *Client) DisableDeadHost(ctx context.Context, id int) error
- func (c *Client) DisableProxyHost(ctx context.Context, id int) error
- func (c *Client) DisableRedirectHost(ctx context.Context, id int) error
- func (c *Client) DisableStream(ctx context.Context, id int) error
- func (c *Client) EnableDeadHost(ctx context.Context, id int) error
- func (c *Client) EnableProxyHost(ctx context.Context, id int) error
- func (c *Client) EnableRedirectHost(ctx context.Context, id int) error
- func (c *Client) EnableStream(ctx context.Context, id int) error
- func (c *Client) EnableVerboseLogging(w io.Writer)
- func (c *Client) Get(ctx context.Context, path string) (*Response, error)
- func (c *Client) GetAccessList(ctx context.Context, id int) (*AccessList, error)
- func (c *Client) GetAuditEntry(ctx context.Context, id int) (*AuditEntry, error)
- func (c *Client) GetCertificate(ctx context.Context, id int) (*Certificate, error)
- func (c *Client) GetDeadHost(ctx context.Context, id int) (*DeadHost, error)
- func (c *Client) GetHostReport(ctx context.Context) (json.RawMessage, error)
- func (c *Client) GetProxyHost(ctx context.Context, id int) (*ProxyHost, error)
- func (c *Client) GetRedirectHost(ctx context.Context, id int) (*RedirectHost, error)
- func (c *Client) GetSetting(ctx context.Context, id string) (*Setting, error)
- func (c *Client) GetStatus(ctx context.Context) (*Status, error)
- func (c *Client) GetStream(ctx context.Context, id int) (*Stream, error)
- func (c *Client) GetUser(ctx context.Context, id string) (*User, error)
- func (c *Client) ListAccessLists(ctx context.Context) ([]AccessList, error)
- func (c *Client) ListAuditLog(ctx context.Context) ([]AuditEntry, error)
- func (c *Client) ListCertificates(ctx context.Context) ([]Certificate, error)
- func (c *Client) ListDNSProviders(ctx context.Context) (json.RawMessage, error)
- func (c *Client) ListDeadHosts(ctx context.Context) ([]DeadHost, error)
- func (c *Client) ListProxyHosts(ctx context.Context) ([]ProxyHost, error)
- func (c *Client) ListRedirectHosts(ctx context.Context) ([]RedirectHost, error)
- func (c *Client) ListSettings(ctx context.Context) ([]Setting, error)
- func (c *Client) ListStreams(ctx context.Context) ([]Stream, error)
- func (c *Client) ListUsers(ctx context.Context) ([]User, error)
- func (c *Client) Post(ctx context.Context, path string, body interface{}) (*Response, error)
- func (c *Client) PostMultipart(ctx context.Context, path string, body io.Reader, contentType string) (*Response, error)
- func (c *Client) Put(ctx context.Context, path string, body interface{}) (*Response, error)
- func (c *Client) RenewCertificate(ctx context.Context, id int) error
- func (c *Client) SetUserPermissions(ctx context.Context, id int, body interface{}) error
- func (c *Client) TestHTTP(ctx context.Context, body interface{}) error
- func (c *Client) UpdateAccessList(ctx context.Context, id int, body interface{}) (*AccessList, error)
- func (c *Client) UpdateDeadHost(ctx context.Context, id int, body interface{}) (*DeadHost, error)
- func (c *Client) UpdateProxyHost(ctx context.Context, id int, body interface{}) (*ProxyHost, error)
- func (c *Client) UpdateRedirectHost(ctx context.Context, id int, body interface{}) (*RedirectHost, error)
- func (c *Client) UpdateSetting(ctx context.Context, id string, body interface{}) (*Setting, error)
- func (c *Client) UpdateStream(ctx context.Context, id int, body interface{}) (*Stream, error)
- func (c *Client) UpdateUser(ctx context.Context, id int, body interface{}) (*User, error)
- type DeadHost
- type ProxyHost
- type ProxyLocation
- type RedirectHost
- type Response
- type Setting
- type Status
- type Stream
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsConflict ¶
IsConflict returns true if the error is a 409 Conflict.
func IsForbidden ¶
IsForbidden returns true if the error is a 403 Forbidden.
func IsNotFound ¶
IsNotFound returns true if the error is a 404 Not Found.
Types ¶
type AccessList ¶
type AccessList struct {
ID int `json:"id"`
CreatedOn string `json:"created_on"`
ModifiedOn string `json:"modified_on"`
OwnerUserID int `json:"owner_user_id"`
Name string `json:"name"`
SatisfyAny Bool `json:"satisfy_any"`
PassAuth Bool `json:"pass_auth"`
Items json.RawMessage `json:"items"`
Clients json.RawMessage `json:"clients"`
Meta map[string]interface{} `json:"meta"`
}
type AuditEntry ¶
type Bool ¶
type Bool bool
Bool is a bool that tolerates the different encodings used by the Nginx Proxy Manager API. NPM releases before v2.12.0 return database boolean columns as JSON numbers (0/1); newer releases return real booleans. Bool accepts true/false, 0/1, "0"/"1"/"true"/"false", and null.
func (*Bool) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type Certificate ¶
type Certificate struct {
ID int `json:"id"`
CreatedOn string `json:"created_on"`
ModifiedOn string `json:"modified_on"`
OwnerUserID int `json:"owner_user_id"`
Provider string `json:"provider"`
NiceName string `json:"nice_name"`
DomainNames []string `json:"domain_names"`
ExpiresOn string `json:"expires_on"`
Meta map[string]interface{} `json:"meta"`
}
type Client ¶
Client is the Nginx Proxy Manager HTTP API client.
func NewClient ¶
func NewClient(rc *config.ResolvedConfig) (*Client, error)
NewClient creates a new client from a ResolvedConfig. It authenticates with the NPM API to obtain a JWT token.
func NewClientWithToken ¶
NewClientWithToken creates a client with a pre-existing JWT token (for login testing).
func (*Client) ChangePassword ¶
func (*Client) CreateAccessList ¶
func (c *Client) CreateAccessList(ctx context.Context, body interface{}) (*AccessList, error)
func (*Client) CreateCertificate ¶
func (c *Client) CreateCertificate(ctx context.Context, body interface{}) (*Certificate, error)
func (*Client) CreateDeadHost ¶
func (*Client) CreateProxyHost ¶
func (*Client) CreateRedirectHost ¶
func (c *Client) CreateRedirectHost(ctx context.Context, body interface{}) (*RedirectHost, error)
func (*Client) CreateStream ¶
func (*Client) CreateUser ¶
func (*Client) DeleteAccessList ¶
func (*Client) DeleteCertificate ¶
func (*Client) DeleteProxyHost ¶
func (*Client) DeleteRedirectHost ¶
func (*Client) DisableDeadHost ¶
func (*Client) DisableProxyHost ¶
func (*Client) DisableRedirectHost ¶
func (*Client) EnableProxyHost ¶
func (*Client) EnableRedirectHost ¶
func (*Client) EnableVerboseLogging ¶
EnableVerboseLogging wraps the client's HTTP transport with verbose logging.
func (*Client) GetAccessList ¶
func (*Client) GetAuditEntry ¶
func (*Client) GetCertificate ¶
func (*Client) GetDeadHost ¶
func (*Client) GetHostReport ¶
func (*Client) GetProxyHost ¶
func (*Client) GetRedirectHost ¶
func (*Client) GetSetting ¶
func (*Client) ListAccessLists ¶
func (c *Client) ListAccessLists(ctx context.Context) ([]AccessList, error)
func (*Client) ListAuditLog ¶
func (c *Client) ListAuditLog(ctx context.Context) ([]AuditEntry, error)
func (*Client) ListCertificates ¶
func (c *Client) ListCertificates(ctx context.Context) ([]Certificate, error)
func (*Client) ListDNSProviders ¶
func (*Client) ListDeadHosts ¶
func (*Client) ListProxyHosts ¶
func (*Client) ListRedirectHosts ¶
func (c *Client) ListRedirectHosts(ctx context.Context) ([]RedirectHost, error)
func (*Client) PostMultipart ¶
func (c *Client) PostMultipart(ctx context.Context, path string, body io.Reader, contentType string) (*Response, error)
PostMultipart sends a POST request with a raw body and custom content type.
func (*Client) RenewCertificate ¶
func (*Client) SetUserPermissions ¶
func (*Client) UpdateAccessList ¶
func (*Client) UpdateDeadHost ¶
func (*Client) UpdateProxyHost ¶
func (*Client) UpdateRedirectHost ¶
func (*Client) UpdateSetting ¶
func (*Client) UpdateStream ¶
type DeadHost ¶
type DeadHost struct {
ID int `json:"id"`
CreatedOn string `json:"created_on"`
ModifiedOn string `json:"modified_on"`
OwnerUserID int `json:"owner_user_id"`
DomainNames []string `json:"domain_names"`
CertificateID interface{} `json:"certificate_id"`
SSLForced Bool `json:"ssl_forced"`
HSTSEnabled Bool `json:"hsts_enabled"`
HSTSSubdomains Bool `json:"hsts_subdomains"`
HTTP2Support Bool `json:"http2_support"`
AdvancedConfig string `json:"advanced_config"`
Enabled Bool `json:"enabled"`
Meta map[string]interface{} `json:"meta"`
}
type ProxyHost ¶
type ProxyHost struct {
ID int `json:"id"`
CreatedOn string `json:"created_on"`
ModifiedOn string `json:"modified_on"`
OwnerUserID int `json:"owner_user_id"`
DomainNames []string `json:"domain_names"`
ForwardHost string `json:"forward_host"`
ForwardPort int `json:"forward_port"`
ForwardScheme string `json:"forward_scheme"`
AccessListID int `json:"access_list_id"`
CertificateID interface{} `json:"certificate_id"` // int or "new"
SSLForced Bool `json:"ssl_forced"`
HSTSEnabled Bool `json:"hsts_enabled"`
HSTSSubdomains Bool `json:"hsts_subdomains"`
HTTP2Support Bool `json:"http2_support"`
BlockExploits Bool `json:"block_exploits"`
CachingEnabled Bool `json:"caching_enabled"`
AllowWebsocketUpgrade Bool `json:"allow_websocket_upgrade"`
AdvancedConfig string `json:"advanced_config"`
Enabled Bool `json:"enabled"`
Meta map[string]interface{} `json:"meta"`
Locations []ProxyLocation `json:"locations"`
}
type ProxyLocation ¶
type RedirectHost ¶
type RedirectHost struct {
ID int `json:"id"`
CreatedOn string `json:"created_on"`
ModifiedOn string `json:"modified_on"`
OwnerUserID int `json:"owner_user_id"`
DomainNames []string `json:"domain_names"`
ForwardScheme string `json:"forward_scheme"`
ForwardHTTPCode int `json:"forward_http_code"`
ForwardDomainName string `json:"forward_domain_name"`
PreservePath Bool `json:"preserve_path"`
CertificateID interface{} `json:"certificate_id"`
SSLForced Bool `json:"ssl_forced"`
HSTSEnabled Bool `json:"hsts_enabled"`
HSTSSubdomains Bool `json:"hsts_subdomains"`
HTTP2Support Bool `json:"http2_support"`
BlockExploits Bool `json:"block_exploits"`
AdvancedConfig string `json:"advanced_config"`
Enabled Bool `json:"enabled"`
Meta map[string]interface{} `json:"meta"`
}
type Response ¶
Response wraps an http.Response with convenience methods.
func (*Response) Error ¶
Error checks if the response indicates an error and returns an APIError. It always closes the response body to prevent leaks.
func (*Response) JSON ¶
JSON reads the response body and unmarshals it into v. It also checks for error status codes.
func (*Response) StatusCode ¶
StatusCode returns the HTTP status code.
type Stream ¶
type Stream struct {
ID int `json:"id"`
CreatedOn string `json:"created_on"`
ModifiedOn string `json:"modified_on"`
OwnerUserID int `json:"owner_user_id"`
IncomingPort int `json:"incoming_port"`
ForwardingHost string `json:"forwarding_host"`
ForwardingPort int `json:"forwarding_port"`
TCPForwarding Bool `json:"tcp_forwarding"`
UDPForwarding Bool `json:"udp_forwarding"`
CertificateID interface{} `json:"certificate_id"`
Enabled Bool `json:"enabled"`
Meta map[string]interface{} `json:"meta"`
}
type User ¶
type User struct {
ID int `json:"id"`
CreatedOn string `json:"created_on"`
ModifiedOn string `json:"modified_on"`
Name string `json:"name"`
Nickname string `json:"nickname"`
Email string `json:"email"`
Avatar string `json:"avatar"`
IsDisabled Bool `json:"is_disabled"`
Roles []string `json:"roles"`
Permissions json.RawMessage `json:"permissions"`
}