helper

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTP_VERBOSE_ENVVAR = "THREESCALE_DEBUG"
)

Variables

This section is empty.

Functions

func BackendList

func BackendList(ns string, cl client.Client, providerAccountURLStr string, logger logr.Logger) ([]capabilitiesv1beta1.Backend, error)

BackendList returns a list of backend custom resources where all elements: - Sync state (ensure remote backend exist and in sync) - Same 3scale provider Account

func CreateAdminUser added in v0.9.0

func CreateAdminUser(portaClient *porta_client_pkg.ThreeScaleClient, tenantID int64, email, username string) (*porta_client_pkg.DeveloperUser, error)

CreateAdminUser creates and active admin user - portaClient - tenantID - email - username

func FetchTenant added in v0.9.0

func FetchTenant(tenantID int64, portaClient *porta_client_pkg.ThreeScaleClient) (*porta_client_pkg.Tenant, error)

FetchTenant fetches tenant from 3scale - tenantID - portaClient

func FindDeveloperUserList added in v0.8.0

func FindDeveloperUserList(logger logr.Logger, cl client.Client, queryOpts []client.ListOption, filters ...DeveloperUserListFilter) ([]capabilitiesv1beta1.DeveloperUser, error)

FindDeveloperUserList returns a list of developerusers custom resources: - Provide []ListOption to modify options for a list request. - Filter results with a set of DeveloperUserListFilter methods

func FindProductBySystemName added in v0.8.0

func FindProductBySystemName(list []capabilitiesv1beta1.Product, systemName string) int

func FindUser added in v0.9.0

func FindUser(portaClient *porta_client_pkg.ThreeScaleClient, tenantID int64, email, username string) (*porta_client_pkg.DeveloperUser, error)

FindUser finds users by email and username - portaClient - tenantID - email - username

func GetInsecureSkipVerifyAnnotation added in v0.11.0

func GetInsecureSkipVerifyAnnotation(annotations map[string]string) bool

GetInsecureSkipVerifyAnnotation extracts the insecure_skip_verify annotation from an object

func PortaClient

func PortaClient(providerAccount *ProviderAccount, insecureSkipVerify bool) (*threescaleapi.ThreeScaleClient, error)

PortaClient instantiates porta_client.ThreeScaleClient from ProviderAccount object

func PortaClientFromURL

func PortaClientFromURL(url *url.URL, token string, insecureSkipVerify bool) (*threescaleapi.ThreeScaleClient, error)

PortaClientFromURL instantiates porta_client.ThreeScaleClient from admin url object

func PortaClientFromURLString

func PortaClientFromURLString(adminURLStr, token string, insecureSkipVerify bool) (*threescaleapi.ThreeScaleClient, error)

PortaClientFromURLString instantiates porta_client.ThreeScaleClient from url string

func ProductList

func ProductList(ns string, cl client.Client, providerAccountURLStr string, logger logr.Logger) ([]capabilitiesv1beta1.Product, error)

ProductList returns a list of product custom resources where all elements: - Sync state (ensure remote product exist and in sync) - Same 3scale provider Account

func RetrieveTenantCR added in v0.9.0

func RetrieveTenantCR(providerAccount *ProviderAccount, client k8sclient.Client, logger logr.Logger, namespace string) (*capabilitiesv1alpha1.Tenant, error)

RetrieveTenantCR retrieves tenantCR of a tenant that matches the provider account org name - providerAccount - k8client - logger If the tenantList is empty it will return nil, nil If tenantCR for given providerAccount org is not present, it will return nil, nil

func SanitizeBackendSystemName

func SanitizeBackendSystemName(systemName string) string

func URLFromDomain added in v0.8.0

func URLFromDomain(domain string) (*url.URL, error)

Types

type ApplicationEntity added in v0.11.0

type ApplicationEntity struct {
	ApplicationObj  *threescaleapi.Application
	ApplicationList *threescaleapi.ApplicationList
	*threescaleapi.ApplicationPlanJSONList
	// contains filtered or unexported fields
}

