managementserver

package
v0.0.0-...-dea9284 Latest Latest
Warning

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

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

Documentation

Overview

* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *

* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *

* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAIProvider

func AddAIProvider(aiProvider eventHub.AIProvider)

AddAIProvider adds an AI provider to the aiProviderMap

func AddAllApplicationKeyMappings

func AddAllApplicationKeyMappings(applicationKeyMappingMapTemp map[string]ApplicationKeyMapping)

AddAllApplicationKeyMappings adds all the application key mappings in the applicationKeyMappingMap

func AddAllApplicationMappings

func AddAllApplicationMappings(applicationMappingMapTemp map[string]ApplicationMapping)

AddAllApplicationMappings adds all the application mappings in the applicationMappingMap

func AddAllApplications

func AddAllApplications(applicationMapTemp map[string]Application)

AddAllApplications adds all the applications in the applicationMap

func AddAllSubscriptions

func AddAllSubscriptions(subscriptionMapTemp map[string]Subscription)

AddAllSubscriptions adds all the subscriptions in the subscriptionMap

func AddApplication

func AddApplication(application Application)

AddApplication adds an application to the applicationMap

func AddApplicationKeyMapping

func AddApplicationKeyMapping(applicationKeyMapping ApplicationKeyMapping)

AddApplicationKeyMapping adds an application key mapping to the applicationKeyMappingMap

func AddApplicationMapping

func AddApplicationMapping(applicationMapping ApplicationMapping)

AddApplicationMapping adds an application mapping to the applicationMappingMap

func AddRateLimitPolicy

func AddRateLimitPolicy(rateLimitPolicy eventHub.RateLimitPolicy)

AddRateLimitPolicy adds a rate limit policy to the rateLimitPolicyMap

func AddSubscription

func AddSubscription(subscription Subscription)

AddSubscription adds a subscription to the subscriptionMap

func AddSubscriptionPolicy

func AddSubscriptionPolicy(rateLimitPolicy eventHub.SubscriptionPolicy)

AddSubscriptionPolicy adds a rate limit policy to the subscriptionPolicyMap

func ConvertYAMLToMap

func ConvertYAMLToMap(yamlString string) (map[string]interface{}, error)

ConvertYAMLToMap converts a YAML string to a map[string]interface{}

func DeleteAIProvider

func DeleteAIProvider(id string)

DeleteAIProvider deletes an AI provider from the aiProviderMap

func DeleteAllApplicationKeyMappings

func DeleteAllApplicationKeyMappings()

DeleteAllApplicationKeyMappings deletes all the application key mappings in the applicationKeyMappingMap

func DeleteAllApplicationMappings

func DeleteAllApplicationMappings()

DeleteAllApplicationMappings deletes all the application mappings in the applicationMappingMap

func DeleteAllApplicationMappingsByApplicationsUUID

func DeleteAllApplicationMappingsByApplicationsUUID(uuid string)

DeleteAllApplicationMappingsByApplicationsUUID deletes all the application mappings in the applicationMappingMap

func DeleteAllApplications

func DeleteAllApplications()

DeleteAllApplications deletes all the applications in the applicationMap

func DeleteAllSubscriptions

func DeleteAllSubscriptions()

DeleteAllSubscriptions deletes all the subscriptions in the subscriptionMap

func DeleteAllSubscriptionsByApplicationsUUID

func DeleteAllSubscriptionsByApplicationsUUID(uuid string)

DeleteAllSubscriptionsByApplicationsUUID deletes all the subscriptions in the subscriptionMap

func DeleteApplication

func DeleteApplication(uuid string)

DeleteApplication deletes an application from the applicationMap

func DeleteApplicationKeyMapping

func DeleteApplicationKeyMapping(uuid string)

DeleteApplicationKeyMapping deletes an application key mapping from the applicationKeyMappingMap

func DeleteApplicationMapping

func DeleteApplicationMapping(uuid string)

DeleteApplicationMapping deletes an application mapping from the applicationMappingMap

func DeleteRateLimitPolicy

func DeleteRateLimitPolicy(name string, tenantDomain string)

DeleteRateLimitPolicy deletes a rate limit policy from the rateLimitPolicyMap

func DeleteSubscription

func DeleteSubscription(uuid string)

DeleteSubscription deletes a subscription from the subscriptionMap

func DeleteSubscriptionPolicy

func DeleteSubscriptionPolicy(name string, tenantDomain string)

DeleteSubscriptionPolicy deletes a subscription policy from the subscriptionPolicyMap

func GetAIProvider

