Skip to content

Person pb2

Protocol buffer message and service definitions for the AddressBook pedagogical example.

This module is auto-generated from the person.proto file using the protobuf compiler. It provides Python classes for all messages and services defined in the proto file, and is intended for use in educational and demonstration contexts.

Note

This file is generated code. Manual changes (except for documentation improvements) will be overwritten if the file is regenerated.

Attributes

DESCRIPTOR: _descriptor.FileDescriptor = _descriptor_pool.Default().AddSerializedFile(b'\n\x0cperson.proto\x12\x06person"\x9f\x02\n\x06Person\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\n\n\x02id\x18\x02 \x01(\x05\x12\r\n\x05email\x18\x03 \x01(\t\x12*\n\x06phones\x18\x04 \x03(\x0b2\x1a.person.Person.PhoneNumber\x1aV\n\x0bPhoneNumber\x12\x0e\n\x06number\x18\x01 \x01(\t\x127\n\x04type\x18\x02 \x01(\x0e2\x18.person.Person.PhoneType:\x0fPHONE_TYPE_HOME"h\n\tPhoneType\x12\x1a\n\x16PHONE_TYPE_UNSPECIFIED\x10\x00\x12\x15\n\x11PHONE_TYPE_MOBILE\x10\x01\x12\x13\n\x0fPHONE_TYPE_HOME\x10\x02\x12\x13\n\x0fPHONE_TYPE_WORK\x10\x03"-\n\x0bAddressBook\x12\x1e\n\x06people\x18\x01 \x03(\x0b2\x0e.person.Person"%\n\x10GetPersonRequest\x12\x11\n\tperson_id\x18\x01 \x01(\x05"3\n\x11GetPersonResponse\x12\x1e\n\x06person\x18\x01 \x01(\x0b2\x0e.person.Person"\x13\n\x11ListPeopleRequest"4\n\x12ListPeopleResponse\x12\x1e\n\x06people\x18\x01 \x03(\x0b2\x0e.person.Person"2\n\x10AddPersonRequest\x12\x1e\n\x06person\x18\x01 \x01(\x0b2\x0e.person.Person"3\n\x11AddPersonResponse\x12\x1e\n\x06person\x18\x01 \x01(\x0b2\x0e.person.Person2\xdd\x01\n\x12AddressBookService\x12@\n\tGetPerson\x12\x18.person.GetPersonRequest\x1a\x19.person.GetPersonResponse\x12C\n\nListPeople\x12\x19.person.ListPeopleRequest\x1a\x1a.person.ListPeopleResponse\x12@\n\tAddPerson\x12\x18.person.AddPersonRequest\x1a\x19.person.AddPersonResponseb\x08editionsp\xe8\x07') module-attribute

Classes

AddPersonRequest(person: _Optional[_Union[Person, _Mapping]] = ...)

Bases: Message

Request message for adding a new person to the address book.

PARAMETER DESCRIPTION
person

The Person object to add.

TYPE: Optional[Union[Person, Mapping]] DEFAULT: ...

Attributes

PERSON_FIELD_NUMBER: int class-attribute
person: Person instance-attribute

AddPersonResponse(person: _Optional[_Union[Person, _Mapping]] = ...)

Bases: Message

Response message confirming the addition of a person.

PARAMETER DESCRIPTION
person

The Person object that was added.

TYPE: Optional[Union[Person, Mapping]] DEFAULT: ...

Attributes

PERSON_FIELD_NUMBER: int class-attribute
person: Person instance-attribute

AddressBook(people: _Optional[_Iterable[_Union[Person, _Mapping]]] = ...)

Bases: Message

Represents an address book containing multiple people.

PARAMETER DESCRIPTION
people

A list of Person objects in the address book.

TYPE: Optional[Iterable[Union[Person, Mapping]]] DEFAULT: ...

Attributes

PEOPLE_FIELD_NUMBER: int class-attribute
people: _containers.RepeatedCompositeFieldContainer[Person] instance-attribute

GetPersonRequest(person_id: _Optional[int] = ...)

