fnapi

package
v0.0.390 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const AdminScope = "admin"

Variables

View Source
var (
	AdminMode        = false
	DebugApiResponse = false

	UserAgent = "ns/unknown"
)
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 ResolveFunc, 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 ResolveFunc, method string, req interface{}, handle func(io.Reader) error) error

func BearerToken added in v0.0.176

func BearerToken(ctx context.Context, t Token, skipCache bool) (string, error)

func DecodeJSONResponse

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

func IssueDevelopmentToken added in v0.0.300

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

func IssueTenantTokenFromSession added in v0.0.314

func IssueTenantTokenFromSession(ctx context.Context, sessionToken string, duration time.Duration) (string, error)

func IssueToken added in v0.0.311

func IssueToken(ctx context.Context, minDur time.Duration) (string, error)

func Map

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

func ResolveGlobalEndpoint added in v0.0.334

func ResolveGlobalEndpoint(ctx context.Context, tok ResolvedToken) (string, error)

func ResolveIAMEndpoint added in v0.0.334

func ResolveIAMEndpoint(ctx context.Context, tok ResolvedToken) (string, error)

func ResolveSpec added in v0.0.216

func ResolveSpec() (string, error)

func SetupFlags

func SetupFlags(flags *pflag.FlagSet)

func TrustAWSCognitoJWT added in v0.0.261

func TrustAWSCognitoJWT(ctx context.Context, tenantID, identityPool, identityProvider string) error

func VerifySession added in v0.0.371

func VerifySession(ctx context.Context, t Token) error

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 {
	Method           string
	IssueBearerToken func(context.Context) (ResolvedToken, error)
	ScrubRequest     func(*RequestT)
	Retryable        bool
}

func (Call[RequestT]) Do

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

type CompleteLoginRequest

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

type CompleteTenantLoginResponse added in v0.0.180

type CompleteTenantLoginResponse struct {
	TenantToken  string `json:"tenant_token,omitempty"`
	TenantName   string `json:"tenant_name,omitempty"`
	SessionToken string `json:"session_token,omitempty"`
}

func CompleteTenantLogin added in v0.0.180

func CompleteTenantLogin(ctx context.Context, id string) (*CompleteTenantLoginResponse, error)

type ExchangeAWSCognitoJWTRequest added in v0.0.261

type ExchangeAWSCognitoJWTRequest struct {
	TenantId        string `json:"tenant_id,omitempty"`
	AwsCognitoToken string `json:"aws_cognito_token,omitempty"`
}

type ExchangeCircleciTokenRequest added in v0.0.244

type ExchangeCircleciTokenRequest struct {
	CircleciToken string `json:"circleci_token,omitempty"`
}

type ExchangeCircleciTokenResponse added in v0.0.244

type ExchangeCircleciTokenResponse struct {
	TenantToken string  `json:"tenant_token,omitempty"`
	Tenant      *Tenant `json:"tenant,omitempty"`
}

func ExchangeCircleciToken added in v0.0.244

func ExchangeCircleciToken(ctx context.Context, token string) (ExchangeCircleciTokenResponse, error)

type ExchangeGithubTokenRequest added in v0.0.142

type ExchangeGithubTokenRequest struct {
	GithubToken string `json:"github_token,omitempty"`
}

type ExchangeGithubTokenResponse added in v0.0.142

type ExchangeGithubTokenResponse struct {
	TenantToken string  `json:"tenant_token,omitempty"`
	Tenant      *Tenant `json:"tenant,omitempty"`
}

func ExchangeGithubToken added in v0.0.142

func ExchangeGithubToken(ctx context.Context, jwt string) (ExchangeGithubTokenResponse, error)

type ExchangeOIDCTokenRequest added in v0.0.282

type ExchangeOIDCTokenRequest struct {
	TenantId  string `json:"tenant_id,omitempty"`
	OidcToken string `json:"oidc_token,omitempty"`
}

type ExchangeTokenResponse added in v0.0.261

type ExchangeTokenResponse struct {
	TenantToken string  `json:"tenant_token,omitempty"`
	Tenant      *Tenant `json:"tenant,omitempty"`
}

func ExchangeAWSCognitoJWT added in v0.0.261

func ExchangeAWSCognitoJWT(ctx context.Context, tenantID, token string) (ExchangeTokenResponse, error)

func ExchangeOIDCToken added in v0.0.282