func GetAIProvider(id string) eventHub.AIProvider

GetAIProvider returns an AI provider from the aiProviderMap

func GetAllAIProviders

func GetAllAIProviders() []eventHub.AIProvider

GetAllAIProviders returns all the AI providers in the aiProviderMap

func GetAllRateLimitPolicies

func GetAllRateLimitPolicies() []eventHub.RateLimitPolicy

GetAllRateLimitPolicies returns all the rate limit policies in the rateLimitPolicyMap

func GetRateLimitPolicy

func GetRateLimitPolicy(name string, tenantDomain string) eventHub.RateLimitPolicy

GetRateLimitPolicy returns a rate limit policy from the rateLimitPolicyMap

func GetSubscriptionPolicies

func GetSubscriptionPolicies() map[string]eventHub.SubscriptionPolicy

GetSubscriptionPolicies return the subscription policy map

func JSONToYAML

func JSONToYAML(jsonString string) (string, error)

JSONToYAML convert json string to yaml

func StartInternalServer

func StartInternalServer(port uint)

StartInternalServer starts the internal server

func UpdateApplication

func UpdateApplication(uuid string, application Application)

UpdateApplication updates an application in the applicationMap

func UpdateApplicationKeyMapping

func UpdateApplicationKeyMapping(uuid string, applicationKeyMapping ApplicationKeyMapping)

UpdateApplicationKeyMapping updates an application key mapping in the applicationKeyMappingMap

func UpdateApplicationMapping

func UpdateApplicationMapping(uuid string, applicationMapping ApplicationMapping)

UpdateApplicationMapping updates an application mapping in the applicationMappingMap

func UpdateRateLimitPolicy

func UpdateRateLimitPolicy(name string, tenantDomain string, rateLimitPolicy eventHub.RateLimitPolicy)

UpdateRateLimitPolicy updates a rate limit policy in the rateLimitPolicyMap

func UpdateSubscription

func UpdateSubscription(uuid string, subscription Subscription)

UpdateSubscription updates a subscription in the subscriptionMap

Types

type AIConfiguration

type AIConfiguration struct {
	LLMProviderID         string `json:"llmProviderID"`
	LLMProviderName       string `json:"llmProviderName"`
	LLMProviderAPIVersion string `json:"llmProviderApiVersion"`
}

AIConfiguration holds the AI configuration

type AIRL

type AIRL struct {
	PromptTokenCount     *uint32 `json:"promptTokenCount"`
	CompletionTokenCount *uint32 `json:"CompletionTokenCount"`
	TotalTokenCount      *uint32 `json:"totalTokenCount"`
	TimeUnit             string  `json:"timeUnit"`
	RequestCount         *uint32 `json:"requestCount"`
}

AIRL holds AI ratelimit related data

type API

type API struct {
	APIUUID              string            `json:"apiUUID"`
	APIName              string            `json:"apiName"`
	APIVersion           string            `json:"apiVersion"`
	IsDefaultVersion     bool              `json:"isDefaultVersion"`
	Definition           string            `json:"definition"`
	APIType              string            `json:"apiType"`
	APISubType           string            `json:"apiSubType"`
	BasePath             string            `json:"basePath"`
	Organization         string            `json:"organization"`
	SystemAPI            bool              `json:"systemAPI"`
	APIProperties        map[string]string `json:"apiProperties,omitempty"`
	Environment          string            `json:"environment,omitempty"`
	RevisionID           string            `json:"revisionID"`
	SandEndpoint         string            `json:"sandEndpoint"`
	SandEndpointSecurity EndpointSecurity  `json:"sandEndpointSecurity"`
	ProdEndpoint         string            `json:"prodEndpoint"`
	ProdEndpointSecurity EndpointSecurity  `json:"prodEndpointSecurity"`
	EndpointProtocol     string            `json:"endpointProtocol"`
	CORSPolicy           *CORSPolicy       `json:"cORSPolicy"`
	Vhost                string            `json:"vhost"`
	SandVhost            string            `json:"sandVhost"`
	SecurityScheme       []string          `json:"securityScheme"`
	AuthHeader           string            `json:"authHeader"`
	APIKeyHeader         string            `json:"apiKeyHeader"`
	Operations           []OperationFromDP `json:"operations"`
	SandAIRL             *AIRL             `json:"sandAIRL"`
	ProdAIRL             *AIRL             `json:"prodAIRL"`
	AIConfiguration      AIConfiguration   `json:"aiConfiguration"`
}

API holds the api data from adapter api event

type APICPEvent

