Documentation
¶
Overview ¶
Package serviceconfig reads and parses API service config files.
Index ¶
- Variables
- func ExtractVersion(path string) string
- func FindGAPICConfig(googleapisDir, path string) (string, error)
- func FindGRPCServiceConfig(googleapisDir, path string) (string, error)
- func HasAPIPath(path, language string) bool
- func SortAPIs(apis []*config.API)
- type API
- func (api *API) HasRESTNumericEnums(language string) bool
- func (api *API) ReleaseLevel(language, version string) string
- func (api *API) RepoMetadataReleaseLevel(language, version string) string
- func (api *API) RepoMetadataTransport(language string, library *config.Library) string
- func (api *API) Transport(language string) Transport
- type Authentication
- type AuthenticationRule
- type Backend
- type BackendRule
- type Documentation
- type DocumentationRule
- type OAuthRequirements
- type Service
- type Transport
Constants ¶
This section is empty.
Variables ¶
var ( // APIs defines API paths that require explicit configurations. // APIs not in this list are implicitly allowed if // they start with "google/cloud/". // This is unmarshaled from sdk.yaml, which is embedded into the librarian // executable. The file can be edited by hand or via tooling. To change // the file in tooling: // 1. Access serviceconfig.APIs to implicitly load the existing file. // 2. Modify the data in memory. // 3. Call yaml.Write("internal/serviceconfig/sdk.yaml", serviceconfig.APIs) // within the tool. // 4. Run `go tool yamlfmt .` from the root of the repository to reformat // the file as per repository conventions. APIs = unmarshalAPIsOrPanic() )
Functions ¶
func ExtractVersion ¶ added in v0.8.4
ExtractVersion extracts the version from the given API path. It only checks the last path component.
func FindGAPICConfig ¶ added in v0.8.4
FindGAPICConfig searches for GAPIC configuration files in the given API directory. It returns the path relative to googleapisDir for use with protoc's gapic-config option. Returns empty string if no config is found. Returns an error if multiple matching files exist.
func FindGRPCServiceConfig ¶ added in v0.8.1
FindGRPCServiceConfig searches for gRPC service config files in the given API directory. It returns the path relative to googleapisDir for use with protoc's retry-config option. Returns empty string if no config is found. Returns an error if multiple matching files exist.
func HasAPIPath ¶ added in v0.8.4
HasAPIPath reports whether path matches the Path field of any API in sdk.yaml that is available for the given language.
func SortAPIs ¶ added in v0.8.4
SortAPIs sorts APIs in-place to ensure the primary version is first. The sorting logic: versioned APIs come before unversioned ones, stable versions before unstable ones, shallower paths before deeper ones, and higher versions before lower ones. This is used in languages (e.g. Java) to match existing behaviors.
Types ¶
type API ¶
type API struct {
// Path is the proto directory path in github.com/googleapis/googleapis.
// If ServiceConfig is empty, the service config is assumed to live at this
// path.
Path string `yaml:"path,omitempty"`
// Description provides the information for describing an API.
Description string `yaml:"description,omitempty"`
// Discovery is the file path to a discovery document in
// github.com/googleapis/discovery-artifact-manager.
// Used by sidekick languages (Rust, Dart) as an alternative to proto files.
Discovery string `yaml:"discovery,omitempty"`
// DocumentationURI overrides the product documentation URI from the service
// config's publishing section.
DocumentationURI string `yaml:"documentation_uri,omitempty"`
// Languages restricts which languages can generate client libraries for this API.
// Use "all" to indicate all languages can use this API.
//
// Restrictions exist for several reasons:
// - Newer languages (Rust, Dart) skip older beta versions when stable versions exist
// - Python has historical legacy APIs not available to other languages
// - Some APIs (like DIREGAPIC protos) are only used by specific languages
Languages []string `yaml:"languages,omitempty"`
// NewIssueURI overrides the new issue URI from the service config's
// publishing section.
NewIssueURI string `yaml:"new_issue_uri,omitempty"`
// SkipRESTNumericEnums lists languages that should not pass the
// rest-numeric-enums flag to the generator. The special value "all"
// skips it for every language. If empty, all languages use numeric enums.
SkipRESTNumericEnums []string `yaml:"skip_rest_numeric_enums,omitempty"`
// OpenAPI is the file path to an OpenAPI spec, currently in internal/testdata.
// This is not an official spec yet and exists only for Rust to validate OpenAPI support.
OpenAPI string `yaml:"open_api,omitempty"`
// ReleaseLevels is the release level per language.
// Map key is the language name (e.g., "python", "rust").
// Optional. If omitted, the generator default is used.
//
// TODO(https://github.com/googleapis/librarian/issues/4834): Go uses
// "alpha", "beta", and "ga" instead of "preview" and "stable". We should
// standardize release level vocabulary across languages.
ReleaseLevels map[string]string `yaml:"release_level,omitempty"`
// ShortName overrides the API short name from the service config's
// publishing section.
ShortName string `yaml:"short_name,omitempty"`
// ServiceConfig is the service config file path override.
// If empty, the service config is discovered in the directory specified by Path.
ServiceConfig string `yaml:"service_config,omitempty"`
// ServiceName is a DNS-like logical identifier for the service, such as `calendar.googleapis.com`.
ServiceName string `yaml:"service_name,omitempty"`
// Title overrides the API title from the service config.
Title string `yaml:"title,omitempty"`
// Transports defines the supported transports per language.
// Map key is the language name (e.g., "python", "rust").
// Optional. If omitted, all languages use GRPCRest by default.
Transports map[string]Transport `yaml:"transports,omitempty"`
}
API describes an API path and its availability across languages.
func Find ¶
Find looks up the service config path and title override for a given API path, and validates that the API is allowed for the specified language.
It first checks the API list for overrides and language restrictions, then searches for YAML files containing "type: google.api.Service", skipping any files ending in _gapic.yaml.
The path should be relative to googleapisDir (e.g., "google/cloud/secretmanager/v1"). Returns an API struct with Path, ServiceConfig, and Title fields populated. ServiceConfig and Title may be empty strings if not found or not configured.
The Showcase API ("schema/google/showcase/v1beta1") is a special case: it does not live under https://github.com/googleapis/googleapis. For this API only, googleapisDir should point to showcase source dir instead.
func (*API) HasRESTNumericEnums ¶ added in v0.9.0
HasRESTNumericEnums reports whether the generator should pass the rest-numeric-enums option for the given language. The default (when SkipRESTNumericEnums is empty) is true.
func (*API) ReleaseLevel ¶ added in v0.9.0
ReleaseLevel gets the release level for a given language.
If language-specific release level is not defined, it falls back to the "all" language setting, and then it is derived based on the library version and API path maturity.
func (*API) RepoMetadataReleaseLevel ¶ added in v0.9.0
RepoMetadataReleaseLevel returns the release level for repo metadata.
TODO(https://github.com/googleapis/librarian/issues/4834): delete this function once the issue is resolved. For Go, it maps the raw release level to "stable" or "preview". For other languages, it returns the raw release level.
func (*API) RepoMetadataTransport ¶ added in v0.9.1
RepoMetadataTransport returns the transport for repo metadata.
TODO(https://github.com/googleapis/librarian/issues/4854): delete once the issue is resolved. For Java, it maps the transport to "grpc", "http", or "both".
type Authentication ¶
type Authentication = serviceconfig.Authentication
Type aliases for genproto service config types.
type AuthenticationRule ¶
type AuthenticationRule = serviceconfig.AuthenticationRule
Type aliases for genproto service config types.
type BackendRule ¶
type BackendRule = serviceconfig.BackendRule
Type aliases for genproto service config types.
type Documentation ¶
type Documentation = serviceconfig.Documentation
Type aliases for genproto service config types.
type DocumentationRule ¶
type DocumentationRule = serviceconfig.DocumentationRule
Type aliases for genproto service config types.
type OAuthRequirements ¶
type OAuthRequirements = serviceconfig.OAuthRequirements
Type aliases for genproto service config types.