google-cloud-automl 0.6.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/AUTHENTICATION.md +51 -59
  4. data/LICENSE.md +203 -0
  5. data/MIGRATING.md +324 -0
  6. data/README.md +95 -25
  7. data/lib/google-cloud-automl.rb +6 -2
  8. data/lib/google/cloud/automl.rb +132 -190
  9. data/lib/google/cloud/automl/version.rb +6 -2
  10. metadata +74 -110
  11. data/LICENSE +0 -201
  12. data/lib/google/cloud/automl/v1beta1.rb +0 -231
  13. data/lib/google/cloud/automl/v1beta1/annotation_payload_pb.rb +0 -34
  14. data/lib/google/cloud/automl/v1beta1/annotation_spec_pb.rb +0 -19
  15. data/lib/google/cloud/automl/v1beta1/automl_client.rb +0 -1906
  16. data/lib/google/cloud/automl/v1beta1/automl_client_config.json +0 -146
  17. data/lib/google/cloud/automl/v1beta1/automl_client_helpers.rb +0 -109
  18. data/lib/google/cloud/automl/v1beta1/classification_pb.rb +0 -66
  19. data/lib/google/cloud/automl/v1beta1/column_spec_pb.rb +0 -29
  20. data/lib/google/cloud/automl/v1beta1/credentials.rb +0 -41
  21. data/lib/google/cloud/automl/v1beta1/data_items_pb.rb +0 -88
  22. data/lib/google/cloud/automl/v1beta1/data_stats_pb.rb +0 -77
  23. data/lib/google/cloud/automl/v1beta1/data_types_pb.rb +0 -36
  24. data/lib/google/cloud/automl/v1beta1/dataset_pb.rb +0 -39
  25. data/lib/google/cloud/automl/v1beta1/detection_pb.rb +0 -52
  26. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/annotation_payload.rb +0 -63
  27. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/annotation_spec.rb +0 -39
  28. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/classification.rb +0 -212
  29. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/column_spec.rb +0 -67
  30. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/data_items.rb +0 -202
  31. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/data_stats.rb +0 -160
  32. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/data_types.rb +0 -99
  33. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/dataset.rb +0 -77
  34. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/detection.rb +0 -130
  35. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/geometry.rb +0 -43
  36. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/image.rb +0 -183
  37. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/io.rb +0 -1110
  38. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/model.rb +0 -88
  39. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/model_evaluation.rb +0 -96
  40. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/prediction_service.rb +0 -186
  41. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/ranges.rb +0 -31
  42. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/regression.rb +0 -41
  43. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/service.rb +0 -356
  44. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/table_spec.rb +0 -68
  45. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/tables.rb +0 -275
  46. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/temporal.rb +0 -33
  47. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/text.rb +0 -54
  48. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/text_extraction.rb +0 -60
  49. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/text_segment.rb +0 -37
  50. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/text_sentiment.rb +0 -76
  51. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/translation.rb +0 -63
  52. data/lib/google/cloud/automl/v1beta1/doc/google/cloud/automl/v1beta1/video.rb +0 -35
  53. data/lib/google/cloud/automl/v1beta1/doc/google/longrunning/operations.rb +0 -51
  54. data/lib/google/cloud/automl/v1beta1/doc/google/protobuf/any.rb +0 -131
  55. data/lib/google/cloud/automl/v1beta1/doc/google/protobuf/duration.rb +0 -91
  56. data/lib/google/cloud/automl/v1beta1/doc/google/protobuf/field_mask.rb +0 -222
  57. data/lib/google/cloud/automl/v1beta1/doc/google/protobuf/struct.rb +0 -74
  58. data/lib/google/cloud/automl/v1beta1/doc/google/protobuf/timestamp.rb +0 -113
  59. data/lib/google/cloud/automl/v1beta1/doc/google/rpc/status.rb +0 -39
  60. data/lib/google/cloud/automl/v1beta1/geometry_pb.rb +0 -21
  61. data/lib/google/cloud/automl/v1beta1/image_pb.rb +0 -50
  62. data/lib/google/cloud/automl/v1beta1/io_pb.rb +0 -80
  63. data/lib/google/cloud/automl/v1beta1/model_evaluation_pb.rb +0 -38
  64. data/lib/google/cloud/automl/v1beta1/model_pb.rb +0 -45
  65. data/lib/google/cloud/automl/v1beta1/operations_pb.rb +0 -90
  66. data/lib/google/cloud/automl/v1beta1/prediction_service_client.rb +0 -477
  67. data/lib/google/cloud/automl/v1beta1/prediction_service_client_config.json +0 -36
  68. data/lib/google/cloud/automl/v1beta1/prediction_service_pb.rb +0 -43
  69. data/lib/google/cloud/automl/v1beta1/prediction_service_services_pb.rb +0 -74
  70. data/lib/google/cloud/automl/v1beta1/ranges_pb.rb +0 -17
  71. data/lib/google/cloud/automl/v1beta1/regression_pb.rb +0 -20
  72. data/lib/google/cloud/automl/v1beta1/service_pb.rb +0 -180
  73. data/lib/google/cloud/automl/v1beta1/service_services_pb.rb +0 -158
  74. data/lib/google/cloud/automl/v1beta1/table_spec_pb.rb +0 -24
  75. data/lib/google/cloud/automl/v1beta1/tables_pb.rb +0 -58
  76. data/lib/google/cloud/automl/v1beta1/temporal_pb.rb +0 -18
  77. data/lib/google/cloud/automl/v1beta1/text_extraction_pb.rb +0 -32
  78. data/lib/google/cloud/automl/v1beta1/text_pb.rb +0 -34
  79. data/lib/google/cloud/automl/v1beta1/text_segment_pb.rb +0 -18
  80. data/lib/google/cloud/automl/v1beta1/text_sentiment_pb.rb +0 -29
  81. data/lib/google/cloud/automl/v1beta1/translation_pb.rb +0 -34
  82. data/lib/google/cloud/automl/v1beta1/video_pb.rb +0 -25