func NewApplicationEntity added in v0.11.0

func NewApplicationEntity(ApplicationObj *threescaleapi.Application, client *threescaleapi.ThreeScaleClient, logger logr.Logger) *ApplicationEntity

func (*ApplicationEntity) AppName added in v0.11.0

func (b *ApplicationEntity) AppName() string

func (*ApplicationEntity) ApplicationState added in v0.11.0

func (b *ApplicationEntity) ApplicationState() string

func (*ApplicationEntity) Description added in v0.11.0

func (b *ApplicationEntity) Description() string

func (*ApplicationEntity) ID added in v0.11.0

func (b *ApplicationEntity) ID() int64

func (*ApplicationEntity) PlanID added in v0.11.0

func (b *ApplicationEntity) PlanID() int64

func (*ApplicationEntity) ProductId added in v0.11.0

func (b *ApplicationEntity) ProductId() int64

func (*ApplicationEntity) UserAccountID added in v0.11.0

func (b *ApplicationEntity) UserAccountID() string

type ApplicationPlanEntity

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

func (*ApplicationPlanEntity) ApprovalRequired

func (b *ApplicationPlanEntity) ApprovalRequired() bool

func (*ApplicationPlanEntity) CostPerMonth

func (b *ApplicationPlanEntity) CostPerMonth() float64

func (*ApplicationPlanEntity) CreateLimit

func (b *ApplicationPlanEntity) CreateLimit(metricID int64, params threescaleapi.Params) error

func (*ApplicationPlanEntity) CreatePricingRule

func (b *ApplicationPlanEntity) CreatePricingRule(metricID int64, params threescaleapi.Params) error

func (*ApplicationPlanEntity) DeleteLimit

func (b *ApplicationPlanEntity) DeleteLimit(metricID, id int64) error

func (*ApplicationPlanEntity) DeletePricingRule

func (b *ApplicationPlanEntity) DeletePricingRule(metricID, id int64) error

func (*ApplicationPlanEntity) ID

func (b *ApplicationPlanEntity) ID() int64

func (*ApplicationPlanEntity) Limits

func (*ApplicationPlanEntity) Name

func (b *ApplicationPlanEntity) Name() string

func (*ApplicationPlanEntity) PricingRules

func (*ApplicationPlanEntity) SetupFee

func (b *ApplicationPlanEntity) SetupFee() float64

func (*ApplicationPlanEntity) State added in v0.8.0

func (b *ApplicationPlanEntity) State() string

func (*ApplicationPlanEntity) TrialPeriodDays

func (b *ApplicationPlanEntity) TrialPeriodDays() int

func (*ApplicationPlanEntity) Update

func (b *ApplicationPlanEntity) Update(params threescaleapi.Params) error

type BackendAPIEntity

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

func NewBackendAPIEntity

func NewBackendAPIEntity(backendAPIObj *threescaleapi.BackendApi, client *threescaleapi.ThreeScaleClient, logger logr.Logger) *BackendAPIEntity

func (*BackendAPIEntity) CreateMappingRule

func (b *BackendAPIEntity) CreateMappingRule(params threescaleapi.Params) error

func (*BackendAPIEntity) CreateMethod

func (b *BackendAPIEntity) CreateMethod(params threescaleapi.Params) error

func (*BackendAPIEntity) CreateMetric

func (b *BackendAPIEntity) CreateMetric(params threescaleapi.Params) error

func (*BackendAPIEntity) DeleteMappingRule

func (b *BackendAPIEntity) DeleteMappingRule(id int64) error

func (*BackendAPIEntity) DeleteMethod

func (b *BackendAPIEntity) DeleteMethod(id int64) error

func (*BackendAPIEntity) DeleteMetric

func (b *BackendAPIEntity) DeleteMetric(id int64) error

func (*BackendAPIEntity) Description

func (b *BackendAPIEntity) Description() string

func (*BackendAPIEntity) FindMethodMetricIDBySystemName

func (b *BackendAPIEntity) FindMethodMetricIDBySystemName(systemName string) (int64, error)

