serviceconfig

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package serviceconfig reads and parses API service config files.

Index

Constants

View Source
const (
	// LangAll is the identifier for all languages.
	LangAll = "all"
	// LangCsharp is the language identifier for C#.
	LangCsharp = "csharp"
	// LangDart is the language identifier for Dart.
	LangDart = "dart"
	// LangGo is the language identifier for Go.
	LangGo = "go"
	// LangJava is the language identifier for Java.
	LangJava = "java"
	// LangNodejs is the language identifier for Node.js.
	LangNodejs = "nodejs"
	// LangPhp is the language identifier for PHP.
	LangPhp = "php"
	// LangPython is the language identifier for Python.
	LangPython = "python"
	// LangRuby is the language identifier for Ruby.
	LangRuby = "ruby"
	// LangRust is the language identifier for Rust.
	LangRust = "rust"
)

Variables

View Source
var APIs = []API{}/* 408 elements not displayed */

APIs defines API paths that require explicit configurations. APIs not in this list are implicitly allowed if they start with "google/cloud/".

Functions

func FindGRPCServiceConfig added in v0.8.1

func FindGRPCServiceConfig(googleapisDir, path string) (string, error)

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.

Types

type API

type API struct {
	// Description provides the information for describing an API.
	Description string

	// 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

	// DocumentationURI overrides the product documentation URI from the service
	// config's publishing section.
	DocumentationURI string

	// Languages restricts which languages can generate client libraries for this API.
	// Empty means 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

	// NewIssueURI overrides the new issue URI from the service config's
	// publishing section.
	NewIssueURI string

	// 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

	// 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

	// ShortName overrides the API short name from the service config's
	// publishing section.
	ShortName string

	// ServiceConfig is the service config file path override.
	// If empty, the service config is discovered in the directory specified by Path.
	ServiceConfig string

	// ServiceName is a DNS-like logical identifier for the service, such as `calendar.googleapis.com`.
	ServiceName string

	// Title overrides the API title from the service config.
	Title string

	// 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
}

API describes an API path and its availability across languages.

func Find

func Find(googleapisDir, path, language string) (*API, error)

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) Transport added in v0.8.1

func (api *API) Transport(language string) string

Transport gets transport for a given language.

The default value is GRPCRest, if undefined for a language.

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 Backend

type Backend = serviceconfig.Backend

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.

type Service

type Service = serviceconfig.Service

Type aliases for genproto service config types.

func Read

func Read(serviceConfigPath string) (*Service, error)

Read reads a service config from a YAML file and returns it as a Service proto. The file is parsed as YAML, converted to JSON, and then unmarshaled into a Service proto.

type Transport added in v0.8.1

type Transport string

Transport defines the supported transport protocol.

const (
	// GRPC indicates gRPC transport.
	GRPC Transport = "grpc"
	// Rest indicates REST transport.
	Rest Transport = "rest"
	// GRPCRest indicates both gRPC and REST transports.
	// This is the default if not specified.
	GRPCRest Transport = "grpc+rest"
)

Jump to

Keyboard shortcuts

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