type APICPEvent struct {
	Event EventType `json:"event"`
	API   API       `json:"payload"`
}

APICPEvent holds data of a specific API event from adapter

type APIOperation

type APIOperation struct {
	ID                string            `yaml:"id"`
	Target            string            `yaml:"target"`
	Verb              string            `yaml:"verb"`
	AuthType          string            `yaml:"authType"`
	ThrottlingPolicy  string            `yaml:"throttlingPolicy"`
	Scopes            []string          `yaml:"scopes"`
	UsedProductIDs    []string          `yaml:"usedProductIds"`
	OperationPolicies OperationPolicies `yaml:"operationPolicies"`
}

APIOperation represents the desired struct format for each API operation

type APKHeader

type APKHeader struct {
	Name  string `json:"headerName" yaml:"headerName"`
	Value string `json:"headerValue,omitempty" yaml:"headerValue,omitempty"`
}

APKHeader contains the header information

type APKHeaderModifier

type APKHeaderModifier struct {
	AddHeaders    []APKHeader `json:"addHeaders"`
	RemoveHeaders []string    `json:"removeHeaders"`
}

APKHeaderModifier contains header modifier values

type APKHeaders

type APKHeaders struct {
	Policy
	RequestHeaders  APKHeaderModifier `json:"requestHeaders"`
	ResponseHeaders APKHeaderModifier `json:"responseHeaders"`
}

APKHeaders contains the request and response header modifier information

type APKMirrorRequest

type APKMirrorRequest struct {
	Policy
	URLs []string `json:"urls"`
}

APKMirrorRequest defines the parameters of a mirror request policy sent from the APK

type APKRedirectRequest

type APKRedirectRequest struct {
	Policy
	URL string `json:"url"`
}

APKRedirectRequest defines the parameters of a redirect request policy sent from the APK

type AdditionalProperty

type AdditionalProperty struct {
	Name    string
	Value   string
	Display bool
}

AdditionalProperty represents additional properties of the API

type Application

type Application struct {
	UUID         string            `json:"uuid,omitempty"`
	Name         string            `json:"name,omitempty"`
	Owner        string            `json:"owner,omitempty"`
	Organization string            `json:"organization,omitempty"`
	Attributes   map[string]string `json:"attributes,omitempty"`
	TimeStamp    int64             `json:"timeStamp,omitempty"`
}

Application for struct application

func GetApplication

func GetApplication(uuid string) Application

GetApplication returns an application from the applicationMap

type ApplicationKeyMapping

type ApplicationKeyMapping struct {
	ApplicationUUID       string `json:"applicationUUID,omitempty"`
	SecurityScheme        string `json:"securityScheme,omitempty"`
	ApplicationIdentifier string `json:"applicationIdentifier,omitempty"`
	KeyType               string `json:"keyType,omitempty"`
	EnvID                 string `json:"envID,omitempty"`
	Timestamp             int64  `json:"timestamp,omitempty"`
	Organization          string `json:"organization,omitempty"`
}

ApplicationKeyMapping for struct applicationKeyMapping

func GetApplicationKeyMapping

func GetApplicationKeyMapping(uuid string) ApplicationKeyMapping

GetApplicationKeyMapping returns an application key mapping from the applicationKeyMappingMap

func GetApplicationKeyMappingByApplicationUUID

func GetApplicationKeyMappingByApplicationUUID(uuid string) ApplicationKeyMapping

GetApplicationKeyMappingByApplicationUUID returns an application key mapping from the applicationKeyMappingMap

func GetApplicationKeyMappingByApplicationUUIDAndEnvID

func GetApplicationKeyMappingByApplicationUUIDAndEnvID(uuid string, envID string) ApplicationKeyMapping

GetApplicationKeyMappingByApplicationUUIDAndEnvID returns an application key mapping from the applicationKeyMappingMap

func GetApplicationKeyMappingByApplicationUUIDAndSecurityScheme

func GetApplicationKeyMappingByApplicationUUIDAndSecurityScheme(uuid string, securityScheme string) ApplicationKeyMapping

GetApplicationKeyMappingByApplicationUUIDAndSecurityScheme returns an application key mapping from the applicationKeyMappingMap

func GetApplicationKeyMappingByApplicationUUIDAndSecuritySchemeAndEnvID

func GetApplicationKeyMappingByApplicationUUIDAndSecuritySchemeAndEnvID(uuid string, securityScheme string, envID string) ApplicationKeyMapping

