Back to docs
GCP

SDK & CLI usage — per service

GCP Swagger ›All consoles ›

Point unmodified GCP tools at this simulator at http://192.168.252.7:9000 — no real credentials needed. Snippets are copy-paste ready (your live host is filled in) and mirror the conformance harness in tests/conformance/.

Cloud StorageCompute EngineCloud SQL (Admin)Pub/SubFirestoreCloud FunctionsIAMVPC Network
Connect (one-time setup)

gcloud / gsutil — point at the simulator

bash
gcloud config set auth/disable_credentials true
gcloud config set core/project gcp-dev
# REST services — set the override for the one you use:
export CLOUDSDK_API_ENDPOINT_OVERRIDES_STORAGE="http://192.168.252.7:9000/storage/v1/"
export CLOUDSDK_API_ENDPOINT_OVERRIDES_COMPUTE="http://192.168.252.7:9000/compute/v1/"
export CLOUDSDK_API_ENDPOINT_OVERRIDES_SQLADMIN="http://192.168.252.7:9000/sql/v1beta4/"
export CLOUDSDK_API_ENDPOINT_OVERRIDES_CLOUDFUNCTIONS="http://192.168.252.7:9000/v1/"
export CLOUDSDK_API_ENDPOINT_OVERRIDES_IAM="http://192.168.252.7:9000/v1/"
# gRPC services use the bundled emulators (separate ports):
export STORAGE_EMULATOR_HOST="192.168.252.7:9000"
export PUBSUB_EMULATOR_HOST="192.168.252.7:8085"
export FIRESTORE_EMULATOR_HOST="192.168.252.7:8080" 

Java — shared auth

java
// libraries-bom 26.43.0. gapic clients (Storage/PubSub/Firestore): NoCredentials + setHost
// or *_EMULATOR_HOST. Apiary REST clients (Compute/SQL/Functions/IAM): setRootUrl("http://192.168.252.7:9000/").
HttpTransport transport = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory json = GsonFactory.getDefaultInstance();

Go — shared auth

go
import "google.golang.org/api/option"
var noAuth = option.WithoutAuthentication()   // for REST clients (Compute/SQL/Functions/IAM)
// Storage/PubSub/Firestore: set *_EMULATOR_HOST instead of an endpoint.
Per-service examples (CLI · Java · Go)

Cloud Storage

CLI

bash
export STORAGE_EMULATOR_HOST="192.168.252.7:9000"
gcloud storage buckets create gs://demo
gcloud storage cp ./f.txt gs://demo/f.txt
gcloud storage ls gs://demo

Java

java
Storage st = StorageOptions.newBuilder().setHost("http://192.168.252.7:9000")
    .setProjectId("gcp-dev").setCredentials(NoCredentials.getInstance()).build().getService();
st.create(BucketInfo.of("demo"));
st.create(BlobInfo.newBuilder("demo", "f.txt").build(), "hello".getBytes());

Go

go
// STORAGE_EMULATOR_HOST=192.168.252.7:9000
c, _ := storage.NewClient(ctx)
c.Bucket("demo").Create(ctx, "gcp-dev", nil)
w := c.Bucket("demo").Object("f.txt").NewWriter(ctx); w.Write([]byte("hello")); w.Close()

Compute Engine

CLI

bash
gcloud compute instances create vm1 --zone=us-central1-a --machine-type=e2-micro
gcloud compute instances list --zones=us-central1-a

Java

java
Compute compute = new Compute.Builder(transport, json, null)
    .setRootUrl("http://192.168.252.7:9000/").setApplicationName("cl").build();
compute.instances().list("gcp-dev", "us-central1-a").execute();

Go

go
csvc, _ := compute.NewService(ctx, noAuth, option.WithEndpoint("http://192.168.252.7:9000/compute/v1/"))
list, _ := csvc.Instances.List("gcp-dev", "us-central1-a").Do()

