client

package
v0.0.0-...-0b5231c Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTooManyFailures = errors.New("skipping HTTP Request, too many failures have occurred")

ErrTooManyFailures is returned from remote cache API methods after `maxRemoteFailCount` errors have occurred

Functions

func AddFlags

func AddFlags(opts *Opts, flags *pflag.FlagSet)

AddFlags adds flags specific to the api client to the given flagset

Types

type ApiClient

type ApiClient struct {

	// An http client
	HttpClient *retryablehttp.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(remoteConfig RemoteConfig, logger hclog.Logger, titanVersion string, opts Opts) *ApiClient

New creates a new ApiClient

func (*ApiClient) ArtifactExists

func (c *ApiClient) ArtifactExists(hash string) (*http.Response, error)

ArtifactExists attempts to determine if the build artifact with the given hash exists in the Remote Caching server

func (*ApiClient) FetchArtifact

func (c *ApiClient) FetchArtifact(hash string) (*http.Response, error)

FetchArtifact attempts to retrieve the build artifact with the given hash from the Remote Caching server

func (*ApiClient) GetCachingStatus

func (c *ApiClient) GetCachingStatus() (util.CachingStatus, error)

GetCachingStatus returns the server's perspective on whether or not remote caching requests will be allowed.

func (*ApiClient) GetTeam

func (c *ApiClient) GetTeam(teamID string) (*Team, error)

GetTeam gets a particular Khulnasoft Team. It returns nil if it's not found

func (*ApiClient) GetTeamID

func (c *ApiClient) GetTeamID() string

GetTeamID returns the currently configured team id

func (*ApiClient) GetTeams

func (c *ApiClient) GetTeams() (*TeamsResponse, error)

GetTeams returns a list of Khulnasoft teams

func (*ApiClient) GetUser

func (c *ApiClient) GetUser() (*UserResponse, error)

GetUser returns the current user

func (*ApiClient) HasUser

func (c *ApiClient) HasUser() bool

HasUser returns true if we have credentials for a user

func (*ApiClient) IsLinked

func (c *ApiClient) IsLinked() bool

IsLinked returns true if we have a user and linked team

func (*ApiClient) PutArtifact

func (c *ApiClient) PutArtifact(hash string, artifactBody []byte, duration int, tag string) error

func (*ApiClient) RecordAnalyticsEvents

func (c *ApiClient) RecordAnalyticsEvents(events []map[string]interface{}) error

func (*ApiClient) SetTeamID

func (c *ApiClient) SetTeamID(teamID string)

SetTeamID sets the team parameter used on all requests by this client

func (*ApiClient) SetToken

func (c *ApiClient) SetToken(token string)

SetToken updates the ApiClient's Token

func (*ApiClient) UserAgent

func (c *ApiClient) UserAgent() string

func (*ApiClient) VerifySSOToken

func (c *ApiClient) VerifySSOToken(token string, tokenName string) (*VerifiedSSOUser, error)

type Membership

type Membership struct {
	Role string `json:"role"`
}

Membership is the relationship between the logged-in user and a particular team

type Opts

type Opts struct {
	UsePreflight bool
}

Opts holds values for configuring the behavior of the API client

type Pagination

type Pagination struct {
	Count int `json:"count,omitempty"`
	Next  int `json:"next,omitempty"`
	Prev  int `json:"prev,omitempty"`
}

Pagination is a Khulnasoft pagination object

type RemoteConfig

type RemoteConfig struct {
	Token    string
	TeamID   string
	TeamSlug string
	APIURL   string
}

RemoteConfig holds the authentication and endpoint details for the API client

type Team

type Team struct {
	ID         string     `json:"id,omitempty"`
	Slug       string     `json:"slug,omitempty"`
	Name       string     `json:"name,omitempty"`
	CreatedAt  int        `json:"createdAt,omitempty"`
	Created    string     `json:"created,omitempty"`
	Membership Membership `json:"membership"`
}

Team is a Khulnasoft Team object

func (*Team) IsOwner

func (t *Team) IsOwner() bool

IsOwner returns true if this Team data was fetched by an owner of the team

type TeamsResponse

type TeamsResponse struct {
	Teams      []Team     `json:"teams,omitempty"`
	Pagination Pagination `json:"pagination,omitempty"`
}

TeamsResponse is a Khulnasoft object containing a list of teams and pagination info

type User

type User struct {
	ID        string `json:"id,omitempty"`
	Username  string `json:"username,omitempty"`
	Email     string `json:"email,omitempty"`
	Name      string `json:"name,omitempty"`
	CreatedAt int    `json:"createdAt,omitempty"`
}

type UserResponse

type UserResponse struct {
	User User `json:"user,omitempty"`
}

type VerifiedSSOUser

type VerifiedSSOUser struct {
	Token  string
	TeamID string
}

VerifiedSSOUser contains data returned from the SSO token verification endpoint

Jump to

Keyboard shortcuts

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