GetApplicationKeyMappingByApplicationUUIDAndSecuritySchemeAndEnvID returns an application key mapping from the applicationKeyMappingMap

type ApplicationKeyMappingList

type ApplicationKeyMappingList struct {
	List []ApplicationKeyMapping `json:"list"`
}

ApplicationKeyMappingList for struct list of applicationKeyMapping

type ApplicationList

type ApplicationList struct {
	List []Application `json:"list"`
}

ApplicationList for struct list of application

type ApplicationMapping

type ApplicationMapping struct {
	UUID            string `json:"uuid,omitempty"`
	ApplicationRef  string `json:"applicationRef,omitempty"`
	SubscriptionRef string `json:"subscriptionRef,omitempty"`
	Organization    string `json:"organization,omitempty"`
}

ApplicationMapping for struct applicationMapping

func GetAllApplicationMappings

func GetAllApplicationMappings() []ApplicationMapping

GetAllApplicationMappings returns all the application mappings in the applicationMappingMap

func GetApplicationMapping

func GetApplicationMapping(uuid string) ApplicationMapping

GetApplicationMapping returns an application mapping from the applicationMappingMap

func GetApplicationMappingByApplicationUUID

func GetApplicationMappingByApplicationUUID(uuid string) ApplicationMapping

GetApplicationMappingByApplicationUUID returns an application mapping from the applicationMappingMap

func GetApplicationMappingByApplicationUUIDAndSubscriptionUUID

func GetApplicationMappingByApplicationUUIDAndSubscriptionUUID(uuid string, subscriptionUUID string) ApplicationMapping

GetApplicationMappingByApplicationUUIDAndSubscriptionUUID returns an application mapping from the applicationMappingMap

type ApplicationMappingList

type ApplicationMappingList struct {
	List []ApplicationMapping `json:"list"`
}

ApplicationMappingList for struct list of applicationMapping

type CORSPolicy

type CORSPolicy struct {
	AccessControlAllowCredentials bool     `json:"accessControlAllowCredentials,omitempty"`
	AccessControlAllowHeaders     []string `json:"accessControlAllowHeaders,omitempty"`
	AccessControlAllowOrigins     []string `json:"accessControlAllowOrigins,omitempty"`
	AccessControlExposeHeaders    []string `json:"accessControlExposeHeaders,omitempty"`
	AccessControlMaxAge           *int     `json:"accessControlMaxAge,omitempty"`
	AccessControlAllowMethods     []string `json:"accessControlAllowMethods,omitempty"`
}

CORSPolicy hold cors configs

type EndpointSecurity

type EndpointSecurity struct {
	Enabled       bool   `json:"enabled"`
	SecurityType  string `json:"securityType"`
	APIKeyName    string `json:"apiKeyName"`
	APIKeyValue   string `json:"apiKeyValue"`
	APIKeyIn      string `json:"apiKeyIn"`
	BasicUsername string `json:"basicUsername"`
	BasicPassword string `json:"basicPassword"`
}

EndpointSecurity holds the endpoint security information

type EventServer

type EventServer struct {
	apkmgt.UnimplementedEventStreamServiceServer
}

EventServer struct use to hold event server

func (EventServer) StreamEvents

StreamEvents streams events to the enforcer

type EventType

type EventType string

EventType is the type of api event. One of (CREATE, UPDATE, DELETE)

const (
	// CreateEvent is create api event
	CreateEvent EventType = "CREATE"
	// DeleteEvent is delete api event
	DeleteEvent EventType = "DELETE"
)

type Filter

type Filter interface {
	GetPolicyName() string
	GetPolicyVersion() string
	// contains filtered or unexported methods
}

Filter interface is used to define the type of parameters that can be used in an operation policy

type FilterParameters

type FilterParameters interface {
	// contains filtered or unexported methods
}

FilterParameters interface is used to define the type of parameters that can be used in an operation policy.

type Header struct {
	Name  string `json:"headerName" yaml:"headerName"`
	Value string `json:"headerValue,omitempty" yaml:"headerValue,omitempty"`
}

Header contains the request and response header modifier information

type MirrorRequest

type MirrorRequest struct {
	URL string `json:"url"`
}

MirrorRequest contains the url to mirror the request to

type OpenAPIPaths

type OpenAPIPaths struct {
	Paths map[string]map[string]interface{} `yaml:"paths"`
}

OpenAPIPaths represents the structure of the OpenAPI specification YAML file

type Operation

