# paloaltonetworks/pan-os-codegen architecture

> Architecture diagram of the GitHub repository paloaltonetworks/pan-os-codegen, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/paloaltonetworks/pan-os-codegen
- Repository: https://github.com/paloaltonetworks/pan-os-codegen

## Overview

This repository generates the PAN-OS Go SDK and Terraform provider from normalized schema specifications. The main workflow is CLI selection, configuration and spec loading, normalization, then generation and writing of the selected outputs. The graph preserves the schema model and the distinct SDK and Terraform translation branches. Source excerpts establish the main orchestration and generator relationships; the Terraform translation internals are represented as a subsystem because their individual call relationships were not shown.

Main entry points: [`pkg/generate/generator.go`](https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/generate/generator.go) (Template generator), [`pkg/commands/codegen/codegen.go`](https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/commands/codegen/codegen.go) (Generation command), [`cmd/codegen/main.go`](https://github.com/paloaltonetworks/pan-os-codegen/blob/main/cmd/codegen/main.go) (CLI), [`pkg/properties/normalized.go`](https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/properties/normalized.go) (Spec normalization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and orchestration"]
  node_cli["CLI<br/>[main.go]"]
  node_command["Generation command<br/>[codegen.go]"]
end

subgraph group_spec["Specifications and schema"]
  node_config["Config loading<br/>[file.go]"]
  node_normalization["Spec normalization<br/>[normalized.go]"]
  node_schema["Schema model<br/>[object.go]"]
  node_parameters["Parameter definitions<br/>[parameter.go]"]
end

subgraph group_translate["Code translation"]
  node_sdk_translation["SDK translation"]
  node_sdk_structs["SDK struct generation"]
  node_terraform_translation["Terraform translation"]
end

subgraph group_output["Generation output"]
  node_assets["Generation assets<br/>[assets.go]"]
  node_generator["Template generator<br/>[generator.go]"]
  node_sdk_output["Generated SDK"]
  node_terraform_output["Generated provider"]
end

node_engineer(("Codegen user"))

node_engineer -->|"runs"| node_cli
node_cli -->|"creates and runs"| node_command
node_command -->|"loads config"| node_config
node_command -->|"loads specs"| node_normalization
node_normalization -->|"normalizes"| node_schema
node_schema -->|"contains definitions"| node_parameters
node_command -->|"generates code"| node_generator
node_generator -->|"uses translation"| node_sdk_translation
node_generator -->|"uses translation"| node_terraform_translation
node_sdk_translation -.->|"includes"| node_sdk_structs
node_generator -->|"uses assets"| node_assets
node_generator -->|"writes SDK"| node_sdk_output
node_generator -->|"writes provider"| node_terraform_output

click node_cli "https://github.com/paloaltonetworks/pan-os-codegen/blob/main/cmd/codegen/main.go"
click node_command "https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/commands/codegen/codegen.go"
click node_config "https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/load/file.go"
click node_normalization "https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/properties/normalized.go"
click node_schema "https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/schema/object/object.go"
click node_parameters "https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/schema/parameter/parameter.go"
click node_sdk_translation "https://github.com/paloaltonetworks/pan-os-codegen/tree/main/pkg/translate"
click node_sdk_structs "https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/translate/struct_generation.go"
click node_terraform_translation "https://github.com/paloaltonetworks/pan-os-codegen/tree/main/pkg/translate/terraform_provider"
click node_assets "https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/generate/assets.go"
click node_generator "https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/generate/generator.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_command,node_engineer toneBlue
class node_config,node_normalization,node_schema,node_parameters toneAmber
class node_sdk_translation,node_sdk_structs,node_terraform_translation toneMint
class node_assets,node_generator,node_sdk_output,node_terraform_output toneRose
```

## Components

### Entry and orchestration

- [CLI](https://github.com/paloaltonetworks/pan-os-codegen/blob/main/cmd/codegen/main.go): `cmd/codegen/main.go`
- [Generation command](https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/commands/codegen/codegen.go): `pkg/commands/codegen/codegen.go`

### Specifications and schema

- [Config loading](https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/load/file.go): `pkg/load/file.go`
- [Spec normalization](https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/properties/normalized.go): `pkg/properties/normalized.go`
- [Schema model](https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/schema/object/object.go): `pkg/schema/object/object.go`
- [Parameter definitions](https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/schema/parameter/parameter.go): `pkg/schema/parameter/parameter.go`

### Code translation

- [SDK translation](https://github.com/paloaltonetworks/pan-os-codegen/tree/main/pkg/translate): `pkg/translate`
- [SDK struct generation](https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/translate/struct_generation.go): `pkg/translate/struct_generation.go`
- [Terraform translation](https://github.com/paloaltonetworks/pan-os-codegen/tree/main/pkg/translate/terraform_provider): `pkg/translate/terraform_provider`

### Generation output

- [Generation assets](https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/generate/assets.go): `pkg/generate/assets.go`
- [Template generator](https://github.com/paloaltonetworks/pan-os-codegen/blob/main/pkg/generate/generator.go): `pkg/generate/generator.go`
- **Generated SDK**
- **Generated provider**

### Other components

- **Codegen user**

## Connections

- Codegen user → CLI: runs (evidence: `README.md`)
- CLI → Generation command: creates and runs (evidence: `cmd/codegen/main.go`)
- Generation command → Config loading: loads config (evidence: `pkg/commands/codegen/codegen.go`)
- Generation command → Spec normalization: loads specs (evidence: `pkg/commands/codegen/codegen.go`)
- Spec normalization → Schema model: normalizes (evidence: `pkg/properties/normalized.go`)
- Schema model → Parameter definitions: contains definitions (evidence: `pkg/schema/object/object.go`)
- Generation command → Template generator: generates code (evidence: `pkg/commands/codegen/codegen.go`)
- Template generator → SDK translation: uses translation (evidence: `pkg/generate/generator.go`)
- Template generator → Terraform translation: uses translation (evidence: `pkg/generate/generator.go`)
- SDK translation → SDK struct generation: includes
- Template generator → Generation assets: uses assets (evidence: `pkg/generate/generator.go`)
- Template generator → Generated SDK: writes SDK (evidence: `pkg/generate/generator.go`)
- Template generator → Generated provider: writes provider (evidence: `pkg/generate/generator.go`)