Bases: Message

Request message for retrieving a person by ID.

PARAMETER DESCRIPTION
person_id

The unique identifier of the person to retrieve.

TYPE: Optional[int] DEFAULT: ...

Attributes

PERSON_ID_FIELD_NUMBER: int class-attribute
person_id: int instance-attribute

GetPersonResponse(person: _Optional[_Union[Person, _Mapping]] = ...)

Bases: Message

Response message containing a single person.

PARAMETER DESCRIPTION
person

The Person object returned by the service.

TYPE: Optional[Union[Person, Mapping]] DEFAULT: ...

Attributes

PERSON_FIELD_NUMBER: int class-attribute
person: Person instance-attribute

ListPeopleRequest()

Bases: Message

Request message for listing all people in the address book.

ListPeopleResponse(people: _Optional[_Iterable[_Union[Person, _Mapping]]] = ...)

Bases: Message

Response message containing a list of people.

PARAMETER DESCRIPTION
people

The list of Person objects returned by the service.

TYPE: Optional[Iterable[Union[Person, Mapping]]] DEFAULT: ...

Attributes

PEOPLE_FIELD_NUMBER: int class-attribute
people: _containers.RepeatedCompositeFieldContainer[Person] instance-attribute

Person(name: _Optional[str] = ..., id: _Optional[int] = ..., email: _Optional[str] = ..., phones: _Optional[_Iterable[_Union[Person.PhoneNumber, _Mapping]]] = ...)

Bases: Message

Represents a person in the AddressBook example.

PARAMETER DESCRIPTION
name

The person's name.

TYPE: Optional[str] DEFAULT: ...

id

The unique identifier for the person.

TYPE: Optional[int] DEFAULT: ...

email

The person's email address.

TYPE: Optional[str] DEFAULT: ...

phones

A list of phone numbers for the person.

TYPE: Optional[Iterable[Union[PhoneNumber, Mapping]]] DEFAULT: ...

Attributes

EMAIL_FIELD_NUMBER: int class-attribute
ID_FIELD_NUMBER: int class-attribute
NAME_FIELD_NUMBER: int class-attribute
PHONES_FIELD_NUMBER: int class-attribute
PHONE_TYPE_HOME: Person.PhoneType instance-attribute
PHONE_TYPE_MOBILE: Person.PhoneType instance-attribute
PHONE_TYPE_UNSPECIFIED: Person.PhoneType instance-attribute
PHONE_TYPE_WORK: Person.PhoneType instance-attribute
email: str instance-attribute
id: int instance-attribute
name: str instance-attribute
phones: _containers.RepeatedCompositeFieldContainer[Person.PhoneNumber] instance-attribute

Classes

PhoneNumber(number: _Optional[str] = ..., type: _Optional[_Union[Person.PhoneType, str]] = ...)

Bases: Message

Represents a phone number for a person.

PARAMETER DESCRIPTION
number

The phone number as a string.

TYPE: Optional[str] DEFAULT: ...

type

The type of phone number (e.g., mobile, home, work).

TYPE: Optional[Union[PhoneType, str]] DEFAULT: ...

Source code in examples/plugins/proto/person_pb2.py
    _globals["_ADDPERSONRESPONSE"]._serialized_end = 631
    _globals["_ADDRESSBOOKSERVICE"]._serialized_start = 634
    _globals["_ADDRESSBOOKSERVICE"]._serialized_end = 855
# @@protoc_insertion_point(module_scope)
Attributes
NUMBER_FIELD_NUMBER: int class-attribute
TYPE_FIELD_NUMBER: int class-attribute
number: str instance-attribute
type: Person.PhoneType instance-attribute
PhoneType

Bases: int

Enum for the type of phone number.

Attributes
PHONE_TYPE_HOME: Person.PhoneType class-attribute
PHONE_TYPE_MOBILE: Person.PhoneType class-attribute
PHONE_TYPE_UNSPECIFIED: Person.PhoneType class-attribute
PHONE_TYPE_WORK: Person.PhoneType class-attribute