Documentation
¶
Index ¶
- Variables
- type EncryptionKey
- type Handler
- func (h *Handler) ChaosOperations() []string
- func (h *Handler) ChaosRegions() []string
- func (h *Handler) ChaosServiceName() string
- 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) Snapshot(ctx context.Context) []byte
- type InMemoryBackend
- func (b *InMemoryBackend) AccountID() string
- func (b *InMemoryBackend) CreateParallelData(name, description string, cfg *ParallelDataConfig, encKey *EncryptionKey, ...) (*ParallelData, error)
- func (b *InMemoryBackend) DeleteParallelData(name string) (*ParallelData, error)
- func (b *InMemoryBackend) DeleteTerminology(name string) error
- func (b *InMemoryBackend) DescribeTextTranslationJob(jobID string) (*TranslationJob, error)
- func (b *InMemoryBackend) GetParallelData(name string) (*ParallelData, error)
- func (b *InMemoryBackend) GetTerminology(name string) (*Terminology, error)
- func (b *InMemoryBackend) ImportTerminology(name, description string, data *TerminologyData, encKey *EncryptionKey, ...) (*Terminology, error)
- func (b *InMemoryBackend) ListParallelData(maxResults int, nextToken string) ([]*ParallelData, string)
- func (b *InMemoryBackend) ListTagsForResource(resourceARN string) (map[string]string, error)
- func (b *InMemoryBackend) ListTerminologies(maxResults int, nextToken string) ([]*Terminology, string)
- func (b *InMemoryBackend) ListTextTranslationJobs(statusFilter string, maxResults int, nextToken string) ([]*TranslationJob, string)
- func (b *InMemoryBackend) LookupTerminologies(names []string) []*Terminology
- func (b *InMemoryBackend) Region() string
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) StartTextTranslationJob(jobName, dataAccessRoleARN, sourceLang string, ...) (*TranslationJob, error)
- func (b *InMemoryBackend) StopTextTranslationJob(jobID string) (*TranslationJob, error)
- func (b *InMemoryBackend) TagResource(resourceARN string, newTags map[string]string) error
- func (b *InMemoryBackend) UntagResource(resourceARN string, keys []string) error
- func (b *InMemoryBackend) UpdateParallelData(name, description string, cfg *ParallelDataConfig) (*ParallelData, error)
- type ParallelData
- type ParallelDataConfig
- type Provider
- type Terminology
- type TerminologyData
- type TranslationJob
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned when a requested resource is absent. ErrNotFound = errors.New("ResourceNotFoundException") // ErrConflict is returned when a resource already exists. ErrConflict = errors.New("ResourceInUseException") // ErrValidation is returned for invalid request parameters. ErrValidation = errors.New("InvalidRequestException") )
var ErrNilAppContext = errors.New("AppContext is required")
ErrNilAppContext is returned when Provider.Init is called with a nil AppContext.
Functions ¶
This section is empty.
Types ¶
type EncryptionKey ¶
EncryptionKey holds optional KMS encryption key details.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
// contains filtered or unexported fields
}
Handler serves Amazon Translate JSON operations.
func NewHandler ¶
func NewHandler(backend *InMemoryBackend) *Handler
NewHandler creates a Translate handler backed by in-memory state.
func (*Handler) ChaosOperations ¶
ChaosOperations returns fault-injectable operations.
func (*Handler) ChaosRegions ¶
ChaosRegions returns configured service region.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns service key for fault matching.
func (*Handler) ExtractOperation ¶
ExtractOperation returns the operation name from the request target.
func (*Handler) ExtractResource ¶
ExtractResource retrieves the primary resource name.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations returns all implemented operation names.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo HTTP handler.
func (*Handler) MatchPriority ¶
MatchPriority returns header matching priority.
func (*Handler) RouteMatcher ¶
RouteMatcher matches Translate X-Amz-Target headers.
func (*Handler) Snapshot ¶
Snapshot implements persistence.Persistable by delegating to the backend. Handler previously had no Snapshot/Restore of its own -- and neither did InMemoryBackend -- so cli.go's generic setupPersistence (which type-asserts the registered service.Registerable, i.e. the Handler, for a Snapshot/Restore pair) never picked Translate up at all: dead wiring, with no persistence underneath it either. This delegation (matching the codecommit/polly/cleanrooms pattern) is what wires Translate into persistence for the first time.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend stores Translate state for concurrent requests.
terminologies, parallelData, and jobs are *store.Table[T]-backed (see store_setup.go and pkgs/store's package doc); tags remains a plain map since its values are map[string]string, not *T, so there is nothing for store.Table to key on.
func NewInMemoryBackend ¶
func NewInMemoryBackend(accountID, region string) *InMemoryBackend
NewInMemoryBackend returns an initialized InMemoryBackend.
func (*InMemoryBackend) AccountID ¶
func (b *InMemoryBackend) AccountID() string
AccountID returns the configured account ID.
func (*InMemoryBackend) CreateParallelData ¶
func (b *InMemoryBackend) CreateParallelData( name, description string, cfg *ParallelDataConfig, encKey *EncryptionKey, tags map[string]string, ) (*ParallelData, error)
CreateParallelData creates a new parallel data resource.
func (*InMemoryBackend) DeleteParallelData ¶
func (b *InMemoryBackend) DeleteParallelData(name string) (*ParallelData, error)
DeleteParallelData removes a parallel data resource by name.
func (*InMemoryBackend) DeleteTerminology ¶
func (b *InMemoryBackend) DeleteTerminology(name string) error
DeleteTerminology removes a terminology by name.
func (*InMemoryBackend) DescribeTextTranslationJob ¶
func (b *InMemoryBackend) DescribeTextTranslationJob(jobID string) (*TranslationJob, error)
DescribeTextTranslationJob retrieves a translation job and advances it one step through its lifecycle, matching services/comprehend's DescribeJob pattern: real batch translation jobs move from SUBMITTED to IN_PROGRESS to a terminal state (COMPLETED/FAILED, or STOPPED once stop was requested) asynchronously. Without this, a job started via StartTextTranslationJob would sit at its initial status forever and SDK callers polling DescribeTextTranslationJob (the documented way to track job progress) would never observe completion.
func (*InMemoryBackend) GetParallelData ¶
func (b *InMemoryBackend) GetParallelData(name string) (*ParallelData, error)
GetParallelData retrieves a parallel data resource by name.
func (*InMemoryBackend) GetTerminology ¶
func (b *InMemoryBackend) GetTerminology(name string) (*Terminology, error)
GetTerminology retrieves a terminology by name.
func (*InMemoryBackend) ImportTerminology ¶
func (b *InMemoryBackend) ImportTerminology( name, description string, data *TerminologyData, encKey *EncryptionKey, tags map[string]string, ) (*Terminology, error)
ImportTerminology creates or overwrites a custom terminology.
func (*InMemoryBackend) ListParallelData ¶
func (b *InMemoryBackend) ListParallelData(maxResults int, nextToken string) ([]*ParallelData, string)
ListParallelData returns a paginated list of parallel data resources.
func (*InMemoryBackend) ListTagsForResource ¶
func (b *InMemoryBackend) ListTagsForResource(resourceARN string) (map[string]string, error)
ListTagsForResource returns tags for a resource.
func (*InMemoryBackend) ListTerminologies ¶
func (b *InMemoryBackend) ListTerminologies(maxResults int, nextToken string) ([]*Terminology, string)
ListTerminologies returns a paginated list of terminologies.
func (*InMemoryBackend) ListTextTranslationJobs ¶
func (b *InMemoryBackend) ListTextTranslationJobs( statusFilter string, maxResults int, nextToken string, ) ([]*TranslationJob, string)
ListTextTranslationJobs returns a paginated list of translation jobs.
func (*InMemoryBackend) LookupTerminologies ¶
func (b *InMemoryBackend) LookupTerminologies(names []string) []*Terminology
LookupTerminologies returns terminology entries for the given names (missing names skipped).
func (*InMemoryBackend) Region ¶
func (b *InMemoryBackend) Region() string
Region returns the configured region.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore deserializes backend state from a snapshot. It implements persistence.Persistable.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serializes the backend state to JSON. It implements persistence.Persistable.
func (*InMemoryBackend) StartTextTranslationJob ¶
func (b *InMemoryBackend) StartTextTranslationJob( jobName, dataAccessRoleARN, sourceLang string, targetLangs, terminologyNames, parallelDataNames []string, inputCfg, outputCfg, settings map[string]any, tags map[string]string, ) (*TranslationJob, error)
StartTextTranslationJob creates a new async translation job.
func (*InMemoryBackend) StopTextTranslationJob ¶
func (b *InMemoryBackend) StopTextTranslationJob(jobID string) (*TranslationJob, error)
StopTextTranslationJob requests stop of a translation job.
func (*InMemoryBackend) TagResource ¶
func (b *InMemoryBackend) TagResource(resourceARN string, newTags map[string]string) error
TagResource adds or replaces tags on a resource.
func (*InMemoryBackend) UntagResource ¶
func (b *InMemoryBackend) UntagResource(resourceARN string, keys []string) error
UntagResource removes specific tags from a resource.
func (*InMemoryBackend) UpdateParallelData ¶
func (b *InMemoryBackend) UpdateParallelData( name, description string, cfg *ParallelDataConfig, ) (*ParallelData, error)
UpdateParallelData updates an existing parallel data resource.
type ParallelData ¶
type ParallelData struct {
ParallelDataConfig *ParallelDataConfig
EncryptionKey *EncryptionKey
Tags map[string]string
CreatedAt time.Time
LastUpdatedAt time.Time
ARN string
Name string
Description string
SourceLanguage string
Status string
TargetLanguages []string
}
ParallelData stores a parallel data resource.
type ParallelDataConfig ¶
ParallelDataConfig holds S3 data config for parallel data.
type Provider ¶
type Provider struct{}
Provider implements service.Provider for the Translate service.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init initializes the Translate backend and handler.
type Terminology ¶
type Terminology struct {
TerminologyData *TerminologyData
EncryptionKey *EncryptionKey
Tags map[string]string
CreatedAt time.Time
LastUpdatedAt time.Time
ARN string
Name string
Description string
SourceLanguage string
Directionality string
Format string
TargetLanguages []string
SizeBytes int
TermCount int
}
Terminology stores a custom terminology resource.
type TerminologyData ¶
TerminologyData holds imported terminology file bytes.
type TranslationJob ¶
type TranslationJob struct {
InputDataConfig map[string]any
OutputDataConfig map[string]any
Settings map[string]any
Tags map[string]string
SubmittedAt time.Time
EndAt time.Time
JobID string
JobName string
JobStatus string
DataAccessRoleARN string
SourceLanguage string
Message string
TargetLanguages []string
TerminologyNames []string
ParallelDataNames []string
// contains filtered or unexported fields
}
TranslationJob stores an async translation job.