Documentation
¶
Index ¶
- Constants
- Variables
- func EscapeValidatePathSegments(seg ...*string) error
- func GetBaseApi() string
- func GiteaApiParsef(format string, a ...any) string
- func SetBaseApi(api string)
- type GiteaApiFunc
- type GiteaApiResponse
- type GiteaListOpt
- type GiteaTokenClient
- func (g *GiteaTokenClient) ApiGiteaDelete(httpPath string, header http.Header, response interface{}) (*GiteaApiResponse, error)
- func (g *GiteaTokenClient) ApiGiteaGet(httpPath string, header http.Header, response interface{}) (*GiteaApiResponse, error)
- func (g *GiteaTokenClient) ApiGiteaPatch(httpPath string, header http.Header, body io.Reader, response interface{}) (*GiteaApiResponse, error)
- func (g *GiteaTokenClient) ApiGiteaPatchJson(httpPath string, header http.Header, body interface{}, response interface{}) (*GiteaApiResponse, error)
- func (g *GiteaTokenClient) ApiGiteaPost(httpPath string, header http.Header, body io.Reader, response interface{}) (*GiteaApiResponse, error)
- func (g *GiteaTokenClient) ApiGiteaPostJson(httpPath string, header http.Header, body interface{}, response interface{}) (*GiteaApiResponse, error)
- func (g *GiteaTokenClient) ApiGiteaPut(httpPath string, header http.Header, body io.Reader, response interface{}) (*GiteaApiResponse, error)
- func (g *GiteaTokenClient) ApiGiteaPutJson(httpPath string, header http.Header, body io.Reader, response interface{}) (*GiteaApiResponse, error)
- func (g *GiteaTokenClient) ApiGiteaStatusCode(method, path string, header http.Header, body io.Reader) (int, error)
- func (g *GiteaTokenClient) GetBaseUrl() string
- func (g *GiteaTokenClient) GetContext() context.Context
- func (g *GiteaTokenClient) GetRemoteGiteaVersion() string
- func (g *GiteaTokenClient) GetUsername() string
- func (g *GiteaTokenClient) GiteaClient() *gitea.Client
- func (g *GiteaTokenClient) IsDebug() bool
- func (g *GiteaTokenClient) NewClient(url, accessToken string, httpClient *http.Client) error
- func (g *GiteaTokenClient) NewClientWithHttpTimeout(url, accessToken string, timeoutSecond uint, insecure bool) error
- func (g *GiteaTokenClient) SetBasicAuth(username, password string)
- func (g *GiteaTokenClient) SetDebug(debug bool)
- func (g *GiteaTokenClient) SetOTP(otp string)
- func (g *GiteaTokenClient) SetSudo(sudo string)
- type GiteaTokenClientFunc
Constants ¶
const (
BaseGiteaApi = "/api/v1"
)
Variables ¶
var JsonHeader = http.Header{"content-type": []string{"application/json"}}
JsonHeader is a default header for json request for http.MethodPost , http.MethodPatch , http.MethodPut, http.MethodDelete
Functions ¶
func EscapeValidatePathSegments ¶ added in v1.2.0
EscapeValidatePathSegments is a help function to validate and encode url path segments use as
pkgName := "foo.one.two" errEsCapePkgName := EscapeValidatePathSegments(&pkgName)
func GetBaseApi ¶ added in v1.2.0
func GetBaseApi() string
func GiteaApiParsef ¶ added in v1.2.0
GiteaApiParsef is a help function to parse api path
func SetBaseApi ¶ added in v1.2.0
func SetBaseApi(api string)
Types ¶
type GiteaApiFunc ¶ added in v1.1.0
type GiteaApiFunc interface { ApiGiteaStatusCode(method, path string, header http.Header, body io.Reader) (int, error) ApiGiteaGet(httpPath string, header http.Header, response interface{}) (*GiteaApiResponse, error) ApiGiteaPostJson(httpPath string, header http.Header, body interface{}, response interface{}) (*GiteaApiResponse, error) ApiGiteaPost(httpPath string, header http.Header, body io.Reader, response interface{}) (*GiteaApiResponse, error) ApiGiteaPatchJson(httpPath string, header http.Header, body interface{}, response interface{}) (*GiteaApiResponse, error) ApiGiteaPatch(httpPath string, header http.Header, body io.Reader, response interface{}) (*GiteaApiResponse, error) ApiGiteaPutJson(httpPath string, header http.Header, body io.Reader, response interface{}) (*GiteaApiResponse, error) ApiGiteaPut(httpPath string, header http.Header, body io.Reader, response interface{}) (*GiteaApiResponse, error) ApiGiteaDelete(httpPath string, header http.Header, response interface{}) (*GiteaApiResponse, error) }
type GiteaApiResponse ¶ added in v1.1.0
type GiteaApiResponse struct { *http.Response FirstPage int PrevPage int NextPage int LastPage int }
GiteaApiResponse represents the gitea response
type GiteaListOpt ¶ added in v1.2.0
type GiteaListOpt struct { // Setting Page to -1 disables pagination on endpoints that support it. // Page numbering starts at 1. Page int // The default value depends on the server config DEFAULT_PAGING_NUM // The highest valid value depends on the server config MAX_RESPONSE_ITEMS PageSize int }
func (*GiteaListOpt) GetURLQuery ¶ added in v1.2.0
func (o *GiteaListOpt) GetURLQuery() url.Values
GetURLQuery returns the query parameters for the given options. use as:
opt.GetURLQuery().Encode()
func (*GiteaListOpt) SetDefaults ¶ added in v1.2.0
func (o *GiteaListOpt) SetDefaults()
SetDefaults applies default pagination options. If .Page is set to -1, it will disable pagination. WARNING: This function is not idempotent, make sure to never call this method twice!
type GiteaTokenClient ¶
type GiteaTokenClient struct { GiteaTokenClientFunc GiteaTokenClientFunc `json:"-"` GiteaApiFunc GiteaApiFunc `json:"-"` // contains filtered or unexported fields }
func (*GiteaTokenClient) ApiGiteaDelete ¶ added in v1.1.0
func (g *GiteaTokenClient) ApiGiteaDelete(httpPath string, header http.Header, response interface{}) (*GiteaApiResponse, error)
ApiGiteaDelete sends a DELETE request to the Gitea API and returns the response
func (*GiteaTokenClient) ApiGiteaGet ¶ added in v1.1.0
func (g *GiteaTokenClient) ApiGiteaGet(httpPath string, header http.Header, response interface{}) (*GiteaApiResponse, error)
ApiGiteaGet sends a GET request to the Gitea API and returns the response
func (*GiteaTokenClient) ApiGiteaPatch ¶ added in v1.1.0
func (g *GiteaTokenClient) ApiGiteaPatch(httpPath string, header http.Header, body io.Reader, response interface{}) (*GiteaApiResponse, error)
ApiGiteaPatch sends a PATCH request to the Gitea API and returns the response
func (*GiteaTokenClient) ApiGiteaPatchJson ¶ added in v1.1.0
func (g *GiteaTokenClient) ApiGiteaPatchJson(httpPath string, header http.Header, body interface{}, response interface{}) (*GiteaApiResponse, error)
ApiGiteaPatchJson sends a PATCH request to the Gitea API with a JSON body and returns the response
func (*GiteaTokenClient) ApiGiteaPost ¶ added in v1.1.0
func (g *GiteaTokenClient) ApiGiteaPost(httpPath string, header http.Header, body io.Reader, response interface{}) (*GiteaApiResponse, error)
ApiGiteaPost sends a POST request to the Gitea API and returns the response
func (*GiteaTokenClient) ApiGiteaPostJson ¶ added in v1.1.0
func (g *GiteaTokenClient) ApiGiteaPostJson(httpPath string, header http.Header, body interface{}, response interface{}) (*GiteaApiResponse, error)
ApiGiteaPostJson sends a POST request to the Gitea API with a JSON body and returns the response
func (*GiteaTokenClient) ApiGiteaPut ¶ added in v1.1.0
func (g *GiteaTokenClient) ApiGiteaPut(httpPath string, header http.Header, body io.Reader, response interface{}) (*GiteaApiResponse, error)
ApiGiteaPut sends a PUT request to the Gitea API and returns the response
func (*GiteaTokenClient) ApiGiteaPutJson ¶ added in v1.1.0
func (g *GiteaTokenClient) ApiGiteaPutJson(httpPath string, header http.Header, body io.Reader, response interface{}) (*GiteaApiResponse, error)
ApiGiteaPutJson sends a PUT request to the Gitea API with a JSON body and returns the response
func (*GiteaTokenClient) ApiGiteaStatusCode ¶ added in v1.1.0
func (g *GiteaTokenClient) ApiGiteaStatusCode(method, path string, header http.Header, body io.Reader) (int, error)
ApiGiteaStatusCode sends a request to the Gitea API and returns the status code
func (*GiteaTokenClient) GetBaseUrl ¶
func (g *GiteaTokenClient) GetBaseUrl() string
GetBaseUrl returns the base URL of the Gitea instance
func (*GiteaTokenClient) GetContext ¶ added in v1.1.0
func (g *GiteaTokenClient) GetContext() context.Context
func (*GiteaTokenClient) GetRemoteGiteaVersion ¶ added in v1.3.0
func (g *GiteaTokenClient) GetRemoteGiteaVersion() string
func (*GiteaTokenClient) GetUsername ¶
func (g *GiteaTokenClient) GetUsername() string
GetUsername returns the username by SetBasicAuth
func (*GiteaTokenClient) GiteaClient ¶
func (g *GiteaTokenClient) GiteaClient() *gitea.Client
GiteaClient returns the gitea.Client
func (*GiteaTokenClient) IsDebug ¶
func (g *GiteaTokenClient) IsDebug() bool
IsDebug returns the debug status
func (*GiteaTokenClient) NewClient ¶
func (g *GiteaTokenClient) NewClient(url, accessToken string, httpClient *http.Client) error
NewClient creates a new Gitea client This function is a wrapper around gitea.NewClient
func (*GiteaTokenClient) NewClientWithHttpTimeout ¶
func (g *GiteaTokenClient) NewClientWithHttpTimeout(url, accessToken string, timeoutSecond uint, insecure bool) error
NewClientWithHttpTimeout creates a new Gitea client with a timeout for the http client The timeout is in seconds, and the minimum is 30 seconds If insecure is true, the client will skip SSL verification This function is a wrapper around gitea.NewClient
func (*GiteaTokenClient) SetBasicAuth ¶
func (g *GiteaTokenClient) SetBasicAuth(username, password string)
SetBasicAuth sets the basic auth for the client from gitea.Client
func (*GiteaTokenClient) SetDebug ¶
func (g *GiteaTokenClient) SetDebug(debug bool)
SetDebug sets the debug status for the client from gitea.Client
func (*GiteaTokenClient) SetOTP ¶
func (g *GiteaTokenClient) SetOTP(otp string)
SetOTP sets the otp for the client from gitea.Client
func (*GiteaTokenClient) SetSudo ¶
func (g *GiteaTokenClient) SetSudo(sudo string)
SetSudo sets the sudo for the client from gitea.Client
type GiteaTokenClientFunc ¶
type GiteaTokenClientFunc interface { NewClientWithHttpTimeout(url, accessToken string, timeoutSecond uint, insecure bool) error NewClient(url, accessToken string, httpClient *http.Client) error GetRemoteGiteaVersion() string SetDebug(debug bool) IsDebug() bool GetContext() context.Context SetOTP(otp string) SetSudo(sudo string) SetBasicAuth(username, password string) GiteaClient() *gitea.Client GetBaseUrl() string GetUsername() string // contains filtered or unexported methods }