fnapi

package
v0.0.73 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EndpointAddress = "https://api.namespacelabs.net"
View Source
var ErrRelogin = errors.New("not logged in, please run `ns login`")
View Source
var File_internal_fnapi_userauth_proto protoreflect.FileDescriptor
View Source
var NamingForceStored = false

Functions

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 DecodeJSONResponse

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

func DownloadBundle

func DownloadBundle(ctx context.Context, bundleId string, handle func(body io.ReadCloser) error) 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 StartLogin

func StartLogin(ctx context.Context) (string, error)

func StoreUser

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

func UploadBundle

func UploadBundle(ctx context.Context, bundle io.ReadCloser, handle func(res *UploadBundleResponse) error) error

func WithTelemetry

func WithTelemetry(ctx context.Context, t *Telemetry) 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
}

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 CompleteLoginRequest

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

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 {
	TelemetryEnabled bool           `json:"telemetry_enabled"`
	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"`
}

func GetSessionToken

func GetSessionToken(ctx context.Context, userData string, duration time.Duration) (*GetSessionTokenResponse, error)

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"`
	Subdomain string `json:"subdomain,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{}

type StartLoginResponse

type StartLoginResponse struct {
	LoginId string `json:"login_id"`
}

type Telemetry

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

func NewTelemetry

func NewTelemetry() *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) GetEphemeralCliID

func (tel *Telemetry) GetEphemeralCliID(ctx context.Context) string

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 UploadBundleResponse

type UploadBundleResponse struct {
	BundleId string `json:"bundle_id"`
}

type UserAuth

type UserAuth struct {
	Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"`
	Org      string `protobuf:"bytes,2,opt,name=org,proto3" json:"org,omitempty"` // The organization this user is acting as. Only really relevant for robot accounts which authenticate against a repository.
	Opaque   []byte `protobuf:"bytes,3,opt,name=opaque,proto3" json:"opaque,omitempty"`
	// contains filtered or unexported fields
}

func CheckSignin

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

func CompleteLogin

func CompleteLogin(ctx context.Context, id 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) Descriptor deprecated

func (*UserAuth) Descriptor() ([]byte, []int)

Deprecated: Use UserAuth.ProtoReflect.Descriptor instead.

func (*UserAuth) GetOpaque

func (x *UserAuth) GetOpaque() []byte

func (*UserAuth) GetOrg

func (x *UserAuth) GetOrg() string

func (*UserAuth) GetUsername

func (x *UserAuth) GetUsername() string

func (*UserAuth) ProtoMessage

func (*UserAuth) ProtoMessage()

func (*UserAuth) ProtoReflect

func (x *UserAuth) ProtoReflect() protoreflect.Message

func (*UserAuth) Reset

func (x *UserAuth) Reset()

func (*UserAuth) String

func (x *UserAuth) String() string

Jump to

Keyboard shortcuts

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