api

package
v0.0.0-...-a423d60 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// APIProtocolODataV2 is one of the available api protocol options
	APIProtocolODataV2 string = "odata-v2"
	// APIProtocolRest is one of the available api protocol options
	APIProtocolRest string = "rest"
)

Variables

This section is empty.

Functions

func ConvertTargetURLToJSONArray

func ConvertTargetURLToJSONArray(targetURL string) json.RawMessage

ConvertTargetURLToJSONArray converts targetURL string value to a JSON array.

func ExtractTargetURLFromJSONArray

func ExtractTargetURLFromJSONArray(jsonTargetURL json.RawMessage) string

ExtractTargetURLFromJSONArray extracts targetURL into a string from a JSON array representation.

func NewConverter

func NewConverter(version VersionConverter, specConverter SpecConverter) *converter

NewConverter returns a new Converter that can later be used to make the conversions between the GraphQL, service, and repository layer representations of a Compass APIDefinition.

func NewRepository

func NewRepository(conv APIDefinitionConverter) *pgRepository

NewRepository returns a new entity responsible for repo-layer APIDefinitions operations.

func NewService

func NewService(repo APIRepository, uidService UIDService, specService SpecService, bundleReferenceService BundleReferenceService) *service

NewService returns a new object responsible for service-layer APIDefinition operations.

Types

type APIConverter

type APIConverter interface {
	ToGraphQL(in *model.APIDefinition, spec *model.Spec, bundleRef *model.BundleReference) (*graphql.APIDefinition, error)
	InputFromGraphQL(in *graphql.APIDefinitionInput) (*model.APIDefinitionInput, *model.SpecInput, error)
}

APIConverter converts APIDefinitions between the model.APIDefinition service-layer representation and the graphql-layer representation.

type APIDefCollection

type APIDefCollection []Entity

APIDefCollection is an array of Entities

func (APIDefCollection) Len

func (r APIDefCollection) Len() int

Len returns the length of the collection

type APIDefinitionConverter

type APIDefinitionConverter interface {
	FromEntity(entity *Entity) *model.APIDefinition
	ToEntity(apiModel *model.APIDefinition) *Entity
}

APIDefinitionConverter converts APIDefinitions between the model.APIDefinition service-layer representation and the repo-layer representation Entity.

type APIRepository

type APIRepository interface {
	GetByID(ctx context.Context, tenantID, id string) (*model.APIDefinition, error)
	GetByIDGlobal(ctx context.Context, id string) (*model.APIDefinition, error)
	GetForBundle(ctx context.Context, tenant string, id string, bundleID string) (*model.APIDefinition, error)
	GetByApplicationID(ctx context.Context, tenantID string, id, appID string) (*model.APIDefinition, error)
	Exists(ctx context.Context, tenant, id string) (bool, error)
	ListByBundleIDs(ctx context.Context, tenantID string, bundleIDs []string, bundleRefs []*model.BundleReference, counts map[string]int, pageSize int, cursor string) ([]*model.APIDefinitionPage, error)
	ListByApplicationIDPage(ctx context.Context, tenantID string, appID string, pageSize int, cursor string) (*model.APIDefinitionPage, error)
	ListByResourceID(ctx context.Context, tenantID string, resourceType resource.Type, resourceID string) ([]*model.APIDefinition, error)
	CreateMany(ctx context.Context, tenant string, item []*model.APIDefinition) error
	Create(ctx context.Context, tenant string, item *model.APIDefinition) error
	CreateGlobal(ctx context.Context, item *model.APIDefinition) error
	Update(ctx context.Context, tenant string, item *model.APIDefinition) error
	UpdateGlobal(ctx context.Context, item *model.APIDefinition) error
	Delete(ctx context.Context, tenantID string, id string) error
	DeleteAllByBundleID(ctx context.Context, tenantID, bundleID string) error
	DeleteGlobal(ctx context.Context, id string) error
}

APIRepository is responsible for the repo-layer APIDefinition operations.

type APIService

type APIService interface {
	CreateInBundle(ctx context.Context, resourceType resource.Type, resourceID string, bundleID string, in model.APIDefinitionInput, spec *model.SpecInput) (string, error)
	CreateInApplication(ctx context.Context, appID string, in model.APIDefinitionInput, spec *model.SpecInput) (string, error)
	Update(ctx context.Context, resourceType resource.Type, id string, in model.APIDefinitionInput, spec *model.SpecInput) error
	UpdateForApplication(ctx context.Context, id string, in model.APIDefinitionInput, specIn *model.SpecInput) error
	Get(ctx context.Context, id string) (*model.APIDefinition, error)
	Delete(ctx context.Context, resourceType resource.Type, id string) error
	ListFetchRequests(ctx context.Context, specIDs []string) ([]*model.FetchRequest, error)
	ListByApplicationID(ctx context.Context, appID string) ([]*model.APIDefinition, error)
	ListByApplicationIDPage(ctx context.Context, appID string, pageSize int, cursor string) (*model.APIDefinitionPage, error)
}

