Skip to main content

AIP proto generator

Project description

aipproto

TL;DR - Helper for generating AIP proto files.

The AIPs are a wonderful style guide for building APIs. However, AIP compliant proto files are a bit cumbersome to create and maintain. This python package makes it easy to define hierarchies of AIP resources and then generate the corresponding proto files that define the AIP APIs for those resources.

Installation

pip install aipproto

Usage

import aipproto

# Define the resource hierarchy for your API.
namespace = aipproto.Namespace("api.domain.com")
foo = namespace.resource("Foo")
bar = foo.nest("Bar")

# Generate the proto content.
content = aipproto.generate_file_content(
    package="domain.api.v1",
    service_name="TestService",
    resource_types=[foo, bar],
)

# Save it to a file.
with open("domain/api/v1/service.autogen.proto", "w") as f:
    f.write(content)

If this documentation is out of date, check out tests/test_generate.py or other tests in the tests/ directory.

Conformance testing

To ensure that this package generates protos that conform to the AIP definitions, we run the api-linter on the generated proto files.

The following command is used to run the tests:

pytest && \
bazel build tests/testdata/v1:golden_proto_descriptor_set && \
api-linter --descriptor-set-in bazel-bin/tests/testdata/v1/golden_proto_descriptor_set.pb tests/testdata/v1/golden.proto --output-format github

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aipproto-0.0.3.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aipproto-0.0.3-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file aipproto-0.0.3.tar.gz.

File metadata

  • Download URL: aipproto-0.0.3.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for aipproto-0.0.3.tar.gz
Algorithm Hash digest
SHA256 8f0789251a79ea0ac3301ee407e71c17f8d3a84130d5f31571b3b3d473a2dd51
MD5 edf4f7a0e0c4015ab9664e70dc862a89
BLAKE2b-256 b611785a0c51d304b1816d1145e1b5d87fbb1e3b9165334341f5ed16ba89c7fc

See more details on using hashes here.

File details

Details for the file aipproto-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: aipproto-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for aipproto-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b5da9fcee88186c34bd8550e02ce611a5984843980ff049780908da2c436336c
MD5 68302ce1f5d35ce1ed1b3539a16d80fc
BLAKE2b-256 cd7f30e3b339c6ece5a40019a54c4177f157da065bab8bc99d715af980e6baf9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page