CINXE.COM
Protocol Buffers Well-Known Types | Protocol Buffers Documentation
<!doctype html><html itemscope itemtype=http://schema.org/WebPage lang=en class=no-js><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name=generator content="Hugo 0.121.2"><meta name=robots content="index, follow"><link rel="shortcut icon" href=/favicons/favicon.ico><link rel=apple-touch-icon href=/favicons/apple-touch-icon-180x180.png sizes=180x180><link rel=icon type=image/png href=/favicons/favicon-16x16.png sizes=16x16><link rel=icon type=image/png href=/favicons/favicon-32x32.png sizes=32x32><link rel=icon type=image/png href=/favicons/android-36x36.png sizes=36x36><link rel=icon type=image/png href=/favicons/android-48x48.png sizes=48x48><link rel=icon type=image/png href=/favicons/android-72x72.png sizes=72x72><link rel=icon type=image/png href=/favicons/android-96x96.png sizes=96x96><link rel=icon type=image/png href=/favicons/android-144x144.png sizes=144x144><link rel=icon type=image/png href=/favicons/android-192x192.png sizes=192x192><title>Protocol Buffers Well-Known Types | Protocol Buffers Documentation</title> <meta name=description content="API documentation for the google.protobuf package."><meta property="og:title" content="Protocol Buffers Well-Known Types"><meta property="og:description" content="API documentation for the google.protobuf package."><meta property="og:type" content="article"><meta property="og:url" content="https://protobuf.dev/reference/protobuf/google.protobuf/"><meta property="article:section" content="reference"><meta itemprop=name content="Protocol Buffers Well-Known Types"><meta itemprop=description content="API documentation for the google.protobuf package."><meta itemprop=wordCount content="3314"><meta itemprop=keywords content><meta name=twitter:card content="summary"><meta name=twitter:title content="Protocol Buffers Well-Known Types"><meta name=twitter:description content="API documentation for the google.protobuf package."><link rel=preload href=/scss/main.min.6a57e8f3f347dea5d31cb48e3b4ea9fdae32d499473089bdef9b45457b5debb8.css as=style><link href=/scss/main.min.6a57e8f3f347dea5d31cb48e3b4ea9fdae32d499473089bdef9b45457b5debb8.css rel=stylesheet integrity><script src=https://code.jquery.com/jquery-3.6.0.min.js integrity=sha384-vtXRMe3mGCbOeY7l30aIg8H9p3GdeSe4IFlP6G8JMa7o7lXvnz3GFKzPxzJdPfGK crossorigin=anonymous></script><script async src="https://www.googletagmanager.com/gtag/js?id=G-5L8P8GRN4Y"></script><script>var doNotTrack=!1;if(!doNotTrack){window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments)}gtag("js",new Date),gtag("config","G-5L8P8GRN4Y")}</script></head><body class=td-page><header><nav class="js-navbar-scroll navbar navbar-expand navbar-dark flex-column flex-md-row td-navbar"><a class=navbar-brand href=/><span class="navbar-brand__logo navbar-logo"></span><span class=navbar-brand__name>Protocol Buffers Documentation</span></a><div class="td-navbar-nav-scroll ml-md-auto" id=main_navbar><ul class="navbar-nav mt-2 mt-lg-0"></ul></div><div class="navbar-nav d-none d-lg-block"><div class=td-search><div class=td-search__icon></div><input type=search class="td-search__input form-control td-search-input" placeholder="Search this site…" aria-label="Search this site…" autocomplete=off></div></div></nav></header><div class="container-fluid td-outer"><div class=td-main><div class="row flex-xl-nowrap"><aside class="col-12 col-md-3 col-xl-2 td-sidebar d-print-none"><div id=td-sidebar-menu class=td-sidebar__inner><div id=content-mobile><form class="td-sidebar__search d-flex align-items-center"><div class=td-search><div class=td-search__icon></div><input type=search class="td-search__input form-control td-search-input" placeholder="Search this site…" aria-label="Search this site…" autocomplete=off></div><button class="btn btn-link td-sidebar__toggle d-md-none p-0 ml-3 fas fa-bars" type=button data-toggle=collapse data-target=#td-section-nav aria-controls=td-section-nav aria-expanded=false aria-label="Toggle section navigation"></button></form></div><div id=content-desktop></div><nav class="collapse td-sidebar-nav" id=td-section-nav><ul class="td-sidebar-nav__section pr-md-3 ul-0"><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child active-path" id=m--li><a href=/ class="align-left pl-0 td-sidebar-link td-sidebar-link__section tree-root" id=m-><span>Protocol Buffers</span></a><ul class=ul-1><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-overview-li><a href=/overview/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-overview><span>Overview</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-news-li><a href=/news/ class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-news><span>News</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-programming-guides-li><a href=/programming-guides/ class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-programming-guides><span>Programming Guides</span></a><ul class="ul-2 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guideseditions-li><a href=/programming-guides/editions/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guideseditions><span>Language Guide (editions)</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guidesproto2-li><a href=/programming-guides/proto2/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guidesproto2><span>Language Guide (proto 2)</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guidesproto3-li><a href=/programming-guides/proto3/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guidesproto3><span>Language Guide (proto 3)</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guidesproto-limits-li><a href=/programming-guides/proto-limits/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guidesproto-limits><span>Proto Limits</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guidesstyle-li><a href=/programming-guides/style/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guidesstyle><span>Style Guide</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guidesenum-li><a href=/programming-guides/enum/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guidesenum><span>Enum Behavior</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guidesencoding-li><a href=/programming-guides/encoding/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guidesencoding><span>Encoding</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guidesjson-li><a href=/programming-guides/json/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guidesjson><span>ProtoJSON Format</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guidestechniques-li><a href=/programming-guides/techniques/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guidestechniques><span>Techniques</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guidesaddons-li><a href=/programming-guides/addons/ title="Third-Party Add-ons" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guidesaddons><span>Add-ons</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guidesextension_declarations-li><a href=/programming-guides/extension_declarations/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guidesextension_declarations><span>Extension Declarations</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guidesfield_presence-li><a href=/programming-guides/field_presence/ title="Application Note: Field Presence" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guidesfield_presence><span>Field Presence</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guidesserialization-not-canonical-li><a href=/programming-guides/serialization-not-canonical/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guidesserialization-not-canonical><span>Proto Serialization Is Not Canonical</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guidesnullable-getters-setters-li><a href=/programming-guides/nullable-getters-setters/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guidesnullable-getters-setters><span>No Nullable Setters/Getters Support</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guidesbest-practices-li><a href=/programming-guides/best-practices/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guidesbest-practices><span>Proto Best Practices</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guidesdos-donts-li><a href=/programming-guides/dos-donts/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guidesdos-donts><span>Proto Best Practices</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guidesapi-li><a href=/programming-guides/api/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guidesapi><span>API Best Practices</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-programming-guides1-1-1-li><a href=/programming-guides/1-1-1/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-programming-guides1-1-1><span>1-1-1 Best Practice</span></a></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-editions-li><a href=/editions/ class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-editions><span>Protobuf Editions</span></a><ul class="ul-2 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-editionsoverview-li><a href=/editions/overview/ title="Protobuf Editions Overview" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-editionsoverview><span>Overview</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-editionsfeatures-li><a href=/editions/features/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-editionsfeatures><span>Feature Settings for Editions</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-editionsimplementation-li><a href=/editions/implementation/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-editionsimplementation><span>Implementing Editions Support</span></a></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-getting-started-li><a href=/getting-started/ class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-getting-started><span>Tutorials</span></a><ul class="ul-2 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-getting-startedcpptutorial-li><a href=/getting-started/cpptutorial/ title="Protocol Buffer Basics: C++" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-getting-startedcpptutorial><span>C++</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-getting-startedcsharptutorial-li><a href=/getting-started/csharptutorial/ title="Protocol Buffer Basics: C#" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-getting-startedcsharptutorial><span>C#</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-getting-starteddarttutorial-li><a href=/getting-started/darttutorial/ title="Protocol Buffer Basics: Dart" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-getting-starteddarttutorial><span>Dart</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-getting-startedgotutorial-li><a href=/getting-started/gotutorial/ title="Protocol Buffer Basics: Go" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-getting-startedgotutorial><span>Go</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-getting-startedjavatutorial-li><a href=/getting-started/javatutorial/ title="Protocol Buffer Basics: Java" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-getting-startedjavatutorial><span>Java</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-getting-startedkotlintutorial-li><a href=/getting-started/kotlintutorial/ title="Protocol Buffer Basics: Kotlin" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-getting-startedkotlintutorial><span>Kotlin</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-getting-startedpythontutorial-li><a href=/getting-started/pythontutorial/ title="Protocol Buffer Basics: Python" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-getting-startedpythontutorial><span>Python</span></a></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child active-path" id=m-reference-li><a href=/reference/ class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-reference><span>Reference Guides</span></a><ul class="ul-2 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-referencecpp-li><a href=/reference/cpp/ title="C++ Reference" class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-referencecpp><span>C++</span></a><ul class="ul-3 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencecppcpp-generated-li><a href=/reference/cpp/cpp-generated/ title="C++ Generated Code Guide" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencecppcpp-generated><span>Generated Code Guide</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencecpparenas-li><a href=/reference/cpp/arenas/ title="C++ Arena Allocation Guide" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencecpparenas><span>Arena Allocation Guide</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencecppabseil-li><a href=/reference/cpp/abseil/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencecppabseil><span>Asbseil Support</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencecppapi-docs-link-li><a href=/reference/cpp/api-docs/ target=_blank rel=noopener class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencecppapi-docs-link><span>C++ API</span></a></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-referencecsharp-li><a href=/reference/csharp/ title="C# Reference" class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-referencecsharp><span>C#</span></a><ul class="ul-3 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencecsharpcsharp-generated-li><a href=/reference/csharp/csharp-generated/ title="C# Generated Code Guide" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencecsharpcsharp-generated><span>Generated Code Guide</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencecsharpapi-docs-link-li><a href=/reference/csharp/api-docs target=_blank rel=noopener class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencecsharpapi-docs-link><span>C# API</span></a></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-referencedart-li><a href=/reference/dart/ title="Dart Reference" class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-referencedart><span>Dart</span></a><ul class="ul-3 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencedartdart-generated-li><a href=/reference/dart/dart-generated/ title="Dart Generated Code" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencedartdart-generated><span>Generated Code</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencedartapi-docs-link-li><a href=https://pub.dartlang.org/documentation/protobuf target=_blank rel=noopener class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencedartapi-docs-link><span>Dart API</span></a></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-referencego-li><a href=/reference/go/ title="Go Reference" class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-referencego><span>Go</span></a><ul class="ul-3 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencegogo-generated-li><a href=/reference/go/go-generated/ title="Go Generated Code Guide" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencegogo-generated><span>Generated Code Guide</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencegofaq-li><a href=/reference/go/faq/ title="Go FAQ" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencegofaq><span>FAQ</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencegosize-li><a href=/reference/go/size/ title="Go Size Semantics" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencegosize><span>Size Semantics</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencegoapi-docs-link-li><a href=https://pkg.go.dev/google.golang.org/protobuf/proto target=_blank rel=noopener class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencegoapi-docs-link><span>Go API</span></a></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-referencejava-li><a href=/reference/java/ title="Java Reference" class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-referencejava><span>Java</span></a><ul class="ul-3 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencejavajava-generated-li><a href=/reference/java/java-generated/ title="Java Generated Code Guide" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencejavajava-generated><span>Generated Code Guide</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencejavajava-proto-names-li><a href=/reference/java/java-proto-names/ title="Java Proto Names" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencejavajava-proto-names><span>Generated Proto Names</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencejavaapi-docs-link-li><a href=/reference/java/api-docs/overview-summary.html target=_blank rel=noopener class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencejavaapi-docs-link><span>Java API</span></a></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-referencekotlin-li><a href=/reference/kotlin/ title="Kotlin Reference" class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-referencekotlin><span>Kotlin</span></a><ul class="ul-3 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencekotlinapi-docs-li><a href=/reference/kotlin/api-docs/ title="Kotlin Reference" class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-referencekotlinapi-docs><span>Kotlin</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencekotlinkotlin-generated-li><a href=/reference/kotlin/kotlin-generated/ title="Kotlin Generated Code Guide" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencekotlinkotlin-generated><span>Generated Code Guide</span></a></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-referenceobjective-c-li><a href=/reference/objective-c/ title="Objective-C Reference" class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-referenceobjective-c><span>Objective-C</span></a><ul class="ul-3 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referenceobjective-cobjective-c-generated-li><a href=/reference/objective-c/objective-c-generated/ title="Objective-C Generated Code Guide" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referenceobjective-cobjective-c-generated><span>Generated Code Guide</span></a></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-referencephp-li><a href=/reference/php/ title="PHP Reference" class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-referencephp><span>PHP</span></a><ul class="ul-3 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencephpphp-generated-li><a href=/reference/php/php-generated/ title="PHP Generated Code Guide" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencephpphp-generated><span>Generated Code Guide</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencephpapi-docs-link-li><a href=/reference/php/api-docs/ target=_blank rel=noopener class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencephpapi-docs-link><span>PHP API</span></a></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-referencepython-li><a href=/reference/python/ title="Python Reference" class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-referencepython><span>Python</span></a><ul class="ul-3 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencepythonpython-generated-li><a href=/reference/python/python-generated/ title="Python Generated Code Guide" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencepythonpython-generated><span>Generated Code Guide</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencepythonapi-docs-link-li><a href=https://googleapis.dev/python/protobuf/latest/ target=_blank rel=noopener class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencepythonapi-docs-link><span>Python API</span></a></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-referenceruby-li><a href=/reference/ruby/ title="Ruby Reference" class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-referenceruby><span>Ruby</span></a><ul class="ul-3 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referencerubyruby-generated-li><a href=/reference/ruby/ruby-generated/ title="Ruby Generated Code Guide" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referencerubyruby-generated><span>Generated Code Guide</span></a></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child active-path" id=m-referenceprotobuf-li><a href=/reference/protobuf/ title="Protocol Buffers Reference" class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-referenceprotobuf><span>Protocol Buffers</span></a><ul class="ul-3 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referenceprotobufedition-2023-spec-li><a href=/reference/protobuf/edition-2023-spec/ title="Protocol Buffers Edition 2023 Language Specification" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referenceprotobufedition-2023-spec><span>2023 Language Specification</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referenceprotobufproto2-spec-li><a href=/reference/protobuf/proto2-spec/ title="Protocol Buffers Version 2 Language Specification" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referenceprotobufproto2-spec><span>Version 2 Language Specification</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referenceprotobufproto3-spec-li><a href=/reference/protobuf/proto3-spec/ title="Protocol Buffers Version 3 Language Specification" class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referenceprotobufproto3-spec><span>Version 3 Language Specification</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referenceprotobuftextformat-spec-li><a href=/reference/protobuf/textformat-spec/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referenceprotobuftextformat-spec><span>Text Format Language Specification</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child active-path" id=m-referenceprotobufgoogleprotobuf-li><a href=/reference/protobuf/google.protobuf/ title="Protocol Buffers Well-Known Types" class="align-left pl-0 active td-sidebar-link td-sidebar-link__page" id=m-referenceprotobufgoogleprotobuf><span class=td-sidebar-nav-active-item>Well-Known Types</span></a></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-referenceother-li><a href=/reference/other/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-referenceother><span>Other Languages</span></a></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section with-child" id=m-support-li><a href=/support/ class="align-left pl-0 td-sidebar-link td-sidebar-link__section" id=m-support><span>Support</span></a><ul class="ul-2 foldable"><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-supportversion-support-li><a href=/support/version-support/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-supportversion-support><span>Version Support</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-supportmigration-li><a href=/support/migration/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-supportmigration><span>Migration Guide</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-supportcross-version-runtime-guarantee-li><a href=/support/cross-version-runtime-guarantee/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-supportcross-version-runtime-guarantee><span>Cross-Version Runtime Guarantee</span></a></li></ul></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-downloads-li><a href=/downloads/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-downloads><span>Downloads</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-history-li><a href=/history/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-history><span>History</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-forum-link-li><a href=https://groups.google.com/g/protobuf target=_blank rel=noopener class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-forum-link><span>Forum</span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-navbar-li><a href=/navbar/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-navbar><span></span></a></li><li class="td-sidebar-nav__section-title td-sidebar-nav__section without-child" id=m-search-li><a href=/search/ class="align-left pl-0 td-sidebar-link td-sidebar-link__page" id=m-search><span>Search Results</span></a></li></ul></li></ul></nav></div></aside><aside class="d-none d-xl-block col-xl-2 td-sidebar-toc d-print-none"><div class="td-page-meta ml-2 pb-1 pt-2 mb-0"><a href=https://github.com/protocolbuffers/protocolbuffers.github.io/tree/main/content/reference/protobuf/google.protobuf.md class=td-page-meta--view target=_blank rel=noopener><i class="fa-solid fa-file-lines fa-fw"></i> View page source</a> <a href=https://github.com/protocolbuffers/protocolbuffers.github.io/edit/main/content/reference/protobuf/google.protobuf.md class=td-page-meta--edit target=_blank rel=noopener><i class="fa-solid fa-pen-to-square fa-fw"></i> Edit this page</a> <a href="https://github.com/protocolbuffers/protocolbuffers.github.io/new/main/content/reference/protobuf/google.protobuf.md?filename=change-me.md&value=---%0Atitle%3A+%22Long+Page+Title%22%0AlinkTitle%3A+%22Short+Nav+Title%22%0Aweight%3A+100%0Adescription%3A+%3E-%0A+++++Page+description+for+heading+and+indexes.%0A---%0A%0A%23%23+Heading%0A%0AEdit+this+template+to+create+your+new+page.%0A%0A%2A+Give+it+a+good+name%2C+ending+in+%60.md%60+-+e.g.+%60getting-started.md%60%0A%2A+Edit+the+%22front+matter%22+section+at+the+top+of+the+page+%28weight+controls+how+its+ordered+amongst+other+pages+in+the+same+directory%3B+lowest+number+first%29.%0A%2A+Add+a+good+commit+message+at+the+bottom+of+the+page+%28%3C80+characters%3B+use+the+extended+description+field+for+more+detail%29.%0A%2A+Create+a+new+branch+so+you+can+preview+your+new+file+and+request+a+review+via+Pull+Request.%0A" class=td-page-meta--child target=_blank rel=noopener><i class="fa-solid fa-pen-to-square fa-fw"></i> Create child page</a> <a href="https://github.com/protocolbuffers/protocolbuffers.github.io/issues/new?title=Protocol%20Buffers%20Well-Known%20Types" class=td-page-meta--issue target=_blank rel=noopener><i class="fa-solid fa-list-check fa-fw"></i> Create documentation issue</a> <a href=https://github.com/protocolbuffers/protobuf/issues/new class=td-page-meta--project-issue target=_blank rel=noopener><i class="fa-solid fa-list-check fa-fw"></i> Create project issue</a></div><div class=td-toc><nav id=TableOfContents><ul><li><a href=#index>Index</a></li><li><a href=#any>Any</a><ul><li></li></ul></li><li><a href=#api>Api</a></li><li><a href=#bool-value>BoolValue</a></li><li><a href=#bytes-value>BytesValue</a></li><li><a href=#double-value>DoubleValue</a></li><li><a href=#duration>Duration</a></li><li><a href=#empty>Empty</a></li><li><a href=#enum>Enum</a></li><li><a href=#enum-value>EnumValue</a></li><li><a href=#field>Field</a></li><li><a href=#field-cardinality>Cardinality</a></li><li><a href=#field-kind>Kind</a></li><li><a href=#field-mask>FieldMask</a><ul><li></li></ul></li><li><a href=#float-value>FloatValue</a></li><li><a href=#int32-value>Int32Value</a></li><li><a href=#int64-value>Int64Value</a></li><li><a href=#list-value>ListValue</a></li><li><a href=#method>Method</a></li><li><a href=#mixin>Mixin</a></li><li><a href=#null-value>NullValue</a></li><li><a href=#option>Option</a></li><li><a href=#source-context>SourceContext</a></li><li><a href=#string-value>StringValue</a></li><li><a href=#struct>Struct</a></li><li><a href=#syntax>Syntax</a></li><li><a href=#timestamp>Timestamp</a></li><li><a href=#type>Type</a></li><li><a href=#uint32-value>UInt32Value</a></li><li><a href=#uint64-value>UInt64Value</a></li><li><a href=#value>Value</a></li></ul></nav></div></aside><main class="col-12 col-md-9 col-xl-8 pl-md-5" role=main><nav aria-label=breadcrumb class=td-breadcrumbs><ol class=breadcrumb><li class=breadcrumb-item><a href=https://protobuf.dev/reference/>Reference Guides</a></li><li class=breadcrumb-item><a href=https://protobuf.dev/reference/protobuf/>Protocol Buffers</a></li><li class="breadcrumb-item active" aria-current=page><a href=https://protobuf.dev/reference/protobuf/google.protobuf/ aria-disabled=true class="btn-link disabled">Well-Known Types</a></li></ol></nav><div class=td-content><h1>Protocol Buffers Well-Known Types</h1><div class=lead>API documentation for the google.protobuf package.</div><header class=article-meta></header><h2 id=index>Index</h2><ul><li><a href=#any><code>Any</code></a> (message)</li><li><a href=#api><code>Api</code></a> (message)</li><li><a href=#bool-value><code>BoolValue</code></a> (message)</li><li><a href=#bytes-value><code>BytesValue</code></a> (message)</li><li><a href=#double-value><code>DoubleValue</code></a> (message)</li><li><a href=#duration><code>Duration</code></a> (message)</li><li><a href=#empty><code>Empty</code></a> (message)</li><li><a href=#enum><code>Enum</code></a> (message)</li><li><a href=#enum-value><code>EnumValue</code></a> (message)</li><li><a href=#field><code>Field</code></a> (message)</li><li><a href=#field-cardinality><code>Field.Cardinality</code></a> (enum)</li><li><a href=#field-kind><code>Field.Kind</code></a> (enum)</li><li><a href=#field-mask><code>FieldMask</code></a> (message)</li><li><a href=#float-value><code>FloatValue</code></a> (message)</li><li><a href=#int32-value><code>Int32Value</code></a> (message)</li><li><a href=#int64-value><code>Int64Value</code></a> (message)</li><li><a href=#list-value><code>ListValue</code></a> (message)</li><li><a href=#method><code>Method</code></a> (message)</li><li><a href=#mixin><code>Mixin</code></a> (message)</li><li><a href=#null-value><code>NullValue</code></a> (enum)</li><li><a href=#option><code>Option</code></a> (message)</li><li><a href=#source-context><code>SourceContext</code></a> (message)</li><li><a href=#string-value><code>StringValue</code></a> (message)</li><li><a href=#struct><code>Struct</code></a> (message)</li><li><a href=#syntax><code>Syntax</code></a> (enum)</li><li><a href=#timestamp><code>Timestamp</code></a> (message)</li><li><a href=#type><code>Type</code></a> (message)</li><li><a href=#uint32-value><code>UInt32Value</code></a> (message)</li><li><a href=#uint64-value><code>UInt64Value</code></a> (message)</li><li><a href=#value><code>Value</code></a> (message)</li></ul><p>Well-Known Types that end in “<code>Value</code>” are wrapper messages for other types, such as <code>BoolValue</code> and <code>EnumValue</code>. These are now obsolete. The only reasons to use wrappers today would be:</p><ul><li>Wire compatibility with messages that already use them.</li><li>If you want to put a scalar value into an <code>Any</code> message.</li></ul><p>In most cases, there are better options:</p><ul><li>For new messages, it’s better to use regular explicit-presence fields (<code>optional</code> in proto2/proto3, regular field in edition >= 2023).</li><li>Extensions are generally a better option than <code>Any</code> fields.</li></ul><h2 id=any>Any</h2><p><code>Any</code> contains an arbitrary serialized message along with a URL that describes the type of the serialized message.</p><h4 id=json>JSON</h4><p>The JSON representation of an <code>Any</code> value uses the regular representation of the deserialized, embedded message, with an additional field <code>@type</code> which contains the type URL. Example:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-proto data-lang=proto><span style=display:flex><span><span style=color:#204a87;font-weight:700>package</span> <span style=color:#000>google</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>profile</span><span style=color:#000;font-weight:700>;</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#204a87;font-weight:700>message</span> <span style=color:#000>Person</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#204a87;font-weight:700>string</span> <span style=color:#000>first_name</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#0000cf;font-weight:700>1</span><span style=color:#000;font-weight:700>;</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#204a87;font-weight:700>string</span> <span style=color:#000>last_name</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#0000cf;font-weight:700>2</span><span style=color:#000;font-weight:700>;</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#000;font-weight:700>}</span><span style=color:#a40000> </span></span></span></code></pre></div><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#000;font-weight:700>{</span> </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"@type"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>"type.googleapis.com/google.profile.Person"</span><span style=color:#000;font-weight:700>,</span> </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"firstName"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#a40000><string></span><span style=color:#000;font-weight:700>,</span> </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"lastName"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#a40000><string></span> </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span> </span></span></code></pre></div><p>If the embedded message type is well-known and has a custom JSON representation, that representation will be embedded adding a field <code>value</code> which holds the custom JSON in addition to the <code>@type</code> field. Example (for message <code>google.protobuf.Duration</code>):</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#000;font-weight:700>{</span> </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"@type"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>"type.googleapis.com/google.protobuf.Duration"</span><span style=color:#000;font-weight:700>,</span> </span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>"value"</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>"1.212s"</span> </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span> </span></span></code></pre></div><table id=google.protobuf.Any.FIELDS><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>type_url</code></td><td><code class=apitype>string</code></td><td><p>A URL/resource name whose content describes the type of the serialized message.</p><p>For URLs which use the schema <code>http</code>, <code>https</code>, or no schema, the following restrictions and interpretations apply:</p><ul><li>If no schema is provided, <code>https</code> is assumed.</li><li>The last segment of the URL's path must represent the fully qualified name of the type (as in <code>path/google.protobuf.Duration</code>).</li><li>An HTTP GET on the URL must yield a <code><a href=#type>google.protobuf.Type</a></code> value in binary format, or produce an error.</li><li>Applications are allowed to cache lookup results based on the URL, or have them precompiled into a binary to avoid any lookup. Therefore, binary compatibility needs to be preserved on changes to types. (Use versioned type names to manage breaking changes.)</li></ul><p>Schemas other than <code>http</code>, <code>https</code> (or the empty schema) might be used with implementation specific semantics.</p></td></tr><tr><td><code>value</code></td><td><code class=apitype>bytes</code></td><td>Must be valid serialized data of the above specified type.</td></tr></tbody></table><h2 id=api>Api</h2><p>Api is a light-weight descriptor for a protocol buffer service.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td><td>The fully qualified name of this api, including package name followed by the api's simple name.</td></tr><tr><td><code>methods</code></td><td><code><a href=#method>Method</a></code></td><td>The methods of this api, in unspecified order.</td></tr><tr><td><code>options</code></td><td><code><a href=#option>Option</a></code></td><td>Any metadata attached to the API.</td></tr><tr><td><code>version</code></td><td><code>string</code></td><td><p>A version string for this api. If specified, must have the form <code>major-version.minor-version</code>, as in <code>1.10</code>. If the minor version is omitted, it defaults to zero. If the entire version field is empty, the major version is derived from the package name, as outlined below. If the field is not empty, the version in the package name will be verified to be consistent with what is provided here.</p><p>The versioning schema uses <a href=http://semver.org>semantic versioning</a> where the major version number indicates a breaking change and the minor version an additive, non-breaking change. Both version numbers are signals to users what to expect from different versions, and should be carefully chosen based on the product plan.</p><p>The major version is also reflected in the package name of the API, which must end in <code>v<major-version></code>, as in <code>google.feature.v1</code>. For major versions 0 and 1, the suffix can be omitted. Zero major versions must only be used for experimental, none-GA apis.</p></td></tr><tr><td><code>source_context</code></td><td><code><code><a href=#source-context>SourceContext</a></code></code></td><td>Source context for the protocol buffer service represented by this message.</td></tr><tr><td><code>mixins</code></td><td><code><code><a href=#mixin>Mixin</a></code></code></td><td>Included APIs. See <code><a href=#mixin>Mixin</a></code>.</td></tr><tr><td><code>syntax</code></td><td><code><a href=#syntax>Syntax</a></code></td><td>The source syntax of the service.</td></tr></tbody></table><h2 id=bool-value>BoolValue</h2><p>Wrapper message for <code>bool</code>.</p><p>The JSON representation for <code>BoolValue</code> is JSON <code>true</code> and <code>false</code>.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code class=apitype>bool</code></td><td>The bool value.</td></tr></tbody></table><h2 id=bytes-value>BytesValue</h2><p>Wrapper message for <code>bytes</code>.</p><p>The JSON representation for <code>BytesValue</code> is JSON string.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>bytes</code></td><td>The bytes value.</td></tr></tbody></table><h2 id=double-value>DoubleValue</h2><p>Wrapper message for <code>double</code>.</p><p>The JSON representation for <code>DoubleValue</code> is JSON number.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>double</code></td><td>The double value.</td></tr></tbody></table><h2 id=duration>Duration</h2><p>A Duration represents a signed, fixed-length span of time represented as a count of seconds and fractions of seconds at nanosecond resolution. It is independent of any calendar and concepts like "day" or "month". It is related to Timestamp in that the difference between two Timestamp values is a Duration and it can be added or subtracted from a Timestamp. Range is approximately +-10,000 years.</p><p>Example 1: Compute Duration from two Timestamps in pseudo code.</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-c data-lang=c><span style=display:flex><span><span style=color:#000>Timestamp</span> <span style=color:#000>start</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000;font-weight:700>...;</span> </span></span><span style=display:flex><span><span style=color:#000>Timestamp</span> <span style=color:#000>end</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000;font-weight:700>...;</span> </span></span><span style=display:flex><span><span style=color:#000>Duration</span> <span style=color:#000>duration</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000;font-weight:700>...;</span> </span></span><span style=display:flex><span> </span></span><span style=display:flex><span><span style=color:#000>duration</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>seconds</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>end</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>seconds</span> <span style=color:#ce5c00;font-weight:700>-</span> <span style=color:#000>start</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>seconds</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span><span style=color:#000>duration</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>nanos</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>end</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>nanos</span> <span style=color:#ce5c00;font-weight:700>-</span> <span style=color:#000>start</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>nanos</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span> </span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>if</span> <span style=color:#000;font-weight:700>(</span><span style=color:#000>duration</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>seconds</span> <span style=color:#ce5c00;font-weight:700><</span> <span style=color:#0000cf;font-weight:700>0</span> <span style=color:#ce5c00;font-weight:700>&&</span> <span style=color:#000>duration</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>nanos</span> <span style=color:#ce5c00;font-weight:700>></span> <span style=color:#0000cf;font-weight:700>0</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>{</span> </span></span><span style=display:flex><span> <span style=color:#000>duration</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>seconds</span> <span style=color:#ce5c00;font-weight:700>+=</span> <span style=color:#0000cf;font-weight:700>1</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span> <span style=color:#000>duration</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>nanos</span> <span style=color:#ce5c00;font-weight:700>-=</span> <span style=color:#0000cf;font-weight:700>1000000000</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span> <span style=color:#204a87;font-weight:700>else</span> <span style=color:#204a87;font-weight:700>if</span> <span style=color:#000;font-weight:700>(</span><span style=color:#000>duration</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>seconds</span> <span style=color:#ce5c00;font-weight:700>></span> <span style=color:#0000cf;font-weight:700>0</span> <span style=color:#ce5c00;font-weight:700>&&</span> <span style=color:#000>duration</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>nanos</span> <span style=color:#ce5c00;font-weight:700><</span> <span style=color:#0000cf;font-weight:700>0</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>{</span> </span></span><span style=display:flex><span> <span style=color:#000>duration</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>seconds</span> <span style=color:#ce5c00;font-weight:700>-=</span> <span style=color:#0000cf;font-weight:700>1</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span> <span style=color:#000>duration</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>nanos</span> <span style=color:#ce5c00;font-weight:700>+=</span> <span style=color:#0000cf;font-weight:700>1000000000</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span> </span></span></code></pre></div><p>Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-c data-lang=c><span style=display:flex><span><span style=color:#000>Timestamp</span> <span style=color:#000>start</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000;font-weight:700>...;</span> </span></span><span style=display:flex><span><span style=color:#000>Duration</span> <span style=color:#000>duration</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000;font-weight:700>...;</span> </span></span><span style=display:flex><span><span style=color:#000>Timestamp</span> <span style=color:#000>end</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000;font-weight:700>...;</span> </span></span><span style=display:flex><span> </span></span><span style=display:flex><span><span style=color:#000>end</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>seconds</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>start</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>seconds</span> <span style=color:#ce5c00;font-weight:700>+</span> <span style=color:#000>duration</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>seconds</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span><span style=color:#000>end</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>nanos</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>start</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>nanos</span> <span style=color:#ce5c00;font-weight:700>+</span> <span style=color:#000>duration</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>nanos</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span> </span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>if</span> <span style=color:#000;font-weight:700>(</span><span style=color:#000>end</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>nanos</span> <span style=color:#ce5c00;font-weight:700><</span> <span style=color:#0000cf;font-weight:700>0</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>{</span> </span></span><span style=display:flex><span> <span style=color:#000>end</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>seconds</span> <span style=color:#ce5c00;font-weight:700>-=</span> <span style=color:#0000cf;font-weight:700>1</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span> <span style=color:#000>end</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>nanos</span> <span style=color:#ce5c00;font-weight:700>+=</span> <span style=color:#0000cf;font-weight:700>1000000000</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span> <span style=color:#204a87;font-weight:700>else</span> <span style=color:#204a87;font-weight:700>if</span> <span style=color:#000;font-weight:700>(</span><span style=color:#000>end</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>nanos</span> <span style=color:#ce5c00;font-weight:700>>=</span> <span style=color:#0000cf;font-weight:700>1000000000</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>{</span> </span></span><span style=display:flex><span> <span style=color:#000>end</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>seconds</span> <span style=color:#ce5c00;font-weight:700>+=</span> <span style=color:#0000cf;font-weight:700>1</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span> <span style=color:#000>end</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>nanos</span> <span style=color:#ce5c00;font-weight:700>-=</span> <span style=color:#0000cf;font-weight:700>1000000000</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span> </span></span></code></pre></div><p>The JSON representation for <code>Duration</code> is a <code>String</code> that ends in <code>s</code> to indicate seconds and is preceded by the number of seconds, with nanoseconds expressed as fractional seconds.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>seconds</code></td><td><code>int64</code></td><td>Signed seconds of the span of time. Must be from -315,576,000,000 to +315,576,000,000 inclusive.</td></tr><tr><td><code>nanos</code></td><td><code>int32</code></td><td>Signed fractions of a second at nanosecond resolution of the span of time. Durations less than one second are represented with a 0 <code>seconds</code> field and a positive or negative <code>nanos</code> field. For durations of one second or more, a non-zero value for the <code>nanos</code> field must be of the same sign as the <code>seconds</code> field. Must be from -999,999,999 to +999,999,999 inclusive.</td></tr></tbody></table><h2 id=empty>Empty</h2><p>A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-proto data-lang=proto><span style=display:flex><span><span style=color:#204a87;font-weight:700>service</span> <span style=color:#000>Foo</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#204a87;font-weight:700>rpc</span> <span style=color:#000>Bar</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>google.protobuf.Empty</span><span style=color:#000;font-weight:700>)</span> <span style=color:#204a87;font-weight:700>returns</span> <span style=color:#000;font-weight:700>(</span><span style=color:#000>google.protobuf.Empty</span><span style=color:#000;font-weight:700>);</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#000;font-weight:700>}</span><span style=color:#a40000> </span></span></span></code></pre></div><p>The JSON representation for <code>Empty</code> is empty JSON object <code>{}</code>.</p><h2 id=enum>Enum</h2><p>Enum type definition</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td><td>Enum type name.</td></tr><tr><td><code>enumvalue</code></td><td><code><a href=#enum-value>EnumValue</a></code></td><td>Enum value definitions.</td></tr><tr><td><code>options</code></td><td><code><a href=#option>Option</a></code></td><td>Protocol buffer options.</td></tr><tr><td><code>source_context</code></td><td><code><a href=#source-context>SourceContext</a></code></td><td>The source context.</td></tr><tr><td><code>syntax</code></td><td><code><a href=#syntax>Syntax</a></code></td><td>The source syntax.</td></tr></tbody></table><h2 id=enum-value>EnumValue</h2><p>Enum value definition.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td><td>Enum value name.</td></tr><tr><td><code>number</code></td><td><code>int32</code></td><td>Enum value number.</td></tr><tr><td><code>options</code></td><td><code><a href=#option>Option</a></code></td><td>Protocol buffer options.</td></tr></tbody></table><h2 id=field>Field</h2><p>A single field of a message type.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>kind</code></td><td><code><a href=#field-kind>Kind</a></code></td><td>The field type.</td></tr><tr><td><code>cardinality</code></td><td><code><a href=#field-cardinality>Cardinality</a></code></td><td>The field cardinality.</td></tr><tr><td><code>number</code></td><td><code>int32</code></td><td>The field number.</td></tr><tr><td><code>name</code></td><td><code>string</code></td><td>The field name.</td></tr><tr><td><code>type_url</code></td><td><code>string</code></td><td>The field type URL, without the scheme, for message or enumeration types. Example: <code>"type.googleapis.com/google.protobuf.Timestamp"</code>.</td></tr><tr><td><code>oneof_index</code></td><td><code>int32</code></td><td>The index of the field type in <code>Type.oneofs</code>, for message or enumeration types. The first type has index 1; zero means the type is not in the list.</td></tr><tr><td><code>packed</code></td><td><code>bool</code></td><td>Whether to use alternative packed wire representation.</td></tr><tr><td><code>options</code></td><td><code><a href=#option>Option</a></code></td><td>The protocol buffer options.</td></tr><tr><td><code>json_name</code></td><td><code>string</code></td><td>The field JSON name.</td></tr><tr><td><code>default_value</code></td><td><code>string</code></td><td>The string value of the default value of this field. Proto2 syntax only.</td></tr></tbody></table><h2 id=field-cardinality>Cardinality</h2><p>Whether a field is optional, required, or repeated.</p><table><thead><tr><th>Enum value</th><th>Description</th></tr></thead><tbody><tr><td><code>CARDINALITY_UNKNOWN</code></td><td>For fields with unknown cardinality.</td></tr><tr><td><code>CARDINALITY_OPTIONAL</code></td><td>For optional fields.</td></tr><tr><td><code>CARDINALITY_REQUIRED</code></td><td>For required fields. Proto2 syntax only.</td></tr><tr><td><code>CARDINALITY_REPEATED</code></td><td>For repeated fields.</td></tr></tbody></table><h2 id=field-kind>Kind</h2><p>Basic field types.</p><table class=matchpre><thead><tr><th>Enum value</th><th>Description</th></tr></thead><tbody><tr><td><code>TYPE_UNKNOWN</code></td><td>Field type unknown.</td></tr><tr><td><code>TYPE_DOUBLE</code></td><td>Field type double.</td></tr><tr><td><code>TYPE_FLOAT</code></td><td>Field type float.</td></tr><tr><td><code>TYPE_INT64</code></td><td>Field type int64.</td></tr><tr><td><code>TYPE_UINT64</code></td><td>Field type uint64.</td></tr><tr><td><code>TYPE_INT32</code></td><td>Field type int32.</td></tr><tr><td><code>TYPE_FIXED64</code></td><td>Field type fixed64.</td></tr><tr><td><code>TYPE_FIXED32</code></td><td>Field type fixed32.</td></tr><tr><td><code>TYPE_BOOL</code></td><td>Field type bool.</td></tr><tr><td><code>TYPE_STRING</code></td><td>Field type string.</td></tr><tr><td><code>TYPE_GROUP</code></td><td>Field type group. Proto2 syntax only, and deprecated.</td></tr><tr><td><code>TYPE_MESSAGE</code></td><td>Field type message.</td></tr><tr><td><code>TYPE_BYTES</code></td><td>Field type bytes.</td></tr><tr><td><code>TYPE_UINT32</code></td><td>Field type uint32.</td></tr><tr><td><code>TYPE_ENUM</code></td><td>Field type enum.</td></tr><tr><td><code>TYPE_SFIXED32</code></td><td>Field type sfixed32.</td></tr><tr><td><code>TYPE_SFIXED64</code></td><td>Field type sfixed64.</td></tr><tr><td><code>TYPE_SINT32</code></td><td>Field type sint32.</td></tr><tr><td><code>TYPE_SINT64</code></td><td>Field type sint64.</td></tr></tbody></table><h2 id=field-mask>FieldMask</h2><p><code>FieldMask</code> represents a set of symbolic field paths, for example:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-proto data-lang=proto><span style=display:flex><span><span style=color:#000>paths</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#4e9a06>"f.a"</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#000>paths</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#4e9a06>"f.b.d"</span><span style=color:#a40000> </span></span></span></code></pre></div><p>Here <code>f</code> represents a field in some root message, <code>a</code> and <code>b</code> fields in the message found in <code>f</code>, and <code>d</code> a field found in the message in <code>f.b</code>.</p><p>Field masks are used to specify a subset of fields that should be returned by a get operation (a <em>projection</em>), or modified by an update operation. Field masks also have a custom JSON encoding (see below).</p><h4 id=field-masks-projections>Field Masks in Projections</h4><p>When a <code>FieldMask</code> specifies a <em>projection</em>, the API will filter the response message (or sub-message) to contain only those fields specified in the mask. For example, consider this "pre-masking" response message:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-proto data-lang=proto><span style=display:flex><span><span style=color:#000>f</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000>a</span> <span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>22</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000>b</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000>d</span> <span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>1</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000>x</span> <span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>2</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000;font-weight:700>}</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000>y</span> <span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>13</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#000;font-weight:700>}</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#000>z</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>8</span><span style=color:#a40000> </span></span></span></code></pre></div><p>After applying the mask in the previous example, the API response will not contain specific values for fields x, y, or z (their value will be set to the default, and omitted in proto text output):</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-proto data-lang=proto><span style=display:flex><span><span style=color:#000>f</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000>a</span> <span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>22</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000>b</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000>d</span> <span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>1</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000;font-weight:700>}</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#000;font-weight:700>}</span><span style=color:#a40000> </span></span></span></code></pre></div><p>A repeated field is not allowed except at the last position of a field mask.</p><p>If a <code>FieldMask</code> object is not present in a get operation, the operation applies to all fields (as if a FieldMask of all fields had been specified).</p><p>Note that a field mask does not necessarily apply to the top-level response message. In case of a REST get operation, the field mask applies directly to the response, but in case of a REST list operation, the mask instead applies to each individual message in the returned resource list. In case of a REST custom method, other definitions may be used. Where the mask applies will be clearly documented together with its declaration in the API. In any case, the effect on the returned resource/resources is required behavior for APIs.</p><h4 id=field-masks-updates>Field Masks in Update Operations</h4><p>A field mask in update operations specifies which fields of the targeted resource are going to be updated. The API is required to only change the values of the fields as specified in the mask and leave the others untouched. If a resource is passed in to describe the updated values, the API ignores the values of all fields not covered by the mask.</p><p>In order to reset a field’s value to the default, the field must be in the mask and set to the default value in the provided resource. Hence, in order to reset all fields of a resource, provide a default instance of the resource and set all fields in the mask, or do not provide a mask as described below.</p><p>If a field mask is not present on update, the operation applies to all fields (as if a field mask of all fields has been specified). Note that in the presence of schema evolution, this may mean that fields the client does not know and has therefore not filled into the request will be reset to their default. If this is unwanted behavior, a specific service may require a client to always specify a field mask, producing an error if not.</p><p>As with get operations, the location of the resource which describes the updated values in the request message depends on the operation kind. In any case, the effect of the field mask is required to be honored by the API.</p><h5 id=http-rest>Considerations for HTTP REST</h5><p>The HTTP kind of an update operation which uses a field mask must be set to PATCH instead of PUT in order to satisfy HTTP semantics (PUT must only be used for full updates).</p><h4 id=json-encoding-field-masks>JSON Encoding of Field Masks</h4><p>In JSON, a field mask is encoded as a single string where paths are separated by a comma. Fields name in each path are converted to/from lower-camel naming conventions.</p><p>As an example, consider the following message declarations:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-proto data-lang=proto><span style=display:flex><span><span style=color:#204a87;font-weight:700>message</span> <span style=color:#000>Profile</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000>User</span> <span style=color:#000>user</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#0000cf;font-weight:700>1</span><span style=color:#000;font-weight:700>;</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000>Photo</span> <span style=color:#000>photo</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#0000cf;font-weight:700>2</span><span style=color:#000;font-weight:700>;</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#000;font-weight:700>}</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#204a87;font-weight:700>message</span> <span style=color:#000>User</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#204a87;font-weight:700>string</span> <span style=color:#000>display_name</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#0000cf;font-weight:700>1</span><span style=color:#000;font-weight:700>;</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#204a87;font-weight:700>string</span> <span style=color:#000>address</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#0000cf;font-weight:700>2</span><span style=color:#000;font-weight:700>;</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#000;font-weight:700>}</span><span style=color:#a40000> </span></span></span></code></pre></div><p>In proto a field mask for <code>Profile</code> may look as such:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-proto data-lang=proto><span style=display:flex><span><span style=color:#000>mask</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000>paths</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#4e9a06>"user.display_name"</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000>paths</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#4e9a06>"photo"</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#000;font-weight:700>}</span><span style=color:#a40000> </span></span></span></code></pre></div><p>In JSON, the same mask is represented as below:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#000;font-weight:700>{</span> </span></span><span style=display:flex><span> <span style=color:#a40000>mask:</span> <span style=color:#204a87;font-weight:700>"user.displayName,photo"</span> </span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span> </span></span></code></pre></div><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>paths</code></td><td><code>string</code></td><td>The set of field mask paths.</td></tr></tbody></table><h2 id=float-value>FloatValue</h2><p>Wrapper message for <code>float</code>.</p><p>The JSON representation for <code>FloatValue</code> is JSON number.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>float</code></td><td>The float value.</td></tr></tbody></table><h2 id=int32-value>Int32Value</h2><p>Wrapper message for <code>int32</code>.</p><p>The JSON representation for <code>Int32Value</code> is JSON number.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>int32</code></td><td>The int32 value.</td></tr></tbody></table><h2 id=int64-value>Int64Value</h2><p>Wrapper message for <code>int64</code>.</p><p>The JSON representation for <code>Int64Value</code> is JSON string.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>int64</code></td><td>The int64 value.</td></tr></tbody></table><h2 id=list-value>ListValue</h2><p><code>ListValue</code> is a wrapper around a repeated field of values.</p><p>The JSON representation for <code>ListValue</code> is JSON array.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>values</code></td><td><code><a href=#value>Value</a></code></td><td>Repeated field of dynamically typed values.</td></tr></tbody></table><h2 id=method>Method</h2><p>Method represents a method of an api.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td><td>The simple name of this method.</td></tr><tr><td><code>request_type_url</code></td><td><code>string</code></td><td>A URL of the input message type.</td></tr><tr><td><code>request_streaming</code></td><td><code>bool</code></td><td>If true, the request is streamed.</td></tr><tr><td><code>response_type_url</code></td><td><code>string</code></td><td>The URL of the output message type.</td></tr><tr><td><code>response_streaming</code></td><td><code>bool</code></td><td>If true, the response is streamed.</td></tr><tr><td><code>options</code></td><td><code><a href=#option>Option</a></code></td><td>Any metadata attached to the method.</td></tr><tr><td><code>syntax</code></td><td><code><a href=#syntax>Syntax</a></code></td><td>The source syntax of this method.</td></tr></tbody></table><h2 id=mixin>Mixin</h2><p>Declares an API to be included in this API. The including API must redeclare all the methods from the included API, but documentation and options are inherited as follows:</p><ul><li><p>If after comment and whitespace stripping, the documentation string of the redeclared method is empty, it will be inherited from the original method.</p></li><li><p>Each annotation belonging to the service config (http, visibility) which is not set in the redeclared method will be inherited.</p></li><li><p>If an http annotation is inherited, the path pattern will be modified as follows. Any version prefix will be replaced by the version of the including API plus the <code>root</code> path if specified.</p></li></ul><p>Example of a simple mixin:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-proto data-lang=proto><span style=display:flex><span><span style=color:#204a87;font-weight:700>package</span> <span style=color:#000>google</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>acl.v1</span><span style=color:#000;font-weight:700>;</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#204a87;font-weight:700>service</span> <span style=color:#000>AccessControl</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#8f5902;font-style:italic>// Get the underlying ACL object. </span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span> <span style=color:#204a87;font-weight:700>rpc</span> <span style=color:#000>GetAcl</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>GetAclRequest</span><span style=color:#000;font-weight:700>)</span> <span style=color:#204a87;font-weight:700>returns</span> <span style=color:#000;font-weight:700>(</span><span style=color:#000>Acl</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#204a87;font-weight:700>option</span> <span style=color:#000;font-weight:700>(</span><span style=color:#000>google.api.http</span><span style=color:#000;font-weight:700>)</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>get</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#4e9a06>"/v1/{resource=**}:getAcl"</span><span style=color:#000;font-weight:700>;</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000;font-weight:700>}</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#000;font-weight:700>}</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#204a87;font-weight:700>package</span> <span style=color:#000>google</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>storage.v2</span><span style=color:#000;font-weight:700>;</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#204a87;font-weight:700>service</span> <span style=color:#000>Storage</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#8f5902;font-style:italic>// rpc GetAcl(GetAclRequest) returns (Acl); </span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#8f5902;font-style:italic>// Get a data record. </span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span> <span style=color:#204a87;font-weight:700>rpc</span> <span style=color:#000>GetData</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>GetDataRequest</span><span style=color:#000;font-weight:700>)</span> <span style=color:#204a87;font-weight:700>returns</span> <span style=color:#000;font-weight:700>(</span><span style=color:#000>Data</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#204a87;font-weight:700>option</span> <span style=color:#000;font-weight:700>(</span><span style=color:#000>google.api.http</span><span style=color:#000;font-weight:700>)</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>get</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#4e9a06>"/v2/{resource=**}"</span><span style=color:#000;font-weight:700>;</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000;font-weight:700>}</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#000;font-weight:700>}</span><span style=color:#a40000> </span></span></span></code></pre></div><p>Example of a mixin configuration:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>apis: </span></span><span style=display:flex><span>- name: google.storage.v2.Storage </span></span><span style=display:flex><span> mixins: </span></span><span style=display:flex><span> - name: google.acl.v1.AccessControl </span></span></code></pre></div><p>The mixin construct implies that all methods in <code>AccessControl</code> are also declared with same name and request/response types in <code>Storage</code>. A documentation generator or annotation processor will see the effective <code>Storage.GetAcl</code> method after inheriting documentation and annotations as follows:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-proto data-lang=proto><span style=display:flex><span><span style=color:#204a87;font-weight:700>service</span> <span style=color:#000>Storage</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#8f5902;font-style:italic>// Get the underlying ACL object. </span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span> <span style=color:#204a87;font-weight:700>rpc</span> <span style=color:#000>GetAcl</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>GetAclRequest</span><span style=color:#000;font-weight:700>)</span> <span style=color:#204a87;font-weight:700>returns</span> <span style=color:#000;font-weight:700>(</span><span style=color:#000>Acl</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#204a87;font-weight:700>option</span> <span style=color:#000;font-weight:700>(</span><span style=color:#000>google.api.http</span><span style=color:#000;font-weight:700>)</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>get</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#4e9a06>"/v2/{resource=**}:getAcl"</span><span style=color:#000;font-weight:700>;</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000;font-weight:700>}</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#ce5c00;font-weight:700>...</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#000;font-weight:700>}</span><span style=color:#a40000> </span></span></span></code></pre></div><p>Note how the version in the path pattern changed from <code>v1</code> to <code>v2</code>.</p><p>If the <code>root</code> field in the mixin is specified, it should be a relative path under which inherited HTTP paths are placed. Example:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>apis: </span></span><span style=display:flex><span>- name: google.storage.v2.Storage </span></span><span style=display:flex><span> mixins: </span></span><span style=display:flex><span> - name: google.acl.v1.AccessControl </span></span><span style=display:flex><span> root: acls </span></span></code></pre></div><p>This implies the following inherited HTTP annotation:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-proto data-lang=proto><span style=display:flex><span><span style=color:#204a87;font-weight:700>service</span> <span style=color:#000>Storage</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#8f5902;font-style:italic>// Get the underlying ACL object. </span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span> <span style=color:#204a87;font-weight:700>rpc</span> <span style=color:#000>GetAcl</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>GetAclRequest</span><span style=color:#000;font-weight:700>)</span> <span style=color:#204a87;font-weight:700>returns</span> <span style=color:#000;font-weight:700>(</span><span style=color:#000>Acl</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>{</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#204a87;font-weight:700>option</span> <span style=color:#000;font-weight:700>(</span><span style=color:#000>google.api.http</span><span style=color:#000;font-weight:700>)</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>get</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#4e9a06>"/v2/acls/{resource=**}:getAcl"</span><span style=color:#000;font-weight:700>;</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#000;font-weight:700>}</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span> <span style=color:#ce5c00;font-weight:700>...</span><span style=color:#a40000> </span></span></span><span style=display:flex><span><span style=color:#a40000></span><span style=color:#000;font-weight:700>}</span><span style=color:#a40000> </span></span></span></code></pre></div><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td><td>The fully qualified name of the API which is included.</td></tr><tr><td><code>root</code></td><td><code>string</code></td><td>If non-empty specifies a path under which inherited HTTP paths are rooted.</td></tr></tbody></table><h2 id=null-value>NullValue</h2><p><code>NullValue</code> is a singleton enumeration to represent the null value for the <code>Value</code> type union.</p><p>The JSON representation for <code>NullValue</code> is JSON <code>null</code>.</p><table><thead><tr><th>Enum value</th><th>Description</th></tr></thead><tbody><tr><td><code>NULL_VALUE</code></td><td>Null value.</td></tr></tbody></table><h2 id=option>Option</h2><p>A protocol buffer option, which can be attached to a message, field, enumeration, etc.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td><td>The option's name. For example, <code>"java_package"</code>.</td></tr><tr><td><code>value</code></td><td><code><a href=#any>Any</a></code></td><td>The option's value. For example, <code>"com.google.protobuf"</code>.</td></tr></tbody></table><h2 id=source-context>SourceContext</h2><p><code>SourceContext</code> represents information about the source of a protobuf element, like the file in which it is defined.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>file_name</code></td><td><code>string</code></td><td>The path-qualified name of the .proto file that contained the associated protobuf element. For example: <code>"google/protobuf/source.proto"</code>.</td></tr></tbody></table><h2 id=string-value>StringValue</h2><p>Wrapper message for <code>string</code>.</p><p>The JSON representation for <code>StringValue</code> is JSON string.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>string</code></td><td>The string value.</td></tr></tbody></table><h2 id=struct>Struct</h2><p><code>Struct</code> represents a structured data value, consisting of fields which map to dynamically typed values. In some languages, <code>Struct</code> might be supported by a native representation. For example, in scripting languages like JS a struct is represented as an object. The details of that representation are described together with the proto support for the language.</p><p>The JSON representation for <code>Struct</code> is JSON object.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>fields</code></td><td><code>map<string, <a href=#value>Value</a>></code></td><td>Map of dynamically typed values.</td></tr></tbody></table><h2 id=syntax>Syntax</h2><p>The syntax in which a protocol buffer element is defined.</p><table><thead><tr><th>Enum value</th><th>Description</th></tr></thead><tbody><tr><td><code>SYNTAX_PROTO2</code></td><td>Syntax <code>proto2</code>.</td></tr><tr><td><code>SYNTAX_PROTO3</code></td><td>Syntax <code>proto3</code>.</td></tr></tbody></table><h2 id=timestamp>Timestamp</h2><p>A Timestamp represents a point in time independent of any time zone or calendar, represented as seconds and fractions of seconds at nanosecond resolution in UTC Epoch time. It is encoded using the Proleptic Gregorian Calendar which extends the Gregorian calendar backwards to year one. It is encoded assuming all minutes are 60 seconds long, i.e. leap seconds are "smeared" so that no leap second table is needed for interpretation. Range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By restricting to that range, we ensure that we can convert to and from RFC 3339 date strings. See <a href=https://www.ietf.org/rfc/rfc3339.txt>https://www.ietf.org/rfc/rfc3339.txt</a>.</p><p>Example 1: Compute Timestamp from POSIX <code>time()</code>.</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#000>Timestamp</span> <span style=color:#000>timestamp</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span><span style=color:#000>timestamp</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>set_seconds</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>time</span><span style=color:#000;font-weight:700>(</span><span style=color:#204a87>NULL</span><span style=color:#000;font-weight:700>));</span> </span></span><span style=display:flex><span><span style=color:#000>timestamp</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>set_nanos</span><span style=color:#000;font-weight:700>(</span><span style=color:#0000cf;font-weight:700>0</span><span style=color:#000;font-weight:700>);</span> </span></span></code></pre></div><p>Example 2: Compute Timestamp from POSIX <code>gettimeofday()</code>.</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#204a87;font-weight:700>struct</span> <span style=color:#000>timeval</span> <span style=color:#000>tv</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span><span style=color:#000>gettimeofday</span><span style=color:#000;font-weight:700>(</span><span style=color:#ce5c00;font-weight:700>&</span><span style=color:#000>tv</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87>NULL</span><span style=color:#000;font-weight:700>);</span> </span></span><span style=display:flex><span> </span></span><span style=display:flex><span><span style=color:#000>Timestamp</span> <span style=color:#000>timestamp</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span><span style=color:#000>timestamp</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>set_seconds</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>tv</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>tv_sec</span><span style=color:#000;font-weight:700>);</span> </span></span><span style=display:flex><span><span style=color:#000>timestamp</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>set_nanos</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>tv</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>tv_usec</span> <span style=color:#ce5c00;font-weight:700>*</span> <span style=color:#0000cf;font-weight:700>1000</span><span style=color:#000;font-weight:700>);</span> </span></span></code></pre></div><p>Example 3: Compute Timestamp from Win32 <code>GetSystemTimeAsFileTime()</code>.</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-cpp data-lang=cpp><span style=display:flex><span><span style=color:#000>FILETIME</span> <span style=color:#000>ft</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span><span style=color:#000>GetSystemTimeAsFileTime</span><span style=color:#000;font-weight:700>(</span><span style=color:#ce5c00;font-weight:700>&</span><span style=color:#000>ft</span><span style=color:#000;font-weight:700>);</span> </span></span><span style=display:flex><span><span style=color:#000>UINT64</span> <span style=color:#000>ticks</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000;font-weight:700>(((</span><span style=color:#000>UINT64</span><span style=color:#000;font-weight:700>)</span><span style=color:#000>ft</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>dwHighDateTime</span><span style=color:#000;font-weight:700>)</span> <span style=color:#ce5c00;font-weight:700><<</span> <span style=color:#0000cf;font-weight:700>32</span><span style=color:#000;font-weight:700>)</span> <span style=color:#ce5c00;font-weight:700>|</span> <span style=color:#000>ft</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>dwLowDateTime</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span> </span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>// A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z </span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>// is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. </span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span><span style=color:#000>Timestamp</span> <span style=color:#000>timestamp</span><span style=color:#000;font-weight:700>;</span> </span></span><span style=display:flex><span><span style=color:#000>timestamp</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>set_seconds</span><span style=color:#000;font-weight:700>((</span><span style=color:#000>INT64</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>((</span><span style=color:#000>ticks</span> <span style=color:#ce5c00;font-weight:700>/</span> <span style=color:#0000cf;font-weight:700>10000000</span><span style=color:#000;font-weight:700>)</span> <span style=color:#ce5c00;font-weight:700>-</span> <span style=color:#0000cf;font-weight:700>11644473600LL</span><span style=color:#000;font-weight:700>));</span> </span></span><span style=display:flex><span><span style=color:#000>timestamp</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>set_nanos</span><span style=color:#000;font-weight:700>((</span><span style=color:#000>INT32</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>((</span><span style=color:#000>ticks</span> <span style=color:#ce5c00;font-weight:700>%</span> <span style=color:#0000cf;font-weight:700>10000000</span><span style=color:#000;font-weight:700>)</span> <span style=color:#ce5c00;font-weight:700>*</span> <span style=color:#0000cf;font-weight:700>100</span><span style=color:#000;font-weight:700>));</span> </span></span></code></pre></div><p>Example 4: Compute Timestamp from Java <code>System.currentTimeMillis()</code>.</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-java data-lang=java><span style=display:flex><span><span style=color:#204a87;font-weight:700>long</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>millis</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>System</span><span style=color:#000;font-weight:700>.</span><span style=color:#c4a000>currentTimeMillis</span><span style=color:#000;font-weight:700>();</span><span style=color:#f8f8f8;text-decoration:underline> </span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline></span><span style=color:#000>Timestamp</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>timestamp</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>Timestamp</span><span style=color:#000;font-weight:700>.</span><span style=color:#c4a000>newBuilder</span><span style=color:#000;font-weight:700>().</span><span style=color:#c4a000>setSeconds</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>millis</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#ce5c00;font-weight:700>/</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>1000</span><span style=color:#000;font-weight:700>)</span><span style=color:#f8f8f8;text-decoration:underline> </span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000;font-weight:700>.</span><span style=color:#c4a000>setNanos</span><span style=color:#000;font-weight:700>((</span><span style=color:#204a87;font-weight:700>int</span><span style=color:#000;font-weight:700>)</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000;font-weight:700>((</span><span style=color:#000>millis</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#ce5c00;font-weight:700>%</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>1000</span><span style=color:#000;font-weight:700>)</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#ce5c00;font-weight:700>*</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>1000000</span><span style=color:#000;font-weight:700>)).</span><span style=color:#c4a000>build</span><span style=color:#000;font-weight:700>();</span><span style=color:#f8f8f8;text-decoration:underline> </span></span></span></code></pre></div><p>Example 5: Compute Timestamp from current time in Python.</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-py data-lang=py><span style=display:flex><span><span style=color:#000>now</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>time</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>time</span><span style=color:#000;font-weight:700>()</span> </span></span><span style=display:flex><span><span style=color:#000>seconds</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87>int</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>now</span><span style=color:#000;font-weight:700>)</span> </span></span><span style=display:flex><span><span style=color:#000>nanos</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87>int</span><span style=color:#000;font-weight:700>((</span><span style=color:#000>now</span> <span style=color:#ce5c00;font-weight:700>-</span> <span style=color:#000>seconds</span><span style=color:#000;font-weight:700>)</span> <span style=color:#ce5c00;font-weight:700>*</span> <span style=color:#0000cf;font-weight:700>10</span><span style=color:#ce5c00;font-weight:700>**</span><span style=color:#0000cf;font-weight:700>9</span><span style=color:#000;font-weight:700>)</span> </span></span><span style=display:flex><span><span style=color:#000>timestamp</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>Timestamp</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>seconds</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#000>seconds</span><span style=color:#000;font-weight:700>,</span> <span style=color:#000>nanos</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#000>nanos</span><span style=color:#000;font-weight:700>)</span> </span></span></code></pre></div><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>seconds</code></td><td><code>int64</code></td><td>Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive.</td></tr><tr><td><code>nanos</code></td><td><code>int32</code></td><td>Non-negative fractions of a second at nanosecond resolution. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be from 0 to 999,999,999 inclusive.</td></tr></tbody></table><h2 id=type>Type</h2><p>A protocol buffer message type.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td><td>The fully qualified message name.</td></tr><tr><td><code>fields</code></td><td><code><a href=#field>Field</a></code></td><td>The list of fields.</td></tr><tr><td><code>oneofs</code></td><td><code>string</code></td><td>The list of types appearing in <code>oneof</code> definitions in this type.</td></tr><tr><td><code>options</code></td><td><code><a href=#option>Option</a></code></td><td>The protocol buffer options.</td></tr><tr><td><code>source_context</code></td><td><code><a href=#source-context>SourceContext</a></code></td><td>The source context.</td></tr><tr><td><code>syntax</code></td><td><code><a href=#syntax>Syntax</a></code></td><td>The source syntax.</td></tr></tbody></table><h2 id=uint32-value>UInt32Value</h2><p>Wrapper message for <code>uint32</code>.</p><p>The JSON representation for <code>UInt32Value</code> is JSON number.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>uint32</code></td><td>The uint32 value.</td></tr></tbody></table><h2 id=uint64-value>UInt64Value</h2><p>Wrapper message for <code>uint64</code>.</p><p>The JSON representation for <code>UInt64Value</code> is JSON string.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>uint64</code></td><td>The uint64 value.</td></tr></tbody></table><h2 id=value>Value</h2><p><code>Value</code> represents a dynamically typed value which can be either null, a number, a string, a boolean, a recursive struct value, or a list of values. A producer of value is expected to set one of that variants, absence of any variant indicates an error.</p><p>The JSON representation for <code>Value</code> is JSON value.</p><table><thead><tr><th>Field name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td colspan=3>Union field, only one of the following:</td></tr><tr><td><code>null_value</code></td><td><code><a href=#null-value>NullValue</a></code></td><td>Represents a null value.</td></tr><tr><td><code>number_value</code></td><td><code>double</code></td><td>Represents a double value. Note that attempting to serialize NaN or Infinity results in error. (We can't serialize these as string "NaN" or "Infinity" values like we do for regular fields, because they would parse as string_value, not number_value).</td></tr><tr><td><code>string_value</code></td><td><code>string</code></td><td>Represents a string value.</td></tr><tr><td><code>bool_value</code></td><td><code>bool</code></td><td>Represents a boolean value.</td></tr><tr><td><code>struct_value</code></td><td><code><a href=#struct>Struct</a></code></td><td>Represents a structured value.</td></tr><tr><td><code>list_value</code></td><td><code><a href=#list-value>ListValue</a></code></td><td>Represents a repeated <code>Value</code>.</td></tr></tbody></table></div></main></div></div><footer class="bg-dark py-5 row d-print-none"><div class="container-fluid mx-sm-5"><div class=row><div class="col-6 col-sm-4 text-xs-center order-sm-2"><ul class="list-inline mb-0"><li class="list-inline-item mx-2 h3" data-toggle=tooltip data-placement=top title="Stack Overflow" aria-label="Stack Overflow"><a class=text-white target=_blank rel=noopener href=https://stackoverflow.com/questions/tagged/protocol-buffers aria-label="Stack Overflow"><i class="fab fa-stack-overflow"></i></a></li></ul><script type=text/javascript id=cookiebanner src=https://cdn.jsdelivr.net/gh/dobarkod/cookie-banner@1.2.2/dist/cookiebanner.min.js data-height=50px data-message="Protobuf.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic." data-bg=#ffb data-fg=#000 data-position=bottom data-padding="10px 16px" data-close-text="OK, got it" data-font-size=18px data-moreinfo=https://policies.google.com/technologies/cookies></script></div><div class="col-6 col-sm-4 text-right text-xs-center order-sm-3"><ul class="list-inline mb-0"><li class="list-inline-item mx-2 h3" data-toggle=tooltip data-placement=top title=GitHub aria-label=GitHub><a class=text-white target=_blank rel=noopener href=https://github.com/protocolbuffers/protobuf aria-label=GitHub><i class="fab fa-github"></i></a></li><li class="list-inline-item mx-2 h3" data-toggle=tooltip data-placement=top title="Developer mailing list" aria-label="Developer mailing list"><a class=text-white target=_blank rel=noopener href=https://groups.google.com/g/protobuf aria-label="Developer mailing list"><i class="fa fa-envelope"></i></a></li></ul><script type=text/javascript id=cookiebanner src=https://cdn.jsdelivr.net/gh/dobarkod/cookie-banner@1.2.2/dist/cookiebanner.min.js data-height=50px data-message="Protobuf.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic." data-bg=#ffb data-fg=#000 data-position=bottom data-padding="10px 16px" data-close-text="OK, got it" data-font-size=18px data-moreinfo=https://policies.google.com/technologies/cookies></script></div><div class="col-12 col-sm-4 text-center py-2 order-sm-2"><small class=text-white>© 2024 Google LLC All Rights Reserved</small> <small class=ml-1><a href=https://policies.google.com/privacy target=_blank rel=noopener>Privacy Policy</a></small> <span class=text-white>Hosted by GitHub Pages.</span> <a href=https://docs.github.com/en/site-policy/privacy-policies/github-privacy-statement target=_blank>GitHub Privacy Statement</a></div></div></div></footer></div><script src=/js/main.min.ba08a6b7f24e657f0a1b9b55be3a3162585168cd862ace0957f5b44e6cb6dc61.js integrity="sha256-ugimt/JOZX8KG5tVvjoxYlhRaM2GKs4JV/W0Tmy23GE=" crossorigin=anonymous></script><script src=/js/tabpane-persist.js></script></body></html>