func ExchangeOIDCToken(ctx context.Context, tenantID, token string) (ExchangeTokenResponse, error)

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 GetLatestResponse

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

func GetLatestVersion

func GetLatestVersion(ctx context.Context, req map[string]any) (*GetLatestResponse, error)

type GetTenantResponse added in v0.0.258

type GetTenantResponse struct {
	Tenant *Tenant `json:"tenant,omitempty"`
}

func GetTenant added in v0.0.258

func GetTenant(ctx context.Context) (GetTenantResponse, error)

type IssueDevelopmentTokenResponse added in v0.0.300

type IssueDevelopmentTokenResponse struct {
	DevelopmentToken string `json:"development_token,omitempty"`
}

type IssueIdTokenRequest added in v0.0.262

type IssueIdTokenRequest struct {
	Audience string `json:"audience,omitempty"`
	Version  int    `json:"version,omitempty"`
}

type IssueIdTokenResponse added in v0.0.262

type IssueIdTokenResponse struct {
	IdToken string `json:"id_token,omitempty"`
}

func IssueIdToken added in v0.0.262

func IssueIdToken(ctx context.Context, aud string, version int) (IssueIdTokenResponse, error)

type IssueIngressAccessTokenRequest added in v0.0.293

type IssueIngressAccessTokenRequest struct {
	InstanceId string `json:"instance_id,omitempty"`
}

type IssueIngressAccessTokenResponse added in v0.0.293

type IssueIngressAccessTokenResponse struct {
	IngressAccessToken string `json:"ingress_access_token,omitempty"`
}

func IssueIngressAccessToken added in v0.0.293

func IssueIngressAccessToken(ctx context.Context, instanceId string) (IssueIngressAccessTokenResponse, error)

type IssueRequest

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

type IssueResponse

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

type IssueTenantTokenFromSessionRequest added in v0.0.311

type IssueTenantTokenFromSessionRequest struct {
	SessionToken      string `json:"session_token,omitempty"`
	TokenDurationSecs int64  `json:"token_duration_secs,omitempty"`
}

type IssueTenantTokenFromSessionResponse added in v0.0.311

type IssueTenantTokenFromSessionResponse struct {
	TenantToken string `json:"tenant_token,omitempty"`
}

type MapRequest

type MapRequest struct {
	UserAuth *auth.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 ResolveFunc added in v0.0.334

type ResolveFunc func(context.Context, ResolvedToken) (string, error)

type ResolvedToken added in v0.0.312

type ResolvedToken struct {
	BearerToken string

	PrimaryRegion string // Only available in tenant tokens.
}

func IssueBearerToken added in v0.0.312

func IssueBearerToken(ctx context.Context) (ResolvedToken, error)

func IssueBearerTokenFromToken added in v0.0.312

func IssueBearerTokenFromToken(ctx context.Context, tok Token) (ResolvedToken, error)

type ResourceID

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

type StartLoginRequest

type StartLoginRequest struct {
	Kind                string   `json:"kind"`
	SupportedKinds      []string `json:"supported_kinds"`
	TenantId            string   `json:"tenant_id,omitempty"`
	SessionDurationSecs int64    `json:"session_duration_secs,omitempty"`
}

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, tenantId string, sessionDuration time.Duration) (*StartLoginResponse, error)

Returns the URL which the user should open.

type Tenant added in v0.0.191

type Tenant struct {
	TenantId      string `json:"tenant_id,omitempty"`
	Name          string `json:"name,omitempty"`
	AppUrl        string `json:"app_url,omitempty"`
	PrimaryRegion string `json:"primary_region,omitempty"`
}

type Token added in v0.0.176

type Token interface {
	IsSessionToken() bool
	Claims(context.Context) (*auth.TokenClaims, error)
	PrimaryRegion(context.Context) (string, error)
	IssueToken(context.Context, time.Duration, func(context.Context, string, time.Duration) (string, error), bool) (string, error)
}

func FetchToken added in v0.0.216

func FetchToken(ctx context.Context) (Token, error)

type TrustAWSCognitoIdentityPoolRequest added in v0.0.261

type TrustAWSCognitoIdentityPoolRequest struct {
	AwsCognitoIdentityPool string `json:"aws_cognito_identity_pool,omitempty"` // E.g. eu-central-1:56388dff-961f-42d4-a2ac-6ad118eb7799
	IdentityProvider       string `json:"identity_provider,omitempty"`         // E.g. namespace.so
}

Jump to

Keyboard shortcuts

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