Debian Codegraph @

civicinfo/v2/civicinfo-gen.go

raw
1 // Copyright 2026 Google LLC.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Code generated file. DO NOT EDIT.
6
7 // Package civicinfo provides access to the Google Civic Information API.
8 //
9 // For product documentation, see: https://developers.google.com/civic-information/
10 //
11 // # Library status
12 //
13 // These client libraries are officially supported by Google. However, this
14 // library is considered complete and is in maintenance mode. This means
15 // that we will address critical bugs and security issues but will not add
16 // any new features.
17 //
18 // When possible, we recommend using our newer
19 // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
20 // that are still actively being worked and iterated on.
21 //
22 // # Creating a client
23 //
24 // Usage example:
25 //
26 // import "google.golang.org/api/civicinfo/v2"
27 // ...
28 // ctx := context.Background()
29 // civicinfoService, err := civicinfo.NewService(ctx)
30 //
31 // In this example, Google Application Default Credentials are used for
32 // authentication. For information on how to create and obtain Application
33 // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
34 //
35 // # Other authentication options
36 //
37 // To use an API key for authentication (note: some APIs do not support API
38 // keys), use [google.golang.org/api/option.WithAPIKey]:
39 //
40 // civicinfoService, err := civicinfo.NewService(ctx, option.WithAPIKey("AIza..."))
41 //
42 // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
43 // flow, use [google.golang.org/api/option.WithTokenSource]:
44 //
45 // config := &oauth2.Config{...}
46 // // ...
47 // token, err := config.Exchange(ctx, ...)
48 // civicinfoService, err := civicinfo.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
49 //
50 // See [google.golang.org/api/option.ClientOption] for details on options.
51 package civicinfo // import "google.golang.org/api/civicinfo/v2"
52
53 import (
54 "bytes"
55 "context"
56 "encoding/json"
57 "errors"
58 "fmt"
59 "io"
60 "log/slog"
61 "net/http"
62 "net/url"
63 "strconv"
64 "strings"
65
66 "github.com/googleapis/gax-go/v2/internallog"
67 googleapi "google.golang.org/api/googleapi"
68 internal "google.golang.org/api/internal"
69 gensupport "google.golang.org/api/internal/gensupport"
70 option "google.golang.org/api/option"
71 internaloption "google.golang.org/api/option/internaloption"
72 htransport "google.golang.org/api/transport/http"
73 )
74
75 // Always reference these packages, just in case the auto-generated code
76 // below doesn't.
77 var _ = bytes.NewBuffer
78 var _ = strconv.Itoa
79 var _ = fmt.Sprintf
80 var _ = json.NewDecoder
81 var _ = io.Copy
82 var _ = url.Parse
83 var _ = gensupport.MarshalJSON
84 var _ = googleapi.Version
85 var _ = errors.New
86 var _ = strings.Replace
87 var _ = context.Canceled
88 var _ = internaloption.WithDefaultEndpoint
89 var _ = internal.Version
90 var _ = internallog.New
91
92 const apiId = "civicinfo:v2"
93 const apiName = "civicinfo"
94 const apiVersion = "v2"
95 const basePath = "https://civicinfo.googleapis.com/"
96 const basePathTemplate = "https://civicinfo.UNIVERSE_DOMAIN/"
97 const mtlsBasePath = "https://civicinfo.mtls.googleapis.com/"
98
99 // NewService creates a new Service.
100 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
101 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
102 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
103 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
104 opts = append(opts, internaloption.EnableNewAuthLibrary())
105 client, endpoint, err := htransport.NewClient(ctx, opts...)
106 if err != nil {
107 return nil, err
108 }
109 s := &Service{client: client, BasePath: basePath, logger: internaloption.GetLogger(opts)}
110 s.Divisions = NewDivisionsService(s)
111 s.Elections = NewElectionsService(s)
112 if endpoint != "" {
113 s.BasePath = endpoint
114 }
115 return s, nil
116 }
117
118 // New creates a new Service. It uses the provided http.Client for requests.
119 //
120 // Deprecated: please use NewService instead.
121 // To provide a custom HTTP client, use option.WithHTTPClient.
122 // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
123 func New(client *http.Client) (*Service, error) {
124 if client == nil {
125 return nil, errors.New("client is nil")
126 }
127 return NewService(context.TODO(), option.WithHTTPClient(client))
128 }
129
130 type Service struct {
131 client *http.Client
132 logger *slog.Logger
133 BasePath string // API endpoint base URL
134 UserAgent string // optional additional User-Agent fragment
135
136 Divisions *DivisionsService
137
138 Elections *ElectionsService
139 }
140
141 func (s *Service) userAgent() string {
142 if s.UserAgent == "" {
143 return googleapi.UserAgent
144 }
145 return googleapi.UserAgent + " " + s.UserAgent
146 }
147
148 func NewDivisionsService(s *Service) *DivisionsService {
149 rs := &DivisionsService{s: s}
150 return rs
151 }
152
153 type DivisionsService struct {
154 s *Service
155 }
156
157 func NewElectionsService(s *Service) *ElectionsService {
158 rs := &ElectionsService{s: s}
159 return rs
160 }
161
162 type ElectionsService struct {
163 s *Service
164 }
165
166 type CivicinfoApiprotosV2DivisionByAddressResponse struct {
167 Divisions map[string]CivicinfoSchemaV2GeographicDivision `json:"divisions,omitempty"`
168 // NormalizedInput: The normalized version of the requested address.
169 NormalizedInput *CivicinfoSchemaV2SimpleAddressType `json:"normalizedInput,omitempty"`
170
171 // ServerResponse contains the HTTP response code and headers from the server.
172 googleapi.ServerResponse `json:"-"`
173 // ForceSendFields is a list of field names (e.g. "Divisions") to
174 // unconditionally include in API requests. By default, fields with empty or
175 // default values are omitted from API requests. See
176 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
177 // details.
178 ForceSendFields []string `json:"-"`
179 // NullFields is a list of field names (e.g. "Divisions") to include in API
180 // requests with the JSON null value. By default, fields with empty values are
181 // omitted from API requests. See
182 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
183 NullFields []string `json:"-"`
184 }
185
186 func (s CivicinfoApiprotosV2DivisionByAddressResponse) MarshalJSON() ([]byte, error) {
187 type NoMethod CivicinfoApiprotosV2DivisionByAddressResponse
188 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
189 }
190
191 // CivicinfoApiprotosV2DivisionSearchResponse: The result of a division search
192 // query.
193 type CivicinfoApiprotosV2DivisionSearchResponse struct {
194 // Kind: Identifies what kind of resource this is. Value: the fixed string
195 // "civicinfo#divisionSearchResponse".
196 Kind string `json:"kind,omitempty"`
197 Results []*CivicinfoApiprotosV2DivisionSearchResult `json:"results,omitempty"`
198
199 // ServerResponse contains the HTTP response code and headers from the server.
200 googleapi.ServerResponse `json:"-"`
201 // ForceSendFields is a list of field names (e.g. "Kind") to unconditionally
202 // include in API requests. By default, fields with empty or default values are
203 // omitted from API requests. See
204 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
205 // details.
206 ForceSendFields []string `json:"-"`
207 // NullFields is a list of field names (e.g. "Kind") to include in API requests
208 // with the JSON null value. By default, fields with empty values are omitted
209 // from API requests. See
210 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
211 NullFields []string `json:"-"`
212 }
213
214 func (s CivicinfoApiprotosV2DivisionSearchResponse) MarshalJSON() ([]byte, error) {
215 type NoMethod CivicinfoApiprotosV2DivisionSearchResponse
216 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
217 }
218
219 // CivicinfoApiprotosV2DivisionSearchResult: Represents a political geographic
220 // division that matches the requested query.
221 type CivicinfoApiprotosV2DivisionSearchResult struct {
222 // Aliases: Other Open Civic Data identifiers that refer to the same division
223 // -- for example, those that refer to other political divisions whose
224 // boundaries are defined to be coterminous with this one. For example,
225 // ocd-division/country:us/state:wy will include an alias of
226 // ocd-division/country:us/state:wy/cd:1, since Wyoming has only one
227 // Congressional district.
228 Aliases []string `json:"aliases,omitempty"`
229 // Name: The name of the division.
230 Name string `json:"name,omitempty"`
231 // OcdId: The unique Open Civic Data identifier for this division
232 OcdId string `json:"ocdId,omitempty"`
233 // ForceSendFields is a list of field names (e.g. "Aliases") to unconditionally
234 // include in API requests. By default, fields with empty or default values are
235 // omitted from API requests. See
236 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
237 // details.
238 ForceSendFields []string `json:"-"`
239 // NullFields is a list of field names (e.g. "Aliases") to include in API
240 // requests with the JSON null value. By default, fields with empty values are
241 // omitted from API requests. See
242 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
243 NullFields []string `json:"-"`
244 }
245
246 func (s CivicinfoApiprotosV2DivisionSearchResult) MarshalJSON() ([]byte, error) {
247 type NoMethod CivicinfoApiprotosV2DivisionSearchResult
248 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
249 }
250
251 // CivicinfoApiprotosV2ElectionsQueryResponse: The list of elections available
252 // for this version of the API.
253 type CivicinfoApiprotosV2ElectionsQueryResponse struct {
254 // Elections: A list of available elections
255 Elections []*CivicinfoSchemaV2Election `json:"elections,omitempty"`
256 // Kind: Identifies what kind of resource this is. Value: the fixed string
257 // "civicinfo#electionsQueryResponse".
258 Kind string `json:"kind,omitempty"`
259
260 // ServerResponse contains the HTTP response code and headers from the server.
261 googleapi.ServerResponse `json:"-"`
262 // ForceSendFields is a list of field names (e.g. "Elections") to
263 // unconditionally include in API requests. By default, fields with empty or
264 // default values are omitted from API requests. See
265 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
266 // details.
267 ForceSendFields []string `json:"-"`
268 // NullFields is a list of field names (e.g. "Elections") to include in API
269 // requests with the JSON null value. By default, fields with empty values are
270 // omitted from API requests. See
271 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
272 NullFields []string `json:"-"`
273 }
274
275 func (s CivicinfoApiprotosV2ElectionsQueryResponse) MarshalJSON() ([]byte, error) {
276 type NoMethod CivicinfoApiprotosV2ElectionsQueryResponse
277 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
278 }
279
280 // CivicinfoApiprotosV2VoterInfoResponse: The result of a voter info lookup
281 // query.
282 type CivicinfoApiprotosV2VoterInfoResponse struct {
283 // Contests: Contests that will appear on the voter's ballot.
284 Contests []*CivicinfoSchemaV2Contest `json:"contests,omitempty"`
285 // DropOffLocations: Locations where a voter is eligible to drop off a
286 // completed ballot. The voter must have received and completed a ballot prior
287 // to arriving at the location. The location may not have ballots available on
288 // the premises. These locations could be open on or before election day as
289 // indicated in the pollingHours field.
290 DropOffLocations []*CivicinfoSchemaV2PollingLocation `json:"dropOffLocations,omitempty"`
291 // EarlyVoteSites: Locations where the voter is eligible to vote early, prior
292 // to election day.
293 EarlyVoteSites []*CivicinfoSchemaV2PollingLocation `json:"earlyVoteSites,omitempty"`
294 // Election: The election that was queried.
295 Election *CivicinfoSchemaV2Election `json:"election,omitempty"`
296 // Kind: Identifies what kind of resource this is. Value: the fixed string
297 // "civicinfo#voterInfoResponse".
298 Kind string `json:"kind,omitempty"`
299 // MailOnly: Specifies whether voters in the precinct vote only by mailing
300 // their ballots (with the possible option of dropping off their ballots as
301 // well).
302 MailOnly bool `json:"mailOnly,omitempty"`
303 // NormalizedInput: The normalized version of the requested address
304 NormalizedInput *CivicinfoSchemaV2SimpleAddressType `json:"normalizedInput,omitempty"`
305 // OtherElections: When there are multiple elections for a voter address, the
306 // otherElections field is populated in the API response and there are two
307 // possibilities: 1. If the earliest election is not the intended election,
308 // specify the election ID of the desired election in a second API request
309 // using the electionId field. 2. If these elections occur on the same day, the
310 // API doesn?t return any polling location, contest, or election official
311 // information to ensure that an additional query is made. For user-facing
312 // applications, we recommend displaying these elections to the user to
313 // disambiguate. A second API request using the electionId field should be made
314 // for the election that is relevant to the user.
315 OtherElections []*CivicinfoSchemaV2Election `json:"otherElections,omitempty"`
316 // PollingLocations: Locations where the voter is eligible to vote on election
317 // day.
318 PollingLocations []*CivicinfoSchemaV2PollingLocation `json:"pollingLocations,omitempty"`
319 PrecinctId string `json:"precinctId,omitempty"`
320 // Precincts: The precincts that match this voter's address. Will only be
321 // returned for project IDs which have been allowlisted as "partner projects".
322 Precincts []*CivicinfoSchemaV2Precinct `json:"precincts,omitempty"`
323 // State: Local Election Information for the state that the voter votes in. For
324 // the US, there will only be one element in this array.
325 State []*CivicinfoSchemaV2AdministrationRegion `json:"state,omitempty"`
326
327 // ServerResponse contains the HTTP response code and headers from the server.
328 googleapi.ServerResponse `json:"-"`
329 // ForceSendFields is a list of field names (e.g. "Contests") to
330 // unconditionally include in API requests. By default, fields with empty or
331 // default values are omitted from API requests. See
332 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
333 // details.
334 ForceSendFields []string `json:"-"`
335 // NullFields is a list of field names (e.g. "Contests") to include in API
336 // requests with the JSON null value. By default, fields with empty values are
337 // omitted from API requests. See
338 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
339 NullFields []string `json:"-"`
340 }
341
342 func (s CivicinfoApiprotosV2VoterInfoResponse) MarshalJSON() ([]byte, error) {
343 type NoMethod CivicinfoApiprotosV2VoterInfoResponse
344 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
345 }
346
347 // CivicinfoSchemaV2AdministrationRegion: Describes information about a
348 // regional election administrative area.
349 type CivicinfoSchemaV2AdministrationRegion struct {
350 // ElectionAdministrationBody: The election administration body for this area.
351 ElectionAdministrationBody *CivicinfoSchemaV2AdministrativeBody `json:"electionAdministrationBody,omitempty"`
352 // LocalJurisdiction: The city or county that provides election information for
353 // this voter. This object can have the same elements as state.
354 LocalJurisdiction *CivicinfoSchemaV2AdministrationRegion `json:"local_jurisdiction,omitempty"`
355 // Name: The name of the jurisdiction.
356 Name string `json:"name,omitempty"`
357 // Sources: A list of sources for this area. If multiple sources are listed the
358 // data has been aggregated from those sources.
359 Sources []*CivicinfoSchemaV2Source `json:"sources,omitempty"`
360 // ForceSendFields is a list of field names (e.g. "ElectionAdministrationBody")
361 // to unconditionally include in API requests. By default, fields with empty or
362 // default values are omitted from API requests. See
363 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
364 // details.
365 ForceSendFields []string `json:"-"`
366 // NullFields is a list of field names (e.g. "ElectionAdministrationBody") to
367 // include in API requests with the JSON null value. By default, fields with
368 // empty values are omitted from API requests. See
369 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
370 NullFields []string `json:"-"`
371 }
372
373 func (s CivicinfoSchemaV2AdministrationRegion) MarshalJSON() ([]byte, error) {
374 type NoMethod CivicinfoSchemaV2AdministrationRegion
375 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
376 }
377
378 // CivicinfoSchemaV2AdministrativeBody: Information about an election
379 // administrative body (e.g. County Board of Elections).
380 type CivicinfoSchemaV2AdministrativeBody struct {
381 // AbsenteeVotingInfoUrl: A URL provided by this administrative body for
382 // information on absentee voting.
383 AbsenteeVotingInfoUrl string `json:"absenteeVotingInfoUrl,omitempty"`
384 // BallotInfoUrl: A URL provided by this administrative body to give contest
385 // information to the voter.
386 BallotInfoUrl string `json:"ballotInfoUrl,omitempty"`
387 // CorrespondenceAddress: The mailing address of this administrative body.
388 CorrespondenceAddress *CivicinfoSchemaV2SimpleAddressType `json:"correspondenceAddress,omitempty"`
389 // ElectionInfoUrl: A URL provided by this administrative body for looking up
390 // general election information.
391 ElectionInfoUrl string `json:"electionInfoUrl,omitempty"`
392 // ElectionNoticeText: A last minute or emergency notification text provided by
393 // this administrative body.
394 ElectionNoticeText string `json:"electionNoticeText,omitempty"`
395 // ElectionNoticeUrl: A URL provided by this administrative body for additional
396 // information related to the last minute or emergency notification.
397 ElectionNoticeUrl string `json:"electionNoticeUrl,omitempty"`
398 // ElectionOfficials: The election officials for this election administrative
399 // body.
400 ElectionOfficials []*CivicinfoSchemaV2ElectionOfficial `json:"electionOfficials,omitempty"`
401 // ElectionRegistrationConfirmationUrl: A URL provided by this administrative
402 // body for confirming that the voter is registered to vote.
403 ElectionRegistrationConfirmationUrl string `json:"electionRegistrationConfirmationUrl,omitempty"`
404 // ElectionRegistrationUrl: A URL provided by this administrative body for
405 // looking up how to register to vote.
406 ElectionRegistrationUrl string `json:"electionRegistrationUrl,omitempty"`
407 // ElectionRulesUrl: A URL provided by this administrative body describing
408 // election rules to the voter.
409 ElectionRulesUrl string `json:"electionRulesUrl,omitempty"`
410 // HoursOfOperation: A description of the hours of operation for this
411 // administrative body.
412 HoursOfOperation string `json:"hoursOfOperation,omitempty"`
413 // Name: The name of this election administrative body.
414 Name string `json:"name,omitempty"`
415 // PhysicalAddress: The physical address of this administrative body.
416 PhysicalAddress *CivicinfoSchemaV2SimpleAddressType `json:"physicalAddress,omitempty"`
417 // VoterServices: A description of the services this administrative body may
418 // provide.
419 VoterServices []string `json:"voter_services,omitempty"`
420 // VotingLocationFinderUrl: A URL provided by this administrative body for
421 // looking up where to vote.
422 VotingLocationFinderUrl string `json:"votingLocationFinderUrl,omitempty"`
423 // ForceSendFields is a list of field names (e.g. "AbsenteeVotingInfoUrl") to
424 // unconditionally include in API requests. By default, fields with empty or
425 // default values are omitted from API requests. See
426 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
427 // details.
428 ForceSendFields []string `json:"-"`
429 // NullFields is a list of field names (e.g. "AbsenteeVotingInfoUrl") to
430 // include in API requests with the JSON null value. By default, fields with
431 // empty values are omitted from API requests. See
432 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
433 NullFields []string `json:"-"`
434 }
435
436 func (s CivicinfoSchemaV2AdministrativeBody) MarshalJSON() ([]byte, error) {
437 type NoMethod CivicinfoSchemaV2AdministrativeBody
438 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
439 }
440
441 // CivicinfoSchemaV2Candidate: Information about a candidate running for
442 // elected office.
443 type CivicinfoSchemaV2Candidate struct {
444 // CandidateUrl: The URL for the candidate's campaign web site.
445 CandidateUrl string `json:"candidateUrl,omitempty"`
446 // Channels: A list of known (social) media channels for this candidate.
447 Channels []*CivicinfoSchemaV2Channel `json:"channels,omitempty"`
448 // Email: The email address for the candidate's campaign.
449 Email string `json:"email,omitempty"`
450 // Name: The candidate's name. If this is a joint ticket it will indicate the
451 // name of the candidate at the top of a ticket followed by a / and that name
452 // of candidate at the bottom of the ticket. e.g. "Mitt Romney / Paul Ryan"
453 Name string `json:"name,omitempty"`
454 // OrderOnBallot: The order the candidate appears on the ballot for this
455 // contest.
456 OrderOnBallot int64 `json:"orderOnBallot,omitempty,string"`
457 // Party: The full name of the party the candidate is a member of.
458 Party string `json:"party,omitempty"`
459 // Phone: The voice phone number for the candidate's campaign office.
460 Phone string `json:"phone,omitempty"`
461 // PhotoUrl: A URL for a photo of the candidate.
462 PhotoUrl string `json:"photoUrl,omitempty"`
463 // ForceSendFields is a list of field names (e.g. "CandidateUrl") to
464 // unconditionally include in API requests. By default, fields with empty or
465 // default values are omitted from API requests. See
466 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
467 // details.
468 ForceSendFields []string `json:"-"`
469 // NullFields is a list of field names (e.g. "CandidateUrl") to include in API
470 // requests with the JSON null value. By default, fields with empty values are
471 // omitted from API requests. See
472 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
473 NullFields []string `json:"-"`
474 }
475
476 func (s CivicinfoSchemaV2Candidate) MarshalJSON() ([]byte, error) {
477 type NoMethod CivicinfoSchemaV2Candidate
478 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
479 }
480
481 // CivicinfoSchemaV2Channel: A social media or web channel for a candidate.
482 type CivicinfoSchemaV2Channel struct {
483 // Id: The unique public identifier for the candidate's channel.
484 Id string `json:"id,omitempty"`
485 // Type: The type of channel. The following is a list of types of channels, but
486 // is not exhaustive. More channel types may be added at a later time. One of:
487 // GooglePlus, YouTube, Facebook, Twitter
488 Type string `json:"type,omitempty"`
489 // ForceSendFields is a list of field names (e.g. "Id") to unconditionally
490 // include in API requests. By default, fields with empty or default values are
491 // omitted from API requests. See
492 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
493 // details.
494 ForceSendFields []string `json:"-"`
495 // NullFields is a list of field names (e.g. "Id") to include in API requests
496 // with the JSON null value. By default, fields with empty values are omitted
497 // from API requests. See
498 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
499 NullFields []string `json:"-"`
500 }
501
502 func (s CivicinfoSchemaV2Channel) MarshalJSON() ([]byte, error) {
503 type NoMethod CivicinfoSchemaV2Channel
504 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
505 }
506
507 // CivicinfoSchemaV2Contest: Information about a contest that appears on a
508 // voter's ballot.
509 type CivicinfoSchemaV2Contest struct {
510 // BallotPlacement: A number specifying the position of this contest on the
511 // voter's ballot.
512 BallotPlacement int64 `json:"ballotPlacement,omitempty,string"`
513 // BallotTitle: The official title on the ballot for this contest, only where
514 // available.
515 BallotTitle string `json:"ballotTitle,omitempty"`
516 // Candidates: The candidate choices for this contest.
517 Candidates []*CivicinfoSchemaV2Candidate `json:"candidates,omitempty"`
518 // District: Information about the electoral district that this contest is in.
519 District *CivicinfoSchemaV2ElectoralDistrict `json:"district,omitempty"`
520 // ElectorateSpecifications: A description of any additional eligibility
521 // requirements for voting in this contest.
522 ElectorateSpecifications string `json:"electorateSpecifications,omitempty"`
523 // Level: The levels of government of the office for this contest. There may be
524 // more than one in cases where a jurisdiction effectively acts at two
525 // different levels of government; for example, the mayor of the District of
526 // Columbia acts at "locality" level, but also effectively at both
527 // "administrative-area-2" and "administrative-area-1".
528 //
529 // Possible values:
530 // "international"
531 // "country"
532 // "administrativeArea1"
533 // "regional"
534 // "administrativeArea2"
535 // "locality"
536 // "subLocality1"
537 // "subLocality2"
538 // "special"
539 Level []string `json:"level,omitempty"`
540 // NumberElected: The number of candidates that will be elected to office in
541 // this contest.
542 NumberElected int64 `json:"numberElected,omitempty,string"`
543 // NumberVotingFor: The number of candidates that a voter may vote for in this
544 // contest.
545 NumberVotingFor int64 `json:"numberVotingFor,omitempty,string"`
546 // Office: The name of the office for this contest.
547 Office string `json:"office,omitempty"`
548 // PrimaryParties: If this is a partisan election, the name of the
549 // party/parties it is for.
550 PrimaryParties []string `json:"primaryParties,omitempty"`
551 // ReferendumBallotResponses: The set of ballot responses for the referendum. A
552 // ballot response represents a line on the ballot. Common examples might
553 // include "yes" or "no" for referenda. This field is only populated for
554 // contests of type 'Referendum'.
555 ReferendumBallotResponses []string `json:"referendumBallotResponses,omitempty"`
556 // ReferendumBrief: Specifies a short summary of the referendum that is
557 // typically on the ballot below the title but above the text. This field is
558 // only populated for contests of type 'Referendum'.
559 ReferendumBrief string `json:"referendumBrief,omitempty"`
560 // ReferendumConStatement: A statement in opposition to the referendum. It does
561 // not necessarily appear on the ballot. This field is only populated for
562 // contests of type 'Referendum'.
563 ReferendumConStatement string `json:"referendumConStatement,omitempty"`
564 // ReferendumEffectOfAbstain: Specifies what effect abstaining (not voting) on
565 // the proposition will have (i.e. whether abstaining is considered a vote
566 // against it). This field is only populated for contests of type 'Referendum'.
567 ReferendumEffectOfAbstain string `json:"referendumEffectOfAbstain,omitempty"`
568 // ReferendumPassageThreshold: The threshold of votes that the referendum needs
569 // in order to pass, e.g. "two-thirds". This field is only populated for
570 // contests of type 'Referendum'.
571 ReferendumPassageThreshold string `json:"referendumPassageThreshold,omitempty"`
572 // ReferendumProStatement: A statement in favor of the referendum. It does not
573 // necessarily appear on the ballot. This field is only populated for contests
574 // of type 'Referendum'.
575 ReferendumProStatement string `json:"referendumProStatement,omitempty"`
576 // ReferendumSubtitle: A brief description of the referendum. This field is
577 // only populated for contests of type 'Referendum'.
578 ReferendumSubtitle string `json:"referendumSubtitle,omitempty"`
579 // ReferendumText: The full text of the referendum. This field is only
580 // populated for contests of type 'Referendum'.
581 ReferendumText string `json:"referendumText,omitempty"`
582 // ReferendumTitle: The title of the referendum (e.g. 'Proposition 42'). This
583 // field is only populated for contests of type 'Referendum'.
584 ReferendumTitle string `json:"referendumTitle,omitempty"`
585 // ReferendumUrl: A link to the referendum. This field is only populated for
586 // contests of type 'Referendum'.
587 ReferendumUrl string `json:"referendumUrl,omitempty"`
588 // Roles: The roles which this office fulfills.
589 //
590 // Possible values:
591 // "headOfState"
592 // "headOfGovernment"
593 // "deputyHeadOfGovernment"
594 // "governmentOfficer"
595 // "executiveCouncil"
596 // "legislatorUpperBody"
597 // "legislatorLowerBody"
598 // "highestCourtJudge"
599 // "judge"
600 // "schoolBoard"
601 // "specialPurposeOfficer"
602 // "otherRole"
603 Roles []string `json:"roles,omitempty"`
604 // Sources: A list of sources for this contest. If multiple sources are listed,
605 // the data has been aggregated from those sources.
606 Sources []*CivicinfoSchemaV2Source `json:"sources,omitempty"`
607 // Special: "Yes" or "No" depending on whether this a contest being held
608 // outside the normal election cycle.
609 Special string `json:"special,omitempty"`
610 // Type: The type of contest. Usually this will be 'General', 'Primary', or
611 // 'Run-off' for contests with candidates. For referenda this will be
612 // 'Referendum'. For Retention contests this will typically be 'Retention'.
613 Type string `json:"type,omitempty"`
614 // ForceSendFields is a list of field names (e.g. "BallotPlacement") to
615 // unconditionally include in API requests. By default, fields with empty or
616 // default values are omitted from API requests. See
617 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
618 // details.
619 ForceSendFields []string `json:"-"`
620 // NullFields is a list of field names (e.g. "BallotPlacement") to include in
621 // API requests with the JSON null value. By default, fields with empty values
622 // are omitted from API requests. See
623 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
624 NullFields []string `json:"-"`
625 }
626
627 func (s CivicinfoSchemaV2Contest) MarshalJSON() ([]byte, error) {
628 type NoMethod CivicinfoSchemaV2Contest
629 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
630 }
631
632 // CivicinfoSchemaV2Election: Information about the election that was queried.
633 type CivicinfoSchemaV2Election struct {
634 // ElectionDay: Day of the election in YYYY-MM-DD format.
635 ElectionDay string `json:"electionDay,omitempty"`
636 // Id: The unique ID of this election.
637 Id int64 `json:"id,omitempty,string"`
638 // Name: A displayable name for the election.
639 Name string `json:"name,omitempty"`
640 // OcdDivisionId: The political division of the election. Represented as an OCD
641 // Division ID. Voters within these political jurisdictions are covered by this
642 // election. This is typically a state such as ocd-division/country:us/state:ca
643 // or for the midterms or general election the entire US (i.e.
644 // ocd-division/country:us).
645 OcdDivisionId string `json:"ocdDivisionId,omitempty"`
646 // Possible values:
647 // "shapeLookupDefault"
648 // "shapeLookupDisabled"
649 // "shapeLookupEnabled"
650 ShapeLookupBehavior string `json:"shapeLookupBehavior,omitempty"`
651 // ForceSendFields is a list of field names (e.g. "ElectionDay") to
652 // unconditionally include in API requests. By default, fields with empty or
653 // default values are omitted from API requests. See
654 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
655 // details.
656 ForceSendFields []string `json:"-"`
657 // NullFields is a list of field names (e.g. "ElectionDay") to include in API
658 // requests with the JSON null value. By default, fields with empty values are
659 // omitted from API requests. See
660 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
661 NullFields []string `json:"-"`
662 }
663
664 func (s CivicinfoSchemaV2Election) MarshalJSON() ([]byte, error) {
665 type NoMethod CivicinfoSchemaV2Election
666 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
667 }
668
669 // CivicinfoSchemaV2ElectionOfficial: Information about individual election
670 // officials.
671 type CivicinfoSchemaV2ElectionOfficial struct {
672 // EmailAddress: The email address of the election official.
673 EmailAddress string `json:"emailAddress,omitempty"`
674 // FaxNumber: The fax number of the election official.
675 FaxNumber string `json:"faxNumber,omitempty"`
676 // Name: The full name of the election official.
677 Name string `json:"name,omitempty"`
678 // OfficePhoneNumber: The office phone number of the election official.
679 OfficePhoneNumber string `json:"officePhoneNumber,omitempty"`
680 // Title: The title of the election official.
681 Title string `json:"title,omitempty"`
682 // ForceSendFields is a list of field names (e.g. "EmailAddress") to
683 // unconditionally include in API requests. By default, fields with empty or
684 // default values are omitted from API requests. See
685 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
686 // details.
687 ForceSendFields []string `json:"-"`
688 // NullFields is a list of field names (e.g. "EmailAddress") to include in API
689 // requests with the JSON null value. By default, fields with empty values are
690 // omitted from API requests. See
691 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
692 NullFields []string `json:"-"`
693 }
694
695 func (s CivicinfoSchemaV2ElectionOfficial) MarshalJSON() ([]byte, error) {
696 type NoMethod CivicinfoSchemaV2ElectionOfficial
697 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
698 }
699
700 // CivicinfoSchemaV2ElectoralDistrict: Describes the geographic scope of a
701 // contest.
702 type CivicinfoSchemaV2ElectoralDistrict struct {
703 // Id: An identifier for this district, relative to its scope. For example, the
704 // 34th State Senate district would have id "34" and a scope of stateUpper.
705 Id string `json:"id,omitempty"`
706 // Name: The name of the district.
707 Name string `json:"name,omitempty"`
708 // Scope: The geographic scope of this district. If unspecified the district's
709 // geography is not known. One of: national, statewide, congressional,
710 // stateUpper, stateLower, countywide, judicial, schoolBoard, cityWide,
711 // township, countyCouncil, cityCouncil, ward, special
712 //
713 // Possible values:
714 // "statewide"
715 // "congressional"
716 // "stateUpper"
717 // "stateLower"
718 // "countywide"
719 // "judicial"
720 // "schoolBoard"
721 // "citywide"
722 // "special"
723 // "countyCouncil"
724 // "township"
725 // "ward"
726 // "cityCouncil"
727 // "national"
728 Scope string `json:"scope,omitempty"`
729 // ForceSendFields is a list of field names (e.g. "Id") to unconditionally
730 // include in API requests. By default, fields with empty or default values are
731 // omitted from API requests. See
732 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
733 // details.
734 ForceSendFields []string `json:"-"`
735 // NullFields is a list of field names (e.g. "Id") to include in API requests
736 // with the JSON null value. By default, fields with empty values are omitted
737 // from API requests. See
738 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
739 NullFields []string `json:"-"`
740 }
741
742 func (s CivicinfoSchemaV2ElectoralDistrict) MarshalJSON() ([]byte, error) {
743 type NoMethod CivicinfoSchemaV2ElectoralDistrict
744 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
745 }
746
747 // CivicinfoSchemaV2GeographicDivision: Describes a political geography.
748 type CivicinfoSchemaV2GeographicDivision struct {
749 // AlsoKnownAs: Any other valid OCD IDs that refer to the same
750 // division.\n\nBecause OCD IDs are meant to be human-readable and at least
751 // somewhat predictable, there are occasionally several identifiers for a
752 // single division. These identifiers are defined to be equivalent to one
753 // another, and one is always indicated as the primary identifier. The primary
754 // identifier will be returned in ocd_id above, and any other equivalent valid
755 // identifiers will be returned in this list.\n\nFor example, if this
756 // division's OCD ID is ocd-division/country:us/district:dc, this will contain
757 // ocd-division/country:us/state:dc.
758 AlsoKnownAs []string `json:"alsoKnownAs,omitempty"`
759 // Name: The name of the division.
760 Name string `json:"name,omitempty"`
761 // OfficeIndices: List of indices in the offices array, one for each office
762 // elected from this division. Will only be present if includeOffices was true
763 // (or absent) in the request.
764 OfficeIndices []int64 `json:"officeIndices,omitempty"`
765 // ForceSendFields is a list of field names (e.g. "AlsoKnownAs") to
766 // unconditionally include in API requests. By default, fields with empty or
767 // default values are omitted from API requests. See
768 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
769 // details.
770 ForceSendFields []string `json:"-"`
771 // NullFields is a list of field names (e.g. "AlsoKnownAs") to include in API
772 // requests with the JSON null value. By default, fields with empty values are
773 // omitted from API requests. See
774 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
775 NullFields []string `json:"-"`
776 }
777
778 func (s CivicinfoSchemaV2GeographicDivision) MarshalJSON() ([]byte, error) {
779 type NoMethod CivicinfoSchemaV2GeographicDivision
780 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
781 }
782
783 // CivicinfoSchemaV2PollingLocation: A location where a voter can vote. This
784 // may be an early vote site, an election day voting location, or a drop off
785 // location for a completed ballot.
786 type CivicinfoSchemaV2PollingLocation struct {
787 // Address: The address of the location.
788 Address *CivicinfoSchemaV2SimpleAddressType `json:"address,omitempty"`
789 // EndDate: The last date that this early vote site or drop off location may be
790 // used. This field is not populated for polling locations.
791 EndDate string `json:"endDate,omitempty"`
792 // Latitude: Latitude of the location, in degrees north of the equator. Note
793 // this field may not be available for some locations.
794 Latitude float64 `json:"latitude,omitempty"`
795 // Longitude: Longitude of the location, in degrees east of the Prime Meridian.
796 // Note this field may not be available for some locations.
797 Longitude float64 `json:"longitude,omitempty"`
798 // Name: The name of the early vote site or drop off location. This field is
799 // not populated for polling locations.
800 Name string `json:"name,omitempty"`
801 // Notes: Notes about this location (e.g. accessibility ramp or entrance to
802 // use).
803 Notes string `json:"notes,omitempty"`
804 // PollingHours: A description of when this location is open.
805 PollingHours string `json:"pollingHours,omitempty"`
806 // Sources: A list of sources for this location. If multiple sources are listed
807 // the data has been aggregated from those sources.
808 Sources []*CivicinfoSchemaV2Source `json:"sources,omitempty"`
809 // StartDate: The first date that this early vote site or drop off location may
810 // be used. This field is not populated for polling locations.
811 StartDate string `json:"startDate,omitempty"`
812 // VoterServices: The services provided by this early vote site or drop off
813 // location. This field is not populated for polling locations.
814 VoterServices string `json:"voterServices,omitempty"`
815 // ForceSendFields is a list of field names (e.g. "Address") to unconditionally
816 // include in API requests. By default, fields with empty or default values are
817 // omitted from API requests. See
818 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
819 // details.
820 ForceSendFields []string `json:"-"`
821 // NullFields is a list of field names (e.g. "Address") to include in API
822 // requests with the JSON null value. By default, fields with empty values are
823 // omitted from API requests. See
824 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
825 NullFields []string `json:"-"`
826 }
827
828 func (s CivicinfoSchemaV2PollingLocation) MarshalJSON() ([]byte, error) {
829 type NoMethod CivicinfoSchemaV2PollingLocation
830 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
831 }
832
833 func (s *CivicinfoSchemaV2PollingLocation) UnmarshalJSON(data []byte) error {
834 type NoMethod CivicinfoSchemaV2PollingLocation
835 var s1 struct {
836 Latitude gensupport.JSONFloat64 `json:"latitude"`
837 Longitude gensupport.JSONFloat64 `json:"longitude"`
838 *NoMethod
839 }
840 s1.NoMethod = (*NoMethod)(s)
841 if err := json.Unmarshal(data, &s1); err != nil {
842 return err
843 }
844 s.Latitude = float64(s1.Latitude)
845 s.Longitude = float64(s1.Longitude)
846 return nil
847 }
848
849 type CivicinfoSchemaV2Precinct struct {
850 // AdministrationRegionId: ID of the AdministrationRegion message for this
851 // precinct. Corresponds to LocalityId xml tag.
852 AdministrationRegionId string `json:"administrationRegionId,omitempty"`
853 // ContestId: ID(s) of the Contest message(s) for this precinct.
854 ContestId []string `json:"contestId,omitempty"`
855 // DatasetId: Required. Dataset ID. What datasets our Precincts come from.
856 DatasetId int64 `json:"datasetId,omitempty,string"`
857 // EarlyVoteSiteId: ID(s) of the PollingLocation message(s) for this precinct.
858 EarlyVoteSiteId []string `json:"earlyVoteSiteId,omitempty"`
859 // ElectoralDistrictId: ID(s) of the ElectoralDistrict message(s) for this
860 // precinct.
861 ElectoralDistrictId []string `json:"electoralDistrictId,omitempty"`
862 // Id: Required. A unique identifier for this precinct.
863 Id string `json:"id,omitempty"`
864 // MailOnly: Specifies if the precinct runs mail-only elections.
865 MailOnly bool `json:"mailOnly,omitempty"`
866 // Name: Required. The name of the precinct.
867 Name string `json:"name,omitempty"`
868 // Number: The number of the precinct.
869 Number string `json:"number,omitempty"`
870 // OcdId: Encouraged. The OCD ID of the precinct
871 OcdId []string `json:"ocdId,omitempty"`
872 // PollingLocationId: ID(s) of the PollingLocation message(s) for this
873 // precinct.
874 PollingLocationId []string `json:"pollingLocationId,omitempty"`
875 // SpatialBoundaryId: ID(s) of the SpatialBoundary message(s) for this
876 // precinct. Used to specify a geometrical boundary of the precinct.
877 SpatialBoundaryId []string `json:"spatialBoundaryId,omitempty"`
878 // SplitName: If present, this proto corresponds to one portion of split
879 // precinct. Other portions of this precinct are guaranteed to have the same
880 // `name`. If not present, this proto represents a full precicnt.
881 SplitName string `json:"splitName,omitempty"`
882 // Ward: Specifies the ward the precinct is contained within.
883 Ward string `json:"ward,omitempty"`
884 // ForceSendFields is a list of field names (e.g. "AdministrationRegionId") to
885 // unconditionally include in API requests. By default, fields with empty or
886 // default values are omitted from API requests. See
887 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
888 // details.
889 ForceSendFields []string `json:"-"`
890 // NullFields is a list of field names (e.g. "AdministrationRegionId") to
891 // include in API requests with the JSON null value. By default, fields with
892 // empty values are omitted from API requests. See
893 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
894 NullFields []string `json:"-"`
895 }
896
897 func (s CivicinfoSchemaV2Precinct) MarshalJSON() ([]byte, error) {
898 type NoMethod CivicinfoSchemaV2Precinct
899 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
900 }
901
902 // CivicinfoSchemaV2SimpleAddressType: A simple representation of an address.
903 type CivicinfoSchemaV2SimpleAddressType struct {
904 AddressLine []string `json:"addressLine,omitempty"`
905 // City: The city or town for the address.
906 City string `json:"city,omitempty"`
907 // Line1: The street name and number of this address.
908 Line1 string `json:"line1,omitempty"`
909 // Line2: The second line the address, if needed.
910 Line2 string `json:"line2,omitempty"`
911 // Line3: The third line of the address, if needed.
912 Line3 string `json:"line3,omitempty"`
913 // LocationName: The name of the location.
914 LocationName string `json:"locationName,omitempty"`
915 // State: The US two letter state abbreviation of the address.
916 State string `json:"state,omitempty"`
917 // Zip: The US Postal Zip Code of the address.
918 Zip string `json:"zip,omitempty"`
919 // ForceSendFields is a list of field names (e.g. "AddressLine") to
920 // unconditionally include in API requests. By default, fields with empty or
921 // default values are omitted from API requests. See
922 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
923 // details.
924 ForceSendFields []string `json:"-"`
925 // NullFields is a list of field names (e.g. "AddressLine") to include in API
926 // requests with the JSON null value. By default, fields with empty values are
927 // omitted from API requests. See
928 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
929 NullFields []string `json:"-"`
930 }
931
932 func (s CivicinfoSchemaV2SimpleAddressType) MarshalJSON() ([]byte, error) {
933 type NoMethod CivicinfoSchemaV2SimpleAddressType
934 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
935 }
936
937 // CivicinfoSchemaV2Source: Contains information about the data source for the
938 // element containing it.
939 type CivicinfoSchemaV2Source struct {
940 // Name: The name of the data source.
941 Name string `json:"name,omitempty"`
942 // Official: Whether this data comes from an official government source.
943 Official bool `json:"official,omitempty"`
944 // ForceSendFields is a list of field names (e.g. "Name") to unconditionally
945 // include in API requests. By default, fields with empty or default values are
946 // omitted from API requests. See
947 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
948 // details.
949 ForceSendFields []string `json:"-"`
950 // NullFields is a list of field names (e.g. "Name") to include in API requests
951 // with the JSON null value. By default, fields with empty values are omitted
952 // from API requests. See
953 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
954 NullFields []string `json:"-"`
955 }
956
957 func (s CivicinfoSchemaV2Source) MarshalJSON() ([]byte, error) {
958 type NoMethod CivicinfoSchemaV2Source
959 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
960 }
961
962 type DivisionsQueryDivisionByAddressCall struct {
963 s *Service
964 urlParams_ gensupport.URLParams
965 ifNoneMatch_ string
966 ctx_ context.Context
967 header_ http.Header
968 }
969
970 // QueryDivisionByAddress: Lookup OCDIDs and names for divisions related to an
971 // address.
972 func (r *DivisionsService) QueryDivisionByAddress() *DivisionsQueryDivisionByAddressCall {
973 c := &DivisionsQueryDivisionByAddressCall{s: r.s, urlParams_: make(gensupport.URLParams)}
974 return c
975 }
976
977 // Address sets the optional parameter "address":
978 func (c *DivisionsQueryDivisionByAddressCall) Address(address string) *DivisionsQueryDivisionByAddressCall {
979 c.urlParams_.Set("address", address)
980 return c
981 }
982
983 // Fields allows partial responses to be retrieved. See
984 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
985 // details.
986 func (c *DivisionsQueryDivisionByAddressCall) Fields(s ...googleapi.Field) *DivisionsQueryDivisionByAddressCall {
987 c.urlParams_.Set("fields", googleapi.CombineFields(s))
988 return c
989 }
990
991 // IfNoneMatch sets an optional parameter which makes the operation fail if the
992 // object's ETag matches the given value. This is useful for getting updates
993 // only after the object has changed since the last request.
994 func (c *DivisionsQueryDivisionByAddressCall) IfNoneMatch(entityTag string) *DivisionsQueryDivisionByAddressCall {
995 c.ifNoneMatch_ = entityTag
996 return c
997 }
998
999 // Context sets the context to be used in this call's Do method.
1000 func (c *DivisionsQueryDivisionByAddressCall) Context(ctx context.Context) *DivisionsQueryDivisionByAddressCall {
1001 c.ctx_ = ctx
1002 return c
1003 }
1004
1005 // Header returns a http.Header that can be modified by the caller to add
1006 // headers to the request.
1007 func (c *DivisionsQueryDivisionByAddressCall) Header() http.Header {
1008 if c.header_ == nil {
1009 c.header_ = make(http.Header)
1010 }
1011 return c.header_
1012 }
1013
1014 func (c *DivisionsQueryDivisionByAddressCall) doRequest(alt string) (*http.Response, error) {
1015 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1016 if c.ifNoneMatch_ != "" {
1017 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1018 }
1019 c.urlParams_.Set("alt", alt)
1020 c.urlParams_.Set("prettyPrint", "false")
1021 urls := googleapi.ResolveRelative(c.s.BasePath, "civicinfo/v2/divisionsByAddress")
1022 urls += "?" + c.urlParams_.Encode()
1023 req, err := http.NewRequest("GET", urls, nil)
1024 if err != nil {
1025 return nil, err
1026 }
1027 req.Header = reqHeaders
1028 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "civicinfo.divisions.queryDivisionByAddress", "request", internallog.HTTPRequest(req, nil))
1029 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1030 }
1031
1032 // Do executes the "civicinfo.divisions.queryDivisionByAddress" call.
1033 // Any non-2xx status code is an error. Response headers are in either
1034 // *CivicinfoApiprotosV2DivisionByAddressResponse.ServerResponse.Header or (if
1035 // a response was returned at all) in error.(*googleapi.Error).Header. Use
1036 // googleapi.IsNotModified to check whether the returned error was because
1037 // http.StatusNotModified was returned.
1038 func (c *DivisionsQueryDivisionByAddressCall) Do(opts ...googleapi.CallOption) (*CivicinfoApiprotosV2DivisionByAddressResponse, error) {
1039 gensupport.SetOptions(c.urlParams_, opts...)
1040 res, err := c.doRequest("json")
1041 if res != nil && res.StatusCode == http.StatusNotModified {
1042 if res.Body != nil {
1043 res.Body.Close()
1044 }
1045 return nil, gensupport.WrapError(&googleapi.Error{
1046 Code: res.StatusCode,
1047 Header: res.Header,
1048 })
1049 }
1050 if err != nil {
1051 return nil, err
1052 }
1053 defer googleapi.CloseBody(res)
1054 if err := googleapi.CheckResponse(res); err != nil {
1055 return nil, gensupport.WrapError(err)
1056 }
1057 ret := &CivicinfoApiprotosV2DivisionByAddressResponse{
1058 ServerResponse: googleapi.ServerResponse{
1059 Header: res.Header,
1060 HTTPStatusCode: res.StatusCode,
1061 },
1062 }
1063 target := &ret
1064 b, err := gensupport.DecodeResponseBytes(target, res)
1065 if err != nil {
1066 return nil, err
1067 }
1068 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "civicinfo.divisions.queryDivisionByAddress", "response", internallog.HTTPResponse(res, b))
1069 return ret, nil
1070 }
1071
1072 type DivisionsSearchCall struct {
1073 s *Service
1074 urlParams_ gensupport.URLParams
1075 ifNoneMatch_ string
1076 ctx_ context.Context
1077 header_ http.Header
1078 }
1079
1080 // Search: Searches for political divisions by their natural name or OCD ID.
1081 func (r *DivisionsService) Search() *DivisionsSearchCall {
1082 c := &DivisionsSearchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1083 return c
1084 }
1085
1086 // Query sets the optional parameter "query": The search query. Queries can
1087 // cover any parts of a OCD ID or a human readable division name. All words
1088 // given in the query are treated as required patterns. In addition to that,
1089 // most query operators of the Apache Lucene library are supported. See
1090 // http://lucene.apache.org/core/2_9_4/queryparsersyntax.html
1091 func (c *DivisionsSearchCall) Query(query string) *DivisionsSearchCall {
1092 c.urlParams_.Set("query", query)
1093 return c
1094 }
1095
1096 // Fields allows partial responses to be retrieved. See
1097 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
1098 // details.
1099 func (c *DivisionsSearchCall) Fields(s ...googleapi.Field) *DivisionsSearchCall {
1100 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1101 return c
1102 }
1103
1104 // IfNoneMatch sets an optional parameter which makes the operation fail if the
1105 // object's ETag matches the given value. This is useful for getting updates
1106 // only after the object has changed since the last request.
1107 func (c *DivisionsSearchCall) IfNoneMatch(entityTag string) *DivisionsSearchCall {
1108 c.ifNoneMatch_ = entityTag
1109 return c
1110 }
1111
1112 // Context sets the context to be used in this call's Do method.
1113 func (c *DivisionsSearchCall) Context(ctx context.Context) *DivisionsSearchCall {
1114 c.ctx_ = ctx
1115 return c
1116 }
1117
1118 // Header returns a http.Header that can be modified by the caller to add
1119 // headers to the request.
1120 func (c *DivisionsSearchCall) Header() http.Header {
1121 if c.header_ == nil {
1122 c.header_ = make(http.Header)
1123 }
1124 return c.header_
1125 }
1126
1127 func (c *DivisionsSearchCall) doRequest(alt string) (*http.Response, error) {
1128 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1129 if c.ifNoneMatch_ != "" {
1130 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1131 }
1132 c.urlParams_.Set("alt", alt)
1133 c.urlParams_.Set("prettyPrint", "false")
1134 urls := googleapi.ResolveRelative(c.s.BasePath, "civicinfo/v2/divisions")
1135 urls += "?" + c.urlParams_.Encode()
1136 req, err := http.NewRequest("GET", urls, nil)
1137 if err != nil {
1138 return nil, err
1139 }
1140 req.Header = reqHeaders
1141 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "civicinfo.divisions.search", "request", internallog.HTTPRequest(req, nil))
1142 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1143 }
1144
1145 // Do executes the "civicinfo.divisions.search" call.
1146 // Any non-2xx status code is an error. Response headers are in either
1147 // *CivicinfoApiprotosV2DivisionSearchResponse.ServerResponse.Header or (if a
1148 // response was returned at all) in error.(*googleapi.Error).Header. Use
1149 // googleapi.IsNotModified to check whether the returned error was because
1150 // http.StatusNotModified was returned.
1151 func (c *DivisionsSearchCall) Do(opts ...googleapi.CallOption) (*CivicinfoApiprotosV2DivisionSearchResponse, error) {
1152 gensupport.SetOptions(c.urlParams_, opts...)
1153 res, err := c.doRequest("json")
1154 if res != nil && res.StatusCode == http.StatusNotModified {
1155 if res.Body != nil {
1156 res.Body.Close()
1157 }
1158 return nil, gensupport.WrapError(&googleapi.Error{
1159 Code: res.StatusCode,
1160 Header: res.Header,
1161 })
1162 }
1163 if err != nil {
1164 return nil, err
1165 }
1166 defer googleapi.CloseBody(res)
1167 if err := googleapi.CheckResponse(res); err != nil {
1168 return nil, gensupport.WrapError(err)
1169 }
1170 ret := &CivicinfoApiprotosV2DivisionSearchResponse{
1171 ServerResponse: googleapi.ServerResponse{
1172 Header: res.Header,
1173 HTTPStatusCode: res.StatusCode,
1174 },
1175 }
1176 target := &ret
1177 b, err := gensupport.DecodeResponseBytes(target, res)
1178 if err != nil {
1179 return nil, err
1180 }
1181 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "civicinfo.divisions.search", "response", internallog.HTTPResponse(res, b))
1182 return ret, nil
1183 }
1184
1185 type ElectionsElectionQueryCall struct {
1186 s *Service
1187 urlParams_ gensupport.URLParams
1188 ifNoneMatch_ string
1189 ctx_ context.Context
1190 header_ http.Header
1191 }
1192
1193 // ElectionQuery: List of available elections to query.
1194 func (r *ElectionsService) ElectionQuery() *ElectionsElectionQueryCall {
1195 c := &ElectionsElectionQueryCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1196 return c
1197 }
1198
1199 // ProductionDataOnly sets the optional parameter "productionDataOnly": Whether
1200 // to include data that has not been allowlisted yet
1201 func (c *ElectionsElectionQueryCall) ProductionDataOnly(productionDataOnly bool) *ElectionsElectionQueryCall {
1202 c.urlParams_.Set("productionDataOnly", fmt.Sprint(productionDataOnly))
1203 return c
1204 }
1205
1206 // Fields allows partial responses to be retrieved. See
1207 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
1208 // details.
1209 func (c *ElectionsElectionQueryCall) Fields(s ...googleapi.Field) *ElectionsElectionQueryCall {
1210 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1211 return c
1212 }
1213
1214 // IfNoneMatch sets an optional parameter which makes the operation fail if the
1215 // object's ETag matches the given value. This is useful for getting updates
1216 // only after the object has changed since the last request.
1217 func (c *ElectionsElectionQueryCall) IfNoneMatch(entityTag string) *ElectionsElectionQueryCall {
1218 c.ifNoneMatch_ = entityTag
1219 return c
1220 }
1221
1222 // Context sets the context to be used in this call's Do method.
1223 func (c *ElectionsElectionQueryCall) Context(ctx context.Context) *ElectionsElectionQueryCall {
1224 c.ctx_ = ctx
1225 return c
1226 }
1227
1228 // Header returns a http.Header that can be modified by the caller to add
1229 // headers to the request.
1230 func (c *ElectionsElectionQueryCall) Header() http.Header {
1231 if c.header_ == nil {
1232 c.header_ = make(http.Header)
1233 }
1234 return c.header_
1235 }
1236
1237 func (c *ElectionsElectionQueryCall) doRequest(alt string) (*http.Response, error) {
1238 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1239 if c.ifNoneMatch_ != "" {
1240 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1241 }
1242 c.urlParams_.Set("alt", alt)
1243 c.urlParams_.Set("prettyPrint", "false")
1244 urls := googleapi.ResolveRelative(c.s.BasePath, "civicinfo/v2/elections")
1245 urls += "?" + c.urlParams_.Encode()
1246 req, err := http.NewRequest("GET", urls, nil)
1247 if err != nil {
1248 return nil, err
1249 }
1250 req.Header = reqHeaders
1251 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "civicinfo.elections.electionQuery", "request", internallog.HTTPRequest(req, nil))
1252 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1253 }
1254
1255 // Do executes the "civicinfo.elections.electionQuery" call.
1256 // Any non-2xx status code is an error. Response headers are in either
1257 // *CivicinfoApiprotosV2ElectionsQueryResponse.ServerResponse.Header or (if a
1258 // response was returned at all) in error.(*googleapi.Error).Header. Use
1259 // googleapi.IsNotModified to check whether the returned error was because
1260 // http.StatusNotModified was returned.
1261 func (c *ElectionsElectionQueryCall) Do(opts ...googleapi.CallOption) (*CivicinfoApiprotosV2ElectionsQueryResponse, error) {
1262 gensupport.SetOptions(c.urlParams_, opts...)
1263 res, err := c.doRequest("json")
1264 if res != nil && res.StatusCode == http.StatusNotModified {
1265 if res.Body != nil {
1266 res.Body.Close()
1267 }
1268 return nil, gensupport.WrapError(&googleapi.Error{
1269 Code: res.StatusCode,
1270 Header: res.Header,
1271 })
1272 }
1273 if err != nil {
1274 return nil, err
1275 }
1276 defer googleapi.CloseBody(res)
1277 if err := googleapi.CheckResponse(res); err != nil {
1278 return nil, gensupport.WrapError(err)
1279 }
1280 ret := &CivicinfoApiprotosV2ElectionsQueryResponse{
1281 ServerResponse: googleapi.ServerResponse{
1282 Header: res.Header,
1283 HTTPStatusCode: res.StatusCode,
1284 },
1285 }
1286 target := &ret
1287 b, err := gensupport.DecodeResponseBytes(target, res)
1288 if err != nil {
1289 return nil, err
1290 }
1291 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "civicinfo.elections.electionQuery", "response", internallog.HTTPResponse(res, b))
1292 return ret, nil
1293 }
1294
1295 type ElectionsVoterInfoQueryCall struct {
1296 s *Service
1297 urlParams_ gensupport.URLParams
1298 ifNoneMatch_ string
1299 ctx_ context.Context
1300 header_ http.Header
1301 }
1302
1303 // VoterInfoQuery: Looks up information relevant to a voter based on the
1304 // voter's registered address.
1305 func (r *ElectionsService) VoterInfoQuery() *ElectionsVoterInfoQueryCall {
1306 c := &ElectionsVoterInfoQueryCall{s: r.s, urlParams_: make(gensupport.URLParams)}
1307 return c
1308 }
1309
1310 // Address sets the optional parameter "address": The registered address of the
1311 // voter to look up.
1312 func (c *ElectionsVoterInfoQueryCall) Address(address string) *ElectionsVoterInfoQueryCall {
1313 c.urlParams_.Set("address", address)
1314 return c
1315 }
1316
1317 // ElectionId sets the optional parameter "electionId": The unique ID of the
1318 // election to look up. A list of election IDs can be obtained at
1319 // https://www.googleapis.com/civicinfo/{version}/elections. If no election ID
1320 // is specified in the query and there is more than one election with data for
1321 // the given voter, the additional elections are provided in the otherElections
1322 // response field.
1323 func (c *ElectionsVoterInfoQueryCall) ElectionId(electionId int64) *ElectionsVoterInfoQueryCall {
1324 c.urlParams_.Set("electionId", fmt.Sprint(electionId))
1325 return c
1326 }
1327
1328 // OfficialOnly sets the optional parameter "officialOnly": If set to true,
1329 // only data from official state sources will be returned.
1330 func (c *ElectionsVoterInfoQueryCall) OfficialOnly(officialOnly bool) *ElectionsVoterInfoQueryCall {
1331 c.urlParams_.Set("officialOnly", fmt.Sprint(officialOnly))
1332 return c
1333 }
1334
1335 // ProductionDataOnly sets the optional parameter "productionDataOnly": Whether
1336 // to include data that has not been vetted yet. Should only be made available
1337 // to internal IPs or trusted partners. This is a non-discoverable parameter in
1338 // the One Platform API config.
1339 func (c *ElectionsVoterInfoQueryCall) ProductionDataOnly(productionDataOnly bool) *ElectionsVoterInfoQueryCall {
1340 c.urlParams_.Set("productionDataOnly", fmt.Sprint(productionDataOnly))
1341 return c
1342 }
1343
1344 // ReturnAllAvailableData sets the optional parameter "returnAllAvailableData":
1345 // If set to true, the query will return the success code and include any
1346 // partial information when it is unable to determine a matching address or
1347 // unable to determine the election for electionId=0 queries.
1348 func (c *ElectionsVoterInfoQueryCall) ReturnAllAvailableData(returnAllAvailableData bool) *ElectionsVoterInfoQueryCall {
1349 c.urlParams_.Set("returnAllAvailableData", fmt.Sprint(returnAllAvailableData))
1350 return c
1351 }
1352
1353 // Fields allows partial responses to be retrieved. See
1354 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
1355 // details.
1356 func (c *ElectionsVoterInfoQueryCall) Fields(s ...googleapi.Field) *ElectionsVoterInfoQueryCall {
1357 c.urlParams_.Set("fields", googleapi.CombineFields(s))
1358 return c
1359 }
1360
1361 // IfNoneMatch sets an optional parameter which makes the operation fail if the
1362 // object's ETag matches the given value. This is useful for getting updates
1363 // only after the object has changed since the last request.
1364 func (c *ElectionsVoterInfoQueryCall) IfNoneMatch(entityTag string) *ElectionsVoterInfoQueryCall {
1365 c.ifNoneMatch_ = entityTag
1366 return c
1367 }
1368
1369 // Context sets the context to be used in this call's Do method.
1370 func (c *ElectionsVoterInfoQueryCall) Context(ctx context.Context) *ElectionsVoterInfoQueryCall {
1371 c.ctx_ = ctx
1372 return c
1373 }
1374
1375 // Header returns a http.Header that can be modified by the caller to add
1376 // headers to the request.
1377 func (c *ElectionsVoterInfoQueryCall) Header() http.Header {
1378 if c.header_ == nil {
1379 c.header_ = make(http.Header)
1380 }
1381 return c.header_
1382 }
1383
1384 func (c *ElectionsVoterInfoQueryCall) doRequest(alt string) (*http.Response, error) {
1385 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_)
1386 if c.ifNoneMatch_ != "" {
1387 reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
1388 }
1389 c.urlParams_.Set("alt", alt)
1390 c.urlParams_.Set("prettyPrint", "false")
1391 urls := googleapi.ResolveRelative(c.s.BasePath, "civicinfo/v2/voterinfo")
1392 urls += "?" + c.urlParams_.Encode()
1393 req, err := http.NewRequest("GET", urls, nil)
1394 if err != nil {
1395 return nil, err
1396 }
1397 req.Header = reqHeaders
1398 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "civicinfo.elections.voterInfoQuery", "request", internallog.HTTPRequest(req, nil))
1399 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1400 }
1401
1402 // Do executes the "civicinfo.elections.voterInfoQuery" call.
1403 // Any non-2xx status code is an error. Response headers are in either
1404 // *CivicinfoApiprotosV2VoterInfoResponse.ServerResponse.Header or (if a
1405 // response was returned at all) in error.(*googleapi.Error).Header. Use
1406 // googleapi.IsNotModified to check whether the returned error was because
1407 // http.StatusNotModified was returned.
1408 func (c *ElectionsVoterInfoQueryCall) Do(opts ...googleapi.CallOption) (*CivicinfoApiprotosV2VoterInfoResponse, error) {
1409 gensupport.SetOptions(c.urlParams_, opts...)
1410 res, err := c.doRequest("json")
1411 if res != nil && res.StatusCode == http.StatusNotModified {
1412 if res.Body != nil {
1413 res.Body.Close()
1414 }
1415 return nil, gensupport.WrapError(&googleapi.Error{
1416 Code: res.StatusCode,
1417 Header: res.Header,
1418 })
1419 }
1420 if err != nil {
1421 return nil, err
1422 }
1423 defer googleapi.CloseBody(res)
1424 if err := googleapi.CheckResponse(res); err != nil {
1425 return nil, gensupport.WrapError(err)
1426 }
1427 ret := &CivicinfoApiprotosV2VoterInfoResponse{
1428 ServerResponse: googleapi.ServerResponse{
1429 Header: res.Header,
1430 HTTPStatusCode: res.StatusCode,
1431 },
1432 }
1433 target := &ret
1434 b, err := gensupport.DecodeResponseBytes(target, res)
1435 if err != nil {
1436 return nil, err
1437 }
1438 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "civicinfo.elections.voterInfoQuery", "response", internallog.HTTPResponse(res, b))
1439 return ret, nil
1440 }