google_type

package
v0.0.0-...-dbc791b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2017 License: MIT Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DayOfWeek_name = map[int32]string{
	0: "DAY_OF_WEEK_UNSPECIFIED",
	1: "MONDAY",
	2: "TUESDAY",
	3: "WEDNESDAY",
	4: "THURSDAY",
	5: "FRIDAY",
	6: "SATURDAY",
	7: "SUNDAY",
}
View Source
var DayOfWeek_value = map[string]int32{
	"DAY_OF_WEEK_UNSPECIFIED": 0,
	"MONDAY":                  1,
	"TUESDAY":                 2,
	"WEDNESDAY":               3,
	"THURSDAY":                4,
	"FRIDAY":                  5,
	"SATURDAY":                6,
	"SUNDAY":                  7,
}
View Source
var (
	// SystemDater is a Dater that uses the system UTC time.
	SystemDater = &systemDater{}
)

Functions

This section is empty.

Types

type Color

type Color struct {
	// The amount of red in the color as a value in the interval [0, 1].
	Red float32 `protobuf:"fixed32,1,opt,name=red" json:"red,omitempty"`
	// The amount of green in the color as a value in the interval [0, 1].
	Green float32 `protobuf:"fixed32,2,opt,name=green" json:"green,omitempty"`
	// The amount of blue in the color as a value in the interval [0, 1].
	Blue float32 `protobuf:"fixed32,3,opt,name=blue" json:"blue,omitempty"`
	// The fraction of this color that should be applied to the pixel. That is,
	// the final pixel color is defined by the equation:
	//
	//   pixel color = alpha * (this color) + (1.0 - alpha) * (background color)
	//
	// This means that a value of 1.0 corresponds to a solid color, whereas
	// a value of 0.0 corresponds to a completely transparent color. This
	// uses a wrapper message rather than a simple float scalar so that it is
	// possible to distinguish between a default value and the value being unset.
	// If omitted, this color object is to be rendered as a solid color
	// (as if the alpha value had been explicitly given with a value of 1.0).
	Alpha *google_protobuf.FloatValue `protobuf:"bytes,4,opt,name=alpha" json:"alpha,omitempty"`
}

Represents a color in the RGBA color space. This representation is designed for simplicity of conversion to/from color representations in various languages over compactness; for example, the fields of this representation can be trivially provided to the constructor of "java.awt.Color" in Java; it can also be trivially provided to UIColor's "+colorWithRed:green:blue:alpha" method in iOS; and, with just a little work, it can be easily formatted into a CSS "rgba()" string in JavaScript, as well. Here are some examples:

Example (Java):

import com.google.type.Color;

// ...
public static java.awt.Color fromProto(Color protocolor) {
  float alpha = protocolor.hasAlpha()
      ? protocolor.getAlpha().getValue()
      : 1.0;

  return new java.awt.Color(
      protocolor.getRed(),
      protocolor.getGreen(),
      protocolor.getBlue(),
      alpha);
}

public static Color toProto(java.awt.Color color) {
  float red = (float) color.getRed();
  float green = (float) color.getGreen();
  float blue = (float) color.getBlue();
  float denominator = 255.0;
  Color.Builder resultBuilder =
      Color
          .newBuilder()
          .setRed(red / denominator)
          .setGreen(green / denominator)
          .setBlue(blue / denominator);
  int alpha = color.getAlpha();
  if (alpha != 255) {
    result.setAlpha(
        FloatValue
            .newBuilder()
            .setValue(((float) alpha) / denominator)
            .build());
  }
  return resultBuilder.build();
}
// ...

Example (iOS / Obj-C):

    // ...
    static UIColor* fromProto(Color* protocolor) {
       float red = [protocolor red];
       float green = [protocolor green];
       float blue = [protocolor blue];
       FloatValue* alpha_wrapper = [protocolor alpha];
       float alpha = 1.0;
       if (alpha_wrapper != nil) {
         alpha = [alpha_wrapper value];
       }
       return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
    }

    static Color* toProto(UIColor* color) {
        CGFloat red, green, blue, alpha;
        if (![color getRed:&red green:&green blue:&blue alpha:&alpha]) {
          return nil;
        }
        Color* result = [Color alloc] init];
        [result setRed:red];
        [result setGreen:green];
        [result setBlue:blue];
        if (alpha <= 0.9999) {
          [result setAlpha:floatWrapperWithValue(alpha)];
        }
        [result autorelease];
        return result;
   }
   // ...