APIService is responsible for the service-layer APIDefinition operations.

type ApplicationService

type ApplicationService interface {
	UpdateBaseURL(ctx context.Context, appID, targetURL string) error
}

ApplicationService is responsible for the service-layer Application operations.

type BundleReferenceService

type BundleReferenceService interface {
	GetForBundle(ctx context.Context, objectType model.BundleReferenceObjectType, objectID, bundleID *string) (*model.BundleReference, error)
	CreateByReferenceObjectID(ctx context.Context, in model.BundleReferenceInput, objectType model.BundleReferenceObjectType, objectID, bundleID *string) error
	UpdateByReferenceObjectID(ctx context.Context, in model.BundleReferenceInput, objectType model.BundleReferenceObjectType, objectID, bundleID *string) error
	DeleteByReferenceObjectID(ctx context.Context, objectType model.BundleReferenceObjectType, objectID, bundleID *string) error
	ListByBundleIDs(ctx context.Context, objectType model.BundleReferenceObjectType, bundleIDs []string, pageSize int, cursor string) ([]*model.BundleReference, map[string]int, error)
}

BundleReferenceService is responsible for the service-layer BundleReference operations.

type BundleService

type BundleService interface {
	Get(ctx context.Context, id string) (*model.Bundle, error)
}

BundleService is responsible for the service-layer Bundle operations.

type Entity

type Entity struct {
	ApplicationID                           sql.NullString `db:"app_id"`
	ApplicationTemplateVersionID            sql.NullString `db:"app_template_version_id"`
	PackageID                               sql.NullString `db:"package_id"`
	Name                                    string         `db:"name"`
	Description                             sql.NullString `db:"description"`
	Group                                   sql.NullString `db:"group_name"`
	TargetURLs                              sql.NullString `db:"target_urls"`
	OrdID                                   sql.NullString `db:"ord_id"`
	LocalTenantID                           sql.NullString `db:"local_tenant_id"`
	ShortDescription                        sql.NullString `db:"short_description"`
	SystemInstanceAware                     sql.NullBool   `db:"system_instance_aware"`
	PolicyLevel                             sql.NullString `db:"policy_level"`
	CustomPolicyLevel                       sql.NullString `db:"custom_policy_level"`
	APIProtocol                             sql.NullString `db:"api_protocol"`
	Tags                                    sql.NullString `db:"tags"`
	Countries                               sql.NullString `db:"countries"`
	Links                                   sql.NullString `db:"links"`
	APIResourceLinks                        sql.NullString `db:"api_resource_links"`
	ReleaseStatus                           sql.NullString `db:"release_status"`
	SunsetDate                              sql.NullString `db:"sunset_date"`
	Successors                              sql.NullString `db:"successors"`
	ChangeLogEntries                        sql.NullString `db:"changelog_entries"`
	Labels                                  sql.NullString `db:"labels"`
	Visibility                              string         `db:"visibility"`
	Disabled                                sql.NullBool   `db:"disabled"`
	PartOfProducts                          sql.NullString `db:"part_of_products"`
	LineOfBusiness                          sql.NullString `db:"line_of_business"`
	Industry                                sql.NullString `db:"industry"`
	ImplementationStandard                  sql.NullString `db:"implementation_standard"`
	CustomImplementationStandard            sql.NullString `db:"custom_implementation_standard"`
	CustomImplementationStandardDescription sql.NullString `db:"custom_implementation_standard_description"`
	Extensible                              sql.NullString `db:"extensible"`
	ResourceHash                            sql.NullString `db:"resource_hash"`
	SupportedUseCases                       sql.NullString `db:"supported_use_cases"`
	DocumentationLabels                     sql.NullString `db:"documentation_labels"`
	CorrelationIDs                          sql.NullString `db:"correlation_ids"`
	Direction                               sql.NullString `db:"direction"`
	LastUpdate                              sql.NullString `db:"last_update"`
	DeprecationDate                         sql.NullString `db:"deprecation_date"`
	Responsible                             sql.NullString `db:"responsible"`
	Usage                                   sql.NullString `db:"usage"`

	*repo.BaseEntity
	version.Version
}

Entity is a representation of an API in the database.

func (*Entity) DecorateWithTenantID

func (e *Entity) DecorateWithTenantID(tenant string) interface{}

DecorateWithTenantID decorates the entity with the given tenant ID.

func (*Entity) GetParent

func (e *Entity) GetParent(_ resource.Type) (resource.Type, string)

GetParent returns the parent type and the parent ID of the entity.

type FetchRequestConverter

type FetchRequestConverter interface {
	ToGraphQL(in *model.FetchRequest) (*graphql.FetchRequest, error)
	InputFromGraphQL(in *graphql.FetchRequestInput) (*model.FetchRequestInput, error)
}

FetchRequestConverter converts FetchRequest between the model.FetchRequest service-layer representation and the graphql-layer one.

type Resolver

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

Resolver is an object responsible for resolver-layer APIDefinition operations

func NewResolver

