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.4.tar.gz (26.7 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.4-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aipproto-0.0.4.tar.gz
  • Upload date:
  • Size: 26.7 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.4.tar.gz
Algorithm Hash digest
SHA256 6d87e79eca2daa554b4b30b533ee224e887f1781224e69d2fb55a53fa77546dd
MD5 508ab2323694411ad99f6b639dd29772
BLAKE2b-256 7f738a3ea7bcc424ec41b3c1fc9e7e4e292ca4932aff53a05ad43df06e469386

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aipproto-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 19.5 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 bdfbe9bfc647a1fb1113eda9af38d1d7d77f86386e6b3223309eedc5d596774c
MD5 b2b1d6023924e1fd3ed22a6064c38edf
BLAKE2b-256 2c4f323daf58d2e9d497b5f3683866f37dfbbd378c4e6b2b7a229f9b295a8082

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