Example (JavaScript):

   // ...

   var protoToCssColor = function(rgb_color) {
      var redFrac = rgb_color.red || 0.0;
      var greenFrac = rgb_color.green || 0.0;
      var blueFrac = rgb_color.blue || 0.0;
      var red = Math.floor(redFrac * 255);
      var green = Math.floor(greenFrac * 255);
      var blue = Math.floor(blueFrac * 255);

      if (!('alpha' in rgb_color)) {
         return rgbToCssColor_(red, green, blue);
      }

      var alphaFrac = rgb_color.alpha.value || 0.0;
      var rgbParams = [red, green, blue].join(',');
      return ['rgba(', rgbParams, ',', alphaFrac, ')'].join('');
   };

   var rgbToCssColor_ = function(red, green, blue) {
     var rgbNumber = new Number((red << 16) | (green << 8) | blue);
     var hexString = rgbNumber.toString(16);
     var missingZeros = 6 - hexString.length;
     var resultBuilder = ['#'];
     for (var i = 0; i < missingZeros; i++) {
        resultBuilder.push('0');
     }
     resultBuilder.push(hexString);
     return resultBuilder.join('');
   };

   // ...

func (*Color) Descriptor

func (*Color) Descriptor() ([]byte, []int)

func (*Color) GetAlpha

func (m *Color) GetAlpha() *google_protobuf.FloatValue

func (*Color) GetBlue

func (m *Color) GetBlue() float32

func (*Color) GetGreen

func (m *Color) GetGreen() float32

func (*Color) GetRed

func (m *Color) GetRed() float32

func (*Color) ProtoMessage

func (*Color) ProtoMessage()

func (*Color) Reset

func (m *Color) Reset()

func (*Color) String

func (m *Color) String() string

type Date

type Date struct {
	// Year of date. Must be from 1 to 9999, or 0 if specifying a date without
	// a year.
	Year int32 `protobuf:"varint,1,opt,name=year" json:"year,omitempty"`
	// Month of year. Must be from 1 to 12.
	Month int32 `protobuf:"varint,2,opt,name=month" json:"month,omitempty"`
	// Day of month. Must be from 1 to 31 and valid for the year and month, or 0
	// if specifying a year/month where the day is not significant.
	Day int32 `protobuf:"varint,3,opt,name=day" json:"day,omitempty"`
}

Represents a whole calendar date, e.g. date of birth. The time of day and time zone are either specified elsewhere or are not significant. The date is relative to the Proleptic Gregorian Calendar. The day may be 0 to represent a year and month where the day is not significant, e.g. credit card expiration date. The year may be 0 to represent a month and day independent of year, e.g. anniversary date. Related types are [google.type.TimeOfDay][google.type.TimeOfDay] and `google.protobuf.Timestamp`.

func NewDate

func NewDate(day int32, month int32, year int32) *Date

NewDate is a convienence function to create a new Date.

func Now

func Now() *Date

Now returns the current date at UTC.

func TimeToDate

func TimeToDate(t time.Time) *Date

TimeToDate converts a golang Time to a Date.

func (*Date) Add

func (d *Date) Add(years int32, months int32, days int32) *Date

Add adds the given time to the d and returns a new Date.

func (*Date) Before

func (d *Date) Before(j *Date) bool

Before returns true if d is before j.

func (*Date) Descriptor

func (*Date) Descriptor() ([]byte, []int)

func (*Date) Equal

func (d *Date) Equal(j *Date) bool

Equal returns true if i equals j.

func (*Date) GetDay

func (m *Date) GetDay() int32

func (*Date) GetMonth

func (m *Date) GetMonth() int32

func (*Date) GetYear

func (m *Date) GetYear() int32

func (*Date) GoTime

func (d *Date) GoTime() time.Time

GoTime converts a Date to a golang Time.

func (*Date) InRange

func (d *Date) InRange(start *Date, end *Date) bool

InRange returns whether d is within start to end, inclusive. The given date is expected to not be nil. If start is nil, it checks whether d is less than or equal to end. If end is nil it checks whether d is greater than or equal to end. If start and end are nil, it returns true.

func (*Date) ProtoMessage

func (*Date) ProtoMessage()

func (*Date) Reset

func (m *Date) Reset()

func (*Date) String

func (m *Date) String() string

type Dater

type Dater interface {
	Now() *Date
}

Dater provides the current date.

type DayOfWeek

type DayOfWeek int32

Represents a day of week.