@@ -1,37 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Cloud
18
- module AutoML
19
- module V1beta1
20
- # A contiguous part of a text (string), assuming it has an UTF-8 NFC encoding.
21
- # @!attribute [rw] content
22
- # @return [String]
23
- # Output only. The content of the TextSegment.
24
- # @!attribute [rw] start_offset
25
- # @return [Integer]
26
- # Required. Zero-based character index of the first character of the text
27
- # segment (counting characters from the beginning of the text).
28
- # @!attribute [rw] end_offset
29
- # @return [Integer]
30
- # Required. Zero-based character index of the first character past the end of
31
- # the text segment (counting character from the beginning of the text).
32
- # The character at the end_offset is NOT included in the text segment.
33
- class TextSegment; end
34
- end
35
- end
36
- end
37
- end
@@ -1,76 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Cloud
18
- module AutoML
19
- module V1beta1
20
- # Contains annotation details specific to text sentiment.
21
- # @!attribute [rw] sentiment
22
- # @return [Integer]
23
- # Output only. The sentiment with the semantic, as given to the
24
- # {Google::Cloud::AutoML::V1beta1::AutoML::ImportData AutoML::ImportData} when populating the dataset from which the model used
25
- # for the prediction had been trained.
26
- # The sentiment values are between 0 and
27
- # Dataset.text_sentiment_dataset_metadata.sentiment_max (inclusive),
28
- # with higher value meaning more positive sentiment. They are completely
29
- # relative, i.e. 0 means least positive sentiment and sentiment_max means
30
- # the most positive from the sentiments present in the train data. Therefore
31
- # e.g. if train data had only negative sentiment, then sentiment_max, would
32
- # be still negative (although least negative).
33
- # The sentiment shouldn't be confused with "score" or "magnitude"
34
- # from the previous Natural Language Sentiment Analysis API.
35
- class TextSentimentAnnotation; end
36
-
37
- # Model evaluation metrics for text sentiment problems.
38
- # @!attribute [rw] precision
39
- # @return [Float]
40
- # Output only. Precision.
41
- # @!attribute [rw] recall
42
- # @return [Float]
43
- # Output only. Recall.
44
- # @!attribute [rw] f1_score
45
- # @return [Float]
46
- # Output only. The harmonic mean of recall and precision.
47
- # @!attribute [rw] mean_absolute_error
48
- # @return [Float]
49
- # Output only. Mean absolute error. Only set for the overall model
50
- # evaluation, not for evaluation of a single annotation spec.
51
- # @!attribute [rw] mean_squared_error
52
- # @return [Float]
53
- # Output only. Mean squared error. Only set for the overall model
54
- # evaluation, not for evaluation of a single annotation spec.
55
- # @!attribute [rw] linear_kappa
56
- # @return [Float]
57
- # Output only. Linear weighted kappa. Only set for the overall model
58
- # evaluation, not for evaluation of a single annotation spec.
59
- # @!attribute [rw] quadratic_kappa
60
- # @return [Float]
61
- # Output only. Quadratic weighted kappa. Only set for the overall model
62
- # evaluation, not for evaluation of a single annotation spec.
63
- # @!attribute [rw] confusion_matrix
64
- # @return [Google::Cloud::AutoML::V1beta1::ClassificationEvaluationMetrics::ConfusionMatrix]
65
- # Output only. Confusion matrix of the evaluation.
66
- # Only set for the overall model evaluation, not for evaluation of a single
67
- # annotation spec.
68
- # @!attribute [rw] annotation_spec_id
69
- # @return [Array<String>]
70
- # Output only. The annotation spec ids used for this evaluation.
71
- # Deprecated .
72
- class TextSentimentEvaluationMetrics; end
73
- end
74
- end
75
- end
76
- end
@@ -1,63 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Cloud
18
- module AutoML
19
- module V1beta1
20
- # Dataset metadata that is specific to translation.
21
- # @!attribute [rw] source_language_code
22
- # @return [String]
23
- # Required. The BCP-47 language code of the source language.
24
- # @!attribute [rw] target_language_code
25
- # @return [String]
26
- # Required. The BCP-47 language code of the target language.
27
- class TranslationDatasetMetadata; end
28
-
29
- # Evaluation metrics for the dataset.
30
- # @!attribute [rw] bleu_score
31
- # @return [Float]
32
- # Output only. BLEU score.
33
- # @!attribute [rw] base_bleu_score
34
- # @return [Float]
35
- # Output only. BLEU score for base model.
36
- class TranslationEvaluationMetrics; end
37
-
38
- # Model metadata that is specific to translation.
39
- # @!attribute [rw] base_model
40
- # @return [String]
41
- # The resource name of the model to use as a baseline to train the custom
42
- # model. If unset, we use the default base model provided by Google
43
- # Translate. Format:
44
- # `projects/{project_id}/locations/{location_id}/models/{model_id}`
45
- # @!attribute [rw] source_language_code
46
- # @return [String]
47
- # Output only. Inferred from the dataset.
48
- # The source languge (The BCP-47 language code) that is used for training.
49
- # @!attribute [rw] target_language_code
50
- # @return [String]
51
- # Output only. The target languge (The BCP-47 language code) that is used for
52
- # training.
53
- class TranslationModelMetadata; end
54
-
55
- # Annotation details specific to translation.
56
- # @!attribute [rw] translated_content
57
- # @return [Google::Cloud::AutoML::V1beta1::TextSnippet]
58
- # Output only . The translated content.
59
- class TranslationAnnotation; end
60
- end
61
- end
62
- end
63
- end
@@ -1,35 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Cloud
18
- module AutoML
19
- module V1beta1
20
- # Dataset metadata specific to video classification.
21
- # All Video Classification datasets are treated as multi label.
22
- class VideoClassificationDatasetMetadata; end
23
-
24
- # Dataset metadata specific to video object tracking.
25
- class VideoObjectTrackingDatasetMetadata; end
26
-
27
- # Model metadata specific to video classification.
28
- class VideoClassificationModelMetadata; end
29
-
30
- # Model metadata specific to video object tracking.
31
- class VideoObjectTrackingModelMetadata; end
32
- end
33
- end
34
- end
35
- end
@@ -1,51 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Longrunning
18
- # This resource represents a long-running operation that is the result of a
19
- # network API call.
20
- # @!attribute [rw] name
21
- # @return [String]
22
- # The server-assigned name, which is only unique within the same service that
23
- # originally returns it. If you use the default HTTP mapping, the
24
- # `name` should be a resource name ending with `operations/{unique_id}`.
25
- # @!attribute [rw] metadata
26
- # @return [Google::Protobuf::Any]
27
- # Service-specific metadata associated with the operation. It typically
28
- # contains progress information and common metadata such as create time.
29
- # Some services might not provide such metadata. Any method that returns a
30
- # long-running operation should document the metadata type, if any.
31
- # @!attribute [rw] done
32
- # @return [true, false]
33
- # If the value is `false`, it means the operation is still in progress.
34
- # If `true`, the operation is completed, and either `error` or `response` is
35
- # available.
36
- # @!attribute [rw] error
37
- # @return [Google::Rpc::Status]
38
- # The error result of the operation in case of failure or cancellation.
39
- # @!attribute [rw] response
40
- # @return [Google::Protobuf::Any]
41
- # The normal response of the operation in case of success. If the original
42
- # method returns no data on success, such as `Delete`, the response is
43
- # `google.protobuf.Empty`. If the original method is standard
44
- # `Get`/`Create`/`Update`, the response should be the resource. For other
45
- # methods, the response should have the type `XxxResponse`, where `Xxx`
46
- # is the original method name. For example, if the original method name
47
- # is `TakeSnapshot()`, the inferred response type is
48
- # `TakeSnapshotResponse`.
49
- class Operation; end
50
- end
51
- end
@@ -1,131 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Protobuf
18
- # `Any` contains an arbitrary serialized protocol buffer message along with a
19
- # URL that describes the type of the serialized message.
20
- #
21
- # Protobuf library provides support to pack/unpack Any values in the form
22
- # of utility functions or additional generated methods of the Any type.
23
- #
24
- # Example 1: Pack and unpack a message in C++.
25
- #
26
- # Foo foo = ...;
27
- # Any any;
28
- # any.PackFrom(foo);
29
- # ...
30
- # if (any.UnpackTo(&foo)) {
31
- # ...
32
- # }
33
- #
34
- # Example 2: Pack and unpack a message in Java.
35
- #
36
- # Foo foo = ...;
37
- # Any any = Any.pack(foo);
38
- # ...
39
- # if (any.is(Foo.class)) {
40
- # foo = any.unpack(Foo.class);
41
- # }
42
- #
43
- # Example 3: Pack and unpack a message in Python.
44
- #
45
- # foo = Foo(...)
46
- # any = Any()
47
- # any.Pack(foo)
48
- # ...
49
- # if any.Is(Foo.DESCRIPTOR):
50
- # any.Unpack(foo)
51
- # ...
52
- #
53
- # Example 4: Pack and unpack a message in Go
54
- #
55
- # foo := &pb.Foo{...}
56
- # any, err := ptypes.MarshalAny(foo)
57
- # ...
58
- # foo := &pb.Foo{}
59
- # if err := ptypes.UnmarshalAny(any, foo); err != nil {
60
- # ...
61
- # }
62
- #
63
- # The pack methods provided by protobuf library will by default use
64
- # 'type.googleapis.com/full.type.name' as the type URL and the unpack
65
- # methods only use the fully qualified type name after the last '/'
66
- # in the type URL, for example "foo.bar.com/x/y.z" will yield type
67
- # name "y.z".
68
- #
69
- #
70
- # = JSON
71
- #
72
- # The JSON representation of an `Any` value uses the regular
73
- # representation of the deserialized, embedded message, with an
74
- # additional field `@type` which contains the type URL. Example:
75
- #
76
- # package google.profile;
77
- # message Person {
78
- # string first_name = 1;
79
- # string last_name = 2;
80
- # }
81
- #
82
- # {
83
- # "@type": "type.googleapis.com/google.profile.Person",
84
- # "firstName": <string>,
85
- # "lastName": <string>
86
- # }
87
- #
88
- # If the embedded message type is well-known and has a custom JSON
89
- # representation, that representation will be embedded adding a field
90
- # `value` which holds the custom JSON in addition to the `@type`
91
- # field. Example (for message {Google::Protobuf::Duration}):
92
- #
93
- # {
94
- # "@type": "type.googleapis.com/google.protobuf.Duration",
95
- # "value": "1.212s"
96
- # }
97
- # @!attribute [rw] type_url
98
- # @return [String]
99
- # A URL/resource name that uniquely identifies the type of the serialized
100
- # protocol buffer message. This string must contain at least
101
- # one "/" character. The last segment of the URL's path must represent
102
- # the fully qualified name of the type (as in
103
- # `path/google.protobuf.Duration`). The name should be in a canonical form
104
- # (e.g., leading "." is not accepted).
105
- #
106
- # In practice, teams usually precompile into the binary all types that they
107
- # expect it to use in the context of Any. However, for URLs which use the
108
- # scheme `http`, `https`, or no scheme, one can optionally set up a type
109
- # server that maps type URLs to message definitions as follows:
110
- #
111
- # * If no scheme is provided, `https` is assumed.
112
- # * An HTTP GET on the URL must yield a {Google::Protobuf::Type}
113
- # value in binary format, or produce an error.
114
- # * Applications are allowed to cache lookup results based on the
115
- # URL, or have them precompiled into a binary to avoid any
116
- # lookup. Therefore, binary compatibility needs to be preserved
117
- # on changes to types. (Use versioned type names to manage
118
- # breaking changes.)
119
- #
120
- # Note: this functionality is not currently available in the official
121
- # protobuf release, and it is not used for type URLs beginning with
122
- # type.googleapis.com.
123
- #
124
- # Schemes other than `http`, `https` (or the empty scheme) might be
125
- # used with implementation specific semantics.
126
- # @!attribute [rw] value
127
- # @return [String]
128
- # Must be a valid serialized protocol buffer of the above specified type.
129
- class Any; end
130
- end
131
- end
@@ -1,91 +0,0 @@
1
- # Copyright 2020 Google LLC
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # https://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
-
16
- module Google
17
- module Protobuf
18
- # A Duration represents a signed, fixed-length span of time represented
19
- # as a count of seconds and fractions of seconds at nanosecond
20
- # resolution. It is independent of any calendar and concepts like "day"
21
- # or "month". It is related to Timestamp in that the difference between
22
- # two Timestamp values is a Duration and it can be added or subtracted
23
- # from a Timestamp. Range is approximately +-10,000 years.
24
- #
25
- # = Examples
26
- #
27
- # Example 1: Compute Duration from two Timestamps in pseudo code.
28
- #
29
- # Timestamp start = ...;
30
- # Timestamp end = ...;
31
- # Duration duration = ...;
32
- #
33
- # duration.seconds = end.seconds - start.seconds;
34
- # duration.nanos = end.nanos - start.nanos;
35
- #
36
- # if (duration.seconds < 0 && duration.nanos > 0) {
37
- # duration.seconds += 1;
38
- # duration.nanos -= 1000000000;
39
- # } else if (durations.seconds > 0 && duration.nanos < 0) {
40
- # duration.seconds -= 1;
41
- # duration.nanos += 1000000000;
42
- # }
43
- #
44
- # Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
45
- #
46
- # Timestamp start = ...;
47
- # Duration duration = ...;
48
- # Timestamp end = ...;
49
- #
50
- # end.seconds = start.seconds + duration.seconds;
51
- # end.nanos = start.nanos + duration.nanos;
52
- #
53
- # if (end.nanos < 0) {
54
- # end.seconds -= 1;
55
- # end.nanos += 1000000000;
56
- # } else if (end.nanos >= 1000000000) {
57
- # end.seconds += 1;
58
- # end.nanos -= 1000000000;
59
- # }
60
- #
61
- # Example 3: Compute Duration from datetime.timedelta in Python.
62
- #
63
- # td = datetime.timedelta(days=3, minutes=10)
64
- # duration = Duration()
65
- # duration.FromTimedelta(td)
66
- #
67
- # = JSON Mapping
68
- #
69
- # In JSON format, the Duration type is encoded as a string rather than an
70
- # object, where the string ends in the suffix "s" (indicating seconds) and
71
- # is preceded by the number of seconds, with nanoseconds expressed as
72
- # fractional seconds. For example, 3 seconds with 0 nanoseconds should be
73
- # encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
74
- # be expressed in JSON format as "3.000000001s", and 3 seconds and 1
75
- # microsecond should be expressed in JSON format as "3.000001s".
76
- # @!attribute [rw] seconds
77
- # @return [Integer]
78
- # Signed seconds of the span of time. Must be from -315,576,000,000
79
- # to +315,576,000,000 inclusive. Note: these bounds are computed from:
80
- # 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
81
- # @!attribute [rw] nanos
82
- # @return [Integer]
83
- # Signed fractions of a second at nanosecond resolution of the span
84
- # of time. Durations less than one second are represented with a 0
85
- # `seconds` field and a positive or negative `nanos` field. For durations
86
- # of one second or more, a non-zero value for the `nanos` field must be
87
- # of the same sign as the `seconds` field. Must be from -999,999,999
88
- # to +999,999,999 inclusive.
89
- class Duration; end
90
- end
91
- end