FindMethodMetricIDBySystemName returns metric or method ID from system name. -1 if metric and method is not found

func (*BackendAPIEntity) ID

func (b *BackendAPIEntity) ID() int64

func (*BackendAPIEntity) MappingRules

func (*BackendAPIEntity) Methods

func (*BackendAPIEntity) Metrics

func (*BackendAPIEntity) MetricsAndMethods

func (b *BackendAPIEntity) MetricsAndMethods() (*threescaleapi.MetricJSONList, error)

func (*BackendAPIEntity) Name

func (b *BackendAPIEntity) Name() string

func (*BackendAPIEntity) PrivateEndpoint

func (b *BackendAPIEntity) PrivateEndpoint() string

func (*BackendAPIEntity) SystemName

func (b *BackendAPIEntity) SystemName() string

func (*BackendAPIEntity) Update

func (b *BackendAPIEntity) Update(params threescaleapi.Params) error

func (*BackendAPIEntity) UpdateMappingRule

func (b *BackendAPIEntity) UpdateMappingRule(id int64, params threescaleapi.Params) error

func (*BackendAPIEntity) UpdateMethod

func (b *BackendAPIEntity) UpdateMethod(id int64, params threescaleapi.Params) error

func (*BackendAPIEntity) UpdateMetric

func (b *BackendAPIEntity) UpdateMetric(id int64, params threescaleapi.Params) error

type BackendAPIRemoteIndex

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

func NewBackendAPIRemoteIndex

func NewBackendAPIRemoteIndex(client *threescaleapi.ThreeScaleClient, logger logr.Logger) (*BackendAPIRemoteIndex, error)

func (*BackendAPIRemoteIndex) CreateBackendAPI

func (b *BackendAPIRemoteIndex) CreateBackendAPI(params threescaleapi.Params) (*BackendAPIEntity, error)

CreateBackendAPI create remote backendAPI

func (*BackendAPIRemoteIndex) FindByID

func (b *BackendAPIRemoteIndex) FindByID(id int64) (*BackendAPIEntity, bool)

FindByID finds remote backendAPI item by ID

func (*BackendAPIRemoteIndex) FindBySystemName

func (b *BackendAPIRemoteIndex) FindBySystemName(systemName string) (*BackendAPIEntity, bool)

FindBySystemName finds remote backendAPI item by SystenName

type DeveloperUserListFilter added in v0.8.0

type DeveloperUserListFilter func(developerUser *capabilitiesv1beta1.DeveloperUser) (bool, error)

DeveloperUserListFilter defines the function signature to implement filter

func DeveloperUserProviderAccountFilter added in v0.8.0

func DeveloperUserProviderAccountFilter(cl client.Client, ns, providerAccountURLStr string, logger logr.Logger) DeveloperUserListFilter

DeveloperUserProviderAccountFilter implements a response filter by providerAccount

type ProductEntity

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

func (*ProductEntity) ApplicationPlans

func (b *ProductEntity) ApplicationPlans() (*threescaleapi.ApplicationPlanJSONList, error)

func (*ProductEntity) BackendUsages

func (b *ProductEntity) BackendUsages() (threescaleapi.BackendAPIUsageList, error)

func (*ProductEntity) BackendVersion

func (b *ProductEntity) BackendVersion() string

func (*ProductEntity) CreateApplicationPlan

func (b *ProductEntity) CreateApplicationPlan(params threescaleapi.Params) (*threescaleapi.ApplicationPlan, error)

func (*ProductEntity) CreateBackendUsage

func (b *ProductEntity) CreateBackendUsage(params threescaleapi.Params) error

func (*ProductEntity) CreateMappingRule

func (b *ProductEntity) CreateMappingRule(params threescaleapi.Params) error

func (*ProductEntity) CreateMethod

func (b *ProductEntity) CreateMethod(params threescaleapi.Params) error

func (*ProductEntity) CreateMetric

func (b *ProductEntity) CreateMetric(params threescaleapi.Params) error

func (*ProductEntity) DeleteApplicationPlan