const (
	// The unspecified day-of-week.
	DayOfWeek_DAY_OF_WEEK_UNSPECIFIED DayOfWeek = 0
	// The day-of-week of Monday.
	DayOfWeek_MONDAY DayOfWeek = 1
	// The day-of-week of Tuesday.
	DayOfWeek_TUESDAY DayOfWeek = 2
	// The day-of-week of Wednesday.
	DayOfWeek_WEDNESDAY DayOfWeek = 3
	// The day-of-week of Thursday.
	DayOfWeek_THURSDAY DayOfWeek = 4
	// The day-of-week of Friday.
	DayOfWeek_FRIDAY DayOfWeek = 5
	// The day-of-week of Saturday.
	DayOfWeek_SATURDAY DayOfWeek = 6
	// The day-of-week of Sunday.
	DayOfWeek_SUNDAY DayOfWeek = 7
)

func (DayOfWeek) EnumDescriptor

func (DayOfWeek) EnumDescriptor() ([]byte, []int)

func (DayOfWeek) String

func (x DayOfWeek) String() string

type FakeDater

type FakeDater interface {
	Dater
	Set(day int32, month int32, year int32)
}

FakeDater is a Dater for testing.

func NewFakeDater

func NewFakeDater(day int32, month int32, year int32) FakeDater

NewFakeDater returns a new FakeDater with the initial date.

type LatLng

type LatLng struct {
	// The latitude in degrees. It must be in the range [-90.0, +90.0].
	Latitude float64 `protobuf:"fixed64,1,opt,name=latitude" json:"latitude,omitempty"`
	// The longitude in degrees. It must be in the range [-180.0, +180.0].
	Longitude float64 `protobuf:"fixed64,2,opt,name=longitude" json:"longitude,omitempty"`
}

An object representing a latitude/longitude pair. This is expressed as a pair of doubles representing degrees latitude and degrees longitude. Unless specified otherwise, this must conform to the <a href="http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf">WGS84 standard</a>. Values must be within normalized ranges.

Example of normalization code in Python:

def NormalizeLongitude(longitude):
  """Wraps decimal degrees longitude to [-180.0, 180.0]."""
  q, r = divmod(longitude, 360.0)
  if r > 180.0 or (r == 180.0 and q <= -1.0):
    return r - 360.0
  return r

def NormalizeLatLng(latitude, longitude):
  """Wraps decimal degrees latitude and longitude to
  [-90.0, 90.0] and [-180.0, 180.0], respectively."""
  r = latitude % 360.0
  if r <= 90.0:
    return r, NormalizeLongitude(longitude)
  elif r >= 270.0:
    return r - 360, NormalizeLongitude(longitude)
  else:
    return 180 - r, NormalizeLongitude(longitude + 180.0)

assert 180.0 == NormalizeLongitude(180.0)
assert -180.0 == NormalizeLongitude(-180.0)
assert -179.0 == NormalizeLongitude(181.0)
assert (0.0, 0.0) == NormalizeLatLng(360.0, 0.0)
assert (0.0, 0.0) == NormalizeLatLng(-360.0, 0.0)
assert (85.0, 180.0) == NormalizeLatLng(95.0, 0.0)
assert (-85.0, -170.0) == NormalizeLatLng(-95.0, 10.0)
assert (90.0, 10.0) == NormalizeLatLng(90.0, 10.0)
assert (-90.0, -10.0) == NormalizeLatLng(-90.0, -10.0)
assert (0.0, -170.0) == NormalizeLatLng(-180.0, 10.0)
assert (0.0, -170.0) == NormalizeLatLng(180.0, 10.0)
assert (-90.0, 10.0) == NormalizeLatLng(270.0, 10.0)
assert (90.0, 10.0) == NormalizeLatLng(-270.0, 10.0)

func (*LatLng) Descriptor

func (*LatLng) Descriptor() ([]byte, []int)

func (*LatLng) GetLatitude

func (m *LatLng) GetLatitude() float64

func (*LatLng) GetLongitude

func (m *LatLng) GetLongitude() float64

func (*LatLng) ProtoMessage

func (*LatLng) ProtoMessage()

func (*LatLng) Reset

func (m *LatLng) Reset()

func (*LatLng) String

func (m *LatLng) String() string

type Money

type Money struct {
	// The 3-letter currency code defined in ISO 4217.
	CurrencyCode string `protobuf:"bytes,1,opt,name=currency_code,json=currencyCode" json:"currency_code,omitempty"`
	// The whole units of the amount.
	// For example if `currencyCode` is `"USD"`, then 1 unit is one US dollar.
	Units int64 `protobuf:"varint,2,opt,name=units" json:"units,omitempty"`
	// Number of nano (10^-9) units of the amount.
	// The value must be between -999,999,999 and +999,999,999 inclusive.
	// If `units` is positive, `nanos` must be positive or zero.
	// If `units` is zero, `nanos` can be positive, zero, or negative.
	// If `units` is negative, `nanos` must be negative or zero.
	// For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
	Nanos int32 `protobuf:"varint,3,opt,name=nanos" json:"nanos,omitempty"`
}