func NewResolver(transact persistence.Transactioner, svc APIService, rtmSvc RuntimeService, bndlSvc BundleService, bndlRefSvc BundleReferenceService, converter APIConverter, frConverter FetchRequestConverter, specService SpecService, specConverter SpecConverter, appSvc ApplicationService) *Resolver

NewResolver returns a new object responsible for resolver-layer APIDefinition operations.

func (*Resolver) APIDefinitionsForApplication

func (r *Resolver) APIDefinitionsForApplication(ctx context.Context, appID string, first *int, after *graphql.PageCursor) (*graphql.APIDefinitionPage, error)

APIDefinitionsForApplication lists all APIDefinitions for a given application ID with paging.

func (*Resolver) AddAPIDefinitionToApplication

func (r *Resolver) AddAPIDefinitionToApplication(ctx context.Context, appID string, in graphql.APIDefinitionInput) (*graphql.APIDefinition, error)

AddAPIDefinitionToApplication adds an APIDefinition in the context of an Application without Bundle

func (*Resolver) AddAPIDefinitionToBundle

func (r *Resolver) AddAPIDefinitionToBundle(ctx context.Context, bundleID string, in graphql.APIDefinitionInput) (*graphql.APIDefinition, error)

AddAPIDefinitionToBundle adds an APIDefinition to a Bundle with a given ID,

func (*Resolver) DeleteAPIDefinition

func (r *Resolver) DeleteAPIDefinition(ctx context.Context, id string) (*graphql.APIDefinition, error)

DeleteAPIDefinition deletes an APIDefinition by its ID.

func (*Resolver) FetchRequest

func (r *Resolver) FetchRequest(ctx context.Context, obj *graphql.APISpec) (*graphql.FetchRequest, error)

FetchRequest returns a FetchRequest by a given EventSpec via dataloaders.

func (*Resolver) FetchRequestAPIDefDataLoader

func (r *Resolver) FetchRequestAPIDefDataLoader(keys []dataloader.ParamFetchRequestAPIDef) ([]*graphql.FetchRequest, []error)

FetchRequestAPIDefDataLoader is the dataloader implementation.

func (*Resolver) RefetchAPISpec

func (r *Resolver) RefetchAPISpec(ctx context.Context, apiID string) (*graphql.APISpec, error)

RefetchAPISpec refetches an APISpec for APIDefinition with given ID.

func (*Resolver) Spec

Spec Fetches API Spec for a given APIDefinition

func (*Resolver) UpdateAPIDefinition

func (r *Resolver) UpdateAPIDefinition(ctx context.Context, id string, in graphql.APIDefinitionInput) (*graphql.APIDefinition, error)

UpdateAPIDefinition updates an APIDefinition by its ID.

func (*Resolver) UpdateAPIDefinitionForApplication

func (r *Resolver) UpdateAPIDefinitionForApplication(ctx context.Context, id string, in graphql.APIDefinitionInput) (*graphql.APIDefinition, error)

UpdateAPIDefinitionForApplication updates an APIDefinition for Application without being in a Bundle

type RuntimeService

type RuntimeService interface {
	Get(ctx context.Context, id string) (*model.Runtime, error)
}

RuntimeService is responsible for the service-layer Runtime operations.

type SpecConverter

type SpecConverter interface {
	ToGraphQLAPISpec(in *model.Spec) (*graphql.APISpec, error)
	InputFromGraphQLAPISpec(in *graphql.APISpecInput) (*model.SpecInput, error)
}

SpecConverter converts Specifications between the model.Spec service-layer representation and the graphql-layer representation graphql.APISpec.

type SpecService

type SpecService interface {
	CreateByReferenceObjectID(ctx context.Context, in model.SpecInput, resourceType resource.Type, objectType model.SpecReferenceObjectType, objectID string) (string, error)
	UpdateByReferenceObjectID(ctx context.Context, id string, in model.SpecInput, resourceType resource.Type, objectType model.SpecReferenceObjectType, objectID string) error
	GetByReferenceObjectID(ctx context.Context, resourceType resource.Type, objectType model.SpecReferenceObjectType, objectID string) (*model.Spec, error)
	RefetchSpec(ctx context.Context, id string, objectType model.SpecReferenceObjectType) (*model.Spec, error)
	ListFetchRequestsByReferenceObjectIDs(ctx context.Context, tenant string, objectIDs []string, objectType model.SpecReferenceObjectType) ([]*model.FetchRequest, error)
}

SpecService is responsible for the service-layer Specification operations.

type UIDService

type UIDService interface {
	Generate() string
}

UIDService is responsible for generating GUIDs, which will be used as internal apiDefinition IDs when they are created.

type VersionConverter

type VersionConverter interface {
	ToGraphQL(in *model.Version) *graphql.Version
	InputFromGraphQL(in *graphql.VersionInput) *model.VersionInput
	FromEntity(version version.Version) *model.Version
	ToEntity(version model.Version) version.Version
}

VersionConverter converts Version between model.Version, graphql.Version and repo-layer version.Version

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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