fnapi

package
v0.0.125 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EndpointAddress = "https://api.namespacelabs.net"
	AdminMode       = false
)
View Source
var NamingForceStored = false

Functions

func AddNamespaceHeaders added in v0.0.82

func AddNamespaceHeaders(ctx context.Context, headers *http.Header)

func AnonymousCall

func AnonymousCall(ctx context.Context, endpoint string, method string, req interface{}, handle func(io.Reader) error) error

A nil handle indicates that the caller wants to discard the response.

func AuthenticatedCall added in v0.0.110

func AuthenticatedCall(ctx context.Context, endpoint string, method string, req interface{}, handle func(io.Reader) error) error

func DecodeJSONResponse

func DecodeJSONResponse(resp any) func(io.Reader) error

func LoginAsRobotAndStore

func LoginAsRobotAndStore(ctx context.Context, repository, accessToken string) (string, error)

func Map

func Map(ctx context.Context, fqdn, target string) error

func SetupFlags

func SetupFlags(flags *pflag.FlagSet)

func StoreMarshalledUser added in v0.0.96

func StoreMarshalledUser(ctx context.Context, userAuthData []byte) error

func StoreUser

func StoreUser(ctx context.Context, userAuth *UserAuth) (string, error)

func WithTelemetry

func WithTelemetry(ctx context.Context) context.Context

Types

type AllocateOpts

type AllocateOpts struct {
	Scope     schema.PackageName `json:"-"`
	FQDN      string             `json:"fqdn,omitempty"`
	Subdomain string             `json:"subdomain,omitempty"`
	NoTLS     bool               `json:"-"`
	Org       string             `json:"org,omitempty"`

	Stored *NameResource `json:"-"`
}

JSON annotations below are used for the Arg() serialization below.

type Artifact

type Artifact struct {
	URL    string `json:"url"`
	OS     string `json:"os"`
	Arch   string `json:"arch"`
	SHA256 string `json:"sha256"`
}

type Call

type Call[RequestT any] struct {
	Endpoint               string
	Method                 string
	PreAuthenticateRequest func(*UserAuth, *RequestT) error
	Anonymous              bool
	OptionalAuth           bool // Don't fail if not authenticated.
}

func (Call[RequestT]) Do

func (c Call[RequestT]) Do(ctx context.Context, request RequestT, handle func(io.Reader) error) error

type CheckRequest

type CheckRequest struct {
	UserData string `json:"userData"`
}

type CompleteClerkLoginResponse added in v0.0.96

type CompleteClerkLoginResponse struct {
	Ticket string `json:"ticket,omitempty"`
}

type CompleteLoginRequest

type CompleteLoginRequest struct {
	LoginId        string `json:"login_id"`
	EphemeralCliId string `json:"ephemeral_cli_id"`
}

type GetLatestDeployPlansRequest added in v0.0.109

type GetLatestDeployPlansRequest struct {
	PackageName []string `json:"package_name,omitempty"`
}

type GetLatestDeployPlansResponse added in v0.0.109

type GetLatestDeployPlansResponse struct {
	Plan []*GetLatestDeployPlansResponse_Plan `json:"plan,omitempty"`
}

func GetLatestDeployPlans added in v0.0.109

func GetLatestDeployPlans(ctx context.Context, pkgs ...schema.PackageName) (*GetLatestDeployPlansResponse, error)

type GetLatestDeployPlansResponse_Plan added in v0.0.109

type GetLatestDeployPlansResponse_Plan struct {
	PackageName string `json:"package_name,omitempty"`
	Version     int32  `json:"version,omitempty"`
	Repository  string `json:"repository,omitempty"`
	Digest      string `json:"digest,omitempty"`
}

type GetLatestPrebuiltsRequest

type GetLatestPrebuiltsRequest struct {
	PackageName []string `json:"package_name,omitempty"`
}

type GetLatestPrebuiltsResponse

type GetLatestPrebuiltsResponse struct {
	Prebuilt []*GetLatestPrebuiltsResponse_Prebuilt `json:"prebuilt,omitempty"`
}

func GetLatestPrebuilts

func GetLatestPrebuilts(ctx context.Context, pkgs ...schema.PackageName) (*GetLatestPrebuiltsResponse, error)

type GetLatestPrebuiltsResponse_Prebuilt

type GetLatestPrebuiltsResponse_Prebuilt struct {
	PackageName string `json:"package_name,omitempty"`
	Repository  string `json:"repository,omitempty"`
	Digest      string `json:"digest,omitempty"`
}

type GetLatestRequest

type GetLatestRequest struct {
	NS NSRequirements `json:"ns"`
}

type GetLatestResponse