type Operation struct {
	XAuthType        string `yaml:"x-auth-type"`
	XThrottlingTier  string `yaml:"x-throttling-tier"`
	XWSO2AppSecurity struct {
		SecurityTypes []string `yaml:"security-types"`
		Optional      bool     `yaml:"optional"`
	} `yaml:"x-wso2-application-security"`
}

Operation represents the structure of an operation within the OpenAPI specification

type OperationFromDP

type OperationFromDP struct {
	Path    string   `json:"path"`
	Verb    string   `json:"verb"`
	Scopes  []string `json:"scopes"`
	Filters []Filter `json:"filters"`
}

OperationFromDP holds the path, verb, throttling and interceptor policy

type OperationPolicies

type OperationPolicies struct {
	Request  []OperationPolicy `yaml:"request"`
	Response []OperationPolicy `yaml:"response"`
	Fault    []string          `yaml:"fault"`
}

OperationPolicies contains the request, response and fault policies for an operation

type OperationPolicy

type OperationPolicy struct {
	PolicyName    string           `yaml:"policyName"`
	PolicyVersion string           `yaml:"policyVersion"`
	PolicyID      string           `yaml:"policyId,omitempty"`
	Parameters    FilterParameters `yaml:"parameters"`
}

OperationPolicy represents the desired struct format for an Operation Policy

type Policy

type Policy struct {
	PolicyName    string `json:"policyName"`
	PolicyVersion string `json:"policyVersion"`
}

Policy holds the policy name and version

func (*Policy) GetPolicyName

func (p *Policy) GetPolicyName() string

GetPolicyName returns the name of the policy sent to the APIM

func (*Policy) GetPolicyVersion

func (p *Policy) GetPolicyVersion() string

GetPolicyVersion returns the version of the policy sent to the APIM

type RedirectRequest

type RedirectRequest struct {
	URL string `json:"url"`
}

RedirectRequest contains the url to send the redirected request

type ResolvedApplication

type ResolvedApplication struct {
	UUID            string            `json:"uuid,omitempty"`
	Name            string            `json:"name,omitempty"`
	Owner           string            `json:"owner,omitempty"`
	Organization    string            `json:"organization,omitempty"`
	Attributes      map[string]string `json:"attributes,omitempty"`
	TimeStamp       int64             `json:"timeStamp,omitempty"`
	SecuritySchemes []SecurityScheme  `json:"securitySchemes,omitempty"`
}

ResolvedApplication for struct resolvedApplication

func GetAllApplications

func GetAllApplications() []ResolvedApplication

GetAllApplications returns all the applications in the applicationMap

type ResolvedApplicationList

type ResolvedApplicationList struct {
	List []ResolvedApplication `json:"list"`
}

ResolvedApplicationList for struct list of resolved application

type Scope

type Scope struct {
	Name        string   `yaml:"name"`
	DisplayName string   `yaml:"displayName"`
	Description string   `yaml:"description"`
	Bindings    []string `yaml:"bindings"`
}

Scope to hold scope config

type ScopeWrapper

type ScopeWrapper struct {
	Scope  Scope `yaml:"scope"`
	Shared bool  `yaml:"shared"`
}

ScopeWrapper to hold scope sonfigs

type SecurityScheme

type SecurityScheme struct {
	SecurityScheme        string `json:"securityScheme,omitempty"`
	ApplicationIdentifier string `json:"applicationIdentifier,omitempty"`
	KeyType               string `json:"keyType,omitempty"`
	EnvID                 string `json:"envID,omitempty"`
}

SecurityScheme for struct securityScheme

type SubscribedAPI

type SubscribedAPI struct {
	Name    string `json:"name,omitempty"`
	Version string `json:"version,omitempty"`
}

SubscribedAPI for struct subscribedAPI

type Subscription

type Subscription struct {
	SubStatus     string         `json:"subStatus,omitempty"`
	UUID          string         `json:"uuid,omitempty"`
	Organization  string         `json:"organization,omitempty"`
	SubscribedAPI *SubscribedAPI `json:"subscribedApi,omitempty"`
	TimeStamp     int64          `json:"timeStamp,omitempty"`
	RateLimit     string         `json:"rateLimit,omitempty"`
}

Subscription for struct subscription

func GetAllSubscriptions

func GetAllSubscriptions() []Subscription

GetAllSubscriptions returns all the subscriptions in the subscriptionMap

func GetSubscription

func GetSubscription(uuid string) Subscription

GetSubscription returns a subscription from the subscriptionMap

type SubscriptionList

type SubscriptionList struct {
	List []Subscription `json:"list"`
}

SubscriptionList for struct list of applications

Jump to

Keyboard shortcuts

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