restapi

package
v0.0.0-...-f85e97c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2019 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientHandler

type ClientHandler struct {
	http.Header
	// contains filtered or unexported fields
}

ClientHandler struct to store header and roundtrip info

func WithHeader

func WithHeader(rt http.RoundTripper) ClientHandler

WithHeader Adds ability to edit headers without remaking everything

func (ClientHandler) RoundTrip

func (h ClientHandler) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip middleware that sets the headers of each request

type ResponseError

type ResponseError struct {
	Data struct {
		Type       string `json:"type"`
		Attributes struct {
			Title  string `json:"title"`
			Status string `json:"status"`
			Detail string `json:"detail"`
		} `json:"attributes"`
		ID string `json:"id"`
	} `json:"data"`
}

ResponseError JSONapi response error

func (*ResponseError) Error

func (e *ResponseError) Error() string

type RestClient

type RestClient struct {
	URL          string
	RefreshToken string
	APIKey       string
	Client       http.Client
}

RestClient A stuct to hold persistent data that is used between rest calls

func NewRestClient

func NewRestClient(apiEndpoint string, refreshToken string) RestClient

NewRestClient Use this method to create a new rest client so headers can be setup

func (*RestClient) CreateTunnelAPI

func (restClient *RestClient) CreateTunnelAPI(subdomain string, publicKey string, protocol []string) (Tunnel, error)

CreateTunnelAPI calls holepunch web api to get tunnel details

func (*RestClient) DeleteTunnelAPI

func (restClient *RestClient) DeleteTunnelAPI(subdomainName string) error

DeleteTunnelAPI deletes tunnel

func (*RestClient) GetSubdomainName

func (restClient *RestClient) GetSubdomainName(subdomainID string) (string, error)

GetSubdomainName Returns subdomain name of a given subdomain id

func (*RestClient) ListSubdomainAPI

func (restClient *RestClient) ListSubdomainAPI() ([]Subdomain, error)

ListSubdomainAPI get list of subdomains reserved

func (*RestClient) ListTunnelsAPI

func (restClient *RestClient) ListTunnelsAPI() ([]Tunnel, error)

ListTunnelsAPI get list of tunnels

func (*RestClient) Login

func (restClient *RestClient) Login(username string, password string) (SessionResponse, error)

Login Login user with given username and password. Returns sessionresponse so cmd can set viper configs

func (*RestClient) ReleaseSubdomainAPI

func (restClient *RestClient) ReleaseSubdomainAPI(subdomainName string) error

ReleaseSubdomainAPI deletes subdomain

func (*RestClient) ResendConfirmationEmail

func (restClient *RestClient) ResendConfirmationEmail(email string) error

ResendConfirmationEmail If user is unconfirmed this will resend a confirmation email

func (*RestClient) ReserveSubdomainAPI

func (restClient *RestClient) ReserveSubdomainAPI(subdomainName string) (Subdomain, error)

ReserveSubdomainAPI calls holepunch web api to get reserve a subdomain

func (*RestClient) SetAPIKey

func (restClient *RestClient) SetAPIKey(apiKey string)

SetAPIKey set api key header

func (*RestClient) SetRefreshToken

func (restClient *RestClient) SetRefreshToken(refreshToken string)

func (*RestClient) StartSession

func (restClient *RestClient) StartSession(refreshToken string) error

StartSession Start a session and set the restClient to the current access token

type SessionResponse

type SessionResponse struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires-in"`
	RefreshToken string `json:"refresh_token"`
}

SessionResponse Json response for login/session refresh

type Subdomain

type Subdomain struct {
	ID       string `jsonapi:"primary,subdomain"`
	Name     string `jsonapi:"attr,name"`
	InUse    bool   `jsonapi:"attr,inUse"`
	Reserved bool   `jsonapi:"attr,reserved"`
}

Subdomain Subdomain object that holds all needed info

type Tunnel

type Tunnel struct {
	ID        string     `jsonapi:"primary,tunnel"`
	PortTypes []string   `jsonapi:"attr,port,omitempty"`
	PublicKey string     `jsonapi:"attr,sshKey,omitempty"`
	SSHPort   string     `jsonapi:"attr,sshPort,omitempty"`
	TCPPorts  []string   `jsonapi:"attr,allocatedTcpPorts,omitempty"`
	IPAddress string     `jsonapi:"attr,ipAddress,omitempty"`
	Subdomain *Subdomain `jsonapi:"relation,subdomain,omitempty"`
}

Tunnel JSONAPI response of tunnel object

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL