cloud

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package cloud contains API clients for Mocklet cloud services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsKind

func IsKind(err error, kind ErrorKind) bool

IsKind checks whether error chain contains cloud error kind.

Types

type AuthClient

type AuthClient struct {
	// contains filtered or unexported fields
}

AuthClient is a thin wrapper around auth endpoints.

func NewAuthClient

func NewAuthClient(cfg ClientConfig) (*AuthClient, error)

NewAuthClient constructs an auth client from transport config.

func NewAuthClientWithGeneratedClient

func NewAuthClientWithGeneratedClient(client openapi.ClientWithResponsesInterface) *AuthClient

NewAuthClientWithGeneratedClient wires an already constructed generated client.

func (*AuthClient) ExchangeGoogleCLI

func (c *AuthClient) ExchangeGoogleCLI(ctx context.Context, oneTimeCode string) (GoogleCLIExchange, error)

ExchangeGoogleCLI exchanges one-time-code polling state for final token.

func (*AuthClient) Login

func (c *AuthClient) Login(ctx context.Context, email, password string) (LoginResult, error)

Login authenticates a user using email/password credentials.

func (*AuthClient) StartGoogleCLI

func (c *AuthClient) StartGoogleCLI(ctx context.Context) (GoogleCLIStart, error)

StartGoogleCLI starts one-time-code OAuth flow.

func (*AuthClient) WhoAmI

func (c *AuthClient) WhoAmI(ctx context.Context) (UserIdentity, error)

WhoAmI returns identity information for the current token.

type ClientConfig

type ClientConfig struct {
	BaseURL    string
	Token      string
	RequestID  string
	Timeout    time.Duration
	UserAgent  string
	HTTPClient *http.Client
}

ClientConfig controls HTTP transport and request metadata.

type CreateMockFileOptions

type CreateMockFileOptions struct {
	TTLSeconds            int
	SSLEnabled            *bool
	LatencyEmulation      *bool
	ReplaceLinks          *bool
	CrossDomainMainDomain *string
	MatchingRulesRaw      []byte
}

CreateMockFileOptions defines parameters for multipart mock creation.

type CreateMockRawOptions

type CreateMockRawOptions struct {
	TTLSeconds            int
	SSLEnabled            *bool
	LatencyEmulation      *bool
	ReplaceLinks          *bool
	CrossDomainMainDomain *string
	MatchingRulesRaw      []byte
}

CreateMockRawOptions defines parameters for raw JSON mock creation.

type CreateMockResult

type CreateMockResult struct {
	MockID           string
	BaseURL          string
	ExpiresAt        *time.Time
	HarSizeBytes     *int
	TTLSeconds       *int
	SSLEnabled       *bool
	LatencyEmulation *bool
	DomainMap        []DomainMockInfo
}

CreateMockResult is a normalized creation response.

type DomainMockInfo

type DomainMockInfo struct {
	OriginalDomain string
	MockID         string
	BaseURL        string
	IsMain         bool
}

DomainMockInfo describes one domain-specific mock entry from cross-domain mode.

type Error

type Error struct {
	Kind       ErrorKind
	Message    string
	StatusCode int
	Err        error
}

Error represents a classified cloud layer failure.

func (*Error) Error

func (e *Error) Error() string

Error returns a human-readable error message.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the nested cause.

type ErrorKind

type ErrorKind string

ErrorKind is a stable cloud transport failure class.

const (
	ErrorKindAuth       ErrorKind = "auth_failure"
	ErrorKindValidation ErrorKind = "validation_failure"
	ErrorKindNotFound   ErrorKind = "not_found"
	ErrorKindConflict   ErrorKind = "conflict"
	ErrorKindRateLimit  ErrorKind = "rate_limit"
	ErrorKindTimeout    ErrorKind = "timeout"
	ErrorKindNetwork    ErrorKind = "network_error"
	ErrorKindServer     ErrorKind = "server_error"
	ErrorKindUnknown    ErrorKind = "unknown_error"
)

type GoogleCLIExchange

type GoogleCLIExchange struct {
	Pending           bool
	RetryAfterSeconds int
	Login             *LoginResult
}

GoogleCLIExchange reports either a pending poll or final login response.

type GoogleCLIStart

type GoogleCLIStart struct {
	OneTimeCode      string
	AuthorizationURL string
	IntervalSeconds  int
	ExpiresAt        string
}

GoogleCLIStart is a normalized start response for one-time-code OAuth.

type ListMocksOptions

type ListMocksOptions struct {
	Limit  *int
	Cursor *string
}

ListMocksOptions configures list endpoint query parameters.

type ListMocksResult

type ListMocksResult struct {
	Items      []MockSummary
	NextCursor string
	Totals     *openapi.UserTotals
}

ListMocksResult is a normalized list response.

type LoginResult

type LoginResult struct {
	Token     string
	Email     string
	UserID    int
	ExpiresAt int64
}

LoginResult is an internal auth login model independent from generated response envelopes.

type ManagementClient

type ManagementClient struct {
	// contains filtered or unexported fields
}

ManagementClient is a thin wrapper around management endpoints.

func NewManagementClient

func NewManagementClient(cfg ClientConfig) (*ManagementClient, error)

NewManagementClient constructs a management client from transport config.

func NewManagementClientWithGeneratedClient

func NewManagementClientWithGeneratedClient(client openapi.ClientWithResponsesInterface) *ManagementClient

NewManagementClientWithGeneratedClient wires an existing generated client.

func (*ManagementClient) CreateMockFile

func (c *ManagementClient) CreateMockFile(ctx context.Context, path string, options CreateMockFileOptions) (CreateMockResult, error)

CreateMockFile uploads HAR file and creates a mock.

func (*ManagementClient) CreateMockRaw

func (c *ManagementClient) CreateMockRaw(ctx context.Context, payload []byte, options CreateMockRawOptions) (CreateMockResult, error)

CreateMockRaw creates a mock using raw JSON HAR payload.

func (*ManagementClient) DeleteMock

func (c *ManagementClient) DeleteMock(ctx context.Context, mockID string) error

DeleteMock removes mock by id.

func (*ManagementClient) GetMock

func (c *ManagementClient) GetMock(ctx context.Context, mockID string) (MockSummary, error)

GetMock returns one mock by id.

func (*ManagementClient) GetMockStats

func (c *ManagementClient) GetMockStats(ctx context.Context, mockID string, historyLimit *int) (*openapi.MockStatsResponse, error)

GetMockStats returns full mock stats payload.

func (*ManagementClient) ListMocks

func (c *ManagementClient) ListMocks(ctx context.Context, options ListMocksOptions) (ListMocksResult, error)

ListMocks returns normalized mock summaries.

func (*ManagementClient) RestartMock

func (c *ManagementClient) RestartMock(ctx context.Context, mockID string) (RestartMockResult, error)

RestartMock resets sequence state for a mock.

func (*ManagementClient) ValidateHARFile

func (c *ManagementClient) ValidateHARFile(ctx context.Context, path string) (*openapi.HarValidationResult, error)

ValidateHARFile validates a HAR file upload.

func (*ManagementClient) ValidateHARRaw

ValidateHARRaw validates HAR JSON payload.

func (*ManagementClient) ValidateHARRawBytes

func (c *ManagementClient) ValidateHARRawBytes(ctx context.Context, payload []byte) (*openapi.HarValidationResult, error)

ValidateHARRawBytes validates HAR JSON payload provided as raw bytes.

type MockSummary

type MockSummary struct {
	MockID           string
	BaseURL          string
	Status           string
	CreatedAt        *time.Time
	ExpiresAt        *time.Time
	LastSeenAt       *time.Time
	ParentMockID     *string
	RequestsHit      *int
	RequestsMiss     *int
	RequestsTotal    *int
	HarSizeBytes     *int
	TTLSeconds       *int
	SSLEnabled       *bool
	LatencyEmulation *bool
}

MockSummary is an internal representation for list/get outputs.

type RestartMockResult

type RestartMockResult struct {
	MockID string
	Status string
}

RestartMockResult represents restart endpoint payload.

type UserIdentity

type UserIdentity struct {
	Email  string
	UserID int
}

UserIdentity is a normalized auth/me response.

Directories

Path Synopsis
Package openapi provides primitives to interact with the openapi HTTP API.
Package openapi provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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