Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beccasaurus/f5517d607789bf66ff21ac90b09eceee to your computer and use it in GitHub Desktop.
Save beccasaurus/f5517d607789bf66ff21ac90b09eceee to your computer and use it in GitHub Desktop.
Allowing Standalone Samples to be defined in separate YAML files (GAPIC Generator Monolith)

The GAPIC-generator "monolith" should support loading samples for generation from multiple YAML files.

Ideally we can simplify the YAML a little tiny bit when we do this.

Here are my thoughts.

Current Sample Config (v1) .yaml

and

Proposed Sample Config (v1) .yaml

type: com.google.api.codegen.ConfigProto
config_schema_version: 1.0.0
# A list of API interface configurations.
interfaces:
# The fully qualified name of the API interface.
- name: google.cloud.talent.v4beta1.CompanyService
methods:
- name: CreateCompany
samples:
standalone:
- value_sets: [job_search_create_company]
region_tag: job_search_create_company
sample_value_sets:
- id: job_search_create_company
description: Create Company
parameters:
defaults:
- parent%project="Your Google Cloud Project ID"
attributes:
- parameter: parent%project
sample_argument_name: project_id
on_success:
- print: ["Created Company"]
# Whatever type and schema version you want, if any.
# A list of API interface configurations.
interfaces:
# The fully qualified name of the API interface.
- name: google.cloud.talent.v4beta1.CompanyService
methods:
- name: CreateCompany
# This is where `samples:` was with `standalone:` etc
# It is gone now. Instead, we simply have a list of `samples:`
# below (which is really just `sample_value_sets:` renamed)
samples:
- id: job_search_create_company # <=== The sample ID is used as the region tag
description: Create Company
calling_forms: [".*"] # <=== We will normally not have this, but it needs to go somewhere :)
parameters:
defaults:
- parent%project="Your Google Cloud Project ID"
attributes:
- parameter: parent%project
sample_argument_name: project_id
on_success:
- print: ["Created Company"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment