Skip to main content

A short description of your package

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.1.tar.gz (25.8 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.1-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aipproto-0.0.1.tar.gz
  • Upload date:
  • Size: 25.8 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.1.tar.gz
Algorithm Hash digest
SHA256 6dd2ece8d3d035b5fb3032b2f7fbc3192a17dcfa40714e99c1eb4c59f9bb297b
MD5 c5b6f1db68370ff3e86f7789ad960c44
BLAKE2b-256 228f7e5549de684cf8411fcd3d318f0f9a811fad2d7b2b77f4a34b3316a885ab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aipproto-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 17.4 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c49221a43296f1520343cb08184a08d863ade46615838611d00566235703e492
MD5 d904abcb2701f2488b4c53bc94530dde
BLAKE2b-256 c33b39a5e3f70f79f3b1ed4d1842e2e35f4004a2d0eadd6c9327a0db49452c28

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