|
| 1 | +""" |
| 2 | +@generated by mypy-protobuf. Do not edit manually! |
| 3 | +isort:skip_file |
| 4 | +Protocol Buffers - Google's data interchange format |
| 5 | +Copyright 2008 Google Inc. All rights reserved. |
| 6 | +https://developers.google.com/protocol-buffers/ |
| 7 | +
|
| 8 | +Redistribution and use in source and binary forms, with or without |
| 9 | +modification, are permitted provided that the following conditions are |
| 10 | +met: |
| 11 | +
|
| 12 | + * Redistributions of source code must retain the above copyright |
| 13 | +notice, this list of conditions and the following disclaimer. |
| 14 | + * Redistributions in binary form must reproduce the above |
| 15 | +copyright notice, this list of conditions and the following disclaimer |
| 16 | +in the documentation and/or other materials provided with the |
| 17 | +distribution. |
| 18 | + * Neither the name of Google Inc. nor the names of its |
| 19 | +contributors may be used to endorse or promote products derived from |
| 20 | +this software without specific prior written permission. |
| 21 | +
|
| 22 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 23 | +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 24 | +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 25 | +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 26 | +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 27 | +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 28 | +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 29 | +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 30 | +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 31 | +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 32 | +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 | +""" |
| 34 | + |
| 35 | +import builtins |
| 36 | +import google.protobuf.descriptor |
| 37 | +import google.protobuf.internal.well_known_types |
| 38 | +import google.protobuf.message |
| 39 | +import sys |
| 40 | +import typing |
| 41 | + |
| 42 | +if sys.version_info >= (3, 10): |
| 43 | + import typing as typing_extensions |
| 44 | +else: |
| 45 | + import typing_extensions |
| 46 | + |
| 47 | +DESCRIPTOR: google.protobuf.descriptor.FileDescriptor |
| 48 | + |
| 49 | +@typing.final |
| 50 | +class Duration(google.protobuf.message.Message, google.protobuf.internal.well_known_types.Duration): |
| 51 | + """A Duration represents a signed, fixed-length span of time represented |
| 52 | + as a count of seconds and fractions of seconds at nanosecond |
| 53 | + resolution. It is independent of any calendar and concepts like "day" |
| 54 | + or "month". It is related to Timestamp in that the difference between |
| 55 | + two Timestamp values is a Duration and it can be added or subtracted |
| 56 | + from a Timestamp. Range is approximately +-10,000 years. |
| 57 | +
|
| 58 | + # Examples |
| 59 | +
|
| 60 | + Example 1: Compute Duration from two Timestamps in pseudo code. |
| 61 | +
|
| 62 | + Timestamp start = ...; |
| 63 | + Timestamp end = ...; |
| 64 | + Duration duration = ...; |
| 65 | +
|
| 66 | + duration.seconds = end.seconds - start.seconds; |
| 67 | + duration.nanos = end.nanos - start.nanos; |
| 68 | +
|
| 69 | + if (duration.seconds < 0 && duration.nanos > 0) { |
| 70 | + duration.seconds += 1; |
| 71 | + duration.nanos -= 1000000000; |
| 72 | + } else if (duration.seconds > 0 && duration.nanos < 0) { |
| 73 | + duration.seconds -= 1; |
| 74 | + duration.nanos += 1000000000; |
| 75 | + } |
| 76 | +
|
| 77 | + Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. |
| 78 | +
|
| 79 | + Timestamp start = ...; |
| 80 | + Duration duration = ...; |
| 81 | + Timestamp end = ...; |
| 82 | +
|
| 83 | + end.seconds = start.seconds + duration.seconds; |
| 84 | + end.nanos = start.nanos + duration.nanos; |
| 85 | +
|
| 86 | + if (end.nanos < 0) { |
| 87 | + end.seconds -= 1; |
| 88 | + end.nanos += 1000000000; |
| 89 | + } else if (end.nanos >= 1000000000) { |
| 90 | + end.seconds += 1; |
| 91 | + end.nanos -= 1000000000; |
| 92 | + } |
| 93 | +
|
| 94 | + Example 3: Compute Duration from datetime.timedelta in Python. |
| 95 | +
|
| 96 | + td = datetime.timedelta(days=3, minutes=10) |
| 97 | + duration = Duration() |
| 98 | + duration.FromTimedelta(td) |
| 99 | +
|
| 100 | + # JSON Mapping |
| 101 | +
|
| 102 | + In JSON format, the Duration type is encoded as a string rather than an |
| 103 | + object, where the string ends in the suffix "s" (indicating seconds) and |
| 104 | + is preceded by the number of seconds, with nanoseconds expressed as |
| 105 | + fractional seconds. For example, 3 seconds with 0 nanoseconds should be |
| 106 | + encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should |
| 107 | + be expressed in JSON format as "3.000000001s", and 3 seconds and 1 |
| 108 | + microsecond should be expressed in JSON format as "3.000001s". |
| 109 | + """ |
| 110 | + |
| 111 | + DESCRIPTOR: google.protobuf.descriptor.Descriptor |
| 112 | + |
| 113 | + SECONDS_FIELD_NUMBER: builtins.int |
| 114 | + NANOS_FIELD_NUMBER: builtins.int |
| 115 | + seconds: builtins.int |
| 116 | + """Signed seconds of the span of time. Must be from -315,576,000,000 |
| 117 | + to +315,576,000,000 inclusive. Note: these bounds are computed from: |
| 118 | + 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years |
| 119 | + """ |
| 120 | + nanos: builtins.int |
| 121 | + """Signed fractions of a second at nanosecond resolution of the span |
| 122 | + of time. Durations less than one second are represented with a 0 |
| 123 | + `seconds` field and a positive or negative `nanos` field. For durations |
| 124 | + of one second or more, a non-zero value for the `nanos` field must be |
| 125 | + of the same sign as the `seconds` field. Must be from -999,999,999 |
| 126 | + to +999,999,999 inclusive. |
| 127 | + """ |
| 128 | + def __init__( |
| 129 | + self, |
| 130 | + *, |
| 131 | + seconds: builtins.int = ..., |
| 132 | + nanos: builtins.int = ..., |
| 133 | + ) -> None: ... |
| 134 | + def ClearField(self, field_name: typing.Literal["nanos", b"nanos", "seconds", b"seconds"]) -> None: ... |
| 135 | + |
| 136 | +Global___Duration: typing_extensions.TypeAlias = Duration |
0 commit comments