Represents an amount of money with its currency type.

func (*Money) Descriptor

func (*Money) Descriptor() ([]byte, []int)

func (*Money) GetCurrencyCode

func (m *Money) GetCurrencyCode() string

func (*Money) GetNanos

func (m *Money) GetNanos() int32

func (*Money) GetUnits

func (m *Money) GetUnits() int64

func (*Money) ProtoMessage

func (*Money) ProtoMessage()

func (*Money) Reset

func (m *Money) Reset()

func (*Money) String

func (m *Money) String() string

type PostalAddress

type PostalAddress struct {
	// The schema revision of the `PostalAddress`.
	// All new revisions **must** be backward compatible with old revisions.
	Revision int32 `protobuf:"varint,1,opt,name=revision" json:"revision,omitempty"`
	// Required. CLDR region code of the country/region of the address. This
	// is never inferred and it is up to the user to ensure the value is
	// correct. See http://cldr.unicode.org/ and
	// http://www.unicode.org/cldr/charts/30/supplemental/territory_information.html
	// for details. Example: "CH" for Switzerland.
	RegionCode string `protobuf:"bytes,2,opt,name=region_code,json=regionCode" json:"region_code,omitempty"`
	// Optional. BCP-47 language code of the contents of this address (if
	// known). This is often the UI language of the input form or is expected
	// to match one of the languages used in the address' country/region, or their
	// transliterated equivalents.
	// This can affect formatting in certain countries, but is not critical
	// to the correctness of the data and will never affect any validation or
	// other non-formatting related operations.
	//
	// If this value is not known, it should be omitted (rather than specifying a
	// possibly incorrect default).
	//
	// Examples: "zh-Hant", "ja", "ja-Latn", "en".
	LanguageCode string `protobuf:"bytes,3,opt,name=language_code,json=languageCode" json:"language_code,omitempty"`
	// Optional. Postal code of the address. Not all countries use or require
	// postal codes to be present, but where they are used, they may trigger
	// additional validation with other parts of the address (e.g. state/zip
	// validation in the U.S.A.).
	PostalCode string `protobuf:"bytes,4,opt,name=postal_code,json=postalCode" json:"postal_code,omitempty"`
	// Optional. Additional, country-specific, sorting code. This is not used
	// in most regions. Where it is used, the value is either a string like
	// "CEDEX", optionally followed by a number (e.g. "CEDEX 7"), or just a number
	// alone, representing the "sector code" (Jamaica), "delivery area indicator"
	// (Malawi) or "post office indicator" (e.g. Côte d'Ivoire).
	SortingCode string `protobuf:"bytes,5,opt,name=sorting_code,json=sortingCode" json:"sorting_code,omitempty"`
	// Optional. Highest administrative subdivision which is used for postal
	// addresses of a country or region.
	// For example, this can be a state, a province, an oblast, or a prefecture.
	// Specifically, for Spain this is the province and not the autonomous
	// community (e.g. "Barcelona" and not "Catalonia").
	// Many countries don't use an administrative area in postal addresses. E.g.
	// in Switzerland this should be left unpopulated.
	AdministrativeArea string `protobuf:"bytes,6,opt,name=administrative_area,json=administrativeArea" json:"administrative_area,omitempty"`
	// Optional. Generally refers to the city/town portion of the address.
	// Examples: US city, IT comune, UK post town.
	// In regions of the world where localities are not well defined or do not fit
	// into this structure well, leave locality empty and use address_lines.
	Locality string `protobuf:"bytes,7,opt,name=locality" json:"locality,omitempty"`
	// Optional. Sublocality of the address.
	// For example, this can be neighborhoods, boroughs, districts.
	Sublocality string `protobuf:"bytes,8,opt,name=sublocality" json:"sublocality,omitempty"`
	// Unstructured address lines describing the lower levels of an address.
	//
	// Because values in address_lines do not have type information and may
	// sometimes contain multiple values in a single field (e.g.
	// "Austin, TX"), it is important that the line order is clear. The order of
	// address lines should be "envelope order" for the country/region of the
	// address. In places where this can vary (e.g. Japan), address_language is
	// used to make it explicit (e.g. "ja" for large-to-small ordering and
	// "ja-Latn" or "en" for small-to-large). This way, the most specific line of
	// an address can be selected based on the language.
	//
	// The minimum permitted structural representation of an address consists
	// of a region_code with all remaining information placed in the
	// address_lines. It would be possible to format such an address very
	// approximately without geocoding, but no semantic reasoning could be
	// made about any of the address components until it was at least
	// partially resolved.
	//
	// Creating an address only containing a region_code and address_lines, and
	// then geocoding is the recommended way to handle completely unstructured
	// addresses (as opposed to guessing which parts of the address should be
	// localities or administrative areas).
	AddressLines []string `protobuf:"bytes,9,rep,name=address_lines,json=addressLines" json:"address_lines,omitempty"`
	// Optional. The recipient at the address.
	// This field may, under certain circumstances, contain multiline information.
	// For example, it might contain "care of" information.
	Recipients []string `protobuf:"bytes,10,rep,name=recipients" json:"recipients,omitempty"`
	// Optional. The name of the organization at the address.
	Organization string `protobuf:"bytes,11,opt,name=organization" json:"organization,omitempty"`
}