type GetLatestResponse struct {
	Version   string      `json:"version"`
	BuildTime time.Time   `json:"build_time"`
	Tarballs  []*Artifact `json:"tarballs"`
}

type GetSessionTokenRequest

type GetSessionTokenRequest struct {
	UserData        string `json:"user_data"`
	DurationSeconds uint32 `json:"duration_seconds"`
}

type GetSessionTokenResponse

type GetSessionTokenResponse struct {
	Token      string    `json:"token"`
	Expiration time.Time `json:"expiration"`
}

type IssueRequest

type IssueRequest struct {
	UserAuth    *UserAuth    `json:"user_auth"`
	NameRequest NameRequest  `json:"name_request"`
	Resource    NameResource `json:"previous"`
}

type IssueResponse

type IssueResponse struct {
	Resource NameResource `json:"resource"`
}

type MapRequest

type MapRequest struct {
	UserAuth *UserAuth `json:"userAuth"`
	FQDN     string    `json:"fqdn"`
	Target   string    `json:"target"`
}

type MapResponse

type MapResponse struct {
	FQDN string `json:"fqdn"`
}

type NSRequirements

type NSRequirements struct {
	MinimumApi int32 `json:"minimum_api"`
}

type NameCertificate

type NameCertificate struct {
	PrivateKey        []byte `json:"private_key"`
	CertificateBundle []byte `json:"certificate_bundle"`
	CertificateURL    string `json:"certificate_url"`
}

type NameRequest

type NameRequest struct {
	FQDN  string `json:"fqdn,omitempty"`
	NoTLS bool   `json:"noTls"`
	Org   string `json:"org,omitempty"`
}

type NameResource

type NameResource struct {
	ID          ResourceID      `json:"id"`
	Certificate NameCertificate `json:"certificate"`
}

func AllocateName

func AllocateName(ctx context.Context, opts AllocateOpts) (*NameResource, error)

type ResourceID

type ResourceID struct {
	Opaque []byte `json:"opaque"`
}

type RobotLoginRequest

type RobotLoginRequest struct {
	Repository  string `json:"repository"`
	AccessToken string `json:"accessToken"`
}

type StartLoginRequest

type StartLoginRequest struct {
	Kind string `json:"kind"`
}

type StartLoginResponse

type StartLoginResponse struct {
	LoginId  string `json:"login_id"`
	LoginUrl string `json:"login_url"`
	Kind     string `json:"kind"`
}

func StartLogin

func StartLogin(ctx context.Context, kind string) (*StartLoginResponse, error)

Returns the URL which the user should open.

type Telemetry

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

func InternalNewTelemetry added in v0.0.76

func InternalNewTelemetry(ctx context.Context, makeID func(context.Context) (ephemeralCliID, bool)) *Telemetry

func NewTelemetry

func NewTelemetry(ctx context.Context) *Telemetry

func TelemetryOn

func TelemetryOn(ctx context.Context) *Telemetry

func (*Telemetry) Enable

func (tel *Telemetry) Enable()

Telemetry needs to be excplicitly enabled by calling this function. IsTelemetryEnabled() may still be false if telemetry is disabled through DO_NOT_TRACK, etc.

func (*Telemetry) GetClientID added in v0.0.76

func (tel *Telemetry) GetClientID() string

func (*Telemetry) IsFirstRun added in v0.0.76

func (tel *Telemetry) IsFirstRun() bool

func (*Telemetry) IsTelemetryEnabled

func (tel *Telemetry) IsTelemetryEnabled() bool

func (*Telemetry) RecordError

func (tel *Telemetry) RecordError(ctx context.Context, err error)

func (*Telemetry) RecordInvocation

func (tel *Telemetry) RecordInvocation(ctx context.Context, cmd *cobra.Command, args []string) string

type UserAuth

type UserAuth struct {
	Username       string `json:"username,omitempty"`
	Org            string `json:"org,omitempty"` // The organization this user is acting as. Only really relevant for robot accounts which authenticate against a repository.
	InternalOpaque []byte `json:"opaque,omitempty"`

	Clerk *clerk.State `json:"clerk,omitempty"`
}

func CheckSignin

func CheckSignin(ctx context.Context, userData string) (*UserAuth, error)

func CompleteLogin

func CompleteLogin(ctx context.Context, id, kind string, ephemeralCliId string) (*UserAuth, error)

func LoadUser

func LoadUser() (*UserAuth, error)

func RobotLogin

func RobotLogin(ctx context.Context, repository, accessToken string) (*UserAuth, error)

func (UserAuth) GenerateToken added in v0.0.96

func (user UserAuth) GenerateToken(ctx context.Context) (string, error)

Jump to

Keyboard shortcuts

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