func (b *ProductEntity) DeleteApplicationPlan(id int64) error

func (*ProductEntity) DeleteBackendUsage

func (b *ProductEntity) DeleteBackendUsage(id int64) error

func (*ProductEntity) DeleteMappingRule

func (b *ProductEntity) DeleteMappingRule(id int64) error

func (*ProductEntity) DeleteMethod

func (b *ProductEntity) DeleteMethod(id int64) error

func (*ProductEntity) DeleteMetric

func (b *ProductEntity) DeleteMetric(id int64) error

func (*ProductEntity) DeploymentOption

func (b *ProductEntity) DeploymentOption() string

func (*ProductEntity) Description

func (b *ProductEntity) Description() string

func (*ProductEntity) FindMethodMetricIDBySystemName

func (b *ProductEntity) FindMethodMetricIDBySystemName(systemName string) (int64, error)

FindMethodMetricIDBySystemName returns metric or method ID from system name. -1 if metric and method is not found

func (*ProductEntity) ID

func (b *ProductEntity) ID() int64

func (*ProductEntity) MappingRules

func (b *ProductEntity) MappingRules() (*threescaleapi.MappingRuleJSONList, error)

func (*ProductEntity) Methods

func (b *ProductEntity) Methods() (*threescaleapi.MethodList, error)

func (*ProductEntity) Metrics

func (*ProductEntity) MetricsAndMethods

func (b *ProductEntity) MetricsAndMethods() (*threescaleapi.MetricJSONList, error)

func (*ProductEntity) Name

func (b *ProductEntity) Name() string

func (*ProductEntity) OIDCConfiguration added in v0.8.0

func (b *ProductEntity) OIDCConfiguration() (*threescaleapi.OIDCConfiguration, error)

func (*ProductEntity) Policies added in v0.8.0

func (*ProductEntity) PromoteProxyToStaging

func (b *ProductEntity) PromoteProxyToStaging() error

func (*ProductEntity) Proxy

func (b *ProductEntity) Proxy() (*threescaleapi.ProxyJSON, error)

func (*ProductEntity) State

func (b *ProductEntity) State() string

func (*ProductEntity) Update

func (b *ProductEntity) Update(params threescaleapi.Params) error

func (*ProductEntity) UpdateBackendUsage

func (b *ProductEntity) UpdateBackendUsage(id int64, params threescaleapi.Params) error

func (*ProductEntity) UpdateMappingRule

func (b *ProductEntity) UpdateMappingRule(id int64, params threescaleapi.Params) error

func (*ProductEntity) UpdateMethod

func (b *ProductEntity) UpdateMethod(id int64, params threescaleapi.Params) error

func (*ProductEntity) UpdateMetric

func (b *ProductEntity) UpdateMetric(id int64, params threescaleapi.Params) error

func (*ProductEntity) UpdateOIDCConfiguration added in v0.8.0

func (b *ProductEntity) UpdateOIDCConfiguration(oidcConf *threescaleapi.OIDCConfiguration) error

func (*ProductEntity) UpdatePolicies added in v0.8.0

func (b *ProductEntity) UpdatePolicies(policies *threescaleapi.PoliciesConfigList) error

func (*ProductEntity) UpdateProxy

func (b *ProductEntity) UpdateProxy(params threescaleapi.Params) error

type ProviderAccount

type ProviderAccount struct {
	AdminURLStr string
	Token       string
}

func LookupProviderAccount

func LookupProviderAccount(cl client.Client, ns string, providerAccountRef *corev1.LocalObjectReference, logger logr.Logger) (*ProviderAccount, error)

LookupProviderAccount looks up for account provider url and credentials If provider_account_reference is provided, it must exist and required fields must exists If no provider_account_reference is provided, defaul provider account secret with hardcoded name will be looked up in the namespace. If no provider_account_reference is provided AND default provider account secret is not found either, then, 3scale default provider account (3scale-admin) will be looked up using system-seed secret in the current namespace. If nothing is successfully found, return error

Jump to

Keyboard shortcuts

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