Represents a postal address, e.g. for postal delivery or payments addresses. Given a postal address, a postal service can deliver items to a premise, P.O. Box or similar. It is not intended to model geographical locations (roads, towns, mountains).

In typical usage an address would be created via user input or from importing existing data, depending on the type of process.

Advice on address input / editing:

  • Users should not be presented with UI elements for input or editing of fields outside countries where that field is used.

For more guidance on how to use this schema, please see: https://support.google.com/business/answer/6397478

func (*PostalAddress) Descriptor

func (*PostalAddress) Descriptor() ([]byte, []int)

func (*PostalAddress) GetAddressLines

func (m *PostalAddress) GetAddressLines() []string

func (*PostalAddress) GetAdministrativeArea

func (m *PostalAddress) GetAdministrativeArea() string

func (*PostalAddress) GetLanguageCode

func (m *PostalAddress) GetLanguageCode() string

func (*PostalAddress) GetLocality

func (m *PostalAddress) GetLocality() string

func (*PostalAddress) GetOrganization

func (m *PostalAddress) GetOrganization() string

func (*PostalAddress) GetPostalCode

func (m *PostalAddress) GetPostalCode() string

func (*PostalAddress) GetRecipients

func (m *PostalAddress) GetRecipients() []string

func (*PostalAddress) GetRegionCode

func (m *PostalAddress) GetRegionCode() string

func (*PostalAddress) GetRevision

func (m *PostalAddress) GetRevision() int32

func (*PostalAddress) GetSortingCode

func (m *PostalAddress) GetSortingCode() string

func (*PostalAddress) GetSublocality

func (m *PostalAddress) GetSublocality() string

func (*PostalAddress) ProtoMessage

func (*PostalAddress) ProtoMessage()

func (*PostalAddress) Reset

func (m *PostalAddress) Reset()

func (*PostalAddress) String

func (m *PostalAddress) String() string

type TimeOfDay

type TimeOfDay struct {
	// Hours of day in 24 hour format. Should be from 0 to 23. An API may choose
	// to allow the value "24:00:00" for scenarios like business closing time.
	Hours int32 `protobuf:"varint,1,opt,name=hours" json:"hours,omitempty"`
	// Minutes of hour of day. Must be from 0 to 59.
	Minutes int32 `protobuf:"varint,2,opt,name=minutes" json:"minutes,omitempty"`
	// Seconds of minutes of the time. Must normally be from 0 to 59. An API may
	// allow the value 60 if it allows leap-seconds.
	Seconds int32 `protobuf:"varint,3,opt,name=seconds" json:"seconds,omitempty"`
	// Fractions of seconds in nanoseconds. Must be from 0 to 999,999,999.
	Nanos int32 `protobuf:"varint,4,opt,name=nanos" json:"nanos,omitempty"`
}

Represents a time of day. The date and time zone are either not significant or are specified elsewhere. An API may chose to allow leap seconds. Related types are [google.type.Date][google.type.Date] and `google.protobuf.Timestamp`.

func (*TimeOfDay) Descriptor

func (*TimeOfDay) Descriptor() ([]byte, []int)

func (*TimeOfDay) GetHours

func (m *TimeOfDay) GetHours() int32

func (*TimeOfDay) GetMinutes

func (m *TimeOfDay) GetMinutes() int32

func (*TimeOfDay) GetNanos

func (m *TimeOfDay) GetNanos() int32

func (*TimeOfDay) GetSeconds

func (m *TimeOfDay) GetSeconds() int32

func (*TimeOfDay) ProtoMessage

func (*TimeOfDay) ProtoMessage()

func (*TimeOfDay) Reset

func (m *TimeOfDay) Reset()

func (*TimeOfDay) String

func (m *TimeOfDay) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL