Skip to main content

Module analysis

Module analysis 

Source
Expand description

Analysis module for processing protobuf metadata into code generation plans

This module takes the raw metadata extracted from protobuf files and analyzes it to create a structured plan for code generation. It handles:

  • Grouping methods by service
  • Extracting HTTP routing information
  • Determining parameter types and sources
  • Planning the structure of generated code
  • Extracting managed resources from method return types

§Managed Resources

Services often manage one or more resource types. These resources are automatically extracted from the return types of get, create, and update methods. For example:

message Catalog {
  option (google.api.resource) = {
    type: "example.io/Catalog"
    pattern: "catalogs/{catalog}"
    plural: "catalogs"
    singular: "catalog"
  };
  string name = 1;
  // ... other fields
}

service CatalogService {
  rpc GetCatalog(GetCatalogRequest) returns (Catalog);
  rpc CreateCatalog(CreateCatalogRequest) returns (Catalog);
  rpc UpdateCatalog(UpdateCatalogRequest) returns (Catalog);
}

The analysis will extract that CatalogService manages the Catalog resource, making this information available for subsequent code generation phases.

Structs§

BodyField
A body field that should be extracted from the request body
GenerationPlan
High-level plan for what code to generate
ManagedResource
Information about a resource managed by a service
MethodPlan
Plan for generating code for a single method
PathParam
A path parameter in a URL template
QueryParam
A query parameter for HTTP requests
ResourceHierarchy
Describes one ancestor step in a managed resource’s parent chain, derived from google.api.resource_reference { child_type } annotations on List request fields.
ServicePlan
Plan for generating code for a single service
SkippedMethod
A method that was skipped during analysis due to incomplete metadata.

Enums§

RequestParam
RequestType
The Operation a method is performing

Functions§

analyze_metadata
Analyze collected metadata and create a generation plan.
extract_managed_resources
Extract managed resources from service methods, deduplicating by type name.
split_body_fields
Split body fields from a MethodPlan into required and optional subsets.