Skip to content

Commit

Permalink
all: add ForceSendFields support
Browse files Browse the repository at this point in the history
Allow users to nominate fields that should be included in requests to
the server, regardless of field contents.  This makes it possible to
perform patch requests involving fields with emtpy values -- a common
use case.

This change will also enable immediate workarounds for APIs which expect
values to be present for particular fields in update requests (such as
those in googleapis#54).

The custom JSON marshaling code introduced here is applicable to both
update and patch payloads, and extends naturally to hierarchical
schemas.

Note: this change will result in non-deterministic ordering of fields in the JSON
representation of schemas, due to the intermediate use of a map.

Change-Id: I141cfabcbd500ca15b512cf17665344ba4a66887
Reviewed-on: https://code-review.googlesource.com/3386
Reviewed-by: Michael McGreevy <[email protected]>
  • Loading branch information
mcgreevy committed Sep 28, 2015
1 parent 77b0a8c commit d604dad
Show file tree
Hide file tree
Showing 149 changed files with 59,181 additions and 6 deletions.
127 changes: 127 additions & 0 deletions adexchangebuyer/v1.2/adexchangebuyer-gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"golang.org/x/net/context"
"golang.org/x/net/context/ctxhttp"
"google.golang.org/api/googleapi"
"google.golang.org/api/internal"
"io"
"net/http"
"net/url"
Expand Down Expand Up @@ -125,6 +126,20 @@ type Account struct {
// NumberActiveCreatives: The number of creatives that this account
// inserted or bid with in the last 30 days.
NumberActiveCreatives int64 `json:"numberActiveCreatives,omitempty"`

// ForceSendFields is a list of field names (e.g. "BidderLocation") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
}

func (s *Account) MarshalJSON() ([]byte, error) {
type noMethod Account
raw := noMethod(*s)
return internal.MarshalJSON(raw, s.ForceSendFields)
}

type AccountBidderLocation struct {
Expand All @@ -142,6 +157,20 @@ type AccountBidderLocation struct {

// Url: The URL to which the Ad Exchange will send bid requests.
Url string `json:"url,omitempty"`

// ForceSendFields is a list of field names (e.g. "MaximumQps") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
}

func (s *AccountBidderLocation) MarshalJSON() ([]byte, error) {
type noMethod AccountBidderLocation
raw := noMethod(*s)
return internal.MarshalJSON(raw, s.ForceSendFields)
}

// AccountsList: An account feed lists Ad Exchange buyer accounts that
Expand All @@ -153,6 +182,20 @@ type AccountsList struct {

// Kind: Resource type.
Kind string `json:"kind,omitempty"`

// ForceSendFields is a list of field names (e.g. "Items") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
}

func (s *AccountsList) MarshalJSON() ([]byte, error) {
type noMethod AccountsList
raw := noMethod(*s)
return internal.MarshalJSON(raw, s.ForceSendFields)
}

// Creative: A creative and its classification data.
Expand Down Expand Up @@ -248,6 +291,20 @@ type Creative struct {

// Width: Ad width.
Width int64 `json:"width,omitempty"`

// ForceSendFields is a list of field names (e.g. "HTMLSnippet") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
}

func (s *Creative) MarshalJSON() ([]byte, error) {
type noMethod Creative
raw := noMethod(*s)
return internal.MarshalJSON(raw, s.ForceSendFields)
}

type CreativeCorrections struct {
Expand All @@ -256,6 +313,20 @@ type CreativeCorrections struct {

// Reason: The type of correction that was applied to the creative.
Reason string `json:"reason,omitempty"`

// ForceSendFields is a list of field names (e.g. "Details") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
}

func (s *CreativeCorrections) MarshalJSON() ([]byte, error) {
type noMethod CreativeCorrections
raw := noMethod(*s)
return internal.MarshalJSON(raw, s.ForceSendFields)
}

type CreativeDisapprovalReasons struct {
Expand All @@ -264,6 +335,20 @@ type CreativeDisapprovalReasons struct {

// Reason: The categorized reason for disapproval.
Reason string `json:"reason,omitempty"`

// ForceSendFields is a list of field names (e.g. "Details") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
}

func (s *CreativeDisapprovalReasons) MarshalJSON() ([]byte, error) {
type noMethod CreativeDisapprovalReasons
raw := noMethod(*s)
return internal.MarshalJSON(raw, s.ForceSendFields)
}

// CreativeFilteringReasons: The filtering reasons for the creative.
Expand All @@ -275,6 +360,20 @@ type CreativeFilteringReasons struct {

// Reasons: The filtering reasons.
Reasons []*CreativeFilteringReasonsReasons `json:"reasons,omitempty"`

// ForceSendFields is a list of field names (e.g. "Date") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
}

func (s *CreativeFilteringReasons) MarshalJSON() ([]byte, error) {
type noMethod CreativeFilteringReasons
raw := noMethod(*s)
return internal.MarshalJSON(raw, s.ForceSendFields)
}

type CreativeFilteringReasonsReasons struct {
Expand All @@ -286,6 +385,20 @@ type CreativeFilteringReasonsReasons struct {
// FilteringStatus: The filtering status code. Please refer to the
// creative-status-codes.txt file for different statuses.
FilteringStatus int64 `json:"filteringStatus,omitempty"`

// ForceSendFields is a list of field names (e.g. "FilteringCount") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
}

func (s *CreativeFilteringReasonsReasons) MarshalJSON() ([]byte, error) {
type noMethod CreativeFilteringReasonsReasons
raw := noMethod(*s)
return internal.MarshalJSON(raw, s.ForceSendFields)
}

// CreativesList: The creatives feed lists the active creatives for the
Expand All @@ -302,6 +415,20 @@ type CreativesList struct {
// retrieve the next page of results, set the next request's "pageToken"
// value to this.
NextPageToken string `json:"nextPageToken,omitempty"`

// ForceSendFields is a list of field names (e.g. "Items") to
// unconditionally include in API requests. By default, fields with
// empty values are omitted from API requests. However, any non-pointer,
// non-interface field appearing in ForceSendFields will be sent to the
// server regardless of whether the field is empty or not. This may be
// used to include empty fields in Patch requests.
ForceSendFields []string `json:"-"`
}

func (s *CreativesList) MarshalJSON() ([]byte, error) {
type noMethod CreativesList
raw := noMethod(*s)
return internal.MarshalJSON(raw, s.ForceSendFields)
}

// method id "adexchangebuyer.accounts.get":
Expand Down
Loading

0 comments on commit d604dad

Please sign in to comment.