address_validation_service.proto 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. // Copyright 2022 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. // http://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. syntax = "proto3";
  15. package google.maps.addressvalidation.v1;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/maps/addressvalidation/v1/address.proto";
  20. import "google/maps/addressvalidation/v1/geocode.proto";
  21. import "google/maps/addressvalidation/v1/metadata.proto";
  22. import "google/maps/addressvalidation/v1/usps_data.proto";
  23. import "google/type/postal_address.proto";
  24. option cc_enable_arenas = true;
  25. option csharp_namespace = "Google.Maps.AddressValidation.V1";
  26. option go_package = "google.golang.org/genproto/googleapis/maps/addressvalidation/v1;addressvalidation";
  27. option java_multiple_files = true;
  28. option java_outer_classname = "AddressValidationServiceProto";
  29. option java_package = "com.google.maps.addressvalidation.v1";
  30. option objc_class_prefix = "GMPAVV1";
  31. option php_namespace = "Google\\Maps\\AddressValidation\\V1";
  32. option ruby_package = "Google::Maps::AddressValidation::V1";
  33. // The service for validating addresses.
  34. service AddressValidation {
  35. option (google.api.default_host) = "addressvalidation.googleapis.com";
  36. // Validates an address.
  37. rpc ValidateAddress(ValidateAddressRequest) returns (ValidateAddressResponse) {
  38. option (google.api.http) = {
  39. post: "/v1:validateAddress"
  40. body: "*"
  41. };
  42. }
  43. // Feedback about the outcome of the sequence of validation attempts. This
  44. // should be the last call made after a sequence of validation calls for the
  45. // same address, and should be called once the transaction is concluded. This
  46. // should only be sent once for the sequence of `ValidateAddress` requests
  47. // needed to validate an address fully.
  48. rpc ProvideValidationFeedback(ProvideValidationFeedbackRequest) returns (ProvideValidationFeedbackResponse) {
  49. option (google.api.http) = {
  50. post: "/v1:provideValidationFeedback"
  51. body: "*"
  52. };
  53. }
  54. }
  55. // The request for validating an address.
  56. message ValidateAddressRequest {
  57. // Required. The address being validated. Unformatted addresses should be
  58. // submitted via [`address_lines`][google.type.PostalAddress.address_lines].
  59. //
  60. // The total length of the fields in this input must not exceed 280
  61. // characters.
  62. //
  63. // Supported regions can be found in the
  64. // [FAQ](https://developers.google.com/maps/documentation/address-validation/faq#which_regions_are_currently_supported).
  65. //
  66. // The [language_code][google.type.PostalAddress.language_code] value in the
  67. // input address is reserved for future uses and is ignored today. The
  68. // validated address result will be populated based on the preferred language
  69. // for the given address, as identified by the system.
  70. //
  71. // The Address Validation API ignores the values in
  72. // [recipients][google.type.PostalAddress.recipients] and
  73. // [organization][google.type.PostalAddress.organization]. Any values in those
  74. // fields will be discarded and not returned. Please do not set them.
  75. google.type.PostalAddress address = 1 [(google.api.field_behavior) = REQUIRED];
  76. // This field must be empty for the first address validation request. If
  77. // more requests are necessary to fully validate a single address (for
  78. // example if the changes the user makes after the initial validation need to
  79. // be re-validated), then each followup request must populate this field with
  80. // the
  81. // [response_id][google.maps.addressvalidation.v1.ValidateAddressResponse.response_id]
  82. // from the very first response in the validation sequence.
  83. string previous_response_id = 2;
  84. // Enables USPS CASS compatible mode. This affects _only_ the
  85. // [google.maps.addressvalidation.v1.ValidationResult.usps_data] field of
  86. // [google.maps.addressvalidation.v1.ValidationResult]. Note: for USPS CASS
  87. // enabled requests for addresses in Puerto Rico, a
  88. // [google.type.PostalAddress.region_code] of the `address` must be provided
  89. // as "PR", or an [google.type.PostalAddress.administrative_area] of the
  90. // `address` must be provided as "Puerto Rico" (case-insensitive) or "PR".
  91. //
  92. // It's recommended to use a componentized `address`, or alternatively specify
  93. // at least two [google.type.PostalAddress.address_lines] where the first line
  94. // contains the street number and name and the second line contains the city,
  95. // state, and zip code.
  96. bool enable_usps_cass = 3;
  97. }
  98. // The response to an address validation request.
  99. message ValidateAddressResponse {
  100. // The result of the address validation.
  101. ValidationResult result = 1;
  102. // The UUID that identifies this response. If the address needs to be
  103. // re-validated, this UUID *must* accompany the new request.
  104. string response_id = 2;
  105. }
  106. // The request for sending validation feedback.
  107. message ProvideValidationFeedbackRequest {
  108. // The possible final outcomes of the sequence of address validation requests
  109. // needed to validate an address.
  110. enum ValidationConclusion {
  111. // This value is unused.
  112. // If the `ProvideValidationFeedbackRequest.conclusion` field is set to
  113. // `VALIDATION_CONCLUSION_UNSPECIFIED`, an `INVALID_ARGUMENT` error will be
  114. // returned.
  115. VALIDATION_CONCLUSION_UNSPECIFIED = 0;
  116. // The version of the address returned by the Address Validation API was
  117. // used for the transaction.
  118. VALIDATED_VERSION_USED = 1;
  119. // The version of the address provided by the user was used for the
  120. // transaction
  121. USER_VERSION_USED = 2;
  122. // A version of the address that was entered after the last validation
  123. // attempt but that was not re-validated was used for the transaction.
  124. UNVALIDATED_VERSION_USED = 3;
  125. // The transaction was abandoned and the address was not used.
  126. UNUSED = 4;
  127. }
  128. // Required. The outcome of the sequence of validation attempts.
  129. //
  130. // If this field is set to `VALIDATION_CONCLUSION_UNSPECIFIED`, an
  131. // `INVALID_ARGUMENT` error will be returned.
  132. ValidationConclusion conclusion = 1 [(google.api.field_behavior) = REQUIRED];
  133. // Required. The ID of the response that this feedback is for. This should be the
  134. // [response_id][google.maps.addressvalidation.v1.ValidateAddressRequest.response_id]
  135. // from the first response in a series of address validation attempts.
  136. string response_id = 2 [(google.api.field_behavior) = REQUIRED];
  137. }
  138. // The response for validation feedback.
  139. //
  140. // The response is empty if the feedback is sent successfully.
  141. message ProvideValidationFeedbackResponse {
  142. }
  143. // The result of validating an address.
  144. message ValidationResult {
  145. // Overall verdict flags
  146. Verdict verdict = 1;
  147. // Information about the address itself as opposed to the geocode.
  148. Address address = 2;
  149. // Information about the location and place that the address geocoded to.
  150. Geocode geocode = 3;
  151. // Other information relevant to deliverability.
  152. AddressMetadata metadata = 4;
  153. // Extra deliverability flags provided by USPS. Only provided in region `US`
  154. // and `PR`.
  155. UspsData usps_data = 5;
  156. }
  157. // High level overview of the address validation result and geocode.
  158. message Verdict {
  159. // The various granularities that an address or a geocode can have.
  160. // When used to indicate granularity for an *address*, these values indicate
  161. // with how fine a granularity the address identifies a mailing destination.
  162. // For example, an address such as "123 Main Street, Redwood City, CA, 94061"
  163. // identifies a `PREMISE` while something like "Redwood City, CA, 94061"
  164. // identifies a `LOCALITY`. However, if we are unable to find a geocode for
  165. // "123 Main Street" in Redwood City, the geocode returned might be of
  166. // `LOCALITY` granularity even though the address is more granular.
  167. enum Granularity {
  168. // Default value. This value is unused.
  169. GRANULARITY_UNSPECIFIED = 0;
  170. // Below-building level result, such as an apartment.
  171. SUB_PREMISE = 1;
  172. // Building-level result.
  173. PREMISE = 2;
  174. // A geocode that should be very close to the building-level location of
  175. // the address. Only used for geocodes and not for addresses.
  176. PREMISE_PROXIMITY = 3;
  177. // The address or geocode indicates a block. Only used in regions which
  178. // have block-level addressing, such as Japan.
  179. BLOCK = 4;
  180. // The geocode or address is granular to route, such as a street, road, or
  181. // highway.
  182. ROUTE = 5;
  183. // All other granularities, which are bucketed together since they are not
  184. // deliverable.
  185. OTHER = 6;
  186. }
  187. // The granularity of the **input** address. This is the result of parsing the
  188. // input address and does not give any validation signals. For validation
  189. // signals, refer to `validation_granularity` below.
  190. //
  191. // For example, if the input address includes a specific apartment number,
  192. // then the `input_granularity` here will be `SUB_PREMISE`. If we cannot match
  193. // the apartment number in the databases or the apartment number is invalid,
  194. // the `validation_granularity` will likely be `PREMISE` or below.
  195. Granularity input_granularity = 1;
  196. // The granularity level that the API can fully **validate** the address to.
  197. // For example, an `validation_granularity` of `PREMISE` indicates all address
  198. // components at the level of `PREMISE` or more coarse can be validated.
  199. //
  200. // Per address component validation result can be found in
  201. // [google.maps.addressvalidation.v1.Address.address_components].
  202. Granularity validation_granularity = 2;
  203. // Information about the granularity of the
  204. // [`geocode`][google.maps.addressvalidation.v1.ValidationResult.geocode].
  205. // This can be understood as the semantic meaning of how coarse or fine the
  206. // geocoded location is.
  207. //
  208. // This can differ from the `validation_granularity` above occasionally. For
  209. // example, our database might record the existence of an apartment number but
  210. // do not have a precise location for the apartment within a big apartment
  211. // complex. In that case, the `validation_granularity` will be `SUB_PREMISE`
  212. // but the `geocode_granularity` will be `PREMISE`.
  213. Granularity geocode_granularity = 3;
  214. // The address is considered complete if there are no unresolved tokens, no
  215. // unexpected or missing address components. See
  216. // [`missing_component_types`][google.maps.addressvalidation.v1.Address.missing_component_types],
  217. // [`unresolved_tokens`][google.maps.addressvalidation.v1.Address.unresolved_tokens]
  218. // or
  219. // [`unexpected`][google.maps.addressvalidation.v1.AddressComponent.unexpected]
  220. // fields for more details.
  221. bool address_complete = 4;
  222. // At least one address component cannot be categorized or validated, see
  223. // [google.maps.addressvalidation.v1.Address.address_components] for
  224. // details.
  225. bool has_unconfirmed_components = 5;
  226. // At least one address component was inferred (added) that wasn't in the
  227. // input, see
  228. // [google.maps.addressvalidation.v1.Address.address_components] for
  229. // details.
  230. bool has_inferred_components = 6;
  231. // At least one address component was replaced, see
  232. // [google.maps.addressvalidation.v1.Address.address_components] for
  233. // details.
  234. bool has_replaced_components = 7;
  235. }