Documentation
¶
Index ¶
- func BuildArgumentPresetJSONPathKey(operationName string, jsonPath *jsonpath.Path) string
- func ConvertToNDCSchema(config *ConvertConfig, logger *slog.Logger) (*schema.NDCHttpSchema, error)
- func NewHeaderForwardingResponseObjectType(resultType schema.Type, settings *ForwardResponseHeadersSettings) rest.ObjectType
- func NewHeadersArgumentInfo() rest.ArgumentInfo
- func ResolveConvertConfigArguments(config *ConvertConfig, configDir string, args *ConvertCommandArguments)
- func UpdateHTTPConfiguration(configurationDir string, logger *slog.Logger) (*Configuration, []NDCHttpRuntimeSchema, *schema.NDCHttpSchema, error)
- func ValidateArgumentPreset(httpSchema *rest.NDCHttpSchema, preset rest.ArgumentPresetConfig, ...) (*jsonpath.Path, map[string]schema.TypeRepresentation, error)
- type ConcurrencySettings
- type ConfigItem
- type ConfigValidator
- type Configuration
- type ConvertCommandArguments
- type ConvertConfig
- type ForwardHeadersSettings
- type ForwardResponseHeadersSettings
- type NDCHttpRuntimeSchema
- func BuildSchemaFromConfig(config *Configuration, configDir string, logger *slog.Logger) ([]NDCHttpRuntimeSchema, map[string][]string)
- func MergeNDCHttpSchemas(config *Configuration, schemas []NDCHttpRuntimeSchema) (*rest.NDCHttpSchema, []NDCHttpRuntimeSchema, map[string][]string)
- func ReadSchemaOutputFile(configDir string, filePath string, logger *slog.Logger) ([]NDCHttpRuntimeSchema, error)
- type RawRuntimeSettings
- type RuntimeSettings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildArgumentPresetJSONPathKey ¶
BuildArgumentPresetJSONPathKey builds the argument preset key.
func ConvertToNDCSchema ¶
func ConvertToNDCSchema(config *ConvertConfig, logger *slog.Logger) (*schema.NDCHttpSchema, error)
ConvertToNDCSchema converts to NDC HTTP schema from config.
func NewHeaderForwardingResponseObjectType ¶
func NewHeaderForwardingResponseObjectType( resultType schema.Type, settings *ForwardResponseHeadersSettings, ) rest.ObjectType
NewHeaderForwardingResponseObjectType creates a new type for header forwarding response.
func NewHeadersArgumentInfo ¶
func NewHeadersArgumentInfo() rest.ArgumentInfo
NewHeadersArgumentInfo creates a new forwarding headers argument information.
func ResolveConvertConfigArguments ¶
func ResolveConvertConfigArguments( config *ConvertConfig, configDir string, args *ConvertCommandArguments, )
ResolveConvertConfigArguments resolves convert config arguments.
func UpdateHTTPConfiguration ¶
func UpdateHTTPConfiguration( configurationDir string, logger *slog.Logger, ) (*Configuration, []NDCHttpRuntimeSchema, *schema.NDCHttpSchema, error)
UpdateHTTPConfiguration validates and updates the HTTP configuration.
func ValidateArgumentPreset ¶
func ValidateArgumentPreset( httpSchema *rest.NDCHttpSchema, preset rest.ArgumentPresetConfig, isGlobal bool, ) (*jsonpath.Path, map[string]schema.TypeRepresentation, error)
ValidateArgumentPreset validates the argument preset.
Types ¶
type ConcurrencySettings ¶
type ConcurrencySettings struct {
// Maximum number of concurrent executions if there are many query variables.
Query uint `json:"query" yaml:"query"`
// Maximum number of concurrent executions if there are many mutation operations.
Mutation uint `json:"mutation" yaml:"mutation"`
// Maximum number of concurrent requests to remote servers (distribution mode).
HTTP uint `json:"http" yaml:"http"`
}
ConcurrencySettings represent settings for concurrent webhook executions to remote servers.
type ConfigItem ¶
type ConfigItem struct {
ConvertConfig `yaml:",inline"`
// Distributed enables distributed schema
Distributed *bool `json:"distributed,omitempty" yaml:"distributed,omitempty"`
// configure the request timeout in seconds.
Timeout *goenvconf.EnvInt `json:"timeout,omitempty" yaml:"timeout,omitempty" mapstructure:"timeout"`
Retry *exhttp.RetryPolicySetting `json:"retry,omitempty" yaml:"retry,omitempty" mapstructure:"retry"`
}
ConfigItem extends the ConvertConfig with advanced options.
func (ConfigItem) GetRuntimeSettings ¶
func (ci ConfigItem) GetRuntimeSettings() (*rest.RuntimeSettings, error)
GetRuntimeSettings validate and get runtime settings.
func (ConfigItem) IsDistributed ¶
func (ci ConfigItem) IsDistributed() bool
IsDistributed checks if the distributed option is enabled.
type ConfigValidator ¶
type ConfigValidator struct {
// contains filtered or unexported fields
}
ConfigValidator manages the validation and status of upstreams.
func ValidateConfiguration ¶
func ValidateConfiguration( config *Configuration, contextPath string, schemas []NDCHttpRuntimeSchema, mergedSchema *schema.NDCHttpSchema, logger *slog.Logger, noColor bool, ) (*ConfigValidator, error)
ValidateConfiguration evaluates, validates the configuration and suggests required actions to make the connector working.
func (*ConfigValidator) HasError ¶
func (cv *ConfigValidator) HasError() bool
HasError checks if the configuration has error.
func (*ConfigValidator) IsOk ¶
func (cv *ConfigValidator) IsOk() bool
IsOk checks if the configuration has nothing to be complained.
func (*ConfigValidator) Render ¶
func (cv *ConfigValidator) Render(w io.Writer)
Render renders the help text.
func (*ConfigValidator) WriteReadme ¶
func (cv *ConfigValidator) WriteReadme() error
WriteReadme writes a README.md file for available configurations and instructions.
type Configuration ¶
type Configuration struct {
Output string `json:"output,omitempty" yaml:"output,omitempty"`
// Require strict validation
Strict bool `json:"strict" yaml:"strict"`
Runtime RawRuntimeSettings `json:"runtime,omitempty" yaml:"runtime,omitempty"`
ForwardHeaders ForwardHeadersSettings `json:"forwardHeaders,omitempty" yaml:"forwardHeaders,omitempty"`
Concurrency ConcurrencySettings `json:"concurrency,omitempty" yaml:"concurrency,omitempty"`
Files []ConfigItem `json:"files" yaml:"files"`
}
Configuration contains required settings for the connector.
func ReadConfigurationFile ¶
func ReadConfigurationFile(configurationDir string) (*Configuration, error)
ReadConfigurationFile reads and decodes the configuration file from the configuration directory.
type ConvertCommandArguments ¶
type ConvertCommandArguments struct {
File string `` /* 140-byte string literal not displayed */
Config string `` /* 140-byte string literal not displayed */
Output string `` /* 140-byte string literal not displayed */
Spec string `help:"The API specification of the file, is one of oas3 (openapi3), oas2 (openapi2)"`
Format string `` /* 155-byte string literal not displayed */
Strict bool `` /* 156-byte string literal not displayed */
NoDeprecation bool `` /* 156-byte string literal not displayed */
Pure bool `` /* 156-byte string literal not displayed */
Prefix string `help:"Add a prefix to the function and procedure names"`
TrimPrefix string `help:"Trim the prefix in URL, e.g. /v1"`
EnvPrefix string `help:"The environment variable prefix for security values, e.g. PET_STORE"`
MethodAlias map[string]string `help:"Alias names for HTTP method. Used for prefix renaming, e.g. getUsers, postUser"`
AllowedContentTypes []string `help:"Allowed content types. All content types are allowed by default"`
PatchBefore []string `help:"Patch files to be applied into the input file before converting"`
PatchAfter []string `help:"Patch files to be applied into the input file after converting"`
}
ConvertCommandArguments represent available command arguments for the convert command.
type ConvertConfig ¶
type ConvertConfig struct {
// File path needs to be converted
File string `json:"file" jsonschema:"required" yaml:"file"`
// The API specification of the file, is one of oas3 (openapi3), oas2 (openapi2)
Spec rest.SchemaSpecType `json:"spec,omitempty" jsonschema:"default=oas3" yaml:"spec"`
// Alias names for HTTP method. Used for prefix renaming, e.g. getUsers, postUser
MethodAlias map[string]string `json:"methodAlias,omitempty" yaml:"methodAlias"`
// Add a prefix to the function and procedure names
Prefix string `json:"prefix,omitempty" yaml:"prefix"`
// Trim the prefix in URL, e.g. /v1
TrimPrefix string `json:"trimPrefix,omitempty" yaml:"trimPrefix"`
// The environment variable prefix for security values, e.g. PET_STORE
EnvPrefix string `json:"envPrefix,omitempty" yaml:"envPrefix"`
// Return the pure NDC schema only
Pure bool `json:"pure,omitempty" yaml:"pure"`
// Ignore deprecated fields.
NoDeprecation bool `json:"noDeprecation,omitempty" yaml:"noDeprecation"`
// Patch files to be applied into the input file before converting
PatchBefore []restUtils.PatchConfig `json:"patchBefore,omitempty" yaml:"patchBefore"`
// Patch files to be applied into the input file after converting
PatchAfter []restUtils.PatchConfig `json:"patchAfter,omitempty" yaml:"patchAfter"`
// Allowed content types. All content types are allowed by default
AllowedContentTypes []string `json:"allowedContentTypes,omitempty" yaml:"allowedContentTypes"`
// The location where the ndc schema file will be generated. Print to stdout if not set
Output string `json:"output,omitempty" yaml:"output,omitempty"`
}
ConvertConfig represents the content of convert config file.
type ForwardHeadersSettings ¶
type ForwardHeadersSettings struct {
// Enable headers forwarding.
Enabled bool `json:"enabled" yaml:"enabled"`
// The argument field name to be added for headers forwarding.
ArgumentField *string `json:"argumentField" yaml:"argumentField" jsonschema:"oneof_type=string;null,pattern=^[a-zA-Z_][a-zA-Z0-9_]+$"`
// HTTP response headers to be forwarded from a data connector to the client.
ResponseHeaders *ForwardResponseHeadersSettings `json:"responseHeaders" yaml:"responseHeaders" jsonschema:"nullable"`
}
ForwardHeadersSettings hold settings of header forwarding from and to Hasura engine.
func (*ForwardHeadersSettings) UnmarshalJSON ¶
func (j *ForwardHeadersSettings) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler.
type ForwardResponseHeadersSettings ¶
type ForwardResponseHeadersSettings struct {
// Name of the field in the NDC function/procedure's result which contains the response headers.
HeadersField string `json:"headersField" jsonschema:"pattern=^[a-zA-Z_][a-zA-Z0-9_]+$" yaml:"headersField"`
// Name of the field in the NDC function/procedure's result which contains the result.
ResultField string `json:"resultField" jsonschema:"pattern=^[a-zA-Z_][a-zA-Z0-9_]+$" yaml:"resultField"`
// List of actual HTTP response headers from the data connector to be set as response headers. Returns all headers if empty.
ForwardHeaders []string `json:"forwardHeaders" yaml:"forwardHeaders"`
}
ForwardResponseHeadersSettings hold settings of header forwarding from http response to Hasura engine.
func (ForwardResponseHeadersSettings) Validate ¶
func (j ForwardResponseHeadersSettings) Validate() error
Validate checks if the setting is valid.
type NDCHttpRuntimeSchema ¶
type NDCHttpRuntimeSchema struct {
*rest.NDCHttpSchema
Name string `json:"name" yaml:"name"`
Runtime rest.RuntimeSettings `json:"-" yaml:"-"`
}
NDCHttpRuntimeSchema wraps NDCHttpSchema with runtime settings.
func BuildSchemaFromConfig ¶
func BuildSchemaFromConfig( config *Configuration, configDir string, logger *slog.Logger, ) ([]NDCHttpRuntimeSchema, map[string][]string)
BuildSchemaFromConfig build NDC HTTP schema from the configuration.
func MergeNDCHttpSchemas ¶
func MergeNDCHttpSchemas( config *Configuration, schemas []NDCHttpRuntimeSchema, ) (*rest.NDCHttpSchema, []NDCHttpRuntimeSchema, map[string][]string)
MergeNDCHttpSchemas merge HTTP schemas into a single schema object.
func ReadSchemaOutputFile ¶
func ReadSchemaOutputFile( configDir string, filePath string, logger *slog.Logger, ) ([]NDCHttpRuntimeSchema, error)
ReadSchemaOutputFile reads the schema output file in disk.
type RawRuntimeSettings ¶
type RawRuntimeSettings struct {
// Enable the sendHttpRequest operation.
EnableRawRequest *bool `json:"enableRawRequest,omitempty" yaml:"enableRawRequest,omitempty"`
// Treat the JSON scalar as a json string
StringifyJSON *goenvconf.EnvBool `json:"stringifyJson,omitempty" yaml:"stringifyJson,omitempty"`
}
RawRuntimeSettings hold raw runtime settings.
func (RawRuntimeSettings) Validate ¶
func (rs RawRuntimeSettings) Validate() (*RuntimeSettings, error)
Validate validates and returns validated settings.
type RuntimeSettings ¶
type RuntimeSettings struct {
// Enable the sendHttpRequest operation.
EnableRawRequest bool `json:"enableRawRequest,omitempty" yaml:"enableRawRequest,omitempty"`
// Treat the JSON scalar as a json string
StringifyJSON bool `json:"stringifyJson,omitempty" yaml:"stringifyJson,omitempty"`
}
RuntimeSettings hold optional runtime settings.