コード例 #1
0
    def __init__(
        self,
        *,
        annotation: typing.List['GeneratedCodeInfo.Annotation'] = None,
    ):
        super().__init__(annotation=annotation, )


protox.define_fields(
    FileDescriptorSet,
    file=FileDescriptorProto.as_repeated(number=1),
)

protox.define_fields(
    FileDescriptorProto,
    name=protox.String(number=1, required=False),
    package=protox.String(number=2, required=False),
    dependency=protox.String.as_repeated(number=3),
    public_dependency=protox.Int32.as_repeated(number=10),
    weak_dependency=protox.Int32.as_repeated(number=11),
    message_type=DescriptorProto.as_repeated(number=4),
    enum_type=EnumDescriptorProto.as_repeated(number=5),
    service=ServiceDescriptorProto.as_repeated(number=6),
    extension=FieldDescriptorProto.as_repeated(number=7),
    options=FileOptions.as_field(number=8),
    source_code_info=SourceCodeInfo.as_field(number=9),
    syntax=protox.String(number=12, required=False),
)

protox.define_fields(
    DescriptorProto.ExtensionRange,
コード例 #2
0
    TopLevel,
    second=TopLevel.SecondLevel.as_field(number=1),
    third=TopLevel.SecondLevel.ThirdLevel.as_field(number=2),
)
TopLevel.DESCRIPTOR = protox.DescriptorProto.from_bytes(
    b'\n\x08TopLevel\x12<\n\x06second\x18\x01 \x02(\x0b2$.nested.message.TopLevel.SecondLevelR\x06second\x12E\n\x05third\x18\x02 \x02(\x0b2/.nested.message.TopLevel.SecondLevel.ThirdLevelR\x05third\x1ab\n\x0bSecondLevel\x12E\n\x05third\x18\x01 \x02(\x0b2/.nested.message.TopLevel.SecondLevel.ThirdLevelR\x05third\x1a\x0c\n\nThirdLevel'
)
TopLevel.DESCRIPTOR.file_descriptor = FILE_DESCRIPTOR
TopLevel.DESCRIPTOR.full_name = 'nested.message.TopLevel'

protox.define_fields(
    RepeatedMessage,
    users=RepeatedMessage.User.as_repeated(number=1),
)
RepeatedMessage.DESCRIPTOR = protox.DescriptorProto.from_bytes(
    b'\n\x0fRepeatedMessage\x12:\n\x05users\x18\x01 \x03(\x0b2$.nested.message.RepeatedMessage.UserR\x05users\x1a\x06\n\x04User'
)
RepeatedMessage.DESCRIPTOR.file_descriptor = FILE_DESCRIPTOR
RepeatedMessage.DESCRIPTOR.full_name = 'nested.message.RepeatedMessage'

protox.define_fields(
    OneOfMessage,
    x=protox.String(number=1, required=False),
    empty=protox.Empty.as_field(number=2),
)
OneOfMessage.DESCRIPTOR = protox.DescriptorProto.from_bytes(
    b'\n\x0cOneOfMessage\x12\x0e\n\x01x\x18\x01 \x01(\tH\x00R\x01x\x12.\n\x05empty\x18\x02 \x01(\x0b2\x16.google.protobuf.EmptyH\x00R\x05emptyB\x08\n\x06status'
)
OneOfMessage.DESCRIPTOR.file_descriptor = FILE_DESCRIPTOR
OneOfMessage.DESCRIPTOR.full_name = 'nested.message.OneOfMessage'
コード例 #3
0
import typing

import protox


class SourceContext(protox.Message):
    file_name: typing.Optional[str]

    def __init__(
        self,
        *,
        file_name: typing.Optional[str] = None,
    ):
        super().__init__(file_name=file_name, )


protox.define_fields(
    SourceContext,
    file_name=protox.String(number=1, required=False),
)
コード例 #4
0
        *,
        error: typing.Optional[str] = None,
        file: typing.List['CodeGeneratorResponse.File'] = None,
    ):
        super().__init__(
            error=error,
            file=file,
        )


protox.define_fields(
    Version,
    major=protox.Int32(number=1, required=False),
    minor=protox.Int32(number=2, required=False),
    patch=protox.Int32(number=3, required=False),
    suffix=protox.String(number=4, required=False),
)

protox.define_fields(
    CodeGeneratorRequest,
    file_to_generate=protox.String.as_repeated(number=1),
    parameter=protox.String(number=2, required=False),
    proto_file=FileDescriptorProto.as_repeated(number=15),
    compiler_version=Version.as_field(number=3),
)

protox.define_fields(
    CodeGeneratorResponse,
    error=protox.String(number=1, required=False),
    file=CodeGeneratorResponse.File.as_repeated(number=15),
)
コード例 #5
0
    def __init__(
        self,
        *,
        name: typing.Optional[str] = None,
        root: typing.Optional[str] = None,
    ):
        super().__init__(
            name=name,
            root=root,
        )


protox.define_fields(
    Api,
    name=protox.String(number=1, required=False),
    methods=Method.as_repeated(number=2),
    options=protox.Option.as_repeated(number=3),
    version=protox.String(number=4, required=False),
    source_context=protox.SourceContext.as_field(number=5),
    mixins=Mixin.as_repeated(number=6),
    syntax=protox.EnumField(number=7, py_enum=protox.Syntax, required=False),
)

protox.define_fields(
    Method,
    name=protox.String(number=1, required=False),
    request_type_url=protox.String(number=2, required=False),
    request_streaming=protox.Bool(number=3, required=False),
    response_type_url=protox.String(number=4, required=False),
    response_streaming=protox.Bool(number=5, required=False),
コード例 #6
0
    def __init__(
        self,
        *,
        name: typing.Optional[str] = None,
        value: typing.Optional[Any] = None,
    ):
        super().__init__(
            name=name,
            value=value,
        )


protox.define_fields(
    Type,
    name=protox.String(
        number=1, required=False
    ),
    fields=Field.as_repeated(
        number=2
    ),
    oneofs=protox.String.as_repeated(
        number=3
    ),
    options=Option.as_repeated(
        number=4
    ),
    source_context=SourceContext.as_field(
        number=5,
    ),
    syntax=protox.EnumField(
        number=6, py_enum=Syntax, required=False