Documentation
¶
Index ¶
- Constants
- Variables
- type API
- type APIError
- type APIWire
- type AddressRequest
- type Allocation
- type Certificate
- type CertificateWire
- type Client
- type ConfigProvider
- type Deployment
- type DeploymentWire
- type Entitlement
- type EntitlementTarget
- type FunctionInvoker
- type FunctionRequest
- type FunctionResponse
- type Gateway
- type GatewayWire
- type Handler
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Shutdown(ctx context.Context)
- func (h *Handler) Snapshot(ctx context.Context) []byte
- func (h *Handler) StartWorker(ctx context.Context) error
- func (h *Handler) Trusted() echo.HandlerFunc
- type InMemoryBackend
- func (b *InMemoryBackend) APIContent(id string) (string, string, string, error)
- func (b *InMemoryBackend) APIDeploymentSpecification(id string) (jsontext.Value, string, error)
- func (b *InMemoryBackend) APIValidations(id string) (map[string]any, string, error)
- func (b *InMemoryBackend) AddLock(kind, id, ifMatch string, in lockIn) (any, string, error)
- func (b *InMemoryBackend) CancelWorkRequest(id, ifMatch, retryToken string) error
- func (b *InMemoryBackend) ChangeAPICompartment(id, ifMatch string, in changeCompartmentIn) (string, error)
- func (b *InMemoryBackend) ChangeCertificateCompartment(id, ifMatch string, in changeCompartmentIn) (string, error)
- func (b *InMemoryBackend) ChangeDeploymentCompartment(id, ifMatch string, in changeCompartmentIn) (string, error)
- func (b *InMemoryBackend) ChangeGatewayCompartment(id, ifMatch string, in changeCompartmentIn) (string, error)
- func (b *InMemoryBackend) ChangeSubscriberCompartment(id, ifMatch string, in changeCompartmentIn) (string, error)
- func (b *InMemoryBackend) ChangeUsagePlanCompartment(id, ifMatch string, in changeCompartmentIn) (string, error)
- func (b *InMemoryBackend) Compartments() []string
- func (b *InMemoryBackend) CreateAPI(in createAPIIn) (APIWire, string, string, error)
- func (b *InMemoryBackend) CreateCertificate(in createCertificateIn) (CertificateWire, string, string, error)
- func (b *InMemoryBackend) CreateDeployment(in createDeploymentIn) (DeploymentWire, string, string, error)
- func (b *InMemoryBackend) CreateGateway(in createGatewayIn) (GatewayWire, string, string, error)
- func (b *InMemoryBackend) CreateSDK(in createSdkIn) (SdkWire, string, string, error)
- func (b *InMemoryBackend) CreateSubscriber(in createSubscriberIn) (SubscriberWire, string, string, error)
- func (b *InMemoryBackend) CreateUsagePlan(in createUsagePlanIn) (UsagePlanWire, string, string, error)
- func (b *InMemoryBackend) DeleteAPI(id, ifMatch string) (string, error)
- func (b *InMemoryBackend) DeleteCertificate(id, ifMatch string) (string, error)
- func (b *InMemoryBackend) DeleteDeployment(id, ifMatch string) (string, error)
- func (b *InMemoryBackend) DeleteGateway(id, ifMatch string) (string, error)
- func (b *InMemoryBackend) DeleteSDK(id, ifMatch string) (string, error)
- func (b *InMemoryBackend) DeleteSubscriber(id, ifMatch string) (string, error)
- func (b *InMemoryBackend) DeleteUsagePlan(id, ifMatch string) (string, error)
- func (b *InMemoryBackend) GatewayState(id string) (string, bool)
- func (b *InMemoryBackend) GetAPI(id string) (APIWire, string, error)
- func (b *InMemoryBackend) GetCertificate(id string) (CertificateWire, string, error)
- func (b *InMemoryBackend) GetDeployment(id string) (DeploymentWire, string, error)
- func (b *InMemoryBackend) GetGateway(id string) (GatewayWire, string, error)
- func (b *InMemoryBackend) GetSDK(id string) (SdkWire, string, error)
- func (b *InMemoryBackend) GetSubscriber(id string) (SubscriberWire, string, error)
- func (b *InMemoryBackend) GetUsagePlan(id string) (UsagePlanWire, string, error)
- func (b *InMemoryBackend) GetWorkRequest(id string) (WorkRequestWire, error)
- func (b *InMemoryBackend) ListAPIs(compartment, name, state string, o ListOpts) (page.Page[APIWire], error)
- func (b *InMemoryBackend) ListCertificates(compartment, name, state string, o ListOpts) (page.Page[CertificateWire], error)
- func (b *InMemoryBackend) ListDeployments(compartment, gatewayID, name, state string, o ListOpts) (page.Page[DeploymentWire], error)
- func (b *InMemoryBackend) ListGateways(compartment, name, state, certificate string, o ListOpts) (page.Page[GatewayWire], error)
- func (b *InMemoryBackend) ListSDKs(sdkID, apiID, name, state string, o ListOpts) (page.Page[SdkWire], error)
- func (b *InMemoryBackend) ListSdkLanguageTypes(compartment, name string, o ListOpts) (page.Page[SdkLanguageWire], error)
- func (b *InMemoryBackend) ListSubscribers(compartment, name, state string, o ListOpts) (page.Page[SubscriberWire], error)
- func (b *InMemoryBackend) ListUsagePlans(compartment, name, state string, o ListOpts) (page.Page[UsagePlanWire], error)
- func (b *InMemoryBackend) ListWorkRequests(compartment, resourceID string, o ListOpts) (page.Page[workRequestSummaryWire], error)
- func (b *InMemoryBackend) RegisterCABundle(id, pemData string) error
- func (b *InMemoryBackend) RemoveCABundle(id string) bool
- func (b *InMemoryBackend) RemoveLock(kind, id, ifMatch, lockType string) (any, string, error)
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) ServeData(w http.ResponseWriter, r *http.Request)
- func (b *InMemoryBackend) SetAllowExternal(allow bool)
- func (b *InMemoryBackend) SetBackendResponseLimit(n int64)
- func (b *InMemoryBackend) SetClock(now func() time.Time)
- func (b *InMemoryBackend) SetCompartmentChecker(fn func(string) bool)
- func (b *InMemoryBackend) SetFunctionInvoker(fn FunctionInvoker)
- func (b *InMemoryBackend) SetLogSink(fn LogSink)
- func (b *InMemoryBackend) SetNetwork(n Network)
- func (b *InMemoryBackend) SetSecretResolver(fn SecretResolver)
- func (b *InMemoryBackend) SetSubnetChecker(fn func(string) bool)
- func (b *InMemoryBackend) SetTagLookup(fn ocitags.Lookup)
- func (b *InMemoryBackend) SetTransition(d time.Duration)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) Sweep()
- func (b *InMemoryBackend) UpdateAPI(id, ifMatch string, in updateAPIIn) (string, error)
- func (b *InMemoryBackend) UpdateCertificate(id, ifMatch string, in updateCertificateIn) (string, error)
- func (b *InMemoryBackend) UpdateDeployment(id, ifMatch string, in updateDeploymentIn) (string, error)
- func (b *InMemoryBackend) UpdateGateway(id, ifMatch string, in updateGatewayIn) (string, error)
- func (b *InMemoryBackend) UpdateSDK(id, ifMatch string, in updateSdkIn) (SdkWire, string, error)
- func (b *InMemoryBackend) UpdateSubscriber(id, ifMatch string, in updateSubscriberIn) (string, error)
- func (b *InMemoryBackend) UpdateUsagePlan(id, ifMatch string, in updateUsagePlanIn) (string, error)
- func (b *InMemoryBackend) WorkRequestExists(id string) error
- func (b *InMemoryBackend) WorkRequestLogs(id string, o ListOpts) (page.Page[wrLogWire], error)
- type ListOpts
- type Lock
- type LogSink
- type Network
- type Provider
- type Quota
- type RateLimit
- type Reachability
- type SDK
- type SdkLanguageWire
- type SdkWire
- type SecretResolver
- type Settings
- type SubnetInfo
- type Subscriber
- type SubscriberWire
- type Tags
- type UsagePlan
- type UsagePlanWire
- type WorkRequest
- type WorkRequestWire
Constants ¶
const DefaultPort = 8163
DefaultPort is the dedicated listener's default TCP port.
const (
// Region is the fixed region baked into emulated OCIDs and gateway hostnames.
Region = "us-ashburn-1"
)
Variables ¶
var ErrDestinationNotPermitted = errors.New(
"ociapigateway: destination is outside loopback and external backends are not allowed",
)
ErrDestinationNotPermitted is returned when a backend resolves outside the permitted network range.
var ErrNilAppContext = errors.New("ociapigateway: nil app context")
ErrNilAppContext is returned when Init is called with a nil AppContext.
var ErrSnapshotNull = errors.New("ociapigateway: null entry in snapshot")
ErrSnapshotNull is returned when a snapshot contains a null entry.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
Tags Tags `json:"tags"`
TransitionAt *time.Time `json:"transitionAt,omitempty"`
ID string `json:"id"`
Compartment string `json:"compartmentId"`
DisplayName string `json:"displayName"`
State string `json:"state"`
Etag string `json:"etag"`
Content string `json:"content,omitempty"`
Locks []Lock `json:"locks,omitempty"`
}
API is an API resource: a stored OpenAPI description.
type APIError ¶
APIError is an OCI error response: HTTP status plus the `code` and `message` body fields.
type APIWire ¶
type APIWire struct {
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
DefinedTags map[string]map[string]any `json:"definedTags,omitempty"`
FreeformTags map[string]string `json:"freeformTags,omitempty"`
ID string `json:"id"`
CompartmentID string `json:"compartmentId"`
DisplayName string `json:"displayName"`
LifecycleState string `json:"lifecycleState"`
SpecificationType string `json:"specificationType,omitempty"`
ValidationResults []apiValidationResult `json:"validationResults,omitempty"`
Locks []Lock `json:"locks,omitempty"`
}
APIWire is the wire form of an API resource (also used for list items).
type AddressRequest ¶
type AddressRequest struct {
CompartmentID string
SubnetID string
DisplayName string
ReservedIPIDs []string
IPv6Addresses []string
IPv6SubnetCidrs []string
NSGIDs []string
Public bool
AssignIPv6 bool
}
AddressRequest asks the network for the VNIC that backs a gateway.
type Allocation ¶
Allocation is the VNIC created for a gateway and the addresses it carries.
type Certificate ¶
type Certificate struct {
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
TimeNotValidAfter time.Time `json:"timeNotValidAfter"`
Tags Tags `json:"tags"`
TransitionAt *time.Time `json:"transitionAt,omitempty"`
Locks []Lock `json:"locks,omitempty"`
ID string `json:"id"`
CompartmentID string `json:"compartmentId"`
DisplayName string `json:"displayName"`
CertPEM string `json:"certificate"`
Intermediate string `json:"intermediateCertificates,omitempty"`
PrivateKey string `json:"privateKey,omitempty"`
State string `json:"state"`
Etag string `json:"etag"`
SubjectNames []string `json:"subjectNames"`
}
Certificate is a TLS certificate usable by a gateway.
type CertificateWire ¶
type CertificateWire struct {
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
TimeNotValidAfter time.Time `json:"timeNotValidAfter"`
DefinedTags map[string]map[string]any `json:"definedTags,omitempty"`
FreeformTags map[string]string `json:"freeformTags,omitempty"`
Locks []Lock `json:"locks,omitempty"`
ID string `json:"id"`
CompartmentID string `json:"compartmentId"`
DisplayName string `json:"displayName"`
Certificate string `json:"certificate,omitempty"`
Intermediate string `json:"intermediateCertificates,omitempty"`
LifecycleState string `json:"lifecycleState"`
SubjectNames []string `json:"subjectNames"`
}
CertificateWire is the wire form of a certificate.
type ConfigProvider ¶
type ConfigProvider interface {
GetOCIAPIGatewaySettings() Settings
}
ConfigProvider extracts OCI API Gateway configuration from the AppContext Config.
type Deployment ¶
type Deployment struct {
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
Tags Tags `json:"tags"`
TransitionAt *time.Time `json:"transitionAt,omitempty"`
ID string `json:"id"`
GatewayID string `json:"gatewayId"`
CompartmentID string `json:"compartmentId"`
PathPrefix string `json:"pathPrefix"`
DisplayName string `json:"displayName"`
State string `json:"state"`
Etag string `json:"etag"`
Locks []Lock `json:"locks,omitempty"`
Spec jsontext.Value `json:"specification"`
}
Deployment is an API deployment on a gateway.
type DeploymentWire ¶
type DeploymentWire struct {
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
DefinedTags map[string]map[string]any `json:"definedTags,omitempty"`
FreeformTags map[string]string `json:"freeformTags,omitempty"`
ID string `json:"id"`
GatewayID string `json:"gatewayId"`
CompartmentID string `json:"compartmentId"`
PathPrefix string `json:"pathPrefix"`
Endpoint string `json:"endpoint"`
DisplayName string `json:"displayName"`
LifecycleState string `json:"lifecycleState"`
Locks []Lock `json:"locks,omitempty"`
Specification jsontext.Value `json:"specification,omitempty"`
}
DeploymentWire is the wire form of a deployment.
type Entitlement ¶
type Entitlement struct {
RateLimit *RateLimit `json:"rateLimit,omitempty"`
Quota *Quota `json:"quota,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Targets []EntitlementTarget `json:"targets,omitempty"`
}
Entitlement is one rate limit and quota that applies to a set of deployments.
type EntitlementTarget ¶
type EntitlementTarget struct {
DeploymentID string `json:"deploymentId"`
}
EntitlementTarget names a deployment an entitlement applies to.
type FunctionInvoker ¶
type FunctionInvoker interface {
InvokeFunction(ctx context.Context, functionID string, in FunctionRequest) (FunctionResponse, error)
}
FunctionInvoker invokes an OCI function synchronously; wired to OCI Functions in internal/app.
type FunctionRequest ¶
type FunctionRequest struct {
Header http.Header
Method string
Path string
RawQuery string
Body []byte
}
FunctionRequest is the request an API gateway hands to OCI Functions.
type FunctionResponse ¶
FunctionResponse is the function's reply.
type Gateway ¶
type Gateway struct {
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
Tags Tags `json:"tags"`
TransitionAt *time.Time `json:"transitionAt,omitempty"`
Locks []Lock `json:"locks,omitempty"`
CaBundles jsontext.Value `json:"caBundles,omitempty"`
ResponseCache jsontext.Value `json:"responseCache,omitempty"`
ID string `json:"id"`
CompartmentID string `json:"compartmentId"`
EndpointType string `json:"endpointType"`
DisplayName string `json:"displayName"`
SubnetID string `json:"subnetId"`
Hostname string `json:"hostname"`
CertificateID string `json:"certificateId,omitempty"`
IPMode string `json:"ipMode,omitempty"`
VnicID string `json:"vnicId,omitempty"`
IPv4Config *ipv4Config `json:"ipv4AddressConfiguration,omitempty"`
IPv6Config *ipv6Config `json:"ipv6AddressConfiguration,omitempty"`
State string `json:"state"`
Etag string `json:"etag"`
NSGs []string `json:"networkSecurityGroupIds,omitempty"`
IPs []string `json:"ipAddresses,omitempty"`
}
Gateway is an API gateway.
type GatewayWire ¶
type GatewayWire struct {
IPv4Config *ipv4Config `json:"ipv4AddressConfiguration,omitempty"`
IPv6Config *ipv6Config `json:"ipv6AddressConfiguration,omitempty"`
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
DefinedTags map[string]map[string]any `json:"definedTags,omitempty"`
FreeformTags map[string]string `json:"freeformTags,omitempty"`
Locks []Lock `json:"locks,omitempty"`
CaBundles jsontext.Value `json:"caBundles,omitempty"`
ResponseCache jsontext.Value `json:"responseCacheDetails,omitempty"`
ID string `json:"id"`
CompartmentID string `json:"compartmentId"`
EndpointType string `json:"endpointType"`
DisplayName string `json:"displayName"`
SubnetID string `json:"subnetId"`
Hostname string `json:"hostname"`
CertificateID string `json:"certificateId,omitempty"`
IPMode string `json:"ipMode,omitempty"`
LifecycleState string `json:"lifecycleState"`
NSGs []string `json:"networkSecurityGroupIds,omitempty"`
IPAddresses []ipAddressWire `json:"ipAddresses,omitempty"`
}
GatewayWire is the wire form of a gateway.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
Port int
TLSPort int
EnforceAuth bool
// contains filtered or unexported fields
}
Handler serves OCI API Gateway: gateways, deployments, certificates, work requests and the deployed-API data plane.
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates a Handler; callers override Port and EnforceAuth from Settings.
func (*Handler) ExtractOperation ¶
ExtractOperation returns the operation name for metrics.
func (*Handler) ExtractResource ¶
ExtractResource returns the addressed resource id for metrics.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists the supported operations.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler for all OCIAPIGateway requests.
func (*Handler) MatchPriority ¶
MatchPriority is irrelevant because RouteMatcher never matches.
func (*Handler) RouteMatcher ¶
RouteMatcher never matches: OCIAPIGateway runs on its own listener.
func (*Handler) Snapshot ¶
Snapshot implements persistence.Persistable by delegating to the backend.
func (*Handler) StartWorker ¶
StartWorker binds the dedicated listener synchronously so a port conflict is returned to the caller.
func (*Handler) Trusted ¶
func (h *Handler) Trusted() echo.HandlerFunc
Trusted returns a handler that skips request-signature verification, for the in-process dashboard proxy.
type InMemoryBackend ¶
InMemoryBackend holds every gateway, deployment, certificate and work request under one lock.
func NewInMemoryBackend ¶
func NewInMemoryBackend() *InMemoryBackend
NewInMemoryBackend creates an empty backend.
func (*InMemoryBackend) APIContent ¶
APIContent returns the stored OpenAPI document, its etag and base64 SHA-256.
func (*InMemoryBackend) APIDeploymentSpecification ¶
APIDeploymentSpecification generates a deployment specification from the stored OpenAPI paths.
func (*InMemoryBackend) APIValidations ¶
APIValidations reports the validation checks of the stored content.
func (*InMemoryBackend) AddLock ¶
func (b *InMemoryBackend) AddLock(kind, id, ifMatch string, in lockIn) (any, string, error)
AddLock appends a lock to a resource and returns the resource with its new etag.
func (*InMemoryBackend) CancelWorkRequest ¶
func (b *InMemoryBackend) CancelWorkRequest(id, ifMatch, retryToken string) error
CancelWorkRequest cancels a work request that has not finished; the resource transition it describes still runs.
func (*InMemoryBackend) ChangeAPICompartment ¶
func (b *InMemoryBackend) ChangeAPICompartment(id, ifMatch string, in changeCompartmentIn) (string, error)
ChangeAPICompartment moves an API resource.
func (*InMemoryBackend) ChangeCertificateCompartment ¶
func (b *InMemoryBackend) ChangeCertificateCompartment(id, ifMatch string, in changeCompartmentIn) (string, error)
ChangeCertificateCompartment moves a certificate.
func (*InMemoryBackend) ChangeDeploymentCompartment ¶
func (b *InMemoryBackend) ChangeDeploymentCompartment(id, ifMatch string, in changeCompartmentIn) (string, error)
ChangeDeploymentCompartment moves a deployment.
func (*InMemoryBackend) ChangeGatewayCompartment ¶
func (b *InMemoryBackend) ChangeGatewayCompartment(id, ifMatch string, in changeCompartmentIn) (string, error)
ChangeGatewayCompartment moves a gateway.
func (*InMemoryBackend) ChangeSubscriberCompartment ¶
func (b *InMemoryBackend) ChangeSubscriberCompartment(id, ifMatch string, in changeCompartmentIn) (string, error)
ChangeSubscriberCompartment moves a subscriber.
func (*InMemoryBackend) ChangeUsagePlanCompartment ¶
func (b *InMemoryBackend) ChangeUsagePlanCompartment(id, ifMatch string, in changeCompartmentIn) (string, error)
ChangeUsagePlanCompartment moves a usage plan.
func (*InMemoryBackend) Compartments ¶
func (b *InMemoryBackend) Compartments() []string
Compartments lists the distinct compartments that hold gateways, deployments or certificates.
func (*InMemoryBackend) CreateAPI ¶
func (b *InMemoryBackend) CreateAPI(in createAPIIn) (APIWire, string, string, error)
CreateAPI stores a new API resource.
func (*InMemoryBackend) CreateCertificate ¶
func (b *InMemoryBackend) CreateCertificate(in createCertificateIn) (CertificateWire, string, string, error)
CreateCertificate stores a certificate after validating the PEM material.
func (*InMemoryBackend) CreateDeployment ¶
func (b *InMemoryBackend) CreateDeployment(in createDeploymentIn) (DeploymentWire, string, string, error)
CreateDeployment creates a deployment in CREATING state.
func (*InMemoryBackend) CreateGateway ¶
func (b *InMemoryBackend) CreateGateway(in createGatewayIn) (GatewayWire, string, string, error)
CreateGateway creates a gateway in CREATING state and returns it with its work request id.
func (*InMemoryBackend) CreateSDK ¶
func (b *InMemoryBackend) CreateSDK(in createSdkIn) (SdkWire, string, string, error)
CreateSDK records an SDK resource for an API.
func (*InMemoryBackend) CreateSubscriber ¶
func (b *InMemoryBackend) CreateSubscriber(in createSubscriberIn) (SubscriberWire, string, string, error)
CreateSubscriber creates a subscriber.
func (*InMemoryBackend) CreateUsagePlan ¶
func (b *InMemoryBackend) CreateUsagePlan(in createUsagePlanIn) (UsagePlanWire, string, string, error)
CreateUsagePlan creates a usage plan.
func (*InMemoryBackend) DeleteAPI ¶
func (b *InMemoryBackend) DeleteAPI(id, ifMatch string) (string, error)
DeleteAPI starts deleting an API resource.
func (*InMemoryBackend) DeleteCertificate ¶
func (b *InMemoryBackend) DeleteCertificate(id, ifMatch string) (string, error)
DeleteCertificate starts deleting a certificate that no gateway uses.
func (*InMemoryBackend) DeleteDeployment ¶
func (b *InMemoryBackend) DeleteDeployment(id, ifMatch string) (string, error)
DeleteDeployment starts deleting a deployment.
func (*InMemoryBackend) DeleteGateway ¶
func (b *InMemoryBackend) DeleteGateway(id, ifMatch string) (string, error)
DeleteGateway starts deleting a gateway that has no deployments.
func (*InMemoryBackend) DeleteSDK ¶
func (b *InMemoryBackend) DeleteSDK(id, ifMatch string) (string, error)
DeleteSDK starts deleting an SDK resource.
func (*InMemoryBackend) DeleteSubscriber ¶
func (b *InMemoryBackend) DeleteSubscriber(id, ifMatch string) (string, error)
DeleteSubscriber starts deleting a subscriber.
func (*InMemoryBackend) DeleteUsagePlan ¶
func (b *InMemoryBackend) DeleteUsagePlan(id, ifMatch string) (string, error)
DeleteUsagePlan starts deleting a usage plan no subscriber references.
func (*InMemoryBackend) GatewayState ¶
func (b *InMemoryBackend) GatewayState(id string) (string, bool)
GatewayState returns the lifecycle state of a gateway.
func (*InMemoryBackend) GetAPI ¶
func (b *InMemoryBackend) GetAPI(id string) (APIWire, string, error)
GetAPI returns one API resource and its etag.
func (*InMemoryBackend) GetCertificate ¶
func (b *InMemoryBackend) GetCertificate(id string) (CertificateWire, string, error)
GetCertificate returns one certificate and its etag.
func (*InMemoryBackend) GetDeployment ¶
func (b *InMemoryBackend) GetDeployment(id string) (DeploymentWire, string, error)
GetDeployment returns one deployment and its etag.
func (*InMemoryBackend) GetGateway ¶
func (b *InMemoryBackend) GetGateway(id string) (GatewayWire, string, error)
GetGateway returns one gateway and its etag.
func (*InMemoryBackend) GetSDK ¶
func (b *InMemoryBackend) GetSDK(id string) (SdkWire, string, error)
GetSDK returns one SDK resource and its etag.
func (*InMemoryBackend) GetSubscriber ¶
func (b *InMemoryBackend) GetSubscriber(id string) (SubscriberWire, string, error)
GetSubscriber returns one subscriber and its etag.
func (*InMemoryBackend) GetUsagePlan ¶
func (b *InMemoryBackend) GetUsagePlan(id string) (UsagePlanWire, string, error)
GetUsagePlan returns one usage plan and its etag.
func (*InMemoryBackend) GetWorkRequest ¶
func (b *InMemoryBackend) GetWorkRequest(id string) (WorkRequestWire, error)
GetWorkRequest returns one work request.
func (*InMemoryBackend) ListAPIs ¶
func (b *InMemoryBackend) ListAPIs(compartment, name, state string, o ListOpts) (page.Page[APIWire], error)
ListAPIs lists the API resources of a compartment.
func (*InMemoryBackend) ListCertificates ¶
func (b *InMemoryBackend) ListCertificates( compartment, name, state string, o ListOpts, ) (page.Page[CertificateWire], error)
ListCertificates lists the certificates of a compartment.
func (*InMemoryBackend) ListDeployments ¶
func (b *InMemoryBackend) ListDeployments( compartment, gatewayID, name, state string, o ListOpts, ) (page.Page[DeploymentWire], error)
ListDeployments lists the deployments of a compartment, optionally of one gateway.
func (*InMemoryBackend) ListGateways ¶
func (b *InMemoryBackend) ListGateways( compartment, name, state, certificate string, o ListOpts, ) (page.Page[GatewayWire], error)
ListGateways lists the gateways of a compartment.
func (*InMemoryBackend) ListSDKs ¶
func (b *InMemoryBackend) ListSDKs(sdkID, apiID, name, state string, o ListOpts) (page.Page[SdkWire], error)
ListSDKs lists SDK resources, optionally of one API.
func (*InMemoryBackend) ListSdkLanguageTypes ¶
func (b *InMemoryBackend) ListSdkLanguageTypes( compartment, name string, o ListOpts, ) (page.Page[SdkLanguageWire], error)
ListSdkLanguageTypes lists the target languages SDK resources can name.
func (*InMemoryBackend) ListSubscribers ¶
func (b *InMemoryBackend) ListSubscribers( compartment, name, state string, o ListOpts, ) (page.Page[SubscriberWire], error)
ListSubscribers lists the subscribers of a compartment.
func (*InMemoryBackend) ListUsagePlans ¶
func (b *InMemoryBackend) ListUsagePlans( compartment, name, state string, o ListOpts, ) (page.Page[UsagePlanWire], error)
ListUsagePlans lists the usage plans of a compartment.
func (*InMemoryBackend) ListWorkRequests ¶
func (b *InMemoryBackend) ListWorkRequests( compartment, resourceID string, o ListOpts, ) (page.Page[workRequestSummaryWire], error)
ListWorkRequests lists the work requests of a compartment, optionally for one resource.
func (*InMemoryBackend) RegisterCABundle ¶
func (b *InMemoryBackend) RegisterCABundle(id, pemData string) error
RegisterCABundle stores the PEM behind a gateway caBundles entry (CA_BUNDLE or CERTIFICATE_AUTHORITY id); the emulator has no OCI Certificates service to resolve those ids from.
func (*InMemoryBackend) RemoveCABundle ¶
func (b *InMemoryBackend) RemoveCABundle(id string) bool
RemoveCABundle deletes a registered CA bundle PEM.
func (*InMemoryBackend) RemoveLock ¶
func (b *InMemoryBackend) RemoveLock(kind, id, ifMatch, lockType string) (any, string, error)
RemoveLock removes every lock of the given type and returns the resource with its new etag.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads backend state from a snapshot.
func (*InMemoryBackend) ServeData ¶
func (b *InMemoryBackend) ServeData(w http.ResponseWriter, r *http.Request)
ServeData serves a request addressed to a deployed API.
func (*InMemoryBackend) SetAllowExternal ¶
func (b *InMemoryBackend) SetAllowExternal(allow bool)
SetAllowExternal lets HTTP backends and remote JWKS URIs reach non-loopback hosts.
func (*InMemoryBackend) SetBackendResponseLimit ¶
func (b *InMemoryBackend) SetBackendResponseLimit(n int64)
SetBackendResponseLimit caps the bytes proxied from one back end response; 0 restores the default.
func (*InMemoryBackend) SetClock ¶
func (b *InMemoryBackend) SetClock(now func() time.Time)
SetClock injects the time source used for lifecycle transitions, rate limits and token validation.
func (*InMemoryBackend) SetCompartmentChecker ¶
func (b *InMemoryBackend) SetCompartmentChecker(fn func(string) bool)
SetCompartmentChecker validates compartmentId arguments against another service (OCI Identity).
func (*InMemoryBackend) SetFunctionInvoker ¶
func (b *InMemoryBackend) SetFunctionInvoker(fn FunctionInvoker)
SetFunctionInvoker wires OCI Functions for ORACLE_FUNCTIONS_BACKEND and CUSTOM_AUTHENTICATION.
func (*InMemoryBackend) SetLogSink ¶
func (b *InMemoryBackend) SetLogSink(fn LogSink)
SetLogSink wires deployment access and execution logs to OCI Logging.
func (*InMemoryBackend) SetNetwork ¶
func (b *InMemoryBackend) SetNetwork(n Network)
SetNetwork wires gateway subnets and addresses to OCI Core.
func (*InMemoryBackend) SetSecretResolver ¶
func (b *InMemoryBackend) SetSecretResolver(fn SecretResolver)
SetSecretResolver wires OCI Vault for the client secret of REMOTE_DISCOVERY token validation.
func (*InMemoryBackend) SetSubnetChecker ¶
func (b *InMemoryBackend) SetSubnetChecker(fn func(string) bool)
SetSubnetChecker validates subnetId arguments against another service (OCI Core).
func (*InMemoryBackend) SetTagLookup ¶
func (b *InMemoryBackend) SetTagLookup(fn ocitags.Lookup)
SetTagLookup wires defined-tag validation against a tag namespace source (OCI Identity); nil accepts any namespace.
func (*InMemoryBackend) SetTransition ¶
func (b *InMemoryBackend) SetTransition(d time.Duration)
SetTransition sets how long CREATING, UPDATING and DELETING states last.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises the backend state, including registered API keys.
func (*InMemoryBackend) Sweep ¶
func (b *InMemoryBackend) Sweep()
Sweep applies lifecycle transitions against the backend clock.
func (*InMemoryBackend) UpdateAPI ¶
func (b *InMemoryBackend) UpdateAPI(id, ifMatch string, in updateAPIIn) (string, error)
UpdateAPI changes the name, tags or OpenAPI content of an API resource.
func (*InMemoryBackend) UpdateCertificate ¶
func (b *InMemoryBackend) UpdateCertificate(id, ifMatch string, in updateCertificateIn) (string, error)
UpdateCertificate updates the display name and tags.
func (*InMemoryBackend) UpdateDeployment ¶
func (b *InMemoryBackend) UpdateDeployment(id, ifMatch string, in updateDeploymentIn) (string, error)
UpdateDeployment replaces the specification and/or display name and tags.
func (*InMemoryBackend) UpdateGateway ¶
func (b *InMemoryBackend) UpdateGateway(id, ifMatch string, in updateGatewayIn) (string, error)
UpdateGateway updates mutable gateway attributes and returns the work request id.
func (*InMemoryBackend) UpdateSDK ¶
func (b *InMemoryBackend) UpdateSDK(id, ifMatch string, in updateSdkIn) (SdkWire, string, error)
UpdateSDK changes the name, tags or parameters of an SDK resource.
func (*InMemoryBackend) UpdateSubscriber ¶
func (b *InMemoryBackend) UpdateSubscriber(id, ifMatch string, in updateSubscriberIn) (string, error)
UpdateSubscriber changes the name, tags, clients or usage plans of a subscriber.
func (*InMemoryBackend) UpdateUsagePlan ¶
func (b *InMemoryBackend) UpdateUsagePlan(id, ifMatch string, in updateUsagePlanIn) (string, error)
UpdateUsagePlan changes the name, tags or entitlements of a usage plan.
func (*InMemoryBackend) WorkRequestExists ¶
func (b *InMemoryBackend) WorkRequestExists(id string) error
WorkRequestExists reports whether a work request exists (its error list is always empty).
func (*InMemoryBackend) WorkRequestLogs ¶
WorkRequestLogs returns the log entries of a work request.
type Lock ¶
type Lock struct {
TimeCreated time.Time `json:"timeCreated"`
Type string `json:"type"`
Message string `json:"message,omitempty"`
RelatedResourceID string `json:"relatedResourceId,omitempty"`
}
Lock is a resource lock as the SDK's ResourceLock model reports it.
type LogSink ¶
LogSink receives the access and execution log records of a deployment; wired to OCI Logging SERVICE logs.
type Network ¶
type Network struct {
Subnet func(id string) (SubnetInfo, bool)
Allocate func(AddressRequest) (Allocation, error)
Release func(vnicID string)
// SetNsgs replaces the network security groups of the gateway VNIC.
SetNsgs func(vnicID string, nsgIDs []string) error
// Reach classifies a connection from a private IP to the gateway VNIC on a TCP port.
Reach func(srcIP, vnicID string, port int) Reachability
}
Network backs gateways with subnets and VNICs of OCI Core.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for OCI API Gateway. It runs on its own listener (see Handler.StartWorker) and never matches on the shared AWS router.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init creates the backend and handler; the port is bound in StartWorker.
type Quota ¶
type Quota struct {
Unit string `json:"unit"`
ResetPolicy string `json:"resetPolicy"`
OperationOnBreach string `json:"operationOnBreach"`
Value int `json:"value"`
}
Quota caps requests per calendar period.
type Reachability ¶
type Reachability int
Reachability is how the network sees a connection from a client address to the gateway VNIC.
const ( // ReachUnknown means the source address belongs to no VNIC of the emulator. ReachUnknown Reachability = iota // ReachForeign means the source VNIC is in another VCN. ReachForeign // ReachAllowed means the security lists and NSGs permit the connection. ReachAllowed // ReachDenied means they do not. ReachDenied )
type SDK ¶
type SDK struct {
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
Tags Tags `json:"tags"`
TransitionAt *time.Time `json:"transitionAt,omitempty"`
Parameters map[string]string `json:"parameters,omitempty"`
ID string `json:"id"`
APIID string `json:"apiId"`
Compartment string `json:"compartmentId"`
DisplayName string `json:"displayName"`
TargetLanguage string `json:"targetLanguage"`
State string `json:"state"`
Etag string `json:"etag"`
Locks []Lock `json:"locks,omitempty"`
}
SDK is an SDK resource. No client library is generated: the record is stored and never carries an artifact URL.
type SdkLanguageWire ¶
type SdkLanguageWire struct {
Name string `json:"name"`
Version string `json:"version"`
DisplayName string `json:"displayName"`
Parameters []sdkLanguageParam `json:"parameters,omitempty"`
}
SdkLanguageWire is the SDK language wire shape.
type SdkWire ¶
type SdkWire struct {
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
DefinedTags map[string]map[string]any `json:"definedTags,omitempty"`
FreeformTags map[string]string `json:"freeformTags,omitempty"`
Parameters map[string]string `json:"parameters,omitempty"`
ID string `json:"id"`
APIID string `json:"apiId"`
CompartmentID string `json:"compartmentId"`
DisplayName string `json:"displayName"`
TargetLanguage string `json:"targetLanguage"`
LifecycleState string `json:"lifecycleState"`
Locks []Lock `json:"locks,omitempty"`
}
SdkWire is the wire form of an SDK resource (also used for list items).
type SecretResolver ¶
SecretResolver reads the current content of a secret (OCI Vault) by OCID and version number.
type Settings ¶
type Settings struct {
Port int `` //nolint:lll // config struct tags are intentionally verbose
/* 251-byte string literal not displayed */
TLSPort int `` //nolint:lll // config struct tags are intentionally verbose
/* 261-byte string literal not displayed */
EnforceAuth bool `` //nolint:lll // config struct tags are intentionally verbose
/* 271-byte string literal not displayed */
AllowExternalBackend bool `` //nolint:lll // config struct tags are intentionally verbose
/* 252-byte string literal not displayed */
}
Settings holds service-level configuration, embedded in the root CLI as CLI.OCIAPIGateway.
func DefaultSettings ¶
func DefaultSettings() Settings
DefaultSettings returns the settings used when no ConfigProvider is available.
type SubnetInfo ¶
type SubnetInfo struct {
// Regional is false for an availability-domain-specific subnet.
Regional bool
// Public is false for a subnet that prohibits public IPs.
Public bool
}
SubnetInfo is what the gateway needs to know about a subnet.
type Subscriber ¶
type Subscriber struct {
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
Tags Tags `json:"tags"`
TransitionAt *time.Time `json:"transitionAt,omitempty"`
ID string `json:"id"`
Compartment string `json:"compartmentId"`
DisplayName string `json:"displayName"`
State string `json:"state"`
Etag string `json:"etag"`
Clients []Client `json:"clients"`
UsagePlans []string `json:"usagePlans"`
Locks []Lock `json:"locks,omitempty"`
}
Subscriber maps client tokens to usage plans.
type SubscriberWire ¶
type SubscriberWire struct {
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
DefinedTags map[string]map[string]any `json:"definedTags,omitempty"`
FreeformTags map[string]string `json:"freeformTags,omitempty"`
ID string `json:"id"`
CompartmentID string `json:"compartmentId"`
DisplayName string `json:"displayName"`
LifecycleState string `json:"lifecycleState"`
Clients any `json:"clients"`
UsagePlans []string `json:"usagePlans"`
Locks []Lock `json:"locks,omitempty"`
}
SubscriberWire is the wire form of a subscriber; list summaries carry client names only.
type Tags ¶
type Tags struct {
FreeformTags map[string]string `json:"freeformTags,omitempty"`
DefinedTags map[string]map[string]any `json:"definedTags,omitempty"`
}
Tags are the shared freeform and defined tag sets of a resource.
type UsagePlan ¶
type UsagePlan struct {
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
Tags Tags `json:"tags"`
TransitionAt *time.Time `json:"transitionAt,omitempty"`
ID string `json:"id"`
Compartment string `json:"compartmentId"`
DisplayName string `json:"displayName"`
State string `json:"state"`
Etag string `json:"etag"`
Entitlements []Entitlement `json:"entitlements"`
Locks []Lock `json:"locks,omitempty"`
}
UsagePlan groups entitlements that subscribers receive.
type UsagePlanWire ¶
type UsagePlanWire struct {
TimeCreated time.Time `json:"timeCreated"`
TimeUpdated time.Time `json:"timeUpdated"`
DefinedTags map[string]map[string]any `json:"definedTags,omitempty"`
FreeformTags map[string]string `json:"freeformTags,omitempty"`
ID string `json:"id"`
CompartmentID string `json:"compartmentId"`
DisplayName string `json:"displayName"`
LifecycleState string `json:"lifecycleState"`
Entitlements []Entitlement `json:"entitlements"`
Locks []Lock `json:"locks,omitempty"`
}
UsagePlanWire is the wire form of a usage plan; targets are omitted in list summaries.
type WorkRequest ¶
type WorkRequest struct {
Accepted time.Time `json:"accepted"`
FinishAt time.Time `json:"finishAt"`
ID string `json:"id"`
Operation string `json:"operation"`
CompartmentID string `json:"compartmentId"`
EntityType string `json:"entityType"`
EntityID string `json:"entityId"`
Action string `json:"action"`
Seq int64 `json:"seq"`
Canceled bool `json:"canceled,omitempty"`
}
WorkRequest records an asynchronous operation.
type WorkRequestWire ¶
type WorkRequestWire struct {
TimeAccepted time.Time `json:"timeAccepted"`
TimeStarted *time.Time `json:"timeStarted,omitempty"`
TimeFinished *time.Time `json:"timeFinished,omitempty"`
OperationType string `json:"operationType"`
Status string `json:"status"`
ID string `json:"id"`
CompartmentID string `json:"compartmentId"`
Resources []wrResourceWire `json:"resources"`
PercentComplete float32 `json:"percentComplete"`
}
WorkRequestWire is the wire form of a work request.
Source Files
¶
- apis.go
- auth.go
- backend.go
- cache.go
- certificates.go
- dataplane.go
- defaultcert.go
- deployments.go
- dynauth.go
- errors.go
- extcache.go
- gateways.go
- gwlog.go
- handler.go
- inproc.go
- locks.go
- match.go
- models.go
- mtls.go
- network.go
- ops.go
- peer.go
- persistence.go
- policies.go
- provider.go
- ratelimit.go
- reqpolicy.go
- route.go
- sdks.go
- settings.go
- spec.go
- store.go
- timeouts.go
- tlsserve.go
- usage.go
- usageplans.go
- vars.go
- workreq.go