一个展示生成的 API 客户端 (GAPIC) 功能以及 Google 使用的常见 API 模式的 API。
GAPIC Showcase is an API that demonstrates Generated API Client (GAPIC) features and common API patterns used by Google. It follows the Cloud APIs design guide. This project provides a server and client implementation of the API that can be run locally over both gRPC and HTTP/JSON.
The GAPIC Showcase CLI can be installed using three different mechanisms: pulling a docker image from Google Container Registry, downloading the compiled binary from our our releases page, or simply by installing from source using go.
NOTE: The "latest" Docker image is currently stale. We expect to update it in the near future. (We're upgrading our processes.)
…$ export GAPIC_SHOWCASE_VERSION=0.36.1 # use the current version here
$ export OS=linux
$ export ARCH=amd64
$ curl -L https://github.com/googleapis/gapic-showcase/releases/download/v${GAPIC_SHOWCASE_VERSION}/gapic-showcase-${GAPIC_SHOWCASE_VERSION}-${OS}-${ARCH}.tar.gz | sudo tar -zx --directory /usr/local/bin/
$ gapic-showcase --help
...$ go install github.com/googleapis/gapic-showcase/cmd/gapic-showcase@latest
$ PATH=$PATH:`go env GOPATH`/bin
$ gapic-showcase --help
...* Bear in mind this is not a versioned installation so no versioning guarantees hold using this installation method.
The schema of GAPIC Showcase API can be found in schema/google/showcase/v1beta1 Its dependencies can be found in the googleapis/googleapis submodule.
To set up this repository for local development, follow these steps:
Install protoc from the protobuf release page
or your OS package manager. This API utilizes proto3_optional, thus v3.12.0
is the minimum supported version of protoc.
Initialize the googleapis submodule:
git submodule update --init --recursiveInstall Go
sudo apt-get install golangClone this repository.
Set up Go protobuf tools:
go install github.com/golang/protobuf/protoc-gen-go@latest
go install github.com/googleapis/gapic-generator-go/cmd/protoc-gen-go_gapic@latestExport the Go binaries to your environment path.
PATH=$PATH:`go env GOPATH`/binTo compile the Showcase binary, as well as associated development utilities in this repository, run the following after you make changes:
go install ./...If there are any changes to the protobuf files, the generated support code must be regenerated. This can be done by executing the following command:
go install ./util/cmd/... && go run ./util/cmd/compile_protosIf successful, you may see changes in the following directories:
server/genprotoserver/genrestclient/cmd/gapic-showcaseThen, update the binaries:
go install ./...This quick start guide will show you how to start the server and make a request to it.
Run the showcase server to allow requests to be sent to it. This opens port :7469 to send and receive requests.
$ gapic-showcase run
> 2018/09/19 02:13:09 Showcase listening on port: :7469Open a new terminal window and make a request to the server.
$ gapic-showcase \
identity \ # Service name
create-user \ # Message name
--user.display_name Rumble \ # Request fields
--user.email [email protected]
> name:"users/0" display_name:"Rumble" email:"[email protected]" create_time: update_time:Note: You can make requests to this server from your own client but an insecure channel must be used since the server does not implement auth. Client library generators with Showcase-based integration tests need to provide the insecure channel to the client library in the tests.
const grpc = require('@grpc/grpc-js');
const showcase = require('showcase');
const client = new showcase.EchoClient({ grpc, sslCreds: grpc.credentials.createInsecure() });package main
import (
"context"
"fmt"
"log"
"github.com/googleapis/gapic-showcase/client"
"google.golang.org/api/option"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
func main() {
conn, err := grpc.Dial("localhost:7469", grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatal(err)
}
opt := option.WithGRPCConn(conn)
ctx := context.Background()
_, err = client.NewEchoClient(ctx, opt)
if err != nil {
log.Fatal(err)
}
}EchoSettings echoSettings = EchoSettings.newBuilder()
.setCredentialsProvider(NoCredentialsProvider.create())
.setTransportChannelProvider(
InstantiatingGrpcChannelProvider.newBuilder()
.setChannelConfigurator(
new ApiFunction() {
@Override
public ManagedChannelBuilder apply(ManagedChannelBuilder input) {
return input.usePlaintext();
}
})
.build())
.build();
EchoClient echoClient = EchoClient.create(echoSettings);EchoSettings echoSettings = EchoSettings.newHttpJsonBuilder()
.setTransportChannelProvider(EchoSettings.defaultHttpJsonTransportProviderBuilder()
.setHttpTransport(new NetHttpTransport.Builder().doNotValidateCertificate().build())
.setEndpoint("http://localhost:7469")
.build())
.build();
EchoClient echoClient = EchoClient.create(echoSettings);…GAPIC Showcase releases three main artifacts, a CLI tool, the gapic-showcase service protobuf files staged alongside its dependencies, and a protocol buffer descriptor set compiled from the gapic-showcase service protos.
Check out our releases page to see our released artifacts.
GAPIC Showcase follows semantic versioning. All artifacts that are released for a certain version are guaranteed to be compatible with one another.
Releases are made by release-please based on the contents of the Conventional Commits made to the project. Assets are then uploaded to the releases that are created.
GAPIC Showcase is supported for go versions 1.16 and later.
This API is not publicly served.
This is not an official Google product.
暂无开放 Issues,或尚未同步最近议题。