jina.types.request¶
-
class
jina.types.request.
Request
(request=None, envelope=None, copy=False)[source]¶ Bases:
jina.types.mixin.ProtoTypeMixin
Request
is one of the primitive data type in Jina.It offers a Pythonic interface to allow users access and manipulate
jina.jina_pb2.RequestProto
object without working with Protobuf itself.A container for serialized
jina_pb2.RequestProto
that only triggers deserialization and decompression when receives the first read access to its member.It overrides
__getattr__()
to provide the same get/set interface as anjina_pb2.RequestProto
object.- Parameters
request (
Union
[bytes
,dict
,str
,RequestProto
,None
]) – The request.envelope (
Optional
[EnvelopeProto
]) – EnvelopeProto object.copy (
bool
) – Copy the request ifcopy
is True.
Set constructor method.
- Parameters
request (
Union
[bytes
,dict
,str
,RequestProto
,None
]) – request object as bytes, dictionary, string or protobuf instanceenvelope (
Optional
[EnvelopeProto
]) – envelope of the requestcopy (
bool
) – if true, request is copied
-
is_used
¶ Return True when request has been r/w at least once
-
property
body
¶ Return the request type, raise
ValueError
if request_type not set.- Returns
body property
-
as_typed_request
(request_type)[source]¶ Change the request class according to the one_of value in
body
.- Parameters
request_type (
str
) – string representation of the request type- Returns
self
-
property
request_type
¶ Return the request body type, when not set yet, return
None
.- Return type
Optional
[str
]- Returns
request type
-
property
proto
¶ Cast
self
to ajina_pb2.RequestProto
. This will triggeris_used
. Laziness will be broken and serialization will be recomputed when callingSerializeToString()
.- Return type
RequestProto
- Returns
protobuf instance
-
SerializeToString
()[source]¶ Convert serialized data to string.
- Return type
bytes
- Returns
serialized request
-
property
queryset
¶ Get the queryset in
QueryLangSet
type.- Return type
- Returns
query lang set
-
class
jina.types.request.
Response
[source]¶ Bases:
object
Response is the
Request
object returns from the flow. Right now it shares the same representation asRequest
. At 0.8.12,Response
is a simple alias. But it does give a more consistent semantic on the client API: send aRequest
and receive aResponse
.