Cloud SQL (Admin)

CLI

bash
gcloud sql instances create db1 --database-version=POSTGRES_16 --tier=db-f1-micro --region=us-central1
gcloud sql instances list

Java

java
SQLAdmin sql = new SQLAdmin.Builder(transport, json, null)
    .setRootUrl("http://192.168.252.7:9000/").setApplicationName("cl").build();
sql.instances().list("gcp-dev").execute();

Go

go
ssvc, _ := sqladmin.NewService(ctx, noAuth, option.WithEndpoint("http://192.168.252.7:9000/"))
ssvc.Instances.List("gcp-dev").Do()

Pub/Sub

CLI

bash
export PUBSUB_EMULATOR_HOST="192.168.252.7:8085"
gcloud pubsub topics create demo-topic
gcloud pubsub subscriptions create demo-sub --topic=demo-topic

Java

java
// PUBSUB_EMULATOR_HOST=192.168.252.7:8085
TopicAdminClient admin = TopicAdminClient.create();
admin.createTopic(TopicName.of("gcp-dev", "demo-topic"));
Publisher pub = Publisher.newBuilder(TopicName.of("gcp-dev", "demo-topic")).build();
pub.publish(PubsubMessage.newBuilder().setData(ByteString.copyFromUtf8("hi")).build());

Go

go
// PUBSUB_EMULATOR_HOST=192.168.252.7:8085
c, _ := pubsub.NewClient(ctx, "gcp-dev")
t, _ := c.CreateTopic(ctx, "demo-topic")
t.Publish(ctx, &pubsub.Message{Data: []byte("hi")}).Get(ctx)

Firestore

CLI

bash
export FIRESTORE_EMULATOR_HOST="192.168.252.7:8080"
# Document CRUD is via the client libraries (gcloud has no doc-level CRUD).

Java

java
// FIRESTORE_EMULATOR_HOST=192.168.252.7:8080
Firestore db = FirestoreOptions.getDefaultInstance().getService();
db.collection("users").document("alice").set(Map.of("name", "Alice"));

Go

go
// FIRESTORE_EMULATOR_HOST=192.168.252.7:8080
c, _ := firestore.NewClient(ctx, "gcp-dev")
c.Collection("users").Doc("alice").Set(ctx, map[string]any{"name": "Alice"})

Cloud Functions

CLI

bash
gcloud functions list --region=us-central1

Java

java
CloudFunctions fn = new CloudFunctions.Builder(transport, json, null)
    .setRootUrl("http://192.168.252.7:9000/").setApplicationName("cl").build();
fn.projects().locations().functions().list("projects/gcp-dev/locations/us-central1").execute();

Go

go
fsvc, _ := cloudfunctions.NewService(ctx, noAuth, option.WithEndpoint("http://192.168.252.7:9000/"))
fsvc.Projects.Locations.Functions.List("projects/gcp-dev/locations/us-central1").Do()

IAM

CLI

bash
gcloud iam service-accounts create demo-sa
gcloud iam service-accounts list

Java

java
Iam iam = new Iam.Builder(transport, json, null)
    .setRootUrl("http://192.168.252.7:9000/").setApplicationName("cl").build();
iam.projects().serviceAccounts().list("projects/gcp-dev").execute();

Go

go
isvc, _ := iam.NewService(ctx, noAuth, option.WithEndpoint("http://192.168.252.7:9000/"))
isvc.Projects.ServiceAccounts.List("projects/gcp-dev").Do()

VPC Network

CLI

bash
gcloud compute networks create demo-vpc --subnet-mode=custom
gcloud compute networks list
gcloud compute firewall-rules list

Java

java
// same Apiary Compute client as Compute Engine
compute.networks().list("gcp-dev").execute();
compute.firewalls().list("gcp-dev").execute();

Go

go
csvc.Networks.List("gcp-dev").Do()
csvc.Firewalls.List("gcp-dev").Do()