mirror of
https://github.com/rclone/rclone.git
synced 2025-08-17 09:01:33 +02:00
2
vendor/google.golang.org/api/CONTRIBUTORS
generated
vendored
2
vendor/google.golang.org/api/CONTRIBUTORS
generated
vendored
@ -46,5 +46,7 @@ Johan Euphrosine <proppy@google.com>
|
||||
Kostik Shtoyk <kostik@google.com>
|
||||
Michael McGreevy <mcgreevy@golang.org>
|
||||
Nick Craig-Wood <nickcw@gmail.com>
|
||||
Ross Light <light@google.com>
|
||||
Sarah Adams <shadams@google.com>
|
||||
Scott Van Woudenberg <scottvw@google.com>
|
||||
Takashi Matsuo <tmatsuo@google.com>
|
||||
|
87
vendor/google.golang.org/api/drive/v2/drive-api.json
generated
vendored
87
vendor/google.golang.org/api/drive/v2/drive-api.json
generated
vendored
@ -1,11 +1,11 @@
|
||||
{
|
||||
"kind": "discovery#restDescription",
|
||||
"etag": "\"tbys6C40o18GZwyMen5GMkdK-3s/Q3Kd6t_wsQx8lVoiuJLagBsP-sc\"",
|
||||
"etag": "\"tbys6C40o18GZwyMen5GMkdK-3s/5vvnUnaYZD7vqEjmjYVCOzuEk5s\"",
|
||||
"discoveryVersion": "v1",
|
||||
"id": "drive:v2",
|
||||
"name": "drive",
|
||||
"version": "v2",
|
||||
"revision": "20161103",
|
||||
"revision": "20170207",
|
||||
"title": "Drive API",
|
||||
"description": "Manages files in Drive including uploading, downloading, searching, detecting changes, and updating sharing permissions.",
|
||||
"ownerDomain": "google.com",
|
||||
@ -468,7 +468,7 @@
|
||||
},
|
||||
"items": {
|
||||
"type": "array",
|
||||
"description": "The actual list of apps.",
|
||||
"description": "The list of apps.",
|
||||
"items": {
|
||||
"$ref": "App"
|
||||
}
|
||||
@ -533,7 +533,7 @@
|
||||
},
|
||||
"items": {
|
||||
"type": "array",
|
||||
"description": "The actual list of changes.",
|
||||
"description": "The list of changes. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.",
|
||||
"items": {
|
||||
"$ref": "Change"
|
||||
}
|
||||
@ -554,7 +554,7 @@
|
||||
},
|
||||
"nextPageToken": {
|
||||
"type": "string",
|
||||
"description": "The page token for the next page of changes."
|
||||
"description": "The page token for the next page of changes. This will be absent if the end of the changes list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results."
|
||||
},
|
||||
"selfLink": {
|
||||
"type": "string",
|
||||
@ -626,7 +626,7 @@
|
||||
},
|
||||
"items": {
|
||||
"type": "array",
|
||||
"description": "The actual list of children.",
|
||||
"description": "The list of children. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.",
|
||||
"items": {
|
||||
"$ref": "ChildReference"
|
||||
}
|
||||
@ -642,7 +642,7 @@
|
||||
},
|
||||
"nextPageToken": {
|
||||
"type": "string",
|
||||
"description": "The page token for the next page of children."
|
||||
"description": "The page token for the next page of children. This will be absent if the end of the children list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results."
|
||||
},
|
||||
"selfLink": {
|
||||
"type": "string",
|
||||
@ -775,7 +775,7 @@
|
||||
"properties": {
|
||||
"items": {
|
||||
"type": "array",
|
||||
"description": "List of comments.",
|
||||
"description": "The list of comments. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.",
|
||||
"items": {
|
||||
"$ref": "Comment"
|
||||
}
|
||||
@ -791,7 +791,7 @@
|
||||
},
|
||||
"nextPageToken": {
|
||||
"type": "string",
|
||||
"description": "The token to use to request the next page of results."
|
||||
"description": "The page token for the next page of comments. This will be absent if the end of the comments list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results."
|
||||
},
|
||||
"selfLink": {
|
||||
"type": "string",
|
||||
@ -857,7 +857,7 @@
|
||||
"properties": {
|
||||
"items": {
|
||||
"type": "array",
|
||||
"description": "List of reply.",
|
||||
"description": "The list of replies. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.",
|
||||
"items": {
|
||||
"$ref": "CommentReply"
|
||||
}
|
||||
@ -873,7 +873,7 @@
|
||||
},
|
||||
"nextPageToken": {
|
||||
"type": "string",
|
||||
"description": "The token to use to request the next page of results."
|
||||
"description": "The page token for the next page of replies. This will be absent if the end of the replies list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results."
|
||||
},
|
||||
"selfLink": {
|
||||
"type": "string",
|
||||
@ -963,6 +963,10 @@
|
||||
"type": "string",
|
||||
"description": "The full file extension; extracted from the title. May contain multiple concatenated extensions, such as \"tar.gz\". Removing an extension from the title does not clear this field; however, changing the extension on the title does update this field. This field is only populated for files with content stored in Drive; it is not populated for Google Docs or shortcut files."
|
||||
},
|
||||
"hasThumbnail": {
|
||||
"type": "boolean",
|
||||
"description": "Whether this file has a thumbnail."
|
||||
},
|
||||
"headRevisionId": {
|
||||
"type": "string",
|
||||
"description": "The ID of the file's head revision. This field is only populated for files with content stored in Drive; it is not populated for Google Docs or shortcut files."
|
||||
@ -1262,7 +1266,7 @@
|
||||
},
|
||||
"thumbnail": {
|
||||
"type": "object",
|
||||
"description": "Thumbnail for the file. Only accepted on upload and for files that are not already thumbnailed by Google.",
|
||||
"description": "A thumbnail for the file. This will only be used if Drive cannot generate a standard thumbnail.",
|
||||
"properties": {
|
||||
"image": {
|
||||
"type": "string",
|
||||
@ -1277,7 +1281,12 @@
|
||||
},
|
||||
"thumbnailLink": {
|
||||
"type": "string",
|
||||
"description": "A short-lived link to the file's thumbnail. Typically lasts on the order of hours."
|
||||
"description": "A short-lived link to the file's thumbnail. Typically lasts on the order of hours. Only populated when the requesting app can access the file's content."
|
||||
},
|
||||
"thumbnailVersion": {
|
||||
"type": "string",
|
||||
"description": "The thumbnail version for use in thumbnail cache invalidation.",
|
||||
"format": "int64"
|
||||
},
|
||||
"title": {
|
||||
"type": "string",
|
||||
@ -1338,7 +1347,7 @@
|
||||
},
|
||||
"items": {
|
||||
"type": "array",
|
||||
"description": "The actual list of files.",
|
||||
"description": "The list of files. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.",
|
||||
"items": {
|
||||
"$ref": "File"
|
||||
}
|
||||
@ -1354,7 +1363,7 @@
|
||||
},
|
||||
"nextPageToken": {
|
||||
"type": "string",
|
||||
"description": "The page token for the next page of files."
|
||||
"description": "The page token for the next page of files. This will be absent if the end of the files list has been reached. If the token is rejected for any reason, it should be discarded, and pagination should be restarted from the first page of results."
|
||||
},
|
||||
"selfLink": {
|
||||
"type": "string",
|
||||
@ -1396,7 +1405,7 @@
|
||||
},
|
||||
"items": {
|
||||
"type": "array",
|
||||
"description": "The actual list of parents.",
|
||||
"description": "The list of parents.",
|
||||
"items": {
|
||||
"$ref": "ParentReference"
|
||||
}
|
||||
@ -1480,7 +1489,7 @@
|
||||
},
|
||||
"id": {
|
||||
"type": "string",
|
||||
"description": "The ID of the user this permission refers to, and identical to the permissionId in the About and Files resources. When making a drive.permissions.insert request, exactly one of the id or value fields must be specified unless the permission type anyone, in which case both id and value are ignored."
|
||||
"description": "The ID of the user this permission refers to, and identical to the permissionId in the About and Files resources. When making a drive.permissions.insert request, exactly one of the id or value fields must be specified unless the permission type is anyone, in which case both id and value are ignored."
|
||||
},
|
||||
"kind": {
|
||||
"type": "string",
|
||||
@ -1519,7 +1528,7 @@
|
||||
},
|
||||
"value": {
|
||||
"type": "string",
|
||||
"description": "The email address or domain name for the entity. This is used during inserts and is not populated in responses. When making a drive.permissions.insert request, exactly one of the id or value fields must be specified unless the permission type anyone, in which case both id and value are ignored."
|
||||
"description": "The email address or domain name for the entity. This is used during inserts and is not populated in responses. When making a drive.permissions.insert request, exactly one of the id or value fields must be specified unless the permission type is anyone, in which case both id and value are ignored."
|
||||
},
|
||||
"withLink": {
|
||||
"type": "boolean",
|
||||
@ -1554,7 +1563,7 @@
|
||||
},
|
||||
"items": {
|
||||
"type": "array",
|
||||
"description": "The actual list of permissions.",
|
||||
"description": "The list of permissions.",
|
||||
"items": {
|
||||
"$ref": "Permission"
|
||||
}
|
||||
@ -1726,7 +1735,7 @@
|
||||
},
|
||||
"items": {
|
||||
"type": "array",
|
||||
"description": "The actual list of revisions.",
|
||||
"description": "The list of revisions. If nextPageToken is populated, then this list may be incomplete and an additional page of results should be fetched.",
|
||||
"items": {
|
||||
"$ref": "Revision"
|
||||
}
|
||||
@ -1746,6 +1755,21 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"StartPageToken": {
|
||||
"id": "StartPageToken",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"kind": {
|
||||
"type": "string",
|
||||
"description": "Identifies what kind of resource this is. Value: the fixed string \"drive#startPageToken\".",
|
||||
"default": "drive#startPageToken"
|
||||
},
|
||||
"startPageToken": {
|
||||
"type": "string",
|
||||
"description": "The starting page token for listing changes."
|
||||
}
|
||||
}
|
||||
},
|
||||
"User": {
|
||||
"id": "User",
|
||||
"type": "object",
|
||||
@ -1925,6 +1949,25 @@
|
||||
"https://www.googleapis.com/auth/drive.readonly"
|
||||
]
|
||||
},
|
||||
"getStartPageToken": {
|
||||
"id": "drive.changes.getStartPageToken",
|
||||
"path": "changes/startPageToken",
|
||||
"httpMethod": "GET",
|
||||
"description": "Gets the starting pageToken for listing future changes.",
|
||||
"response": {
|
||||
"$ref": "StartPageToken"
|
||||
},
|
||||
"scopes": [
|
||||
"https://www.googleapis.com/auth/drive",
|
||||
"https://www.googleapis.com/auth/drive.appdata",
|
||||
"https://www.googleapis.com/auth/drive.apps.readonly",
|
||||
"https://www.googleapis.com/auth/drive.file",
|
||||
"https://www.googleapis.com/auth/drive.metadata",
|
||||
"https://www.googleapis.com/auth/drive.metadata.readonly",
|
||||
"https://www.googleapis.com/auth/drive.photos.readonly",
|
||||
"https://www.googleapis.com/auth/drive.readonly"
|
||||
]
|
||||
},
|
||||
"list": {
|
||||
"id": "drive.changes.list",
|
||||
"path": "changes",
|
||||
@ -1953,7 +1996,7 @@
|
||||
},
|
||||
"pageToken": {
|
||||
"type": "string",
|
||||
"description": "Page token for changes.",
|
||||
"description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.",
|
||||
"location": "query"
|
||||
},
|
||||
"spaces": {
|
||||
@ -2011,7 +2054,7 @@
|
||||
},
|
||||
"pageToken": {
|
||||
"type": "string",
|
||||
"description": "Page token for changes.",
|
||||
"description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.",
|
||||
"location": "query"
|
||||
},
|
||||
"spaces": {
|
||||
|
388
vendor/google.golang.org/api/drive/v2/drive-gen.go
generated
vendored
388
vendor/google.golang.org/api/drive/v2/drive-gen.go
generated
vendored
@ -98,9 +98,10 @@ func New(client *http.Client) (*Service, error) {
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
client *http.Client
|
||||
BasePath string // API endpoint base URL
|
||||
UserAgent string // optional additional User-Agent fragment
|
||||
client *http.Client
|
||||
BasePath string // API endpoint base URL
|
||||
UserAgent string // optional additional User-Agent fragment
|
||||
GoogleClientHeaderElement string // client header fragment, for Google use only
|
||||
|
||||
About *AboutService
|
||||
|
||||
@ -136,6 +137,10 @@ func (s *Service) userAgent() string {
|
||||
return googleapi.UserAgent + " " + s.UserAgent
|
||||
}
|
||||
|
||||
func (s *Service) clientHeader() string {
|
||||
return gensupport.GoogleClientHeader("20170210", s.GoogleClientHeaderElement)
|
||||
}
|
||||
|
||||
func NewAboutService(s *Service) *AboutService {
|
||||
rs := &AboutService{s: s}
|
||||
return rs
|
||||
@ -497,6 +502,20 @@ func (s *AboutFeatures) MarshalJSON() ([]byte, error) {
|
||||
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
|
||||
}
|
||||
|
||||
func (s *AboutFeatures) UnmarshalJSON(data []byte) error {
|
||||
type noMethod AboutFeatures
|
||||
var s1 struct {
|
||||
FeatureRate gensupport.JSONFloat64 `json:"featureRate"`
|
||||
*noMethod
|
||||
}
|
||||
s1.noMethod = (*noMethod)(s)
|
||||
if err := json.Unmarshal(data, &s1); err != nil {
|
||||
return err
|
||||
}
|
||||
s.FeatureRate = float64(s1.FeatureRate)
|
||||
return nil
|
||||
}
|
||||
|
||||
type AboutImportFormats struct {
|
||||
// Source: The imported file's content type to convert from.
|
||||
Source string `json:"source,omitempty"`
|
||||
@ -747,7 +766,7 @@ type AppList struct {
|
||||
// Etag: The ETag of the list.
|
||||
Etag string `json:"etag,omitempty"`
|
||||
|
||||
// Items: The actual list of apps.
|
||||
// Items: The list of apps.
|
||||
Items []*App `json:"items,omitempty"`
|
||||
|
||||
// Kind: This is always drive#appList.
|
||||
@ -839,7 +858,9 @@ type ChangeList struct {
|
||||
// Etag: The ETag of the list.
|
||||
Etag string `json:"etag,omitempty"`
|
||||
|
||||
// Items: The actual list of changes.
|
||||
// Items: The list of changes. If nextPageToken is populated, then this
|
||||
// list may be incomplete and an additional page of results should be
|
||||
// fetched.
|
||||
Items []*Change `json:"items,omitempty"`
|
||||
|
||||
// Kind: This is always drive#changeList.
|
||||
@ -851,7 +872,10 @@ type ChangeList struct {
|
||||
// NextLink: A link to the next page of changes.
|
||||
NextLink string `json:"nextLink,omitempty"`
|
||||
|
||||
// NextPageToken: The page token for the next page of changes.
|
||||
// NextPageToken: The page token for the next page of changes. This will
|
||||
// be absent if the end of the changes list has been reached. If the
|
||||
// token is rejected for any reason, it should be discarded, and
|
||||
// pagination should be restarted from the first page of results.
|
||||
NextPageToken string `json:"nextPageToken,omitempty"`
|
||||
|
||||
// SelfLink: A link back to this list.
|
||||
@ -955,7 +979,9 @@ type ChildList struct {
|
||||
// Etag: The ETag of the list.
|
||||
Etag string `json:"etag,omitempty"`
|
||||
|
||||
// Items: The actual list of children.
|
||||
// Items: The list of children. If nextPageToken is populated, then this
|
||||
// list may be incomplete and an additional page of results should be
|
||||
// fetched.
|
||||
Items []*ChildReference `json:"items,omitempty"`
|
||||
|
||||
// Kind: This is always drive#childList.
|
||||
@ -964,7 +990,10 @@ type ChildList struct {
|
||||
// NextLink: A link to the next page of children.
|
||||
NextLink string `json:"nextLink,omitempty"`
|
||||
|
||||
// NextPageToken: The page token for the next page of children.
|
||||
// NextPageToken: The page token for the next page of children. This
|
||||
// will be absent if the end of the children list has been reached. If
|
||||
// the token is rejected for any reason, it should be discarded, and
|
||||
// pagination should be restarted from the first page of results.
|
||||
NextPageToken string `json:"nextPageToken,omitempty"`
|
||||
|
||||
// SelfLink: A link back to this list.
|
||||
@ -1157,7 +1186,9 @@ func (s *CommentContext) MarshalJSON() ([]byte, error) {
|
||||
|
||||
// CommentList: A list of comments on a file in Google Drive.
|
||||
type CommentList struct {
|
||||
// Items: List of comments.
|
||||
// Items: The list of comments. If nextPageToken is populated, then this
|
||||
// list may be incomplete and an additional page of results should be
|
||||
// fetched.
|
||||
Items []*Comment `json:"items,omitempty"`
|
||||
|
||||
// Kind: This is always drive#commentList.
|
||||
@ -1166,7 +1197,10 @@ type CommentList struct {
|
||||
// NextLink: A link to the next page of comments.
|
||||
NextLink string `json:"nextLink,omitempty"`
|
||||
|
||||
// NextPageToken: The token to use to request the next page of results.
|
||||
// NextPageToken: The page token for the next page of comments. This
|
||||
// will be absent if the end of the comments list has been reached. If
|
||||
// the token is rejected for any reason, it should be discarded, and
|
||||
// pagination should be restarted from the first page of results.
|
||||
NextPageToken string `json:"nextPageToken,omitempty"`
|
||||
|
||||
// SelfLink: A link back to this list.
|
||||
@ -1267,7 +1301,9 @@ func (s *CommentReply) MarshalJSON() ([]byte, error) {
|
||||
// CommentReplyList: A list of replies to a comment on a file in Google
|
||||
// Drive.
|
||||
type CommentReplyList struct {
|
||||
// Items: List of reply.
|
||||
// Items: The list of replies. If nextPageToken is populated, then this
|
||||
// list may be incomplete and an additional page of results should be
|
||||
// fetched.
|
||||
Items []*CommentReply `json:"items,omitempty"`
|
||||
|
||||
// Kind: This is always drive#commentReplyList.
|
||||
@ -1276,7 +1312,10 @@ type CommentReplyList struct {
|
||||
// NextLink: A link to the next page of replies.
|
||||
NextLink string `json:"nextLink,omitempty"`
|
||||
|
||||
// NextPageToken: The token to use to request the next page of results.
|
||||
// NextPageToken: The page token for the next page of replies. This will
|
||||
// be absent if the end of the replies list has been reached. If the
|
||||
// token is rejected for any reason, it should be discarded, and
|
||||
// pagination should be restarted from the first page of results.
|
||||
NextPageToken string `json:"nextPageToken,omitempty"`
|
||||
|
||||
// SelfLink: A link back to this list.
|
||||
@ -1384,6 +1423,9 @@ type File struct {
|
||||
// it is not populated for Google Docs or shortcut files.
|
||||
FullFileExtension string `json:"fullFileExtension,omitempty"`
|
||||
|
||||
// HasThumbnail: Whether this file has a thumbnail.
|
||||
HasThumbnail bool `json:"hasThumbnail,omitempty"`
|
||||
|
||||
// HeadRevisionId: The ID of the file's head revision. This field is
|
||||
// only populated for files with content stored in Drive; it is not
|
||||
// populated for Google Docs or shortcut files.
|
||||
@ -1505,14 +1547,19 @@ type File struct {
|
||||
// are 'drive', 'appDataFolder' and 'photos'.
|
||||
Spaces []string `json:"spaces,omitempty"`
|
||||
|
||||
// Thumbnail: Thumbnail for the file. Only accepted on upload and for
|
||||
// files that are not already thumbnailed by Google.
|
||||
// Thumbnail: A thumbnail for the file. This will only be used if Drive
|
||||
// cannot generate a standard thumbnail.
|
||||
Thumbnail *FileThumbnail `json:"thumbnail,omitempty"`
|
||||
|
||||
// ThumbnailLink: A short-lived link to the file's thumbnail. Typically
|
||||
// lasts on the order of hours.
|
||||
// lasts on the order of hours. Only populated when the requesting app
|
||||
// can access the file's content.
|
||||
ThumbnailLink string `json:"thumbnailLink,omitempty"`
|
||||
|
||||
// ThumbnailVersion: The thumbnail version for use in thumbnail cache
|
||||
// invalidation.
|
||||
ThumbnailVersion int64 `json:"thumbnailVersion,omitempty,string"`
|
||||
|
||||
// Title: The title of this file.
|
||||
Title string `json:"title,omitempty"`
|
||||
|
||||
@ -1664,6 +1711,28 @@ func (s *FileImageMediaMetadata) MarshalJSON() ([]byte, error) {
|
||||
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
|
||||
}
|
||||
|
||||
func (s *FileImageMediaMetadata) UnmarshalJSON(data []byte) error {
|
||||
type noMethod FileImageMediaMetadata
|
||||
var s1 struct {
|
||||
Aperture gensupport.JSONFloat64 `json:"aperture"`
|
||||
ExposureBias gensupport.JSONFloat64 `json:"exposureBias"`
|
||||
ExposureTime gensupport.JSONFloat64 `json:"exposureTime"`
|
||||
FocalLength gensupport.JSONFloat64 `json:"focalLength"`
|
||||
MaxApertureValue gensupport.JSONFloat64 `json:"maxApertureValue"`
|
||||
*noMethod
|
||||
}
|
||||
s1.noMethod = (*noMethod)(s)
|
||||
if err := json.Unmarshal(data, &s1); err != nil {
|
||||
return err
|
||||
}
|
||||
s.Aperture = float64(s1.Aperture)
|
||||
s.ExposureBias = float64(s1.ExposureBias)
|
||||
s.ExposureTime = float64(s1.ExposureTime)
|
||||
s.FocalLength = float64(s1.FocalLength)
|
||||
s.MaxApertureValue = float64(s1.MaxApertureValue)
|
||||
return nil
|
||||
}
|
||||
|
||||
// FileImageMediaMetadataLocation: Geographic location information
|
||||
// stored in the image.
|
||||
type FileImageMediaMetadataLocation struct {
|
||||
@ -1699,6 +1768,24 @@ func (s *FileImageMediaMetadataLocation) MarshalJSON() ([]byte, error) {
|
||||
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
|
||||
}
|
||||
|
||||
func (s *FileImageMediaMetadataLocation) UnmarshalJSON(data []byte) error {
|
||||
type noMethod FileImageMediaMetadataLocation
|
||||
var s1 struct {
|
||||
Altitude gensupport.JSONFloat64 `json:"altitude"`
|
||||
Latitude gensupport.JSONFloat64 `json:"latitude"`
|
||||
Longitude gensupport.JSONFloat64 `json:"longitude"`
|
||||
*noMethod
|
||||
}
|
||||
s1.noMethod = (*noMethod)(s)
|
||||
if err := json.Unmarshal(data, &s1); err != nil {
|
||||
return err
|
||||
}
|
||||
s.Altitude = float64(s1.Altitude)
|
||||
s.Latitude = float64(s1.Latitude)
|
||||
s.Longitude = float64(s1.Longitude)
|
||||
return nil
|
||||
}
|
||||
|
||||
// FileIndexableText: Indexable text attributes for the file (can only
|
||||
// be written)
|
||||
type FileIndexableText struct {
|
||||
@ -1774,8 +1861,8 @@ func (s *FileLabels) MarshalJSON() ([]byte, error) {
|
||||
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
|
||||
}
|
||||
|
||||
// FileThumbnail: Thumbnail for the file. Only accepted on upload and
|
||||
// for files that are not already thumbnailed by Google.
|
||||
// FileThumbnail: A thumbnail for the file. This will only be used if
|
||||
// Drive cannot generate a standard thumbnail.
|
||||
type FileThumbnail struct {
|
||||
// Image: The URL-safe Base64 encoded bytes of the thumbnail image. It
|
||||
// should conform to RFC 4648 section 5.
|
||||
@ -1848,7 +1935,9 @@ type FileList struct {
|
||||
// Etag: The ETag of the list.
|
||||
Etag string `json:"etag,omitempty"`
|
||||
|
||||
// Items: The actual list of files.
|
||||
// Items: The list of files. If nextPageToken is populated, then this
|
||||
// list may be incomplete and an additional page of results should be
|
||||
// fetched.
|
||||
Items []*File `json:"items,omitempty"`
|
||||
|
||||
// Kind: This is always drive#fileList.
|
||||
@ -1857,7 +1946,10 @@ type FileList struct {
|
||||
// NextLink: A link to the next page of files.
|
||||
NextLink string `json:"nextLink,omitempty"`
|
||||
|
||||
// NextPageToken: The page token for the next page of files.
|
||||
// NextPageToken: The page token for the next page of files. This will
|
||||
// be absent if the end of the files list has been reached. If the token
|
||||
// is rejected for any reason, it should be discarded, and pagination
|
||||
// should be restarted from the first page of results.
|
||||
NextPageToken string `json:"nextPageToken,omitempty"`
|
||||
|
||||
// SelfLink: A link back to this list.
|
||||
@ -1935,7 +2027,7 @@ type ParentList struct {
|
||||
// Etag: The ETag of the list.
|
||||
Etag string `json:"etag,omitempty"`
|
||||
|
||||
// Items: The actual list of parents.
|
||||
// Items: The list of parents.
|
||||
Items []*ParentReference `json:"items,omitempty"`
|
||||
|
||||
// Kind: This is always drive#parentList.
|
||||
@ -2044,8 +2136,8 @@ type Permission struct {
|
||||
// Id: The ID of the user this permission refers to, and identical to
|
||||
// the permissionId in the About and Files resources. When making a
|
||||
// drive.permissions.insert request, exactly one of the id or value
|
||||
// fields must be specified unless the permission type anyone, in which
|
||||
// case both id and value are ignored.
|
||||
// fields must be specified unless the permission type is anyone, in
|
||||
// which case both id and value are ignored.
|
||||
Id string `json:"id,omitempty"`
|
||||
|
||||
// Kind: This is always drive#permission.
|
||||
@ -2076,8 +2168,8 @@ type Permission struct {
|
||||
// Value: The email address or domain name for the entity. This is used
|
||||
// during inserts and is not populated in responses. When making a
|
||||
// drive.permissions.insert request, exactly one of the id or value
|
||||
// fields must be specified unless the permission type anyone, in which
|
||||
// case both id and value are ignored.
|
||||
// fields must be specified unless the permission type is anyone, in
|
||||
// which case both id and value are ignored.
|
||||
Value string `json:"value,omitempty"`
|
||||
|
||||
// WithLink: Whether the link is required for this permission.
|
||||
@ -2151,7 +2243,7 @@ type PermissionList struct {
|
||||
// Etag: The ETag of the list.
|
||||
Etag string `json:"etag,omitempty"`
|
||||
|
||||
// Items: The actual list of permissions.
|
||||
// Items: The list of permissions.
|
||||
Items []*Permission `json:"items,omitempty"`
|
||||
|
||||
// Kind: This is always drive#permissionList.
|
||||
@ -2386,7 +2478,9 @@ type RevisionList struct {
|
||||
// Etag: The ETag of the list.
|
||||
Etag string `json:"etag,omitempty"`
|
||||
|
||||
// Items: The actual list of revisions.
|
||||
// Items: The list of revisions. If nextPageToken is populated, then
|
||||
// this list may be incomplete and an additional page of results should
|
||||
// be fetched.
|
||||
Items []*Revision `json:"items,omitempty"`
|
||||
|
||||
// Kind: This is always drive#revisionList.
|
||||
@ -2429,6 +2523,41 @@ func (s *RevisionList) MarshalJSON() ([]byte, error) {
|
||||
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
|
||||
}
|
||||
|
||||
type StartPageToken struct {
|
||||
// Kind: Identifies what kind of resource this is. Value: the fixed
|
||||
// string "drive#startPageToken".
|
||||
Kind string `json:"kind,omitempty"`
|
||||
|
||||
// StartPageToken: The starting page token for listing changes.
|
||||
StartPageToken string `json:"startPageToken,omitempty"`
|
||||
|
||||
// ServerResponse contains the HTTP response code and headers from the
|
||||
// server.
|
||||
googleapi.ServerResponse `json:"-"`
|
||||
|
||||
// ForceSendFields is a list of field names (e.g. "Kind") 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:"-"`
|
||||
|
||||
// NullFields is a list of field names (e.g. "Kind") to include in API
|
||||
// requests with the JSON null value. By default, fields with empty
|
||||
// values are omitted from API requests. However, any field with an
|
||||
// empty value appearing in NullFields will be sent to the server as
|
||||
// null. It is an error if a field in this list has a non-empty value.
|
||||
// This may be used to include null fields in Patch requests.
|
||||
NullFields []string `json:"-"`
|
||||
}
|
||||
|
||||
func (s *StartPageToken) MarshalJSON() ([]byte, error) {
|
||||
type noMethod StartPageToken
|
||||
raw := noMethod(*s)
|
||||
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
|
||||
}
|
||||
|
||||
// User: Information about a Drive user.
|
||||
type User struct {
|
||||
// DisplayName: A plain text displayable name for this user.
|
||||
@ -2585,6 +2714,7 @@ func (c *AboutGetCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -2735,6 +2865,7 @@ func (c *AppsGetCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -2906,6 +3037,7 @@ func (c *AppsListCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -3048,6 +3180,7 @@ func (c *ChangesGetCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -3133,6 +3266,136 @@ func (c *ChangesGetCall) Do(opts ...googleapi.CallOption) (*Change, error) {
|
||||
|
||||
}
|
||||
|
||||
// method id "drive.changes.getStartPageToken":
|
||||
|
||||
type ChangesGetStartPageTokenCall struct {
|
||||
s *Service
|
||||
urlParams_ gensupport.URLParams
|
||||
ifNoneMatch_ string
|
||||
ctx_ context.Context
|
||||
header_ http.Header
|
||||
}
|
||||
|
||||
// GetStartPageToken: Gets the starting pageToken for listing future
|
||||
// changes.
|
||||
func (r *ChangesService) GetStartPageToken() *ChangesGetStartPageTokenCall {
|
||||
c := &ChangesGetStartPageTokenCall{s: r.s, urlParams_: make(gensupport.URLParams)}
|
||||
return c
|
||||
}
|
||||
|
||||
// Fields allows partial responses to be retrieved. See
|
||||
// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
|
||||
// for more information.
|
||||
func (c *ChangesGetStartPageTokenCall) Fields(s ...googleapi.Field) *ChangesGetStartPageTokenCall {
|
||||
c.urlParams_.Set("fields", googleapi.CombineFields(s))
|
||||
return c
|
||||
}
|
||||
|
||||
// IfNoneMatch sets the optional parameter which makes the operation
|
||||
// fail if the object's ETag matches the given value. This is useful for
|
||||
// getting updates only after the object has changed since the last
|
||||
// request. Use googleapi.IsNotModified to check whether the response
|
||||
// error from Do is the result of In-None-Match.
|
||||
func (c *ChangesGetStartPageTokenCall) IfNoneMatch(entityTag string) *ChangesGetStartPageTokenCall {
|
||||
c.ifNoneMatch_ = entityTag
|
||||
return c
|
||||
}
|
||||
|
||||
// Context sets the context to be used in this call's Do method. Any
|
||||
// pending HTTP request will be aborted if the provided context is
|
||||
// canceled.
|
||||
func (c *ChangesGetStartPageTokenCall) Context(ctx context.Context) *ChangesGetStartPageTokenCall {
|
||||
c.ctx_ = ctx
|
||||
return c
|
||||
}
|
||||
|
||||
// Header returns an http.Header that can be modified by the caller to
|
||||
// add HTTP headers to the request.
|
||||
func (c *ChangesGetStartPageTokenCall) Header() http.Header {
|
||||
if c.header_ == nil {
|
||||
c.header_ = make(http.Header)
|
||||
}
|
||||
return c.header_
|
||||
}
|
||||
|
||||
func (c *ChangesGetStartPageTokenCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders := make(http.Header)
|
||||
for k, v := range c.header_ {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "changes/startPageToken")
|
||||
urls += "?" + c.urlParams_.Encode()
|
||||
req, _ := http.NewRequest("GET", urls, body)
|
||||
req.Header = reqHeaders
|
||||
return gensupport.SendRequest(c.ctx_, c.s.client, req)
|
||||
}
|
||||
|
||||
// Do executes the "drive.changes.getStartPageToken" call.
|
||||
// Exactly one of *StartPageToken or error will be non-nil. Any non-2xx
|
||||
// status code is an error. Response headers are in either
|
||||
// *StartPageToken.ServerResponse.Header or (if a response was returned
|
||||
// at all) in error.(*googleapi.Error).Header. Use
|
||||
// googleapi.IsNotModified to check whether the returned error was
|
||||
// because http.StatusNotModified was returned.
|
||||
func (c *ChangesGetStartPageTokenCall) Do(opts ...googleapi.CallOption) (*StartPageToken, error) {
|
||||
gensupport.SetOptions(c.urlParams_, opts...)
|
||||
res, err := c.doRequest("json")
|
||||
if res != nil && res.StatusCode == http.StatusNotModified {
|
||||
if res.Body != nil {
|
||||
res.Body.Close()
|
||||
}
|
||||
return nil, &googleapi.Error{
|
||||
Code: res.StatusCode,
|
||||
Header: res.Header,
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer googleapi.CloseBody(res)
|
||||
if err := googleapi.CheckResponse(res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ret := &StartPageToken{
|
||||
ServerResponse: googleapi.ServerResponse{
|
||||
Header: res.Header,
|
||||
HTTPStatusCode: res.StatusCode,
|
||||
},
|
||||
}
|
||||
target := &ret
|
||||
if err := json.NewDecoder(res.Body).Decode(target); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ret, nil
|
||||
// {
|
||||
// "description": "Gets the starting pageToken for listing future changes.",
|
||||
// "httpMethod": "GET",
|
||||
// "id": "drive.changes.getStartPageToken",
|
||||
// "path": "changes/startPageToken",
|
||||
// "response": {
|
||||
// "$ref": "StartPageToken"
|
||||
// },
|
||||
// "scopes": [
|
||||
// "https://www.googleapis.com/auth/drive",
|
||||
// "https://www.googleapis.com/auth/drive.appdata",
|
||||
// "https://www.googleapis.com/auth/drive.apps.readonly",
|
||||
// "https://www.googleapis.com/auth/drive.file",
|
||||
// "https://www.googleapis.com/auth/drive.metadata",
|
||||
// "https://www.googleapis.com/auth/drive.metadata.readonly",
|
||||
// "https://www.googleapis.com/auth/drive.photos.readonly",
|
||||
// "https://www.googleapis.com/auth/drive.readonly"
|
||||
// ]
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
// method id "drive.changes.list":
|
||||
|
||||
type ChangesListCall struct {
|
||||
@ -3172,8 +3435,10 @@ func (c *ChangesListCall) MaxResults(maxResults int64) *ChangesListCall {
|
||||
return c
|
||||
}
|
||||
|
||||
// PageToken sets the optional parameter "pageToken": Page token for
|
||||
// changes.
|
||||
// PageToken sets the optional parameter "pageToken": The token for
|
||||
// continuing a previous list request on the next page. This should be
|
||||
// set to the value of 'nextPageToken' from the previous response or to
|
||||
// the response from the getStartPageToken method.
|
||||
func (c *ChangesListCall) PageToken(pageToken string) *ChangesListCall {
|
||||
c.urlParams_.Set("pageToken", pageToken)
|
||||
return c
|
||||
@ -3235,6 +3500,7 @@ func (c *ChangesListCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -3310,7 +3576,7 @@ func (c *ChangesListCall) Do(opts ...googleapi.CallOption) (*ChangeList, error)
|
||||
// "type": "integer"
|
||||
// },
|
||||
// "pageToken": {
|
||||
// "description": "Page token for changes.",
|
||||
// "description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.",
|
||||
// "location": "query",
|
||||
// "type": "string"
|
||||
// },
|
||||
@ -3406,8 +3672,10 @@ func (c *ChangesWatchCall) MaxResults(maxResults int64) *ChangesWatchCall {
|
||||
return c
|
||||
}
|
||||
|
||||
// PageToken sets the optional parameter "pageToken": Page token for
|
||||
// changes.
|
||||
// PageToken sets the optional parameter "pageToken": The token for
|
||||
// continuing a previous list request on the next page. This should be
|
||||
// set to the value of 'nextPageToken' from the previous response or to
|
||||
// the response from the getStartPageToken method.
|
||||
func (c *ChangesWatchCall) PageToken(pageToken string) *ChangesWatchCall {
|
||||
c.urlParams_.Set("pageToken", pageToken)
|
||||
return c
|
||||
@ -3459,6 +3727,7 @@ func (c *ChangesWatchCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.channel)
|
||||
if err != nil {
|
||||
@ -3536,7 +3805,7 @@ func (c *ChangesWatchCall) Do(opts ...googleapi.CallOption) (*Channel, error) {
|
||||
// "type": "integer"
|
||||
// },
|
||||
// "pageToken": {
|
||||
// "description": "Page token for changes.",
|
||||
// "description": "The token for continuing a previous list request on the next page. This should be set to the value of 'nextPageToken' from the previous response or to the response from the getStartPageToken method.",
|
||||
// "location": "query",
|
||||
// "type": "string"
|
||||
// },
|
||||
@ -3623,6 +3892,7 @@ func (c *ChannelsStopCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.channel)
|
||||
if err != nil {
|
||||
@ -3722,6 +3992,7 @@ func (c *ChildrenDeleteCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "files/{folderId}/children/{childId}")
|
||||
@ -3839,6 +4110,7 @@ func (c *ChildrenGetCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -3981,6 +4253,7 @@ func (c *ChildrenInsertCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.childreference)
|
||||
if err != nil {
|
||||
@ -4160,6 +4433,7 @@ func (c *ChildrenListCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -4338,6 +4612,7 @@ func (c *CommentsDeleteCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}")
|
||||
@ -4463,6 +4738,7 @@ func (c *CommentsGetCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -4607,6 +4883,7 @@ func (c *CommentsInsertCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.comment)
|
||||
if err != nil {
|
||||
@ -4782,6 +5059,7 @@ func (c *CommentsListCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -4961,6 +5239,7 @@ func (c *CommentsPatchCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.comment)
|
||||
if err != nil {
|
||||
@ -5105,6 +5384,7 @@ func (c *CommentsUpdateCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.comment)
|
||||
if err != nil {
|
||||
@ -5303,6 +5583,7 @@ func (c *FilesCopyCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.file)
|
||||
if err != nil {
|
||||
@ -5486,6 +5767,7 @@ func (c *FilesDeleteCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}")
|
||||
@ -5581,6 +5863,7 @@ func (c *FilesEmptyTrashCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "files/trash")
|
||||
@ -5675,6 +5958,7 @@ func (c *FilesExportCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -5824,6 +6108,7 @@ func (c *FilesGenerateIdsCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -6001,6 +6286,7 @@ func (c *FilesGetCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -6298,6 +6584,7 @@ func (c *FilesInsertCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.file)
|
||||
if err != nil {
|
||||
@ -6612,6 +6899,7 @@ func (c *FilesListCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -6922,6 +7210,7 @@ func (c *FilesPatchCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.file)
|
||||
if err != nil {
|
||||
@ -7146,6 +7435,7 @@ func (c *FilesTouchCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/touch")
|
||||
@ -7274,6 +7564,7 @@ func (c *FilesTrashCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/trash")
|
||||
@ -7400,6 +7691,7 @@ func (c *FilesUntrashCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/untrash")
|
||||
@ -7692,6 +7984,7 @@ func (c *FilesUpdateCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.file)
|
||||
if err != nil {
|
||||
@ -8018,6 +8311,7 @@ func (c *FilesWatchCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.channel)
|
||||
if err != nil {
|
||||
@ -8207,6 +8501,7 @@ func (c *ParentsDeleteCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/parents/{parentId}")
|
||||
@ -8324,6 +8619,7 @@ func (c *ParentsGetCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -8466,6 +8762,7 @@ func (c *ParentsInsertCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.parentreference)
|
||||
if err != nil {
|
||||
@ -8610,6 +8907,7 @@ func (c *ParentsListCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -8744,6 +9042,7 @@ func (c *PermissionsDeleteCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/permissions/{permissionId}")
|
||||
@ -8861,6 +9160,7 @@ func (c *PermissionsGetCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -9011,6 +9311,7 @@ func (c *PermissionsGetIdForEmailCall) doRequest(alt string) (*http.Response, er
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -9162,6 +9463,7 @@ func (c *PermissionsInsertCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.permission)
|
||||
if err != nil {
|
||||
@ -9316,6 +9618,7 @@ func (c *PermissionsListCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -9466,6 +9769,7 @@ func (c *PermissionsPatchCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.permission)
|
||||
if err != nil {
|
||||
@ -9637,6 +9941,7 @@ func (c *PermissionsUpdateCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.permission)
|
||||
if err != nil {
|
||||
@ -9798,6 +10103,7 @@ func (c *PropertiesDeleteCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/properties/{propertyKey}")
|
||||
@ -9930,6 +10236,7 @@ func (c *PropertiesGetCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -10079,6 +10386,7 @@ func (c *PropertiesInsertCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.property)
|
||||
if err != nil {
|
||||
@ -10224,6 +10532,7 @@ func (c *PropertiesListCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -10368,6 +10677,7 @@ func (c *PropertiesPatchCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.property)
|
||||
if err != nil {
|
||||
@ -10527,6 +10837,7 @@ func (c *PropertiesUpdateCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.property)
|
||||
if err != nil {
|
||||
@ -10696,6 +11007,7 @@ func (c *RealtimeGetCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -10885,6 +11197,7 @@ func (c *RealtimeUpdateCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/realtime")
|
||||
@ -11055,6 +11368,7 @@ func (c *RepliesDeleteCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/comments/{commentId}/replies/{replyId}")
|
||||
@ -11189,6 +11503,7 @@ func (c *RepliesGetCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -11343,6 +11658,7 @@ func (c *RepliesInsertCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.commentreply)
|
||||
if err != nil {
|
||||
@ -11520,6 +11836,7 @@ func (c *RepliesListCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -11704,6 +12021,7 @@ func (c *RepliesPatchCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.commentreply)
|
||||
if err != nil {
|
||||
@ -11858,6 +12176,7 @@ func (c *RepliesUpdateCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.commentreply)
|
||||
if err != nil {
|
||||
@ -12008,6 +12327,7 @@ func (c *RevisionsDeleteCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "files/{fileId}/revisions/{revisionId}")
|
||||
@ -12126,6 +12446,7 @@ func (c *RevisionsGetCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -12292,6 +12613,7 @@ func (c *RevisionsListCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -12463,6 +12785,7 @@ func (c *RevisionsPatchCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.revision)
|
||||
if err != nil {
|
||||
@ -12608,6 +12931,7 @@ func (c *RevisionsUpdateCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.revision)
|
||||
if err != nil {
|
||||
|
22
vendor/google.golang.org/api/gensupport/header.go
generated
vendored
Normal file
22
vendor/google.golang.org/api/gensupport/header.go
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package gensupport
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GoogleClientHeader returns the value to use for the x-goog-api-client
|
||||
// header, which is used internally by Google.
|
||||
func GoogleClientHeader(generatorVersion, clientElement string) string {
|
||||
elts := []string{"gl-go/" + strings.Replace(runtime.Version(), " ", "_", -1)}
|
||||
if clientElement != "" {
|
||||
elts = append(elts, clientElement)
|
||||
}
|
||||
elts = append(elts, fmt.Sprintf("gdcl/%s", generatorVersion))
|
||||
return strings.Join(elts, " ")
|
||||
}
|
57
vendor/google.golang.org/api/gensupport/jsonfloat.go
generated
vendored
Normal file
57
vendor/google.golang.org/api/gensupport/jsonfloat.go
generated
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
// Copyright 2016 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package gensupport
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
)
|
||||
|
||||
// JSONFloat64 is a float64 that supports proper unmarshaling of special float
|
||||
// values in JSON, according to
|
||||
// https://developers.google.com/protocol-buffers/docs/proto3#json. Although
|
||||
// that is a proto-to-JSON spec, it applies to all Google APIs.
|
||||
//
|
||||
// The jsonpb package
|
||||
// (https://github.com/golang/protobuf/blob/master/jsonpb/jsonpb.go) has
|
||||
// similar functionality, but only for direct translation from proto messages
|
||||
// to JSON.
|
||||
type JSONFloat64 float64
|
||||
|
||||
func (f *JSONFloat64) UnmarshalJSON(data []byte) error {
|
||||
var ff float64
|
||||
if err := json.Unmarshal(data, &ff); err == nil {
|
||||
*f = JSONFloat64(ff)
|
||||
return nil
|
||||
}
|
||||
var s string
|
||||
if err := json.Unmarshal(data, &s); err == nil {
|
||||
switch s {
|
||||
case "NaN":
|
||||
ff = math.NaN()
|
||||
case "Infinity":
|
||||
ff = math.Inf(1)
|
||||
case "-Infinity":
|
||||
ff = math.Inf(-1)
|
||||
default:
|
||||
return fmt.Errorf("google.golang.org/api/internal: bad float string %q", s)
|
||||
}
|
||||
*f = JSONFloat64(ff)
|
||||
return nil
|
||||
}
|
||||
return errors.New("google.golang.org/api/internal: data not float or string")
|
||||
}
|
14
vendor/google.golang.org/api/gensupport/retry.go
generated
vendored
14
vendor/google.golang.org/api/gensupport/retry.go
generated
vendored
@ -1,3 +1,17 @@
|
||||
// Copyright 2017 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package gensupport
|
||||
|
||||
import (
|
||||
|
46
vendor/google.golang.org/api/storage/v1/storage-gen.go
generated
vendored
46
vendor/google.golang.org/api/storage/v1/storage-gen.go
generated
vendored
@ -78,9 +78,10 @@ func New(client *http.Client) (*Service, error) {
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
client *http.Client
|
||||
BasePath string // API endpoint base URL
|
||||
UserAgent string // optional additional User-Agent fragment
|
||||
client *http.Client
|
||||
BasePath string // API endpoint base URL
|
||||
UserAgent string // optional additional User-Agent fragment
|
||||
GoogleClientHeaderElement string // client header fragment, for Google use only
|
||||
|
||||
BucketAccessControls *BucketAccessControlsService
|
||||
|
||||
@ -102,6 +103,10 @@ func (s *Service) userAgent() string {
|
||||
return googleapi.UserAgent + " " + s.UserAgent
|
||||
}
|
||||
|
||||
func (s *Service) clientHeader() string {
|
||||
return gensupport.GoogleClientHeader("20170210", s.GoogleClientHeaderElement)
|
||||
}
|
||||
|
||||
func NewBucketAccessControlsService(s *Service) *BucketAccessControlsService {
|
||||
rs := &BucketAccessControlsService{s: s}
|
||||
return rs
|
||||
@ -1438,6 +1443,7 @@ func (c *BucketAccessControlsDeleteCall) doRequest(alt string) (*http.Response,
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "b/{bucket}/acl/{entity}")
|
||||
@ -1556,6 +1562,7 @@ func (c *BucketAccessControlsGetCall) doRequest(alt string) (*http.Response, err
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -1693,6 +1700,7 @@ func (c *BucketAccessControlsInsertCall) doRequest(alt string) (*http.Response,
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.bucketaccesscontrol)
|
||||
if err != nil {
|
||||
@ -1836,6 +1844,7 @@ func (c *BucketAccessControlsListCall) doRequest(alt string) (*http.Response, er
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -1968,6 +1977,7 @@ func (c *BucketAccessControlsPatchCall) doRequest(alt string) (*http.Response, e
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.bucketaccesscontrol)
|
||||
if err != nil {
|
||||
@ -2112,6 +2122,7 @@ func (c *BucketAccessControlsUpdateCall) doRequest(alt string) (*http.Response,
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.bucketaccesscontrol)
|
||||
if err != nil {
|
||||
@ -2268,6 +2279,7 @@ func (c *BucketsDeleteCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "b/{bucket}")
|
||||
@ -2417,6 +2429,7 @@ func (c *BucketsGetCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -2625,6 +2638,7 @@ func (c *BucketsInsertCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.bucket)
|
||||
if err != nil {
|
||||
@ -2851,6 +2865,7 @@ func (c *BucketsListCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -3101,6 +3116,7 @@ func (c *BucketsPatchCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.bucket2)
|
||||
if err != nil {
|
||||
@ -3370,6 +3386,7 @@ func (c *BucketsUpdateCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.bucket2)
|
||||
if err != nil {
|
||||
@ -3567,6 +3584,7 @@ func (c *ChannelsStopCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.channel)
|
||||
if err != nil {
|
||||
@ -3664,6 +3682,7 @@ func (c *DefaultObjectAccessControlsDeleteCall) doRequest(alt string) (*http.Res
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "b/{bucket}/defaultObjectAcl/{entity}")
|
||||
@ -3782,6 +3801,7 @@ func (c *DefaultObjectAccessControlsGetCall) doRequest(alt string) (*http.Respon
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -3920,6 +3940,7 @@ func (c *DefaultObjectAccessControlsInsertCall) doRequest(alt string) (*http.Res
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.objectaccesscontrol)
|
||||
if err != nil {
|
||||
@ -4080,6 +4101,7 @@ func (c *DefaultObjectAccessControlsListCall) doRequest(alt string) (*http.Respo
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -4224,6 +4246,7 @@ func (c *DefaultObjectAccessControlsPatchCall) doRequest(alt string) (*http.Resp
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.objectaccesscontrol)
|
||||
if err != nil {
|
||||
@ -4368,6 +4391,7 @@ func (c *DefaultObjectAccessControlsUpdateCall) doRequest(alt string) (*http.Res
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.objectaccesscontrol)
|
||||
if err != nil {
|
||||
@ -4521,6 +4545,7 @@ func (c *ObjectAccessControlsDeleteCall) doRequest(alt string) (*http.Response,
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "b/{bucket}/o/{object}/acl/{entity}")
|
||||
@ -4663,6 +4688,7 @@ func (c *ObjectAccessControlsGetCall) doRequest(alt string) (*http.Response, err
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -4824,6 +4850,7 @@ func (c *ObjectAccessControlsInsertCall) doRequest(alt string) (*http.Response,
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.objectaccesscontrol)
|
||||
if err != nil {
|
||||
@ -4991,6 +5018,7 @@ func (c *ObjectAccessControlsListCall) doRequest(alt string) (*http.Response, er
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -5147,6 +5175,7 @@ func (c *ObjectAccessControlsPatchCall) doRequest(alt string) (*http.Response, e
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.objectaccesscontrol)
|
||||
if err != nil {
|
||||
@ -5315,6 +5344,7 @@ func (c *ObjectAccessControlsUpdateCall) doRequest(alt string) (*http.Response,
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.objectaccesscontrol)
|
||||
if err != nil {
|
||||
@ -5511,6 +5541,7 @@ func (c *ObjectsComposeCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.composerequest)
|
||||
if err != nil {
|
||||
@ -5823,6 +5854,7 @@ func (c *ObjectsCopyCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.object)
|
||||
if err != nil {
|
||||
@ -6131,6 +6163,7 @@ func (c *ObjectsDeleteCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
c.urlParams_.Set("alt", alt)
|
||||
urls := googleapi.ResolveRelative(c.s.BasePath, "b/{bucket}/o/{object}")
|
||||
@ -6331,6 +6364,7 @@ func (c *ObjectsGetCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -6673,6 +6707,7 @@ func (c *ObjectsInsertCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.object)
|
||||
if err != nil {
|
||||
@ -7005,6 +7040,7 @@ func (c *ObjectsListCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
if c.ifNoneMatch_ != "" {
|
||||
reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
|
||||
}
|
||||
@ -7274,6 +7310,7 @@ func (c *ObjectsPatchCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.object2)
|
||||
if err != nil {
|
||||
@ -7623,6 +7660,7 @@ func (c *ObjectsRewriteCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.object)
|
||||
if err != nil {
|
||||
@ -7955,6 +7993,7 @@ func (c *ObjectsUpdateCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.object2)
|
||||
if err != nil {
|
||||
@ -8233,6 +8272,7 @@ func (c *ObjectsWatchAllCall) doRequest(alt string) (*http.Response, error) {
|
||||
reqHeaders[k] = v
|
||||
}
|
||||
reqHeaders.Set("User-Agent", c.s.userAgent())
|
||||
reqHeaders.Set("x-goog-api-client", c.s.clientHeader())
|
||||
var body io.Reader = nil
|
||||
body, err := googleapi.WithoutDataWrapper.JSONReader(c.channel)
|
||||
if err != nil {
|
||||
|
18
vendor/google.golang.org/appengine/.travis.yml
generated
vendored
Normal file
18
vendor/google.golang.org/appengine/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.6.3
|
||||
- 1.7.1
|
||||
|
||||
install:
|
||||
- go get -v -t -d google.golang.org/appengine/...
|
||||
- mkdir sdk
|
||||
- curl -o sdk.zip "https://storage.googleapis.com/appengine-sdks/featured/go_appengine_sdk_linux_amd64-1.9.40.zip"
|
||||
- unzip -q sdk.zip -d sdk
|
||||
- export APPENGINE_DEV_APPSERVER=$(pwd)/sdk/go_appengine/dev_appserver.py
|
||||
|
||||
script:
|
||||
- go version
|
||||
- go test -v google.golang.org/appengine/...
|
||||
- go test -v -race google.golang.org/appengine/...
|
||||
- sdk/go_appengine/goapp test -v google.golang.org/appengine/...
|
90
vendor/google.golang.org/appengine/CONTRIBUTING.md
generated
vendored
Normal file
90
vendor/google.golang.org/appengine/CONTRIBUTING.md
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
# Contributing
|
||||
|
||||
1. Sign one of the contributor license agreements below.
|
||||
1. Get the package:
|
||||
|
||||
`go get -d google.golang.org/appengine`
|
||||
1. Change into the checked out source:
|
||||
|
||||
`cd $GOPATH/src/google.golang.org/appengine`
|
||||
1. Fork the repo.
|
||||
1. Set your fork as a remote:
|
||||
|
||||
`git remote add fork git@github.com:GITHUB_USERNAME/appengine.git`
|
||||
1. Make changes, commit to your fork.
|
||||
1. Send a pull request with your changes.
|
||||
The first line of your commit message is conventionally a one-line summary of the change, prefixed by the primary affected package, and is used as the title of your pull request.
|
||||
|
||||
# Testing
|
||||
|
||||
## Running system tests
|
||||
|
||||
Download and install the [Go App Engine SDK](https://cloud.google.com/appengine/docs/go/download). Make sure the `go_appengine` dir is in your `PATH`.
|
||||
|
||||
Set the `APPENGINE_DEV_APPSERVER` environment variable to `/path/to/go_appengine/dev_appserver.py`.
|
||||
|
||||
Run tests with `goapp test`:
|
||||
|
||||
```
|
||||
goapp test -v google.golang.org/appengine/...
|
||||
```
|
||||
|
||||
## Contributor License Agreements
|
||||
|
||||
Before we can accept your pull requests you'll need to sign a Contributor
|
||||
License Agreement (CLA):
|
||||
|
||||
- **If you are an individual writing original source code** and **you own the
|
||||
intellectual property**, then you'll need to sign an [individual CLA][indvcla].
|
||||
- **If you work for a company that wants to allow you to contribute your work**,
|
||||
then you'll need to sign a [corporate CLA][corpcla].
|
||||
|
||||
You can sign these electronically (just scroll to the bottom). After that,
|
||||
we'll be able to accept your pull requests.
|
||||
|
||||
## Contributor Code of Conduct
|
||||
|
||||
As contributors and maintainers of this project,
|
||||
and in the interest of fostering an open and welcoming community,
|
||||
we pledge to respect all people who contribute through reporting issues,
|
||||
posting feature requests, updating documentation,
|
||||
submitting pull requests or patches, and other activities.
|
||||
|
||||
We are committed to making participation in this project
|
||||
a harassment-free experience for everyone,
|
||||
regardless of level of experience, gender, gender identity and expression,
|
||||
sexual orientation, disability, personal appearance,
|
||||
body size, race, ethnicity, age, religion, or nationality.
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery
|
||||
* Personal attacks
|
||||
* Trolling or insulting/derogatory comments
|
||||
* Public or private harassment
|
||||
* Publishing other's private information,
|
||||
such as physical or electronic
|
||||
addresses, without explicit permission
|
||||
* Other unethical or unprofessional conduct.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct.
|
||||
By adopting this Code of Conduct,
|
||||
project maintainers commit themselves to fairly and consistently
|
||||
applying these principles to every aspect of managing this project.
|
||||
Project maintainers who do not follow or enforce the Code of Conduct
|
||||
may be permanently removed from the project team.
|
||||
|
||||
This code of conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community.
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior
|
||||
may be reported by opening an issue
|
||||
or contacting one or more of the project maintainers.
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0,
|
||||
available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
|
||||
|
||||
[indvcla]: https://developers.google.com/open-source/cla/individual
|
||||
[corpcla]: https://developers.google.com/open-source/cla/corporate
|
54
vendor/google.golang.org/appengine/README.md
generated
vendored
54
vendor/google.golang.org/appengine/README.md
generated
vendored
@ -1,16 +1,23 @@
|
||||
# Go App Engine for Managed VMs
|
||||
# Go App Engine packages
|
||||
|
||||
This repository supports the Go runtime for Managed VMs on App Engine.
|
||||
[](https://travis-ci.org/golang/appengine)
|
||||
|
||||
This repository supports the Go runtime on App Engine,
|
||||
including both the standard App Engine and the
|
||||
"App Engine flexible environment" (formerly known as "Managed VMs").
|
||||
It provides APIs for interacting with App Engine services.
|
||||
Its canonical import path is `google.golang.org/appengine`.
|
||||
|
||||
See https://cloud.google.com/appengine/docs/go/managed-vms/
|
||||
See https://cloud.google.com/appengine/docs/go/
|
||||
for more information.
|
||||
|
||||
File issue reports and feature requests on the [Google App Engine issue
|
||||
tracker](https://code.google.com/p/googleappengine/issues/entry?template=Go%20defect).
|
||||
|
||||
## Directory structure
|
||||
The top level directory of this repository is the `appengine` package. It
|
||||
contains the
|
||||
basic types (e.g. `appengine.Context`) that are used across APIs. Specific API
|
||||
basic APIs (e.g. `appengine.NewContext`) that apply across APIs. Specific API
|
||||
packages are in subdirectories (e.g. `datastore`).
|
||||
|
||||
There is an `internal` subdirectory that contains service protocol buffers,
|
||||
@ -19,27 +26,24 @@ should not directly import any package under `internal`.
|
||||
|
||||
## Updating a Go App Engine app
|
||||
|
||||
This section describes how to update a traditional Go App Engine app to run on Managed VMs.
|
||||
This section describes how to update an older Go App Engine app to use
|
||||
these packages. A provided tool, `aefix`, can help automate steps 2 and 3
|
||||
(run `go get google.golang.org/appengine/cmd/aefix` to install it), but
|
||||
read the details below since `aefix` can't perform all the changes.
|
||||
|
||||
### 1. Update YAML files
|
||||
### 1. Update YAML files (App Engine flexible environment / Managed VMs only)
|
||||
|
||||
The `app.yaml` file (and YAML files for modules) should have these new lines added:
|
||||
```
|
||||
vm: true
|
||||
manual_scaling:
|
||||
instances: 1
|
||||
```
|
||||
See https://cloud.google.com/appengine/docs/go/modules/#Go_Instance_scaling_and_class for details.
|
||||
|
||||
### 2. Update import paths
|
||||
|
||||
The import paths for App Engine API packages need to be made relative to `google.golang.org/appengine`.
|
||||
You can do that manually, or by running this command to recursively update all Go source files in the current directory:
|
||||
(may require GNU sed)
|
||||
```
|
||||
sed -i '/"appengine/{s,"appengine,"google.golang.org/appengine,;s,appengine_,appengine/,}' \
|
||||
$(find . -name '*.go')
|
||||
```
|
||||
The import paths for App Engine packages are now fully qualified, based at `google.golang.org/appengine`.
|
||||
You will need to update your code to use import paths starting with that; for instance,
|
||||
code importing `appengine/datastore` will now need to import `google.golang.org/appengine/datastore`.
|
||||
|
||||
### 3. Update code using deprecated, removed or modified APIs
|
||||
|
||||
@ -47,15 +51,23 @@ Most App Engine services are available with exactly the same API.
|
||||
A few APIs were cleaned up, and some are not available yet.
|
||||
This list summarises the differences:
|
||||
|
||||
* `appengine.Datacenter` now takes an `appengine.Context` argument.
|
||||
* `appengine.Context` has been replaced with the `Context` type from `golang.org/x/net/context`.
|
||||
* Logging methods that were on `appengine.Context` are now functions in `google.golang.org/appengine/log`.
|
||||
* `appengine.Timeout` has been removed. Use `context.WithTimeout` instead.
|
||||
* `appengine.Datacenter` now takes a `context.Context` argument.
|
||||
* `datastore.PropertyLoadSaver` has been simplified to use slices in place of channels.
|
||||
* `delay.Call` now returns an error.
|
||||
* `search.FieldLoadSaver` now handles document metadata.
|
||||
* `urlfetch.Transport` no longer has a Deadline field; set a deadline on the
|
||||
`context.Context` instead.
|
||||
* `aetest` no longer declares its own Context type, and uses the standard one instead.
|
||||
* `taskqueue.QueueStats` no longer takes a maxTasks argument. That argument has been
|
||||
deprecated and unused for a long time.
|
||||
* `appengine/aetest`, `appengine/blobstore`, `appengine/cloudsql`
|
||||
and `appengine/runtime` have not been ported yet.
|
||||
* `appengine.BackendHostname` and `appengine.BackendInstance` were for the deprecated backends feature.
|
||||
Use `appengine.ModuleHostname`and `appengine.ModuleName` instead.
|
||||
* `appengine.IsCapabilityDisabled` and `appengine/capability` are obsolete.
|
||||
* Most of `appengine/file` is deprecated. Use [Google Cloud Storage](https://code.google.com/p/google-api-go-client/wiki/GettingStarted) instead.
|
||||
* `appengine/socket` is deprecated. Use the standard `net` package instead.
|
||||
* Most of `appengine/file` and parts of `appengine/blobstore` are deprecated.
|
||||
Use [Google Cloud Storage](https://godoc.org/cloud.google.com/go/storage) if the
|
||||
feature you require is not present in the new
|
||||
[blobstore package](https://google.golang.org/appengine/blobstore).
|
||||
* `appengine/socket` is not required on App Engine flexible environment / Managed VMs.
|
||||
Use the standard `net` package instead.
|
||||
|
105
vendor/google.golang.org/appengine/appengine.go
generated
vendored
105
vendor/google.golang.org/appengine/appengine.go
generated
vendored
@ -12,53 +12,68 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"google.golang.org/appengine/internal"
|
||||
)
|
||||
|
||||
// The gophers party all night; the rabbits provide the beats.
|
||||
|
||||
// Main is the principal entry point for an app running in App Engine.
|
||||
//
|
||||
// On App Engine Flexible it installs a trivial health checker if one isn't
|
||||
// already registered, and starts listening on port 8080 (overridden by the
|
||||
// $PORT environment variable).
|
||||
//
|
||||
// See https://cloud.google.com/appengine/docs/flexible/custom-runtimes#health_check_requests
|
||||
// for details on how to do your own health checking.
|
||||
//
|
||||
// On App Engine Standard it ensures the server has started and is prepared to
|
||||
// receive requests.
|
||||
//
|
||||
// Main never returns.
|
||||
//
|
||||
// Main is designed so that the app's main package looks like this:
|
||||
//
|
||||
// package main
|
||||
//
|
||||
// import (
|
||||
// "google.golang.org/appengine"
|
||||
//
|
||||
// _ "myapp/package0"
|
||||
// _ "myapp/package1"
|
||||
// )
|
||||
//
|
||||
// func main() {
|
||||
// appengine.Main()
|
||||
// }
|
||||
//
|
||||
// The "myapp/packageX" packages are expected to register HTTP handlers
|
||||
// in their init functions.
|
||||
func Main() {
|
||||
internal.Main()
|
||||
}
|
||||
|
||||
// IsDevAppServer reports whether the App Engine app is running in the
|
||||
// development App Server.
|
||||
func IsDevAppServer() bool {
|
||||
// TODO(dsymonds): Detect this.
|
||||
return false
|
||||
}
|
||||
|
||||
// Context represents the context of an in-flight HTTP request.
|
||||
type Context interface {
|
||||
// Debugf formats its arguments according to the format, analogous to fmt.Printf,
|
||||
// and records the text as a log message at Debug level.
|
||||
Debugf(format string, args ...interface{})
|
||||
|
||||
// Infof is like Debugf, but at Info level.
|
||||
Infof(format string, args ...interface{})
|
||||
|
||||
// Warningf is like Debugf, but at Warning level.
|
||||
Warningf(format string, args ...interface{})
|
||||
|
||||
// Errorf is like Debugf, but at Error level.
|
||||
Errorf(format string, args ...interface{})
|
||||
|
||||
// Criticalf is like Debugf, but at Critical level.
|
||||
Criticalf(format string, args ...interface{})
|
||||
|
||||
// The remaining methods are for internal use only.
|
||||
// Developer-facing APIs wrap these methods to provide a more friendly API.
|
||||
|
||||
// Internal use only.
|
||||
Call(service, method string, in, out proto.Message, opts *internal.CallOptions) error
|
||||
// Internal use only. Use AppID instead.
|
||||
FullyQualifiedAppID() string
|
||||
// Internal use only.
|
||||
Request() interface{}
|
||||
return internal.IsDevAppServer()
|
||||
}
|
||||
|
||||
// NewContext returns a context for an in-flight HTTP request.
|
||||
// Repeated calls will return the same value.
|
||||
func NewContext(req *http.Request) Context {
|
||||
return internal.NewContext(req)
|
||||
// This function is cheap.
|
||||
func NewContext(req *http.Request) context.Context {
|
||||
return WithContext(context.Background(), req)
|
||||
}
|
||||
|
||||
// TODO(dsymonds): Add BackgroundContext function?
|
||||
// WithContext returns a copy of the parent context
|
||||
// and associates it with an in-flight HTTP request.
|
||||
// This function is cheap.
|
||||
func WithContext(parent context.Context, req *http.Request) context.Context {
|
||||
return internal.WithContext(parent, req)
|
||||
}
|
||||
|
||||
// TODO(dsymonds): Add a Call function here? Otherwise other packages can't access internal.Call.
|
||||
|
||||
// BlobKey is a key for a blobstore blob.
|
||||
//
|
||||
@ -76,3 +91,23 @@ type GeoPoint struct {
|
||||
func (g GeoPoint) Valid() bool {
|
||||
return -90 <= g.Lat && g.Lat <= 90 && -180 <= g.Lng && g.Lng <= 180
|
||||
}
|
||||
|
||||
// APICallFunc defines a function type for handling an API call.
|
||||
// See WithCallOverride.
|
||||
type APICallFunc func(ctx context.Context, service, method string, in, out proto.Message) error
|
||||
|
||||
// WithAPICallFunc returns a copy of the parent context
|
||||
// that will cause API calls to invoke f instead of their normal operation.
|
||||
//
|
||||
// This is intended for advanced users only.
|
||||
func WithAPICallFunc(ctx context.Context, f APICallFunc) context.Context {
|
||||
return internal.WithCallOverride(ctx, internal.CallOverrideFunc(f))
|
||||
}
|
||||
|
||||
// APICall performs an API call.
|
||||
//
|
||||
// This is not intended for general use; it is exported for use in conjunction
|
||||
// with WithAPICallFunc.
|
||||
func APICall(ctx context.Context, service, method string, in, out proto.Message) error {
|
||||
return internal.Call(ctx, service, method, in, out)
|
||||
}
|
||||
|
20
vendor/google.golang.org/appengine/appengine_vm.go
generated
vendored
Normal file
20
vendor/google.golang.org/appengine/appengine_vm.go
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
// Copyright 2015 Google Inc. All rights reserved.
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !appengine
|
||||
|
||||
package appengine
|
||||
|
||||
import (
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"google.golang.org/appengine/internal"
|
||||
)
|
||||
|
||||
// BackgroundContext returns a context not associated with a request.
|
||||
// This should only be used when not servicing a request.
|
||||
// This only works in App Engine "flexible environment".
|
||||
func BackgroundContext() context.Context {
|
||||
return internal.BackgroundContext()
|
||||
}
|
41
vendor/google.golang.org/appengine/identity.go
generated
vendored
41
vendor/google.golang.org/appengine/identity.go
generated
vendored
@ -7,6 +7,8 @@ package appengine
|
||||
import (
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"google.golang.org/appengine/internal"
|
||||
pb "google.golang.org/appengine/internal/app_identity"
|
||||
modpb "google.golang.org/appengine/internal/modules"
|
||||
@ -15,18 +17,18 @@ import (
|
||||
// AppID returns the application ID for the current application.
|
||||
// The string will be a plain application ID (e.g. "appid"), with a
|
||||
// domain prefix for custom domain deployments (e.g. "example.com:appid").
|
||||
func AppID(c Context) string { return internal.AppID(c.FullyQualifiedAppID()) }
|
||||
func AppID(c context.Context) string { return internal.AppID(c) }
|
||||
|
||||
// DefaultVersionHostname returns the standard hostname of the default version
|
||||
// of the current application (e.g. "my-app.appspot.com"). This is suitable for
|
||||
// use in constructing URLs.
|
||||
func DefaultVersionHostname(c Context) string {
|
||||
return internal.DefaultVersionHostname(c.Request())
|
||||
func DefaultVersionHostname(c context.Context) string {
|
||||
return internal.DefaultVersionHostname(c)
|
||||
}
|
||||
|
||||
// ModuleName returns the module name of the current instance.
|
||||
func ModuleName(c Context) string {
|
||||
return internal.ModuleName()
|
||||
func ModuleName(c context.Context) string {
|
||||
return internal.ModuleName(c)
|
||||
}
|
||||
|
||||
// ModuleHostname returns a hostname of a module instance.
|
||||
@ -34,7 +36,7 @@ func ModuleName(c Context) string {
|
||||
// If version is empty, it refers to the version of the current instance if valid,
|
||||
// or the default version of the module of the current instance.
|
||||
// If instance is empty, ModuleHostname returns the load-balancing hostname.
|
||||
func ModuleHostname(c Context, module, version, instance string) (string, error) {
|
||||
func ModuleHostname(c context.Context, module, version, instance string) (string, error) {
|
||||
req := &modpb.GetHostnameRequest{}
|
||||
if module != "" {
|
||||
req.Module = &module
|
||||
@ -46,7 +48,7 @@ func ModuleHostname(c Context, module, version, instance string) (string, error)
|
||||
req.Instance = &instance
|
||||
}
|
||||
res := &modpb.GetHostnameResponse{}
|
||||
if err := c.Call("modules", "GetHostname", req, res, nil); err != nil {
|
||||
if err := internal.Call(c, "modules", "GetHostname", req, res); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return *res.Hostname, nil
|
||||
@ -56,13 +58,13 @@ func ModuleHostname(c Context, module, version, instance string) (string, error)
|
||||
// It will be of the form "X.Y", where X is specified in app.yaml,
|
||||
// and Y is a number generated when each version of the app is uploaded.
|
||||
// It does not include a module name.
|
||||
func VersionID(c Context) string { return internal.VersionID() }
|
||||
func VersionID(c context.Context) string { return internal.VersionID(c) }
|
||||
|
||||
// InstanceID returns a mostly-unique identifier for this instance.
|
||||
func InstanceID() string { return internal.InstanceID() }
|
||||
|
||||
// Datacenter returns an identifier for the datacenter that the instance is running in.
|
||||
func Datacenter(c Context) string { return internal.Datacenter(c.Request()) }
|
||||
func Datacenter(c context.Context) string { return internal.Datacenter(c) }
|
||||
|
||||
// ServerSoftware returns the App Engine release version.
|
||||
// In production, it looks like "Google App Engine/X.Y.Z".
|
||||
@ -70,16 +72,16 @@ func Datacenter(c Context) string { return internal.Datacenter(c.Request()) }
|
||||
func ServerSoftware() string { return internal.ServerSoftware() }
|
||||
|
||||
// RequestID returns a string that uniquely identifies the request.
|
||||
func RequestID(c Context) string { return internal.RequestID(c.Request()) }
|
||||
func RequestID(c context.Context) string { return internal.RequestID(c) }
|
||||
|
||||
// AccessToken generates an OAuth2 access token for the specified scopes on
|
||||
// behalf of service account of this application. This token will expire after
|
||||
// the returned time.
|
||||
func AccessToken(c Context, scopes ...string) (token string, expiry time.Time, err error) {
|
||||
func AccessToken(c context.Context, scopes ...string) (token string, expiry time.Time, err error) {
|
||||
req := &pb.GetAccessTokenRequest{Scope: scopes}
|
||||
res := &pb.GetAccessTokenResponse{}
|
||||
|
||||
err = c.Call("app_identity_service", "GetAccessToken", req, res, nil)
|
||||
err = internal.Call(c, "app_identity_service", "GetAccessToken", req, res)
|
||||
if err != nil {
|
||||
return "", time.Time{}, err
|
||||
}
|
||||
@ -94,10 +96,10 @@ type Certificate struct {
|
||||
|
||||
// PublicCertificates retrieves the public certificates for the app.
|
||||
// They can be used to verify a signature returned by SignBytes.
|
||||
func PublicCertificates(c Context) ([]Certificate, error) {
|
||||
func PublicCertificates(c context.Context) ([]Certificate, error) {
|
||||
req := &pb.GetPublicCertificateForAppRequest{}
|
||||
res := &pb.GetPublicCertificateForAppResponse{}
|
||||
if err := c.Call("app_identity_service", "GetPublicCertificatesForApp", req, res, nil); err != nil {
|
||||
if err := internal.Call(c, "app_identity_service", "GetPublicCertificatesForApp", req, res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var cs []Certificate
|
||||
@ -112,11 +114,11 @@ func PublicCertificates(c Context) ([]Certificate, error) {
|
||||
|
||||
// ServiceAccount returns a string representing the service account name, in
|
||||
// the form of an email address (typically app_id@appspot.gserviceaccount.com).
|
||||
func ServiceAccount(c Context) (string, error) {
|
||||
func ServiceAccount(c context.Context) (string, error) {
|
||||
req := &pb.GetServiceAccountNameRequest{}
|
||||
res := &pb.GetServiceAccountNameResponse{}
|
||||
|
||||
err := c.Call("app_identity_service", "GetServiceAccountName", req, res, nil)
|
||||
err := internal.Call(c, "app_identity_service", "GetServiceAccountName", req, res)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@ -124,15 +126,14 @@ func ServiceAccount(c Context) (string, error) {
|
||||
}
|
||||
|
||||
// SignBytes signs bytes using a private key unique to your application.
|
||||
func SignBytes(c Context, bytes []byte) (string, []byte, error) {
|
||||
func SignBytes(c context.Context, bytes []byte) (keyName string, signature []byte, err error) {
|
||||
req := &pb.SignForAppRequest{BytesToSign: bytes}
|
||||
res := &pb.SignForAppResponse{}
|
||||
|
||||
err := c.Call("app_identity_service", "SignForApp", req, res, nil)
|
||||
if err != nil {
|
||||
if err := internal.Call(c, "app_identity_service", "SignForApp", req, res); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
return res.GetKeyName(), res.GetSignatureBytes(), err
|
||||
return res.GetKeyName(), res.GetSignatureBytes(), nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
254
vendor/google.golang.org/appengine/internal/api.go
generated
vendored
254
vendor/google.golang.org/appengine/internal/api.go
generated
vendored
@ -2,10 +2,13 @@
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !appengine
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
@ -21,6 +24,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
netcontext "golang.org/x/net/context"
|
||||
|
||||
basepb "google.golang.org/appengine/internal/base"
|
||||
logpb "google.golang.org/appengine/internal/log"
|
||||
@ -28,14 +32,15 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
apiPath = "/rpc_http"
|
||||
apiPath = "/rpc_http"
|
||||
defaultTicketSuffix = "/default.20150612t184001.0"
|
||||
)
|
||||
|
||||
var (
|
||||
// Incoming headers.
|
||||
ticketHeader = http.CanonicalHeaderKey("X-AppEngine-API-Ticket")
|
||||
dapperHeader = http.CanonicalHeaderKey("X-Google-DapperTraceInfo")
|
||||
defNamespaceHeader = http.CanonicalHeaderKey("X-AppEngine-Default-Namespace")
|
||||
traceHeader = http.CanonicalHeaderKey("X-Cloud-Trace-Context")
|
||||
curNamespaceHeader = http.CanonicalHeaderKey("X-AppEngine-Current-Namespace")
|
||||
userIPHeader = http.CanonicalHeaderKey("X-AppEngine-User-IP")
|
||||
remoteAddrHeader = http.CanonicalHeaderKey("X-AppEngine-Remote-Addr")
|
||||
@ -56,23 +61,31 @@ var (
|
||||
Dial: limitDial,
|
||||
},
|
||||
}
|
||||
|
||||
defaultTicketOnce sync.Once
|
||||
defaultTicket string
|
||||
)
|
||||
|
||||
func apiHost() string {
|
||||
host, port := "appengine.googleapis.com", "10001"
|
||||
func apiURL() *url.URL {
|
||||
host, port := "appengine.googleapis.internal", "10001"
|
||||
if h := os.Getenv("API_HOST"); h != "" {
|
||||
host = h
|
||||
}
|
||||
if p := os.Getenv("API_PORT"); p != "" {
|
||||
port = p
|
||||
}
|
||||
return host + ":" + port
|
||||
return &url.URL{
|
||||
Scheme: "http",
|
||||
Host: host + ":" + port,
|
||||
Path: apiPath,
|
||||
}
|
||||
}
|
||||
|
||||
func handleHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
c := &context{
|
||||
req: r,
|
||||
outHeader: w.Header(),
|
||||
apiURL: apiURL(),
|
||||
}
|
||||
stopFlushing := make(chan int)
|
||||
|
||||
@ -135,7 +148,8 @@ func handleHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
func executeRequestSafely(c *context, r *http.Request) {
|
||||
defer func() {
|
||||
if x := recover(); x != nil {
|
||||
c.logf(4, "%s", renderPanic(x)) // 4 == critical
|
||||
logf(c, 4, "%s", renderPanic(x)) // 4 == critical
|
||||
c.outCode = 500
|
||||
}
|
||||
}()
|
||||
|
||||
@ -185,6 +199,10 @@ var ctxs = struct {
|
||||
sync.Mutex
|
||||
m map[*http.Request]*context
|
||||
bg *context // background context, lazily initialized
|
||||
// dec is used by tests to decorate the netcontext.Context returned
|
||||
// for a given request. This allows tests to add overrides (such as
|
||||
// WithAppIDOverride) to the context. The map is nil outside tests.
|
||||
dec map[*http.Request]func(netcontext.Context) netcontext.Context
|
||||
}{
|
||||
m: make(map[*http.Request]*context),
|
||||
}
|
||||
@ -203,38 +221,83 @@ type context struct {
|
||||
lines []*logpb.UserAppLogLine
|
||||
flushes int
|
||||
}
|
||||
|
||||
apiURL *url.URL
|
||||
}
|
||||
|
||||
func NewContext(req *http.Request) *context {
|
||||
var contextKey = "holds a *context"
|
||||
|
||||
func fromContext(ctx netcontext.Context) *context {
|
||||
c, _ := ctx.Value(&contextKey).(*context)
|
||||
return c
|
||||
}
|
||||
|
||||
func withContext(parent netcontext.Context, c *context) netcontext.Context {
|
||||
ctx := netcontext.WithValue(parent, &contextKey, c)
|
||||
if ns := c.req.Header.Get(curNamespaceHeader); ns != "" {
|
||||
ctx = withNamespace(ctx, ns)
|
||||
}
|
||||
return ctx
|
||||
}
|
||||
|
||||
func toContext(c *context) netcontext.Context {
|
||||
return withContext(netcontext.Background(), c)
|
||||
}
|
||||
|
||||
func IncomingHeaders(ctx netcontext.Context) http.Header {
|
||||
if c := fromContext(ctx); c != nil {
|
||||
return c.req.Header
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func WithContext(parent netcontext.Context, req *http.Request) netcontext.Context {
|
||||
ctxs.Lock()
|
||||
c := ctxs.m[req]
|
||||
d := ctxs.dec[req]
|
||||
ctxs.Unlock()
|
||||
|
||||
if d != nil {
|
||||
parent = d(parent)
|
||||
}
|
||||
|
||||
if c == nil {
|
||||
// Someone passed in an http.Request that is not in-flight.
|
||||
// We panic here rather than panicking at a later point
|
||||
// so that stack traces will be more sensible.
|
||||
log.Panic("appengine: NewContext passed an unknown http.Request")
|
||||
}
|
||||
return c
|
||||
return withContext(parent, c)
|
||||
}
|
||||
|
||||
func BackgroundContext() *context {
|
||||
// DefaultTicket returns a ticket used for background context or dev_appserver.
|
||||
func DefaultTicket() string {
|
||||
defaultTicketOnce.Do(func() {
|
||||
if IsDevAppServer() {
|
||||
defaultTicket = "testapp" + defaultTicketSuffix
|
||||
return
|
||||
}
|
||||
appID := partitionlessAppID()
|
||||
escAppID := strings.Replace(strings.Replace(appID, ":", "_", -1), ".", "_", -1)
|
||||
majVersion := VersionID(nil)
|
||||
if i := strings.Index(majVersion, "."); i > 0 {
|
||||
majVersion = majVersion[:i]
|
||||
}
|
||||
defaultTicket = fmt.Sprintf("%s/%s.%s.%s", escAppID, ModuleName(nil), majVersion, InstanceID())
|
||||
})
|
||||
return defaultTicket
|
||||
}
|
||||
|
||||
func BackgroundContext() netcontext.Context {
|
||||
ctxs.Lock()
|
||||
defer ctxs.Unlock()
|
||||
|
||||
if ctxs.bg != nil {
|
||||
return ctxs.bg
|
||||
return toContext(ctxs.bg)
|
||||
}
|
||||
|
||||
// Compute background security ticket.
|
||||
appID := partitionlessAppID()
|
||||
escAppID := strings.Replace(strings.Replace(appID, ":", "_", -1), ".", "_", -1)
|
||||
majVersion := VersionID()
|
||||
if i := strings.Index(majVersion, "_"); i >= 0 {
|
||||
majVersion = majVersion[:i]
|
||||
}
|
||||
ticket := fmt.Sprintf("%s/%s.%s.%s", escAppID, ModuleName(), majVersion, InstanceID())
|
||||
ticket := DefaultTicket()
|
||||
|
||||
ctxs.bg = &context{
|
||||
req: &http.Request{
|
||||
@ -242,12 +305,44 @@ func BackgroundContext() *context {
|
||||
ticketHeader: []string{ticket},
|
||||
},
|
||||
},
|
||||
apiURL: apiURL(),
|
||||
}
|
||||
|
||||
// TODO(dsymonds): Wire up the shutdown handler to do a final flush.
|
||||
go ctxs.bg.logFlusher(make(chan int))
|
||||
|
||||
return ctxs.bg
|
||||
return toContext(ctxs.bg)
|
||||
}
|
||||
|
||||
// RegisterTestRequest registers the HTTP request req for testing, such that
|
||||
// any API calls are sent to the provided URL. It returns a closure to delete
|
||||
// the registration.
|
||||
// It should only be used by aetest package.
|
||||
func RegisterTestRequest(req *http.Request, apiURL *url.URL, decorate func(netcontext.Context) netcontext.Context) func() {
|
||||
c := &context{
|
||||
req: req,
|
||||
apiURL: apiURL,
|
||||
}
|
||||
ctxs.Lock()
|
||||
defer ctxs.Unlock()
|
||||
if _, ok := ctxs.m[req]; ok {
|
||||
log.Panic("req already associated with context")
|
||||
}
|
||||
if _, ok := ctxs.dec[req]; ok {
|
||||
log.Panic("req already associated with context")
|
||||
}
|
||||
if ctxs.dec == nil {
|
||||
ctxs.dec = make(map[*http.Request]func(netcontext.Context) netcontext.Context)
|
||||
}
|
||||
ctxs.m[req] = c
|
||||
ctxs.dec[req] = decorate
|
||||
|
||||
return func() {
|
||||
ctxs.Lock()
|
||||
delete(ctxs.m, req)
|
||||
delete(ctxs.dec, req)
|
||||
ctxs.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
var errTimeout = &CallError{
|
||||
@ -286,21 +381,16 @@ func (c *context) Write(b []byte) (int, error) {
|
||||
|
||||
func (c *context) WriteHeader(code int) {
|
||||
if c.outCode != 0 {
|
||||
c.Errorf("WriteHeader called multiple times on request.")
|
||||
logf(c, 3, "WriteHeader called multiple times on request.") // error level
|
||||
return
|
||||
}
|
||||
c.outCode = code
|
||||
}
|
||||
|
||||
func (c *context) post(body []byte, timeout time.Duration) (b []byte, err error) {
|
||||
dst := apiHost()
|
||||
hreq := &http.Request{
|
||||
Method: "POST",
|
||||
URL: &url.URL{
|
||||
Scheme: "http",
|
||||
Host: dst,
|
||||
Path: apiPath,
|
||||
},
|
||||
URL: c.apiURL,
|
||||
Header: http.Header{
|
||||
apiEndpointHeader: apiEndpointHeaderValue,
|
||||
apiMethodHeader: apiMethodHeaderValue,
|
||||
@ -309,11 +399,14 @@ func (c *context) post(body []byte, timeout time.Duration) (b []byte, err error)
|
||||
},
|
||||
Body: ioutil.NopCloser(bytes.NewReader(body)),
|
||||
ContentLength: int64(len(body)),
|
||||
Host: dst,
|
||||
Host: c.apiURL.Host,
|
||||
}
|
||||
if info := c.req.Header.Get(dapperHeader); info != "" {
|
||||
hreq.Header.Set(dapperHeader, info)
|
||||
}
|
||||
if info := c.req.Header.Get(traceHeader); info != "" {
|
||||
hreq.Header.Set(traceHeader, info)
|
||||
}
|
||||
|
||||
tr := apiHTTPClient.Transport.(*http.Transport)
|
||||
|
||||
@ -354,30 +447,42 @@ func (c *context) post(body []byte, timeout time.Duration) (b []byte, err error)
|
||||
return hrespBody, nil
|
||||
}
|
||||
|
||||
var virtualMethodHeaders = map[string]string{
|
||||
"GetNamespace": curNamespaceHeader,
|
||||
"GetDefaultNamespace": defNamespaceHeader,
|
||||
|
||||
"user:Email": http.CanonicalHeaderKey("X-AppEngine-User-Email"),
|
||||
"user:AuthDomain": http.CanonicalHeaderKey("X-AppEngine-Auth-Domain"),
|
||||
"user:ID": http.CanonicalHeaderKey("X-AppEngine-User-Id"),
|
||||
"user:IsAdmin": http.CanonicalHeaderKey("X-AppEngine-User-Is-Admin"),
|
||||
"user:FederatedIdentity": http.CanonicalHeaderKey("X-AppEngine-Federated-Identity"),
|
||||
"user:FederatedProvider": http.CanonicalHeaderKey("X-AppEngine-Federated-Provider"),
|
||||
}
|
||||
|
||||
func (c *context) Call(service, method string, in, out proto.Message, opts *CallOptions) error {
|
||||
if service == "__go__" {
|
||||
if hdr, ok := virtualMethodHeaders[method]; ok {
|
||||
out.(*basepb.StringProto).Value = proto.String(c.req.Header.Get(hdr))
|
||||
return nil
|
||||
func Call(ctx netcontext.Context, service, method string, in, out proto.Message) error {
|
||||
if ns := NamespaceFromContext(ctx); ns != "" {
|
||||
if fn, ok := NamespaceMods[service]; ok {
|
||||
fn(in, ns)
|
||||
}
|
||||
}
|
||||
|
||||
// Default RPC timeout is 5s.
|
||||
timeout := 5 * time.Second
|
||||
if opts != nil && opts.Timeout > 0 {
|
||||
timeout = opts.Timeout
|
||||
if f, ctx, ok := callOverrideFromContext(ctx); ok {
|
||||
return f(ctx, service, method, in, out)
|
||||
}
|
||||
|
||||
// Handle already-done contexts quickly.
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
default:
|
||||
}
|
||||
|
||||
c := fromContext(ctx)
|
||||
if c == nil {
|
||||
// Give a good error message rather than a panic lower down.
|
||||
return errors.New("not an App Engine context")
|
||||
}
|
||||
|
||||
// Apply transaction modifications if we're in a transaction.
|
||||
if t := transactionFromContext(ctx); t != nil {
|
||||
if t.finished {
|
||||
return errors.New("transaction context has expired")
|
||||
}
|
||||
applyTransaction(in, &t.transaction)
|
||||
}
|
||||
|
||||
// Default RPC timeout is 60s.
|
||||
timeout := 60 * time.Second
|
||||
if deadline, ok := ctx.Deadline(); ok {
|
||||
timeout = deadline.Sub(time.Now())
|
||||
}
|
||||
|
||||
data, err := proto.Marshal(in)
|
||||
@ -386,6 +491,16 @@ func (c *context) Call(service, method string, in, out proto.Message, opts *Call
|
||||
}
|
||||
|
||||
ticket := c.req.Header.Get(ticketHeader)
|
||||
// Use a test ticket under test environment.
|
||||
if ticket == "" {
|
||||
if appid := ctx.Value(&appIDOverrideKey); appid != nil {
|
||||
ticket = appid.(string) + defaultTicketSuffix
|
||||
}
|
||||
}
|
||||
// Fall back to use background ticket when the request ticket is not available in Flex or dev_appserver.
|
||||
if ticket == "" {
|
||||
ticket = DefaultTicket()
|
||||
}
|
||||
req := &remotepb.Request{
|
||||
ServiceName: &service,
|
||||
Method: &method,
|
||||
@ -434,7 +549,7 @@ func (c *context) Call(service, method string, in, out proto.Message, opts *Call
|
||||
return proto.Unmarshal(res.Response, out)
|
||||
}
|
||||
|
||||
func (c *context) Request() interface{} {
|
||||
func (c *context) Request() *http.Request {
|
||||
return c.req
|
||||
}
|
||||
|
||||
@ -460,7 +575,10 @@ var logLevelName = map[int64]string{
|
||||
4: "CRITICAL",
|
||||
}
|
||||
|
||||
func (c *context) logf(level int64, format string, args ...interface{}) {
|
||||
func logf(c *context, level int64, format string, args ...interface{}) {
|
||||
if c == nil {
|
||||
panic("not an App Engine context")
|
||||
}
|
||||
s := fmt.Sprintf(format, args...)
|
||||
s = strings.TrimRight(s, "\n") // Remove any trailing newline characters.
|
||||
c.addLogLine(&logpb.UserAppLogLine{
|
||||
@ -471,17 +589,6 @@ func (c *context) logf(level int64, format string, args ...interface{}) {
|
||||
log.Print(logLevelName[level] + ": " + s)
|
||||
}
|
||||
|
||||
func (c *context) Debugf(format string, args ...interface{}) { c.logf(0, format, args...) }
|
||||
func (c *context) Infof(format string, args ...interface{}) { c.logf(1, format, args...) }
|
||||
func (c *context) Warningf(format string, args ...interface{}) { c.logf(2, format, args...) }
|
||||
func (c *context) Errorf(format string, args ...interface{}) { c.logf(3, format, args...) }
|
||||
func (c *context) Criticalf(format string, args ...interface{}) { c.logf(4, format, args...) }
|
||||
|
||||
// FullyQualifiedAppID returns the fully-qualified application ID.
|
||||
// This may contain a partition prefix (e.g. "s~" for High Replication apps),
|
||||
// or a domain prefix (e.g. "example.com:").
|
||||
func (c *context) FullyQualifiedAppID() string { return fullyQualifiedAppID() }
|
||||
|
||||
// flushLog attempts to flush any pending logs to the appserver.
|
||||
// It should not be called concurrently.
|
||||
func (c *context) flushLog(force bool) (flushed bool) {
|
||||
@ -531,7 +638,7 @@ func (c *context) flushLog(force bool) (flushed bool) {
|
||||
c.pendingLogs.Lock()
|
||||
c.pendingLogs.flushes++
|
||||
c.pendingLogs.Unlock()
|
||||
if err := c.Call("logservice", "Flush", req, res, nil); err != nil {
|
||||
if err := Call(toContext(c), "logservice", "Flush", req, res); err != nil {
|
||||
log.Printf("internal.flushLog: Flush RPC: %v", err)
|
||||
rescueLogs = true
|
||||
return false
|
||||
@ -563,27 +670,6 @@ func (c *context) logFlusher(stop <-chan int) {
|
||||
}
|
||||
}
|
||||
|
||||
func ContextForTesting(req *http.Request) *context {
|
||||
return &context{req: req}
|
||||
}
|
||||
|
||||
// caller is a subset of appengine.Context.
|
||||
type caller interface {
|
||||
Call(service, method string, in, out proto.Message, opts *CallOptions) error
|
||||
}
|
||||
|
||||
var virtualOpts = &CallOptions{
|
||||
// Virtual API calls should happen nearly instantaneously.
|
||||
Timeout: 1 * time.Millisecond,
|
||||
}
|
||||
|
||||
// VirtAPI invokes a virtual API call for the __go__ service.
|
||||
// It is for methods that accept a VoidProto and return a StringProto.
|
||||
// It returns an empty string if the call fails.
|
||||
func VirtAPI(c caller, method string) string {
|
||||
s := &basepb.StringProto{}
|
||||
if err := c.Call("__go__", method, &basepb.VoidProto{}, s, virtualOpts); err != nil {
|
||||
log.Printf("/__go__.%s failed: %v", method, err)
|
||||
}
|
||||
return s.GetValue()
|
||||
func ContextForTesting(req *http.Request) netcontext.Context {
|
||||
return toContext(&context{req: req})
|
||||
}
|
||||
|
159
vendor/google.golang.org/appengine/internal/api_classic.go
generated
vendored
Normal file
159
vendor/google.golang.org/appengine/internal/api_classic.go
generated
vendored
Normal file
@ -0,0 +1,159 @@
|
||||
// Copyright 2015 Google Inc. All rights reserved.
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build appengine
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"appengine"
|
||||
"appengine_internal"
|
||||
basepb "appengine_internal/base"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
netcontext "golang.org/x/net/context"
|
||||
)
|
||||
|
||||
var contextKey = "holds an appengine.Context"
|
||||
|
||||
func fromContext(ctx netcontext.Context) appengine.Context {
|
||||
c, _ := ctx.Value(&contextKey).(appengine.Context)
|
||||
return c
|
||||
}
|
||||
|
||||
// This is only for classic App Engine adapters.
|
||||
func ClassicContextFromContext(ctx netcontext.Context) appengine.Context {
|
||||
return fromContext(ctx)
|
||||
}
|
||||
|
||||
func withContext(parent netcontext.Context, c appengine.Context) netcontext.Context {
|
||||
ctx := netcontext.WithValue(parent, &contextKey, c)
|
||||
|
||||
s := &basepb.StringProto{}
|
||||
c.Call("__go__", "GetNamespace", &basepb.VoidProto{}, s, nil)
|
||||
if ns := s.GetValue(); ns != "" {
|
||||
ctx = NamespacedContext(ctx, ns)
|
||||
}
|
||||
|
||||
return ctx
|
||||
}
|
||||
|
||||
func IncomingHeaders(ctx netcontext.Context) http.Header {
|
||||
if c := fromContext(ctx); c != nil {
|
||||
if req, ok := c.Request().(*http.Request); ok {
|
||||
return req.Header
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func WithContext(parent netcontext.Context, req *http.Request) netcontext.Context {
|
||||
c := appengine.NewContext(req)
|
||||
return withContext(parent, c)
|
||||
}
|
||||
|
||||
type testingContext struct {
|
||||
appengine.Context
|
||||
|
||||
req *http.Request
|
||||
}
|
||||
|
||||
func (t *testingContext) FullyQualifiedAppID() string { return "dev~testcontext" }
|
||||
func (t *testingContext) Call(service, method string, _, _ appengine_internal.ProtoMessage, _ *appengine_internal.CallOptions) error {
|
||||
if service == "__go__" && method == "GetNamespace" {
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("testingContext: unsupported Call")
|
||||
}
|
||||
func (t *testingContext) Request() interface{} { return t.req }
|
||||
|
||||
func ContextForTesting(req *http.Request) netcontext.Context {
|
||||
return withContext(netcontext.Background(), &testingContext{req: req})
|
||||
}
|
||||
|
||||
func Call(ctx netcontext.Context, service, method string, in, out proto.Message) error {
|
||||
if ns := NamespaceFromContext(ctx); ns != "" {
|
||||
if fn, ok := NamespaceMods[service]; ok {
|
||||
fn(in, ns)
|
||||
}
|
||||
}
|
||||
|
||||
if f, ctx, ok := callOverrideFromContext(ctx); ok {
|
||||
return f(ctx, service, method, in, out)
|
||||
}
|
||||
|
||||
// Handle already-done contexts quickly.
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
default:
|
||||
}
|
||||
|
||||
c := fromContext(ctx)
|
||||
if c == nil {
|
||||
// Give a good error message rather than a panic lower down.
|
||||
return errors.New("not an App Engine context")
|
||||
}
|
||||
|
||||
// Apply transaction modifications if we're in a transaction.
|
||||
if t := transactionFromContext(ctx); t != nil {
|
||||
if t.finished {
|
||||
return errors.New("transaction context has expired")
|
||||
}
|
||||
applyTransaction(in, &t.transaction)
|
||||
}
|
||||
|
||||
var opts *appengine_internal.CallOptions
|
||||
if d, ok := ctx.Deadline(); ok {
|
||||
opts = &appengine_internal.CallOptions{
|
||||
Timeout: d.Sub(time.Now()),
|
||||
}
|
||||
}
|
||||
|
||||
err := c.Call(service, method, in, out, opts)
|
||||
switch v := err.(type) {
|
||||
case *appengine_internal.APIError:
|
||||
return &APIError{
|
||||
Service: v.Service,
|
||||
Detail: v.Detail,
|
||||
Code: v.Code,
|
||||
}
|
||||
case *appengine_internal.CallError:
|
||||
return &CallError{
|
||||
Detail: v.Detail,
|
||||
Code: v.Code,
|
||||
Timeout: v.Timeout,
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func handleHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
panic("handleHTTP called; this should be impossible")
|
||||
}
|
||||
|
||||
func logf(c appengine.Context, level int64, format string, args ...interface{}) {
|
||||
var fn func(format string, args ...interface{})
|
||||
switch level {
|
||||
case 0:
|
||||
fn = c.Debugf
|
||||
case 1:
|
||||
fn = c.Infof
|
||||
case 2:
|
||||
fn = c.Warningf
|
||||
case 3:
|
||||
fn = c.Errorf
|
||||
case 4:
|
||||
fn = c.Criticalf
|
||||
default:
|
||||
// This shouldn't happen.
|
||||
fn = c.Criticalf
|
||||
}
|
||||
fn(format, args...)
|
||||
}
|
116
vendor/google.golang.org/appengine/internal/api_common.go
generated
vendored
Normal file
116
vendor/google.golang.org/appengine/internal/api_common.go
generated
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
// Copyright 2015 Google Inc. All rights reserved.
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
netcontext "golang.org/x/net/context"
|
||||
)
|
||||
|
||||
type CallOverrideFunc func(ctx netcontext.Context, service, method string, in, out proto.Message) error
|
||||
|
||||
var callOverrideKey = "holds []CallOverrideFunc"
|
||||
|
||||
func WithCallOverride(ctx netcontext.Context, f CallOverrideFunc) netcontext.Context {
|
||||
// We avoid appending to any existing call override
|
||||
// so we don't risk overwriting a popped stack below.
|
||||
var cofs []CallOverrideFunc
|
||||
if uf, ok := ctx.Value(&callOverrideKey).([]CallOverrideFunc); ok {
|
||||
cofs = append(cofs, uf...)
|
||||
}
|
||||
cofs = append(cofs, f)
|
||||
return netcontext.WithValue(ctx, &callOverrideKey, cofs)
|
||||
}
|
||||
|
||||
func callOverrideFromContext(ctx netcontext.Context) (CallOverrideFunc, netcontext.Context, bool) {
|
||||
cofs, _ := ctx.Value(&callOverrideKey).([]CallOverrideFunc)
|
||||
if len(cofs) == 0 {
|
||||
return nil, nil, false
|
||||
}
|
||||
// We found a list of overrides; grab the last, and reconstitute a
|
||||
// context that will hide it.
|
||||
f := cofs[len(cofs)-1]
|
||||
ctx = netcontext.WithValue(ctx, &callOverrideKey, cofs[:len(cofs)-1])
|
||||
return f, ctx, true
|
||||
}
|
||||
|
||||
type logOverrideFunc func(level int64, format string, args ...interface{})
|
||||
|
||||
var logOverrideKey = "holds a logOverrideFunc"
|
||||
|
||||
func WithLogOverride(ctx netcontext.Context, f logOverrideFunc) netcontext.Context {
|
||||
return netcontext.WithValue(ctx, &logOverrideKey, f)
|
||||
}
|
||||
|
||||
var appIDOverrideKey = "holds a string, being the full app ID"
|
||||
|
||||
func WithAppIDOverride(ctx netcontext.Context, appID string) netcontext.Context {
|
||||
return netcontext.WithValue(ctx, &appIDOverrideKey, appID)
|
||||
}
|
||||
|
||||
var namespaceKey = "holds the namespace string"
|
||||
|
||||
func withNamespace(ctx netcontext.Context, ns string) netcontext.Context {
|
||||
return netcontext.WithValue(ctx, &namespaceKey, ns)
|
||||
}
|
||||
|
||||
func NamespaceFromContext(ctx netcontext.Context) string {
|
||||
// If there's no namespace, return the empty string.
|
||||
ns, _ := ctx.Value(&namespaceKey).(string)
|
||||
return ns
|
||||
}
|
||||
|
||||
// FullyQualifiedAppID returns the fully-qualified application ID.
|
||||
// This may contain a partition prefix (e.g. "s~" for High Replication apps),
|
||||
// or a domain prefix (e.g. "example.com:").
|
||||
func FullyQualifiedAppID(ctx netcontext.Context) string {
|
||||
if id, ok := ctx.Value(&appIDOverrideKey).(string); ok {
|
||||
return id
|
||||
}
|
||||
return fullyQualifiedAppID(ctx)
|
||||
}
|
||||
|
||||
func Logf(ctx netcontext.Context, level int64, format string, args ...interface{}) {
|
||||
if f, ok := ctx.Value(&logOverrideKey).(logOverrideFunc); ok {
|
||||
f(level, format, args...)
|
||||
return
|
||||
}
|
||||
logf(fromContext(ctx), level, format, args...)
|
||||
}
|
||||
|
||||
// NamespacedContext wraps a Context to support namespaces.
|
||||
func NamespacedContext(ctx netcontext.Context, namespace string) netcontext.Context {
|
||||
return withNamespace(ctx, namespace)
|
||||
}
|
||||
|
||||
// SetTestEnv sets the env variables for testing background ticket in Flex.
|
||||
func SetTestEnv() func() {
|
||||
var environ = []struct {
|
||||
key, value string
|
||||
}{
|
||||
{"GAE_LONG_APP_ID", "my-app-id"},
|
||||
{"GAE_MINOR_VERSION", "067924799508853122"},
|
||||
{"GAE_MODULE_INSTANCE", "0"},
|
||||
{"GAE_MODULE_NAME", "default"},
|
||||
{"GAE_MODULE_VERSION", "20150612t184001"},
|
||||
}
|
||||
|
||||
for _, v := range environ {
|
||||
old := os.Getenv(v.key)
|
||||
os.Setenv(v.key, v.value)
|
||||
v.value = old
|
||||
}
|
||||
return func() { // Restore old environment after the test completes.
|
||||
for _, v := range environ {
|
||||
if v.value == "" {
|
||||
os.Unsetenv(v.key)
|
||||
continue
|
||||
}
|
||||
os.Setenv(v.key, v.value)
|
||||
}
|
||||
}
|
||||
}
|
3
vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.pb.go
generated
vendored
3
vendor/google.golang.org/appengine/internal/app_identity/app_identity_service.pb.go
generated
vendored
@ -25,10 +25,12 @@ It has these top-level messages:
|
||||
package app_identity
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
type AppIdentityServiceError_ErrorCode int32
|
||||
@ -291,5 +293,4 @@ func (m *GetDefaultGcsBucketNameResponse) GetDefaultGcsBucketName() string {
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterEnum("appengine.AppIdentityServiceError_ErrorCode", AppIdentityServiceError_ErrorCode_name, AppIdentityServiceError_ErrorCode_value)
|
||||
}
|
||||
|
5
vendor/google.golang.org/appengine/internal/base/api_base.pb.go
generated
vendored
5
vendor/google.golang.org/appengine/internal/base/api_base.pb.go
generated
vendored
@ -20,10 +20,12 @@ It has these top-level messages:
|
||||
package base
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
type StringProto struct {
|
||||
@ -129,6 +131,3 @@ type VoidProto struct {
|
||||
func (m *VoidProto) Reset() { *m = VoidProto{} }
|
||||
func (m *VoidProto) String() string { return proto.CompactTextString(m) }
|
||||
func (*VoidProto) ProtoMessage() {}
|
||||
|
||||
func init() {
|
||||
}
|
||||
|
27
vendor/google.golang.org/appengine/internal/datastore/datastore_v3.pb.go
generated
vendored
27
vendor/google.golang.org/appengine/internal/datastore/datastore_v3.pb.go
generated
vendored
@ -51,10 +51,12 @@ It has these top-level messages:
|
||||
package datastore
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
type Property_Meaning int32
|
||||
@ -815,7 +817,7 @@ func (m *Property) GetLocale() string {
|
||||
}
|
||||
|
||||
type Path struct {
|
||||
Element []*Path_Element `protobuf:"group,1,rep" json:"element,omitempty"`
|
||||
Element []*Path_Element `protobuf:"group,1,rep,name=Element" json:"element,omitempty"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
}
|
||||
|
||||
@ -1041,7 +1043,7 @@ func (m *CompositeProperty) GetValue() []string {
|
||||
type Index struct {
|
||||
EntityType *string `protobuf:"bytes,1,req,name=entity_type" json:"entity_type,omitempty"`
|
||||
Ancestor *bool `protobuf:"varint,5,req,name=ancestor" json:"ancestor,omitempty"`
|
||||
Property []*Index_Property `protobuf:"group,2,rep" json:"property,omitempty"`
|
||||
Property []*Index_Property `protobuf:"group,2,rep,name=Property" json:"property,omitempty"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
}
|
||||
|
||||
@ -1310,9 +1312,9 @@ type Query struct {
|
||||
NameSpace *string `protobuf:"bytes,29,opt,name=name_space" json:"name_space,omitempty"`
|
||||
Kind *string `protobuf:"bytes,3,opt,name=kind" json:"kind,omitempty"`
|
||||
Ancestor *Reference `protobuf:"bytes,17,opt,name=ancestor" json:"ancestor,omitempty"`
|
||||
Filter []*Query_Filter `protobuf:"group,4,rep" json:"filter,omitempty"`
|
||||
Filter []*Query_Filter `protobuf:"group,4,rep,name=Filter" json:"filter,omitempty"`
|
||||
SearchQuery *string `protobuf:"bytes,8,opt,name=search_query" json:"search_query,omitempty"`
|
||||
Order []*Query_Order `protobuf:"group,9,rep" json:"order,omitempty"`
|
||||
Order []*Query_Order `protobuf:"group,9,rep,name=Order" json:"order,omitempty"`
|
||||
Hint *Query_Hint `protobuf:"varint,18,opt,name=hint,enum=appengine.Query_Hint" json:"hint,omitempty"`
|
||||
Count *int32 `protobuf:"varint,23,opt,name=count" json:"count,omitempty"`
|
||||
Offset *int32 `protobuf:"varint,12,opt,name=offset,def=0" json:"offset,omitempty"`
|
||||
@ -1807,7 +1809,7 @@ func (m *CompiledQuery_EntityFilter) GetAncestor() *Reference {
|
||||
}
|
||||
|
||||
type CompiledCursor struct {
|
||||
Position *CompiledCursor_Position `protobuf:"group,2,opt" json:"position,omitempty"`
|
||||
Position *CompiledCursor_Position `protobuf:"group,2,opt,name=Position" json:"position,omitempty"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
}
|
||||
|
||||
@ -2067,7 +2069,7 @@ func (m *GetRequest) GetAllowDeferred() bool {
|
||||
}
|
||||
|
||||
type GetResponse struct {
|
||||
Entity []*GetResponse_Entity `protobuf:"group,1,rep" json:"entity,omitempty"`
|
||||
Entity []*GetResponse_Entity `protobuf:"group,1,rep,name=Entity" json:"entity,omitempty"`
|
||||
Deferred []*Reference `protobuf:"bytes,5,rep,name=deferred" json:"deferred,omitempty"`
|
||||
InOrder *bool `protobuf:"varint,6,opt,name=in_order,def=1" json:"in_order,omitempty"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
@ -2726,7 +2728,7 @@ func (m *BeginTransactionRequest) GetAllowMultipleEg() bool {
|
||||
|
||||
type CommitResponse struct {
|
||||
Cost *Cost `protobuf:"bytes,1,opt,name=cost" json:"cost,omitempty"`
|
||||
Version []*CommitResponse_Version `protobuf:"group,3,rep" json:"version,omitempty"`
|
||||
Version []*CommitResponse_Version `protobuf:"group,3,rep,name=Version" json:"version,omitempty"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
}
|
||||
|
||||
@ -2773,15 +2775,4 @@ func (m *CommitResponse_Version) GetVersion() int64 {
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterEnum("appengine.Property_Meaning", Property_Meaning_name, Property_Meaning_value)
|
||||
proto.RegisterEnum("appengine.Property_FtsTokenizationOption", Property_FtsTokenizationOption_name, Property_FtsTokenizationOption_value)
|
||||
proto.RegisterEnum("appengine.EntityProto_Kind", EntityProto_Kind_name, EntityProto_Kind_value)
|
||||
proto.RegisterEnum("appengine.Index_Property_Direction", Index_Property_Direction_name, Index_Property_Direction_value)
|
||||
proto.RegisterEnum("appengine.CompositeIndex_State", CompositeIndex_State_name, CompositeIndex_State_value)
|
||||
proto.RegisterEnum("appengine.Snapshot_Status", Snapshot_Status_name, Snapshot_Status_value)
|
||||
proto.RegisterEnum("appengine.Query_Hint", Query_Hint_name, Query_Hint_value)
|
||||
proto.RegisterEnum("appengine.Query_Filter_Operator", Query_Filter_Operator_name, Query_Filter_Operator_value)
|
||||
proto.RegisterEnum("appengine.Query_Order_Direction", Query_Order_Direction_name, Query_Order_Direction_value)
|
||||
proto.RegisterEnum("appengine.Error_ErrorCode", Error_ErrorCode_name, Error_ErrorCode_value)
|
||||
proto.RegisterEnum("appengine.PutRequest_AutoIdPolicy", PutRequest_AutoIdPolicy_name, PutRequest_AutoIdPolicy_value)
|
||||
}
|
||||
|
6
vendor/google.golang.org/appengine/internal/identity.go
generated
vendored
6
vendor/google.golang.org/appengine/internal/identity.go
generated
vendored
@ -4,9 +4,11 @@
|
||||
|
||||
package internal
|
||||
|
||||
import netcontext "golang.org/x/net/context"
|
||||
|
||||
// These functions are implementations of the wrapper functions
|
||||
// in ../appengine/identity.go. See that file for commentary.
|
||||
|
||||
func AppID(fqai string) string {
|
||||
return appID(fqai)
|
||||
func AppID(c netcontext.Context) string {
|
||||
return appID(FullyQualifiedAppID(c))
|
||||
}
|
||||
|
27
vendor/google.golang.org/appengine/internal/identity_classic.go
generated
vendored
Normal file
27
vendor/google.golang.org/appengine/internal/identity_classic.go
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
// Copyright 2015 Google Inc. All rights reserved.
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build appengine
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"appengine"
|
||||
|
||||
netcontext "golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func DefaultVersionHostname(ctx netcontext.Context) string {
|
||||
return appengine.DefaultVersionHostname(fromContext(ctx))
|
||||
}
|
||||
|
||||
func RequestID(ctx netcontext.Context) string { return appengine.RequestID(fromContext(ctx)) }
|
||||
func Datacenter(_ netcontext.Context) string { return appengine.Datacenter() }
|
||||
func ServerSoftware() string { return appengine.ServerSoftware() }
|
||||
func ModuleName(ctx netcontext.Context) string { return appengine.ModuleName(fromContext(ctx)) }
|
||||
func VersionID(ctx netcontext.Context) string { return appengine.VersionID(fromContext(ctx)) }
|
||||
func InstanceID() string { return appengine.InstanceID() }
|
||||
func IsDevAppServer() bool { return appengine.IsDevAppServer() }
|
||||
|
||||
func fullyQualifiedAppID(ctx netcontext.Context) string { return fromContext(ctx).FullyQualifiedAppID() }
|
36
vendor/google.golang.org/appengine/internal/identity_vm.go
generated
vendored
36
vendor/google.golang.org/appengine/internal/identity_vm.go
generated
vendored
@ -2,11 +2,15 @@
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !appengine
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
netcontext "golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// These functions are implementations of the wrapper functions
|
||||
@ -18,16 +22,20 @@ const (
|
||||
hDatacenter = "X-AppEngine-Datacenter"
|
||||
)
|
||||
|
||||
func DefaultVersionHostname(req interface{}) string {
|
||||
return req.(*http.Request).Header.Get(hDefaultVersionHostname)
|
||||
func ctxHeaders(ctx netcontext.Context) http.Header {
|
||||
return fromContext(ctx).Request().Header
|
||||
}
|
||||
|
||||
func RequestID(req interface{}) string {
|
||||
return req.(*http.Request).Header.Get(hRequestLogId)
|
||||
func DefaultVersionHostname(ctx netcontext.Context) string {
|
||||
return ctxHeaders(ctx).Get(hDefaultVersionHostname)
|
||||
}
|
||||
|
||||
func Datacenter(req interface{}) string {
|
||||
return req.(*http.Request).Header.Get(hDatacenter)
|
||||
func RequestID(ctx netcontext.Context) string {
|
||||
return ctxHeaders(ctx).Get(hRequestLogId)
|
||||
}
|
||||
|
||||
func Datacenter(ctx netcontext.Context) string {
|
||||
return ctxHeaders(ctx).Get(hDatacenter)
|
||||
}
|
||||
|
||||
func ServerSoftware() string {
|
||||
@ -40,18 +48,18 @@ func ServerSoftware() string {
|
||||
|
||||
// TODO(dsymonds): Remove the metadata fetches.
|
||||
|
||||
func ModuleName() string {
|
||||
func ModuleName(_ netcontext.Context) string {
|
||||
if s := os.Getenv("GAE_MODULE_NAME"); s != "" {
|
||||
return s
|
||||
}
|
||||
return string(mustGetMetadata("instance/attributes/gae_backend_name"))
|
||||
}
|
||||
|
||||
func VersionID() string {
|
||||
if s := os.Getenv("GAE_MODULE_VERSION"); s != "" {
|
||||
return s
|
||||
func VersionID(_ netcontext.Context) string {
|
||||
if s1, s2 := os.Getenv("GAE_MODULE_VERSION"), os.Getenv("GAE_MINOR_VERSION"); s1 != "" && s2 != "" {
|
||||
return s1 + "." + s2
|
||||
}
|
||||
return string(mustGetMetadata("instance/attributes/gae_backend_version"))
|
||||
return string(mustGetMetadata("instance/attributes/gae_backend_version")) + "." + string(mustGetMetadata("instance/attributes/gae_backend_minor_version"))
|
||||
}
|
||||
|
||||
func InstanceID() string {
|
||||
@ -70,7 +78,7 @@ func partitionlessAppID() string {
|
||||
return appID
|
||||
}
|
||||
|
||||
func fullyQualifiedAppID() string {
|
||||
func fullyQualifiedAppID(_ netcontext.Context) string {
|
||||
appID := partitionlessAppID()
|
||||
|
||||
part := os.Getenv("GAE_PARTITION")
|
||||
@ -83,3 +91,7 @@ func fullyQualifiedAppID() string {
|
||||
}
|
||||
return appID
|
||||
}
|
||||
|
||||
func IsDevAppServer() bool {
|
||||
return os.Getenv("RUN_WITH_DEVAPPSERVER") != ""
|
||||
}
|
||||
|
55
vendor/google.golang.org/appengine/internal/internal.go
generated
vendored
55
vendor/google.golang.org/appengine/internal/internal.go
generated
vendored
@ -10,21 +10,12 @@ package internal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
||||
remotepb "google.golang.org/appengine/internal/remote_api"
|
||||
)
|
||||
|
||||
type CallOptions struct {
|
||||
Timeout time.Duration // if non-zero, overrides RPC default
|
||||
}
|
||||
|
||||
// errorCodeMaps is a map of service name to the error code map for the service.
|
||||
var errorCodeMaps = make(map[string]map[int32]string)
|
||||
|
||||
@ -113,52 +104,6 @@ func (e *CallError) IsTimeout() bool {
|
||||
return e.Timeout
|
||||
}
|
||||
|
||||
// The comment below must not be changed.
|
||||
// It is used by go-app-builder to recognise that this package has
|
||||
// the internal.Main function to use in the synthetic main.
|
||||
// The gophers party all night; the rabbits provide the beats.
|
||||
|
||||
// Main is designed so that the complete generated main package is:
|
||||
//
|
||||
// package main
|
||||
//
|
||||
// import (
|
||||
// "google.golang.org/appengine/internal"
|
||||
//
|
||||
// _ "myapp/package0"
|
||||
// _ "myapp/package1"
|
||||
// )
|
||||
//
|
||||
// func main() {
|
||||
// internal.Main()
|
||||
// }
|
||||
//
|
||||
// The "myapp/packageX" packages are expected to register HTTP handlers
|
||||
// in their init functions.
|
||||
func Main() {
|
||||
installHealthChecker(http.DefaultServeMux)
|
||||
|
||||
if err := http.ListenAndServe(":8080", http.HandlerFunc(handleHTTP)); err != nil {
|
||||
log.Fatalf("http.ListenAndServe: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func installHealthChecker(mux *http.ServeMux) {
|
||||
// If no health check handler has been installed by this point, add a trivial one.
|
||||
const healthPath = "/_ah/health"
|
||||
hreq := &http.Request{
|
||||
Method: "GET",
|
||||
URL: &url.URL{
|
||||
Path: healthPath,
|
||||
},
|
||||
}
|
||||
if _, pat := mux.Handler(hreq); pat != healthPath {
|
||||
mux.HandleFunc(healthPath, func(w http.ResponseWriter, r *http.Request) {
|
||||
io.WriteString(w, "ok")
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// NamespaceMods is a map from API service to a function that will mutate an RPC request to attach a namespace.
|
||||
// The function should be prepared to be called on the same message more than once; it should only modify the
|
||||
// RPC request the first time.
|
||||
|
3
vendor/google.golang.org/appengine/internal/log/log_service.pb.go
generated
vendored
3
vendor/google.golang.org/appengine/internal/log/log_service.pb.go
generated
vendored
@ -27,10 +27,12 @@ It has these top-level messages:
|
||||
package log
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
type LogServiceError_ErrorCode int32
|
||||
@ -894,5 +896,4 @@ func (m *LogUsageResponse) GetSummary() *LogUsageRecord {
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterEnum("appengine.LogServiceError_ErrorCode", LogServiceError_ErrorCode_name, LogServiceError_ErrorCode_value)
|
||||
}
|
||||
|
15
vendor/google.golang.org/appengine/internal/main.go
generated
vendored
Normal file
15
vendor/google.golang.org/appengine/internal/main.go
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build appengine
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"appengine_internal"
|
||||
)
|
||||
|
||||
func Main() {
|
||||
appengine_internal.Main()
|
||||
}
|
48
vendor/google.golang.org/appengine/internal/main_vm.go
generated
vendored
Normal file
48
vendor/google.golang.org/appengine/internal/main_vm.go
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
// Copyright 2011 Google Inc. All rights reserved.
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !appengine
|
||||
|
||||
package internal
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
)
|
||||
|
||||
func Main() {
|
||||
installHealthChecker(http.DefaultServeMux)
|
||||
|
||||
port := "8080"
|
||||
if s := os.Getenv("PORT"); s != "" {
|
||||
port = s
|
||||
}
|
||||
|
||||
host := ""
|
||||
if IsDevAppServer() {
|
||||
host = "127.0.0.1"
|
||||
}
|
||||
if err := http.ListenAndServe(host+":"+port, http.HandlerFunc(handleHTTP)); err != nil {
|
||||
log.Fatalf("http.ListenAndServe: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func installHealthChecker(mux *http.ServeMux) {
|
||||
// If no health check handler has been installed by this point, add a trivial one.
|
||||
const healthPath = "/_ah/health"
|
||||
hreq := &http.Request{
|
||||
Method: "GET",
|
||||
URL: &url.URL{
|
||||
Path: healthPath,
|
||||
},
|
||||
}
|
||||
if _, pat := mux.Handler(hreq); pat != healthPath {
|
||||
mux.HandleFunc(healthPath, func(w http.ResponseWriter, r *http.Request) {
|
||||
io.WriteString(w, "ok")
|
||||
})
|
||||
}
|
||||
}
|
2
vendor/google.golang.org/appengine/internal/metadata.go
generated
vendored
2
vendor/google.golang.org/appengine/internal/metadata.go
generated
vendored
@ -24,7 +24,7 @@ const (
|
||||
|
||||
var (
|
||||
metadataRequestHeaders = http.Header{
|
||||
"X-Google-Metadata-Request": []string{"True"},
|
||||
"Metadata-Flavor": []string{"Google"},
|
||||
}
|
||||
)
|
||||
|
||||
|
3
vendor/google.golang.org/appengine/internal/modules/modules_service.pb.go
generated
vendored
3
vendor/google.golang.org/appengine/internal/modules/modules_service.pb.go
generated
vendored
@ -30,10 +30,12 @@ It has these top-level messages:
|
||||
package modules
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
type ModulesServiceError_ErrorCode int32
|
||||
@ -370,5 +372,4 @@ func (m *GetHostnameResponse) GetHostname() string {
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterEnum("appengine.ModulesServiceError_ErrorCode", ModulesServiceError_ErrorCode_name, ModulesServiceError_ErrorCode_value)
|
||||
}
|
||||
|
19
vendor/google.golang.org/appengine/internal/net.go
generated
vendored
19
vendor/google.golang.org/appengine/internal/net.go
generated
vendored
@ -43,21 +43,14 @@ func limitDial(network, addr string) (net.Conn, error) {
|
||||
}
|
||||
|
||||
type limitConn struct {
|
||||
mu sync.Mutex // only for closing the net.Conn
|
||||
close sync.Once
|
||||
net.Conn
|
||||
}
|
||||
|
||||
func (lc *limitConn) Close() error {
|
||||
lc.mu.Lock()
|
||||
defer lc.mu.Unlock()
|
||||
|
||||
if lc.Conn == nil {
|
||||
// Silently ignore double close.
|
||||
return nil
|
||||
}
|
||||
limitRelease()
|
||||
err := lc.Conn.Close()
|
||||
lc.Conn = nil
|
||||
runtime.SetFinalizer(lc, nil)
|
||||
return err
|
||||
defer lc.close.Do(func() {
|
||||
limitRelease()
|
||||
runtime.SetFinalizer(lc, nil)
|
||||
})
|
||||
return lc.Conn.Close()
|
||||
}
|
||||
|
18
vendor/google.golang.org/appengine/internal/regen.sh
generated
vendored
18
vendor/google.golang.org/appengine/internal/regen.sh
generated
vendored
@ -23,14 +23,18 @@ echo 1>&2 $pkgdir
|
||||
base=$(echo $pkgdir | sed "s,/$PKG\$,,")
|
||||
echo 1>&2 "base: $base"
|
||||
cd $base
|
||||
for f in $(find $PKG/internal -name '*.proto'); do
|
||||
echo 1>&2 "* $f"
|
||||
protoc --go_out=. $f
|
||||
|
||||
# Run protoc once per package.
|
||||
for dir in $(find $PKG/internal -name '*.proto' | xargs dirname | sort | uniq); do
|
||||
echo 1>&2 "* $dir"
|
||||
protoc --go_out=. $dir/*.proto
|
||||
done
|
||||
|
||||
# Fix up import lines.
|
||||
# This should be fixed upstream.
|
||||
# https://code.google.com/p/goprotobuf/issues/detail?id=32
|
||||
for f in $(find $PKG/internal -name '*.pb.go'); do
|
||||
sed -i '/^import.*\.pb"$/s,/[^/]*\.pb"$,",' $f
|
||||
# Remove proto.RegisterEnum calls.
|
||||
# These cause duplicate registration panics when these packages
|
||||
# are used on classic App Engine. proto.RegisterEnum only affects
|
||||
# parsing the text format; we don't care about that.
|
||||
# https://code.google.com/p/googleappengine/issues/detail?id=11670#c17
|
||||
sed -i '/proto.RegisterEnum/d' $f
|
||||
done
|
||||
|
3
vendor/google.golang.org/appengine/internal/remote_api/remote_api.pb.go
generated
vendored
3
vendor/google.golang.org/appengine/internal/remote_api/remote_api.pb.go
generated
vendored
@ -17,10 +17,12 @@ It has these top-level messages:
|
||||
package remote_api
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
type RpcError_ErrorCode int32
|
||||
@ -226,5 +228,4 @@ func (m *Response) GetRpcError() *RpcError {
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterEnum("remote_api.RpcError_ErrorCode", RpcError_ErrorCode_name, RpcError_ErrorCode_value)
|
||||
}
|
||||
|
81
vendor/google.golang.org/appengine/internal/transaction.go
generated
vendored
81
vendor/google.golang.org/appengine/internal/transaction.go
generated
vendored
@ -1,12 +1,19 @@
|
||||
// Copyright 2014 Google Inc. All rights reserved.
|
||||
// Use of this source code is governed by the Apache 2.0
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package internal
|
||||
|
||||
// This file implements hooks for applying datastore transactions.
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
netcontext "golang.org/x/net/context"
|
||||
|
||||
basepb "google.golang.org/appengine/internal/base"
|
||||
pb "google.golang.org/appengine/internal/datastore"
|
||||
)
|
||||
|
||||
@ -20,11 +27,81 @@ func RegisterTransactionSetter(f interface{}) {
|
||||
transactionSetters[v.Type().In(0)] = v
|
||||
}
|
||||
|
||||
// ApplyTransaction applies the transaction t to message pb
|
||||
// applyTransaction applies the transaction t to message pb
|
||||
// by using the relevant setter passed to RegisterTransactionSetter.
|
||||
func ApplyTransaction(pb proto.Message, t *pb.Transaction) {
|
||||
func applyTransaction(pb proto.Message, t *pb.Transaction) {
|
||||
v := reflect.ValueOf(pb)
|
||||
if f, ok := transactionSetters[v.Type()]; ok {
|
||||
f.Call([]reflect.Value{v, reflect.ValueOf(t)})
|
||||
}
|
||||
}
|
||||
|
||||
var transactionKey = "used for *Transaction"
|
||||
|
||||
func transactionFromContext(ctx netcontext.Context) *transaction {
|
||||
t, _ := ctx.Value(&transactionKey).(*transaction)
|
||||
return t
|
||||
}
|
||||
|
||||
func withTransaction(ctx netcontext.Context, t *transaction) netcontext.Context {
|
||||
return netcontext.WithValue(ctx, &transactionKey, t)
|
||||
}
|
||||
|
||||
type transaction struct {
|
||||
transaction pb.Transaction
|
||||
finished bool
|
||||
}
|
||||
|
||||
var ErrConcurrentTransaction = errors.New("internal: concurrent transaction")
|
||||
|
||||
func RunTransactionOnce(c netcontext.Context, f func(netcontext.Context) error, xg bool) error {
|
||||
if transactionFromContext(c) != nil {
|
||||
return errors.New("nested transactions are not supported")
|
||||
}
|
||||
|
||||
// Begin the transaction.
|
||||
t := &transaction{}
|
||||
req := &pb.BeginTransactionRequest{
|
||||
App: proto.String(FullyQualifiedAppID(c)),
|
||||
}
|
||||
if xg {
|
||||
req.AllowMultipleEg = proto.Bool(true)
|
||||
}
|
||||
if err := Call(c, "datastore_v3", "BeginTransaction", req, &t.transaction); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Call f, rolling back the transaction if f returns a non-nil error, or panics.
|
||||
// The panic is not recovered.
|
||||
defer func() {
|
||||
if t.finished {
|
||||
return
|
||||
}
|
||||
t.finished = true
|
||||
// Ignore the error return value, since we are already returning a non-nil
|
||||
// error (or we're panicking).
|
||||
Call(c, "datastore_v3", "Rollback", &t.transaction, &basepb.VoidProto{})
|
||||
}()
|
||||
if err := f(withTransaction(c, t)); err != nil {
|
||||
return err
|
||||
}
|
||||
t.finished = true
|
||||
|
||||
// Commit the transaction.
|
||||
res := &pb.CommitResponse{}
|
||||
err := Call(c, "datastore_v3", "Commit", &t.transaction, res)
|
||||
if ae, ok := err.(*APIError); ok {
|
||||
/* TODO: restore this conditional
|
||||
if appengine.IsDevAppServer() {
|
||||
*/
|
||||
// The Python Dev AppServer raises an ApplicationError with error code 2 (which is
|
||||
// Error.CONCURRENT_TRANSACTION) and message "Concurrency exception.".
|
||||
if ae.Code == int32(pb.Error_BAD_REQUEST) && ae.Detail == "ApplicationError: 2 Concurrency exception." {
|
||||
return ErrConcurrentTransaction
|
||||
}
|
||||
if ae.Code == int32(pb.Error_CONCURRENT_TRANSACTION) {
|
||||
return ErrConcurrentTransaction
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
29
vendor/google.golang.org/appengine/namespace.go
generated
vendored
29
vendor/google.golang.org/appengine/namespace.go
generated
vendored
@ -8,41 +8,18 @@ import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"google.golang.org/appengine/internal"
|
||||
basepb "google.golang.org/appengine/internal/base"
|
||||
)
|
||||
|
||||
// Namespace returns a replacement context that operates within the given namespace.
|
||||
func Namespace(c Context, namespace string) (Context, error) {
|
||||
func Namespace(c context.Context, namespace string) (context.Context, error) {
|
||||
if !validNamespace.MatchString(namespace) {
|
||||
return nil, fmt.Errorf("appengine: namespace %q does not match /%s/", namespace, validNamespace)
|
||||
}
|
||||
return &namespacedContext{
|
||||
Context: c,
|
||||
namespace: namespace,
|
||||
}, nil
|
||||
return internal.NamespacedContext(c, namespace), nil
|
||||
}
|
||||
|
||||
// validNamespace matches valid namespace names.
|
||||
var validNamespace = regexp.MustCompile(`^[0-9A-Za-z._-]{0,100}$`)
|
||||
|
||||
// namespacedContext wraps a Context to support namespaces.
|
||||
type namespacedContext struct {
|
||||
Context
|
||||
namespace string
|
||||
}
|
||||
|
||||
func (n *namespacedContext) Call(service, method string, in, out proto.Message, opts *internal.CallOptions) error {
|
||||
// Apply any namespace mods.
|
||||
if mod, ok := internal.NamespaceMods[service]; ok {
|
||||
mod(in, n.namespace)
|
||||
}
|
||||
if service == "__go__" && method == "GetNamespace" {
|
||||
out.(*basepb.StringProto).Value = proto.String(n.namespace)
|
||||
return nil
|
||||
}
|
||||
|
||||
return n.Context.Call(service, method, in, out, opts)
|
||||
}
|
||||
|
37
vendor/google.golang.org/appengine/timeout.go
generated
vendored
37
vendor/google.golang.org/appengine/timeout.go
generated
vendored
@ -4,16 +4,13 @@
|
||||
|
||||
package appengine
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
|
||||
"google.golang.org/appengine/internal"
|
||||
)
|
||||
import "golang.org/x/net/context"
|
||||
|
||||
// IsTimeoutError reports whether err is a timeout error.
|
||||
func IsTimeoutError(err error) bool {
|
||||
if err == context.DeadlineExceeded {
|
||||
return true
|
||||
}
|
||||
if t, ok := err.(interface {
|
||||
IsTimeout() bool
|
||||
}); ok {
|
||||
@ -21,29 +18,3 @@ func IsTimeoutError(err error) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Timeout returns a replacement context that uses d as the default API RPC timeout.
|
||||
func Timeout(c Context, d time.Duration) Context {
|
||||
return &timeoutContext{
|
||||
Context: c,
|
||||
d: d,
|
||||
}
|
||||
}
|
||||
|
||||
type timeoutContext struct {
|
||||
Context
|
||||
d time.Duration
|
||||
}
|
||||
|
||||
func (t *timeoutContext) Call(service, method string, in, out proto.Message, opts *internal.CallOptions) error {
|
||||
// Only affect calls that don't have a timeout.
|
||||
if opts == nil || opts.Timeout == 0 {
|
||||
newOpts := new(internal.CallOptions)
|
||||
if opts != nil {
|
||||
*newOpts = *opts
|
||||
}
|
||||
newOpts.Timeout = t.d
|
||||
opts = newOpts
|
||||
}
|
||||
return t.Context.Call(service, method, in, out, opts)
|
||||
}
|
||||
|
2
vendor/google.golang.org/grpc/.travis.yml
generated
vendored
2
vendor/google.golang.org/grpc/.travis.yml
generated
vendored
@ -14,6 +14,6 @@ before_install:
|
||||
script:
|
||||
- '! gofmt -s -d -l . 2>&1 | read'
|
||||
- '! goimports -l . | read'
|
||||
- 'if [[ $TRAVIS_GO_VERSION != 1.5* ]]; then ! golint ./... | grep -vE "(_string|\.pb)\.go:"; fi'
|
||||
- 'if [[ $TRAVIS_GO_VERSION != 1.5* ]]; then ! golint ./... | grep -vE "(_mock|_string|\.pb)\.go:"; fi'
|
||||
- '! go tool vet -all . 2>&1 | grep -vE "constant [0-9]+ not a string in call to Errorf" | grep -vF .pb.go:' # https://github.com/golang/protobuf/issues/214
|
||||
- make test testrace
|
||||
|
29
vendor/google.golang.org/grpc/call.go
generated
vendored
29
vendor/google.golang.org/grpc/call.go
generated
vendored
@ -42,6 +42,7 @@ import (
|
||||
"golang.org/x/net/context"
|
||||
"golang.org/x/net/trace"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/peer"
|
||||
"google.golang.org/grpc/stats"
|
||||
"google.golang.org/grpc/transport"
|
||||
)
|
||||
@ -66,7 +67,7 @@ func recvResponse(ctx context.Context, dopts dialOptions, t transport.ClientTran
|
||||
}
|
||||
p := &parser{r: stream}
|
||||
var inPayload *stats.InPayload
|
||||
if stats.On() {
|
||||
if dopts.copts.StatsHandler != nil {
|
||||
inPayload = &stats.InPayload{
|
||||
Client: true,
|
||||
}
|
||||
@ -82,14 +83,17 @@ func recvResponse(ctx context.Context, dopts dialOptions, t transport.ClientTran
|
||||
if inPayload != nil && err == io.EOF && stream.StatusCode() == codes.OK {
|
||||
// TODO in the current implementation, inTrailer may be handled before inPayload in some cases.
|
||||
// Fix the order if necessary.
|
||||
stats.HandleRPC(ctx, inPayload)
|
||||
dopts.copts.StatsHandler.HandleRPC(ctx, inPayload)
|
||||
}
|
||||
c.trailerMD = stream.Trailer()
|
||||
if peer, ok := peer.FromContext(stream.Context()); ok {
|
||||
c.peer = peer
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// sendRequest writes out various information of an RPC such as Context and Message.
|
||||
func sendRequest(ctx context.Context, codec Codec, compressor Compressor, callHdr *transport.CallHdr, t transport.ClientTransport, args interface{}, opts *transport.Options) (_ *transport.Stream, err error) {
|
||||
func sendRequest(ctx context.Context, dopts dialOptions, compressor Compressor, callHdr *transport.CallHdr, t transport.ClientTransport, args interface{}, opts *transport.Options) (_ *transport.Stream, err error) {
|
||||
stream, err := t.NewStream(ctx, callHdr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -109,19 +113,19 @@ func sendRequest(ctx context.Context, codec Codec, compressor Compressor, callHd
|
||||
if compressor != nil {
|
||||
cbuf = new(bytes.Buffer)
|
||||
}
|
||||
if stats.On() {
|
||||
if dopts.copts.StatsHandler != nil {
|
||||
outPayload = &stats.OutPayload{
|
||||
Client: true,
|
||||
}
|
||||
}
|
||||
outBuf, err := encode(codec, args, compressor, cbuf, outPayload)
|
||||
outBuf, err := encode(dopts.codec, args, compressor, cbuf, outPayload)
|
||||
if err != nil {
|
||||
return nil, Errorf(codes.Internal, "grpc: %v", err)
|
||||
}
|
||||
err = t.Write(stream, outBuf, opts)
|
||||
if err == nil && outPayload != nil {
|
||||
outPayload.SentTime = time.Now()
|
||||
stats.HandleRPC(ctx, outPayload)
|
||||
dopts.copts.StatsHandler.HandleRPC(ctx, outPayload)
|
||||
}
|
||||
// t.NewStream(...) could lead to an early rejection of the RPC (e.g., the service/method
|
||||
// does not exist.) so that t.Write could get io.EOF from wait(...). Leave the following
|
||||
@ -179,23 +183,24 @@ func invoke(ctx context.Context, method string, args, reply interface{}, cc *Cli
|
||||
}
|
||||
}()
|
||||
}
|
||||
if stats.On() {
|
||||
ctx = stats.TagRPC(ctx, &stats.RPCTagInfo{FullMethodName: method})
|
||||
sh := cc.dopts.copts.StatsHandler
|
||||
if sh != nil {
|
||||
ctx = sh.TagRPC(ctx, &stats.RPCTagInfo{FullMethodName: method})
|
||||
begin := &stats.Begin{
|
||||
Client: true,
|
||||
BeginTime: time.Now(),
|
||||
FailFast: c.failFast,
|
||||
}
|
||||
stats.HandleRPC(ctx, begin)
|
||||
sh.HandleRPC(ctx, begin)
|
||||
}
|
||||
defer func() {
|
||||
if stats.On() {
|
||||
if sh != nil {
|
||||
end := &stats.End{
|
||||
Client: true,
|
||||
EndTime: time.Now(),
|
||||
Error: e,
|
||||
}
|
||||
stats.HandleRPC(ctx, end)
|
||||
sh.HandleRPC(ctx, end)
|
||||
}
|
||||
}()
|
||||
topts := &transport.Options{
|
||||
@ -241,7 +246,7 @@ func invoke(ctx context.Context, method string, args, reply interface{}, cc *Cli
|
||||
if c.traceInfo.tr != nil {
|
||||
c.traceInfo.tr.LazyLog(&payload{sent: true, msg: args}, true)
|
||||
}
|
||||
stream, err = sendRequest(ctx, cc.dopts.codec, cc.dopts.cp, callHdr, t, args, topts)
|
||||
stream, err = sendRequest(ctx, cc.dopts, cc.dopts.cp, callHdr, t, args, topts)
|
||||
if err != nil {
|
||||
if put != nil {
|
||||
put()
|
||||
|
20
vendor/google.golang.org/grpc/clientconn.go
generated
vendored
20
vendor/google.golang.org/grpc/clientconn.go
generated
vendored
@ -45,6 +45,7 @@ import (
|
||||
"golang.org/x/net/trace"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/stats"
|
||||
"google.golang.org/grpc/transport"
|
||||
)
|
||||
|
||||
@ -222,6 +223,14 @@ func WithDialer(f func(string, time.Duration) (net.Conn, error)) DialOption {
|
||||
}
|
||||
}
|
||||
|
||||
// WithStatsHandler returns a DialOption that specifies the stats handler
|
||||
// for all the RPCs and underlying network connections in this ClientConn.
|
||||
func WithStatsHandler(h stats.Handler) DialOption {
|
||||
return func(o *dialOptions) {
|
||||
o.copts.StatsHandler = h
|
||||
}
|
||||
}
|
||||
|
||||
// FailOnNonTempDialError returns a DialOption that specified if gRPC fails on non-temporary dial errors.
|
||||
// If f is true, and dialer returns a non-temporary error, gRPC will fail the connection to the network
|
||||
// address and won't try to reconnect.
|
||||
@ -254,6 +263,15 @@ func WithStreamInterceptor(f StreamClientInterceptor) DialOption {
|
||||
}
|
||||
}
|
||||
|
||||
// WithAuthority returns a DialOption that specifies the value to be used as
|
||||
// the :authority pseudo-header. This value only works with WithInsecure and
|
||||
// has no effect if TransportCredentials are present.
|
||||
func WithAuthority(a string) DialOption {
|
||||
return func(o *dialOptions) {
|
||||
o.copts.Authority = a
|
||||
}
|
||||
}
|
||||
|
||||
// Dial creates a client connection to the given target.
|
||||
func Dial(target string, opts ...DialOption) (*ClientConn, error) {
|
||||
return DialContext(context.Background(), target, opts...)
|
||||
@ -312,6 +330,8 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
|
||||
creds := cc.dopts.copts.TransportCredentials
|
||||
if creds != nil && creds.Info().ServerName != "" {
|
||||
cc.authority = creds.Info().ServerName
|
||||
} else if cc.dopts.insecure && cc.dopts.copts.Authority != "" {
|
||||
cc.authority = cc.dopts.copts.Authority
|
||||
} else {
|
||||
colonPos := strings.LastIndex(target, ":")
|
||||
if colonPos == -1 {
|
||||
|
4
vendor/google.golang.org/grpc/credentials/credentials.go
generated
vendored
4
vendor/google.golang.org/grpc/credentials/credentials.go
generated
vendored
@ -165,9 +165,7 @@ func (c *tlsCreds) ClientHandshake(ctx context.Context, addr string, rawConn net
|
||||
case <-ctx.Done():
|
||||
return nil, nil, ctx.Err()
|
||||
}
|
||||
// TODO(zhaoq): Omit the auth info for client now. It is more for
|
||||
// information than anything else.
|
||||
return conn, nil, nil
|
||||
return conn, TLSInfo{conn.ConnectionState()}, nil
|
||||
}
|
||||
|
||||
func (c *tlsCreds) ServerHandshake(rawConn net.Conn) (net.Conn, AuthInfo, error) {
|
||||
|
3
vendor/google.golang.org/grpc/metadata/metadata.go
generated
vendored
3
vendor/google.golang.org/grpc/metadata/metadata.go
generated
vendored
@ -32,6 +32,7 @@
|
||||
*/
|
||||
|
||||
// Package metadata define the structure of the metadata supported by gRPC library.
|
||||
// Please refer to http://www.grpc.io/docs/guides/wire.html for more information about custom-metadata.
|
||||
package metadata
|
||||
|
||||
import (
|
||||
@ -82,6 +83,7 @@ func DecodeKeyValue(k, v string) (string, string, error) {
|
||||
type MD map[string][]string
|
||||
|
||||
// New creates a MD from given key-value map.
|
||||
// Keys are automatically converted to lowercase. And for keys having "-bin" as suffix, their values will be applied Base64 encoding.
|
||||
func New(m map[string]string) MD {
|
||||
md := MD{}
|
||||
for k, v := range m {
|
||||
@ -93,6 +95,7 @@ func New(m map[string]string) MD {
|
||||
|
||||
// Pairs returns an MD formed by the mapping of key, value ...
|
||||
// Pairs panics if len(kv) is odd.
|
||||
// Keys are automatically converted to lowercase. And for keys having "-bin" as suffix, their values will be appplied Base64 encoding.
|
||||
func Pairs(kv ...string) MD {
|
||||
if len(kv)%2 == 1 {
|
||||
panic(fmt.Sprintf("metadata: Pairs got the odd number of input pairs for metadata: %d", len(kv)))
|
||||
|
26
vendor/google.golang.org/grpc/rpc_util.go
generated
vendored
26
vendor/google.golang.org/grpc/rpc_util.go
generated
vendored
@ -48,6 +48,7 @@ import (
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/peer"
|
||||
"google.golang.org/grpc/stats"
|
||||
"google.golang.org/grpc/transport"
|
||||
)
|
||||
@ -140,6 +141,7 @@ type callInfo struct {
|
||||
failFast bool
|
||||
headerMD metadata.MD
|
||||
trailerMD metadata.MD
|
||||
peer *peer.Peer
|
||||
traceInfo traceInfo // in trace.go
|
||||
}
|
||||
|
||||
@ -183,12 +185,20 @@ func Trailer(md *metadata.MD) CallOption {
|
||||
})
|
||||
}
|
||||
|
||||
// Peer returns a CallOption that retrieves peer information for a
|
||||
// unary RPC.
|
||||
func Peer(peer *peer.Peer) CallOption {
|
||||
return afterCall(func(c *callInfo) {
|
||||
*peer = *c.peer
|
||||
})
|
||||
}
|
||||
|
||||
// FailFast configures the action to take when an RPC is attempted on broken
|
||||
// connections or unreachable servers. If failfast is true, the RPC will fail
|
||||
// immediately. Otherwise, the RPC client will block the call until a
|
||||
// connection is available (or the call is canceled or times out) and will retry
|
||||
// the call if it fails due to a transient error. Please refer to
|
||||
// https://github.com/grpc/grpc/blob/master/doc/fail_fast.md
|
||||
// https://github.com/grpc/grpc/blob/master/doc/fail_fast.md. Note: failFast is default to true.
|
||||
func FailFast(failFast bool) CallOption {
|
||||
return beforeCall(func(c *callInfo) error {
|
||||
c.failFast = failFast
|
||||
@ -486,17 +496,17 @@ type MethodConfig struct {
|
||||
// then the other will be used. If neither is set, then the RPC has no deadline.
|
||||
Timeout time.Duration
|
||||
// MaxReqSize is the maximum allowed payload size for an individual request in a
|
||||
// stream (client->server) in bytes. The size which is measured is the serialized,
|
||||
// uncompressed payload in bytes. The actual value used is the minumum of the value
|
||||
// specified here and the value set by the application via the gRPC client API. If
|
||||
// either one is not set, then the other will be used. If neither is set, then the
|
||||
// built-in default is used.
|
||||
// stream (client->server) in bytes. The size which is measured is the serialized
|
||||
// payload after per-message compression (but before stream compression) in bytes.
|
||||
// The actual value used is the minumum of the value specified here and the value set
|
||||
// by the application via the gRPC client API. If either one is not set, then the other
|
||||
// will be used. If neither is set, then the built-in default is used.
|
||||
// TODO: support this.
|
||||
MaxReqSize uint64
|
||||
MaxReqSize uint32
|
||||
// MaxRespSize is the maximum allowed payload size for an individual response in a
|
||||
// stream (server->client) in bytes.
|
||||
// TODO: support this.
|
||||
MaxRespSize uint64
|
||||
MaxRespSize uint32
|
||||
}
|
||||
|
||||
// ServiceConfig is provided by the service provider and contains parameters for how
|
||||
|
58
vendor/google.golang.org/grpc/server.go
generated
vendored
58
vendor/google.golang.org/grpc/server.go
generated
vendored
@ -113,6 +113,7 @@ type options struct {
|
||||
unaryInt UnaryServerInterceptor
|
||||
streamInt StreamServerInterceptor
|
||||
inTapHandle tap.ServerInHandle
|
||||
statsHandler stats.Handler
|
||||
maxConcurrentStreams uint32
|
||||
useHandlerImpl bool // use http.Handler-based server
|
||||
}
|
||||
@ -200,6 +201,13 @@ func InTapHandle(h tap.ServerInHandle) ServerOption {
|
||||
}
|
||||
}
|
||||
|
||||
// StatsHandler returns a ServerOption that sets the stats handler for the server.
|
||||
func StatsHandler(h stats.Handler) ServerOption {
|
||||
return func(o *options) {
|
||||
o.statsHandler = h
|
||||
}
|
||||
}
|
||||
|
||||
// NewServer creates a gRPC server which has no service registered and has not
|
||||
// started to accept requests yet.
|
||||
func NewServer(opt ...ServerOption) *Server {
|
||||
@ -438,9 +446,10 @@ func (s *Server) handleRawConn(rawConn net.Conn) {
|
||||
// transport.NewServerTransport).
|
||||
func (s *Server) serveHTTP2Transport(c net.Conn, authInfo credentials.AuthInfo) {
|
||||
config := &transport.ServerConfig{
|
||||
MaxStreams: s.opts.maxConcurrentStreams,
|
||||
AuthInfo: authInfo,
|
||||
InTapHandle: s.opts.inTapHandle,
|
||||
MaxStreams: s.opts.maxConcurrentStreams,
|
||||
AuthInfo: authInfo,
|
||||
InTapHandle: s.opts.inTapHandle,
|
||||
StatsHandler: s.opts.statsHandler,
|
||||
}
|
||||
st, err := transport.NewServerTransport("http2", c, config)
|
||||
if err != nil {
|
||||
@ -567,7 +576,7 @@ func (s *Server) sendResponse(t transport.ServerTransport, stream *transport.Str
|
||||
if cp != nil {
|
||||
cbuf = new(bytes.Buffer)
|
||||
}
|
||||
if stats.On() {
|
||||
if s.opts.statsHandler != nil {
|
||||
outPayload = &stats.OutPayload{}
|
||||
}
|
||||
p, err := encode(s.opts.codec, msg, cp, cbuf, outPayload)
|
||||
@ -584,27 +593,28 @@ func (s *Server) sendResponse(t transport.ServerTransport, stream *transport.Str
|
||||
err = t.Write(stream, p, opts)
|
||||
if err == nil && outPayload != nil {
|
||||
outPayload.SentTime = time.Now()
|
||||
stats.HandleRPC(stream.Context(), outPayload)
|
||||
s.opts.statsHandler.HandleRPC(stream.Context(), outPayload)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.Stream, srv *service, md *MethodDesc, trInfo *traceInfo) (err error) {
|
||||
if stats.On() {
|
||||
sh := s.opts.statsHandler
|
||||
if sh != nil {
|
||||
begin := &stats.Begin{
|
||||
BeginTime: time.Now(),
|
||||
}
|
||||
stats.HandleRPC(stream.Context(), begin)
|
||||
sh.HandleRPC(stream.Context(), begin)
|
||||
}
|
||||
defer func() {
|
||||
if stats.On() {
|
||||
if sh != nil {
|
||||
end := &stats.End{
|
||||
EndTime: time.Now(),
|
||||
}
|
||||
if err != nil && err != io.EOF {
|
||||
end.Error = toRPCErr(err)
|
||||
}
|
||||
stats.HandleRPC(stream.Context(), end)
|
||||
sh.HandleRPC(stream.Context(), end)
|
||||
}
|
||||
}()
|
||||
if trInfo != nil {
|
||||
@ -665,7 +675,7 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
|
||||
}
|
||||
}
|
||||
var inPayload *stats.InPayload
|
||||
if stats.On() {
|
||||
if sh != nil {
|
||||
inPayload = &stats.InPayload{
|
||||
RecvTime: time.Now(),
|
||||
}
|
||||
@ -699,7 +709,7 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
|
||||
inPayload.Payload = v
|
||||
inPayload.Data = req
|
||||
inPayload.Length = len(req)
|
||||
stats.HandleRPC(stream.Context(), inPayload)
|
||||
sh.HandleRPC(stream.Context(), inPayload)
|
||||
}
|
||||
if trInfo != nil {
|
||||
trInfo.tr.LazyLog(&payload{sent: false, msg: v}, true)
|
||||
@ -756,35 +766,37 @@ func (s *Server) processUnaryRPC(t transport.ServerTransport, stream *transport.
|
||||
}
|
||||
|
||||
func (s *Server) processStreamingRPC(t transport.ServerTransport, stream *transport.Stream, srv *service, sd *StreamDesc, trInfo *traceInfo) (err error) {
|
||||
if stats.On() {
|
||||
sh := s.opts.statsHandler
|
||||
if sh != nil {
|
||||
begin := &stats.Begin{
|
||||
BeginTime: time.Now(),
|
||||
}
|
||||
stats.HandleRPC(stream.Context(), begin)
|
||||
sh.HandleRPC(stream.Context(), begin)
|
||||
}
|
||||
defer func() {
|
||||
if stats.On() {
|
||||
if sh != nil {
|
||||
end := &stats.End{
|
||||
EndTime: time.Now(),
|
||||
}
|
||||
if err != nil && err != io.EOF {
|
||||
end.Error = toRPCErr(err)
|
||||
}
|
||||
stats.HandleRPC(stream.Context(), end)
|
||||
sh.HandleRPC(stream.Context(), end)
|
||||
}
|
||||
}()
|
||||
if s.opts.cp != nil {
|
||||
stream.SetSendCompress(s.opts.cp.Type())
|
||||
}
|
||||
ss := &serverStream{
|
||||
t: t,
|
||||
s: stream,
|
||||
p: &parser{r: stream},
|
||||
codec: s.opts.codec,
|
||||
cp: s.opts.cp,
|
||||
dc: s.opts.dc,
|
||||
maxMsgSize: s.opts.maxMsgSize,
|
||||
trInfo: trInfo,
|
||||
t: t,
|
||||
s: stream,
|
||||
p: &parser{r: stream},
|
||||
codec: s.opts.codec,
|
||||
cp: s.opts.cp,
|
||||
dc: s.opts.dc,
|
||||
maxMsgSize: s.opts.maxMsgSize,
|
||||
trInfo: trInfo,
|
||||
statsHandler: sh,
|
||||
}
|
||||
if ss.cp != nil {
|
||||
ss.cbuf = new(bytes.Buffer)
|
||||
|
106
vendor/google.golang.org/grpc/stats/handlers.go
generated
vendored
106
vendor/google.golang.org/grpc/stats/handlers.go
generated
vendored
@ -35,10 +35,8 @@ package stats
|
||||
|
||||
import (
|
||||
"net"
|
||||
"sync/atomic"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
)
|
||||
|
||||
// ConnTagInfo defines the relevant information needed by connection context tagger.
|
||||
@ -56,91 +54,23 @@ type RPCTagInfo struct {
|
||||
FullMethodName string
|
||||
}
|
||||
|
||||
var (
|
||||
on = new(int32)
|
||||
rpcHandler func(context.Context, RPCStats)
|
||||
connHandler func(context.Context, ConnStats)
|
||||
connTagger func(context.Context, *ConnTagInfo) context.Context
|
||||
rpcTagger func(context.Context, *RPCTagInfo) context.Context
|
||||
)
|
||||
// Handler defines the interface for the related stats handling (e.g., RPCs, connections).
|
||||
type Handler interface {
|
||||
// TagRPC can attach some information to the given context.
|
||||
// The returned context is used in the rest lifetime of the RPC.
|
||||
TagRPC(context.Context, *RPCTagInfo) context.Context
|
||||
// HandleRPC processes the RPC stats.
|
||||
HandleRPC(context.Context, RPCStats)
|
||||
|
||||
// HandleRPC processes the RPC stats using the rpc handler registered by the user.
|
||||
func HandleRPC(ctx context.Context, s RPCStats) {
|
||||
if rpcHandler == nil {
|
||||
return
|
||||
}
|
||||
rpcHandler(ctx, s)
|
||||
}
|
||||
|
||||
// RegisterRPCHandler registers the user handler function for RPC stats processing.
|
||||
// It should be called only once. The later call will overwrite the former value if it is called multiple times.
|
||||
// This handler function will be called to process the rpc stats.
|
||||
func RegisterRPCHandler(f func(context.Context, RPCStats)) {
|
||||
rpcHandler = f
|
||||
}
|
||||
|
||||
// HandleConn processes the stats using the call back function registered by user.
|
||||
func HandleConn(ctx context.Context, s ConnStats) {
|
||||
if connHandler == nil {
|
||||
return
|
||||
}
|
||||
connHandler(ctx, s)
|
||||
}
|
||||
|
||||
// RegisterConnHandler registers the user handler function for conn stats.
|
||||
// It should be called only once. The later call will overwrite the former value if it is called multiple times.
|
||||
// This handler function will be called to process the conn stats.
|
||||
func RegisterConnHandler(f func(context.Context, ConnStats)) {
|
||||
connHandler = f
|
||||
}
|
||||
|
||||
// TagConn calls user registered connection context tagger.
|
||||
func TagConn(ctx context.Context, info *ConnTagInfo) context.Context {
|
||||
if connTagger == nil {
|
||||
return ctx
|
||||
}
|
||||
return connTagger(ctx, info)
|
||||
}
|
||||
|
||||
// RegisterConnTagger registers the user connection context tagger function.
|
||||
// The connection context tagger can attach some information to the given context.
|
||||
// The returned context will be used for stats handling.
|
||||
// For conn stats handling, the context used in connHandler for this
|
||||
// connection will be derived from the context returned.
|
||||
// For RPC stats handling,
|
||||
// - On server side, the context used in rpcHandler for all RPCs on this
|
||||
// connection will be derived from the context returned.
|
||||
// - On client side, the context is not derived from the context returned.
|
||||
func RegisterConnTagger(t func(context.Context, *ConnTagInfo) context.Context) {
|
||||
connTagger = t
|
||||
}
|
||||
|
||||
// TagRPC calls the user registered RPC context tagger.
|
||||
func TagRPC(ctx context.Context, info *RPCTagInfo) context.Context {
|
||||
if rpcTagger == nil {
|
||||
return ctx
|
||||
}
|
||||
return rpcTagger(ctx, info)
|
||||
}
|
||||
|
||||
// RegisterRPCTagger registers the user RPC context tagger function.
|
||||
// The RPC context tagger can attach some information to the given context.
|
||||
// The context used in stats rpcHandler for this RPC will be derived from the
|
||||
// context returned.
|
||||
func RegisterRPCTagger(t func(context.Context, *RPCTagInfo) context.Context) {
|
||||
rpcTagger = t
|
||||
}
|
||||
|
||||
// Start starts the stats collection and processing if there is a registered stats handle.
|
||||
func Start() {
|
||||
if rpcHandler == nil && connHandler == nil {
|
||||
grpclog.Println("rpcHandler and connHandler are both nil when starting stats. Stats is not started")
|
||||
return
|
||||
}
|
||||
atomic.StoreInt32(on, 1)
|
||||
}
|
||||
|
||||
// On indicates whether the stats collection and processing is on.
|
||||
func On() bool {
|
||||
return atomic.CompareAndSwapInt32(on, 1, 1)
|
||||
// TagConn can attach some information to the given context.
|
||||
// The returned context will be used for stats handling.
|
||||
// For conn stats handling, the context used in HandleConn for this
|
||||
// connection will be derived from the context returned.
|
||||
// For RPC stats handling,
|
||||
// - On server side, the context used in HandleRPC for all RPCs on this
|
||||
// connection will be derived from the context returned.
|
||||
// - On client side, the context is not derived from the context returned.
|
||||
TagConn(context.Context, *ConnTagInfo) context.Context
|
||||
// HandleConn processes the Conn stats.
|
||||
HandleConn(context.Context, ConnStats)
|
||||
}
|
||||
|
39
vendor/google.golang.org/grpc/stream.go
generated
vendored
39
vendor/google.golang.org/grpc/stream.go
generated
vendored
@ -151,23 +151,24 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth
|
||||
}
|
||||
}()
|
||||
}
|
||||
if stats.On() {
|
||||
ctx = stats.TagRPC(ctx, &stats.RPCTagInfo{FullMethodName: method})
|
||||
sh := cc.dopts.copts.StatsHandler
|
||||
if sh != nil {
|
||||
ctx = sh.TagRPC(ctx, &stats.RPCTagInfo{FullMethodName: method})
|
||||
begin := &stats.Begin{
|
||||
Client: true,
|
||||
BeginTime: time.Now(),
|
||||
FailFast: c.failFast,
|
||||
}
|
||||
stats.HandleRPC(ctx, begin)
|
||||
sh.HandleRPC(ctx, begin)
|
||||
}
|
||||
defer func() {
|
||||
if err != nil && stats.On() {
|
||||
if err != nil && sh != nil {
|
||||
// Only handle end stats if err != nil.
|
||||
end := &stats.End{
|
||||
Client: true,
|
||||
Error: err,
|
||||
}
|
||||
stats.HandleRPC(ctx, end)
|
||||
sh.HandleRPC(ctx, end)
|
||||
}
|
||||
}()
|
||||
gopts := BalancerGetOptions{
|
||||
@ -223,7 +224,8 @@ func newClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth
|
||||
tracing: EnableTracing,
|
||||
trInfo: trInfo,
|
||||
|
||||
statsCtx: ctx,
|
||||
statsCtx: ctx,
|
||||
statsHandler: cc.dopts.copts.StatsHandler,
|
||||
}
|
||||
if cc.dopts.cp != nil {
|
||||
cs.cbuf = new(bytes.Buffer)
|
||||
@ -281,7 +283,8 @@ type clientStream struct {
|
||||
// statsCtx keeps the user context for stats handling.
|
||||
// All stats collection should use the statsCtx (instead of the stream context)
|
||||
// so that all the generated stats for a particular RPC can be associated in the processing phase.
|
||||
statsCtx context.Context
|
||||
statsCtx context.Context
|
||||
statsHandler stats.Handler
|
||||
}
|
||||
|
||||
func (cs *clientStream) Context() context.Context {
|
||||
@ -335,7 +338,7 @@ func (cs *clientStream) SendMsg(m interface{}) (err error) {
|
||||
err = toRPCErr(err)
|
||||
}()
|
||||
var outPayload *stats.OutPayload
|
||||
if stats.On() {
|
||||
if cs.statsHandler != nil {
|
||||
outPayload = &stats.OutPayload{
|
||||
Client: true,
|
||||
}
|
||||
@ -352,14 +355,14 @@ func (cs *clientStream) SendMsg(m interface{}) (err error) {
|
||||
err = cs.t.Write(cs.s, out, &transport.Options{Last: false})
|
||||
if err == nil && outPayload != nil {
|
||||
outPayload.SentTime = time.Now()
|
||||
stats.HandleRPC(cs.statsCtx, outPayload)
|
||||
cs.statsHandler.HandleRPC(cs.statsCtx, outPayload)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (cs *clientStream) RecvMsg(m interface{}) (err error) {
|
||||
defer func() {
|
||||
if err != nil && stats.On() {
|
||||
if err != nil && cs.statsHandler != nil {
|
||||
// Only generate End if err != nil.
|
||||
// If err == nil, it's not the last RecvMsg.
|
||||
// The last RecvMsg gets either an RPC error or io.EOF.
|
||||
@ -370,11 +373,11 @@ func (cs *clientStream) RecvMsg(m interface{}) (err error) {
|
||||
if err != io.EOF {
|
||||
end.Error = toRPCErr(err)
|
||||
}
|
||||
stats.HandleRPC(cs.statsCtx, end)
|
||||
cs.statsHandler.HandleRPC(cs.statsCtx, end)
|
||||
}
|
||||
}()
|
||||
var inPayload *stats.InPayload
|
||||
if stats.On() {
|
||||
if cs.statsHandler != nil {
|
||||
inPayload = &stats.InPayload{
|
||||
Client: true,
|
||||
}
|
||||
@ -395,7 +398,7 @@ func (cs *clientStream) RecvMsg(m interface{}) (err error) {
|
||||
cs.mu.Unlock()
|
||||
}
|
||||
if inPayload != nil {
|
||||
stats.HandleRPC(cs.statsCtx, inPayload)
|
||||
cs.statsHandler.HandleRPC(cs.statsCtx, inPayload)
|
||||
}
|
||||
if !cs.desc.ClientStreams || cs.desc.ServerStreams {
|
||||
return
|
||||
@ -520,6 +523,8 @@ type serverStream struct {
|
||||
statusDesc string
|
||||
trInfo *traceInfo
|
||||
|
||||
statsHandler stats.Handler
|
||||
|
||||
mu sync.Mutex // protects trInfo.tr after the service handler runs.
|
||||
}
|
||||
|
||||
@ -562,7 +567,7 @@ func (ss *serverStream) SendMsg(m interface{}) (err error) {
|
||||
}
|
||||
}()
|
||||
var outPayload *stats.OutPayload
|
||||
if stats.On() {
|
||||
if ss.statsHandler != nil {
|
||||
outPayload = &stats.OutPayload{}
|
||||
}
|
||||
out, err := encode(ss.codec, m, ss.cp, ss.cbuf, outPayload)
|
||||
@ -580,7 +585,7 @@ func (ss *serverStream) SendMsg(m interface{}) (err error) {
|
||||
}
|
||||
if outPayload != nil {
|
||||
outPayload.SentTime = time.Now()
|
||||
stats.HandleRPC(ss.s.Context(), outPayload)
|
||||
ss.statsHandler.HandleRPC(ss.s.Context(), outPayload)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -601,7 +606,7 @@ func (ss *serverStream) RecvMsg(m interface{}) (err error) {
|
||||
}
|
||||
}()
|
||||
var inPayload *stats.InPayload
|
||||
if stats.On() {
|
||||
if ss.statsHandler != nil {
|
||||
inPayload = &stats.InPayload{}
|
||||
}
|
||||
if err := recv(ss.p, ss.codec, ss.s, ss.dc, m, ss.maxMsgSize, inPayload); err != nil {
|
||||
@ -614,7 +619,7 @@ func (ss *serverStream) RecvMsg(m interface{}) (err error) {
|
||||
return toRPCErr(err)
|
||||
}
|
||||
if inPayload != nil {
|
||||
stats.HandleRPC(ss.s.Context(), inPayload)
|
||||
ss.statsHandler.HandleRPC(ss.s.Context(), inPayload)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
23
vendor/google.golang.org/grpc/transport/http2_client.go
generated
vendored
23
vendor/google.golang.org/grpc/transport/http2_client.go
generated
vendored
@ -99,6 +99,8 @@ type http2Client struct {
|
||||
|
||||
creds []credentials.PerRPCCredentials
|
||||
|
||||
statsHandler stats.Handler
|
||||
|
||||
mu sync.Mutex // guard the following variables
|
||||
state transportState // the state of underlying connection
|
||||
activeStreams map[uint32]*Stream
|
||||
@ -208,16 +210,17 @@ func newHTTP2Client(ctx context.Context, addr TargetInfo, opts ConnectOptions) (
|
||||
creds: opts.PerRPCCredentials,
|
||||
maxStreams: math.MaxInt32,
|
||||
streamSendQuota: defaultWindowSize,
|
||||
statsHandler: opts.StatsHandler,
|
||||
}
|
||||
if stats.On() {
|
||||
t.ctx = stats.TagConn(t.ctx, &stats.ConnTagInfo{
|
||||
if t.statsHandler != nil {
|
||||
t.ctx = t.statsHandler.TagConn(t.ctx, &stats.ConnTagInfo{
|
||||
RemoteAddr: t.remoteAddr,
|
||||
LocalAddr: t.localAddr,
|
||||
})
|
||||
connBegin := &stats.ConnBegin{
|
||||
Client: true,
|
||||
}
|
||||
stats.HandleConn(t.ctx, connBegin)
|
||||
t.statsHandler.HandleConn(t.ctx, connBegin)
|
||||
}
|
||||
// Start the reader goroutine for incoming message. Each transport has
|
||||
// a dedicated goroutine which reads HTTP2 frame from network. Then it
|
||||
@ -470,7 +473,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Strea
|
||||
return nil, connectionErrorf(true, err, "transport: %v", err)
|
||||
}
|
||||
}
|
||||
if stats.On() {
|
||||
if t.statsHandler != nil {
|
||||
outHeader := &stats.OutHeader{
|
||||
Client: true,
|
||||
WireLength: bufLen,
|
||||
@ -479,7 +482,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (_ *Strea
|
||||
LocalAddr: t.localAddr,
|
||||
Compression: callHdr.SendCompress,
|
||||
}
|
||||
stats.HandleRPC(s.clientStatsCtx, outHeader)
|
||||
t.statsHandler.HandleRPC(s.clientStatsCtx, outHeader)
|
||||
}
|
||||
t.writableChan <- 0
|
||||
return s, nil
|
||||
@ -559,11 +562,11 @@ func (t *http2Client) Close() (err error) {
|
||||
s.mu.Unlock()
|
||||
s.write(recvMsg{err: ErrConnClosing})
|
||||
}
|
||||
if stats.On() {
|
||||
if t.statsHandler != nil {
|
||||
connEnd := &stats.ConnEnd{
|
||||
Client: true,
|
||||
}
|
||||
stats.HandleConn(t.ctx, connEnd)
|
||||
t.statsHandler.HandleConn(t.ctx, connEnd)
|
||||
}
|
||||
return
|
||||
}
|
||||
@ -911,19 +914,19 @@ func (t *http2Client) operateHeaders(frame *http2.MetaHeadersFrame) {
|
||||
endStream := frame.StreamEnded()
|
||||
var isHeader bool
|
||||
defer func() {
|
||||
if stats.On() {
|
||||
if t.statsHandler != nil {
|
||||
if isHeader {
|
||||
inHeader := &stats.InHeader{
|
||||
Client: true,
|
||||
WireLength: int(frame.Header().Length),
|
||||
}
|
||||
stats.HandleRPC(s.clientStatsCtx, inHeader)
|
||||
t.statsHandler.HandleRPC(s.clientStatsCtx, inHeader)
|
||||
} else {
|
||||
inTrailer := &stats.InTrailer{
|
||||
Client: true,
|
||||
WireLength: int(frame.Header().Length),
|
||||
}
|
||||
stats.HandleRPC(s.clientStatsCtx, inTrailer)
|
||||
t.statsHandler.HandleRPC(s.clientStatsCtx, inTrailer)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
27
vendor/google.golang.org/grpc/transport/http2_server.go
generated
vendored
27
vendor/google.golang.org/grpc/transport/http2_server.go
generated
vendored
@ -88,6 +88,8 @@ type http2Server struct {
|
||||
// sendQuotaPool provides flow control to outbound message.
|
||||
sendQuotaPool *quotaPool
|
||||
|
||||
stats stats.Handler
|
||||
|
||||
mu sync.Mutex // guard the following
|
||||
state transportState
|
||||
activeStreams map[uint32]*Stream
|
||||
@ -146,14 +148,15 @@ func newHTTP2Server(conn net.Conn, config *ServerConfig) (_ ServerTransport, err
|
||||
shutdownChan: make(chan struct{}),
|
||||
activeStreams: make(map[uint32]*Stream),
|
||||
streamSendQuota: defaultWindowSize,
|
||||
stats: config.StatsHandler,
|
||||
}
|
||||
if stats.On() {
|
||||
t.ctx = stats.TagConn(t.ctx, &stats.ConnTagInfo{
|
||||
if t.stats != nil {
|
||||
t.ctx = t.stats.TagConn(t.ctx, &stats.ConnTagInfo{
|
||||
RemoteAddr: t.remoteAddr,
|
||||
LocalAddr: t.localAddr,
|
||||
})
|
||||
connBegin := &stats.ConnBegin{}
|
||||
stats.HandleConn(t.ctx, connBegin)
|
||||
t.stats.HandleConn(t.ctx, connBegin)
|
||||
}
|
||||
go t.controller()
|
||||
t.writableChan <- 0
|
||||
@ -250,8 +253,8 @@ func (t *http2Server) operateHeaders(frame *http2.MetaHeadersFrame, handle func(
|
||||
t.updateWindow(s, uint32(n))
|
||||
}
|
||||
s.ctx = traceCtx(s.ctx, s.method)
|
||||
if stats.On() {
|
||||
s.ctx = stats.TagRPC(s.ctx, &stats.RPCTagInfo{FullMethodName: s.method})
|
||||
if t.stats != nil {
|
||||
s.ctx = t.stats.TagRPC(s.ctx, &stats.RPCTagInfo{FullMethodName: s.method})
|
||||
inHeader := &stats.InHeader{
|
||||
FullMethod: s.method,
|
||||
RemoteAddr: t.remoteAddr,
|
||||
@ -259,7 +262,7 @@ func (t *http2Server) operateHeaders(frame *http2.MetaHeadersFrame, handle func(
|
||||
Compression: s.recvCompress,
|
||||
WireLength: int(frame.Header().Length),
|
||||
}
|
||||
stats.HandleRPC(s.ctx, inHeader)
|
||||
t.stats.HandleRPC(s.ctx, inHeader)
|
||||
}
|
||||
handle(s)
|
||||
return
|
||||
@ -540,11 +543,11 @@ func (t *http2Server) WriteHeader(s *Stream, md metadata.MD) error {
|
||||
if err := t.writeHeaders(s, t.hBuf, false); err != nil {
|
||||
return err
|
||||
}
|
||||
if stats.On() {
|
||||
if t.stats != nil {
|
||||
outHeader := &stats.OutHeader{
|
||||
WireLength: bufLen,
|
||||
}
|
||||
stats.HandleRPC(s.Context(), outHeader)
|
||||
t.stats.HandleRPC(s.Context(), outHeader)
|
||||
}
|
||||
t.writableChan <- 0
|
||||
return nil
|
||||
@ -603,11 +606,11 @@ func (t *http2Server) WriteStatus(s *Stream, statusCode codes.Code, statusDesc s
|
||||
t.Close()
|
||||
return err
|
||||
}
|
||||
if stats.On() {
|
||||
if t.stats != nil {
|
||||
outTrailer := &stats.OutTrailer{
|
||||
WireLength: bufLen,
|
||||
}
|
||||
stats.HandleRPC(s.Context(), outTrailer)
|
||||
t.stats.HandleRPC(s.Context(), outTrailer)
|
||||
}
|
||||
t.closeStream(s)
|
||||
t.writableChan <- 0
|
||||
@ -789,9 +792,9 @@ func (t *http2Server) Close() (err error) {
|
||||
for _, s := range streams {
|
||||
s.cancel()
|
||||
}
|
||||
if stats.On() {
|
||||
if t.stats != nil {
|
||||
connEnd := &stats.ConnEnd{}
|
||||
stats.HandleConn(t.ctx, connEnd)
|
||||
t.stats.HandleConn(t.ctx, connEnd)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
13
vendor/google.golang.org/grpc/transport/transport.go
generated
vendored
13
vendor/google.golang.org/grpc/transport/transport.go
generated
vendored
@ -48,6 +48,7 @@ import (
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/credentials"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/stats"
|
||||
"google.golang.org/grpc/tap"
|
||||
)
|
||||
|
||||
@ -357,9 +358,10 @@ const (
|
||||
|
||||
// ServerConfig consists of all the configurations to establish a server transport.
|
||||
type ServerConfig struct {
|
||||
MaxStreams uint32
|
||||
AuthInfo credentials.AuthInfo
|
||||
InTapHandle tap.ServerInHandle
|
||||
MaxStreams uint32
|
||||
AuthInfo credentials.AuthInfo
|
||||
InTapHandle tap.ServerInHandle
|
||||
StatsHandler stats.Handler
|
||||
}
|
||||
|
||||
// NewServerTransport creates a ServerTransport with conn or non-nil error
|
||||
@ -372,6 +374,9 @@ func NewServerTransport(protocol string, conn net.Conn, config *ServerConfig) (S
|
||||
type ConnectOptions struct {
|
||||
// UserAgent is the application user agent.
|
||||
UserAgent string
|
||||
// Authority is the :authority pseudo-header to use. This field has no effect if
|
||||
// TransportCredentials is set.
|
||||
Authority string
|
||||
// Dialer specifies how to dial a network address.
|
||||
Dialer func(context.Context, string) (net.Conn, error)
|
||||
// FailOnNonTempDialError specifies if gRPC fails on non-temporary dial errors.
|
||||
@ -380,6 +385,8 @@ type ConnectOptions struct {
|
||||
PerRPCCredentials []credentials.PerRPCCredentials
|
||||
// TransportCredentials stores the Authenticator required to setup a client connection.
|
||||
TransportCredentials credentials.TransportCredentials
|
||||
// StatsHandler stores the handler for stats.
|
||||
StatsHandler stats.Handler
|
||||
}
|
||||
|
||||
// TargetInfo contains the information of the target such as network address and metadata.
|
||||
|
Reference in New Issue
Block a user