Documentation
¶
Index ¶
Constants ¶
View Source
const ( GlobalpingAuthURL = "https://auth.globalping.io" GlobalpingDashboardURL = "https://dash.globalping.io" )
Variables ¶
View Source
var ( ErrTypeExchangeFailed = "exchange_failed" ErrTypeRefreshFailed = "refresh_failed" ErrTypeRevokeFailed = "revoke_failed" ErrTypeIntrospectionFailed = "introspection_failed" ErrTypeInvalidGrant = "invalid_grant" ErrTypeNotAuthorized = "not_authorized" )
View Source
var (
)
Functions ¶
This section is empty.
Types ¶
type AuthorizeError ¶
type AuthorizeError struct {
Code int `json:"-"`
ErrorType string `json:"error"`
Description string `json:"error_description"`
}
func (*AuthorizeError) Error ¶
func (e *AuthorizeError) Error() string
type AuthorizeResponse ¶
type Client ¶
type Client interface {
// Creates a new measurement with parameters set in the request body. The measurement runs asynchronously and you can retrieve its current state at the URL returned in the Location header.
//
// https://globalping.io/docs/api.globalping.io#post-/v1/measurements
CreateMeasurement(ctx context.Context, measurement *globalping.MeasurementCreate) (*globalping.MeasurementCreateResponse, error)
// Returns the status and results of an existing measurement. Measurements are typically available for up to 7 days after creation.
//
// https://globalping.io/docs/api.globalping.io#get-/v1/measurements/-id-
GetMeasurement(ctx context.Context, id string) (*globalping.Measurement, error)
// Waits for the measurement to complete and returns the results.
//
// https://globalping.io/docs/api.globalping.io#get-/v1/measurements/-id-
AwaitMeasurement(ctx context.Context, id string) (*globalping.Measurement, error)
// Returns the status and results of an existing measurement. Measurements are typically available for up to 7 days after creation.
//
// https://globalping.io/docs/api.globalping.io#get-/v1/measurements/-id-
GetMeasurementRaw(ctx context.Context, id string) ([]byte, error)
// Returns a link to be used for authorization and listens for the authorization callback.
Authorize(ctx context.Context, callback func(error)) (*AuthorizeResponse, error)
// Returns the introspection response for the token.
//
// If the token is empty, the client's current token will be used.
TokenIntrospection(ctx context.Context, token string) (*IntrospectionResponse, error)
// Removes the current token from the client. It also revokes the tokens if the refresh token is available.
Logout(ctx context.Context) error
// Revokes the token.
RevokeToken(ctx context.Context, token string) error
// Returns the rate limits for the current user or IP address.
Limits(ctx context.Context) (*globalping.LimitsResponse, error)
// Closes the client.
Close()
}
type Config ¶
type Config struct {
Utils utils.Utils
Storage *storage.LocalStorage
Printer *view.Printer
Globalping globalping.Client
HTTPClient *http.Client // If set, this client will be used for API requests and authorization
DashboardURL string // optional
AuthURL string // optional
AuthClientID string
AuthClientSecret string
AuthToken *storage.Token
UserAgent string
}
type IntrospectionResponse ¶
type IntrospectionResponse struct {
// Required fields
Active bool `json:"active"`
// Optional fields
Scope string `json:"scope"`
ClientID string `json:"client_id"`
Username string `json:"username"`
TokenType string `json:"token_type"`
Exp int64 `json:"exp"` // Expiration Time. Unix timestamp
Iat int64 `json:"iat"` // Issued At. Unix timestamp
Nbf int64 `json:"nbf"` // Not to be used before. Unix timestamp
Sub string `json:"sub"` // Subject
Aud string `json:"aud"` // Audience
Iss string `json:"iss"` // Issuer
Jti string `json:"jti"` // JWT ID
}
Click to show internal directories.
Click to hide internal directories.