Bye bye openapi (#1081)

* add DateTime sans mgo

* change all uses of strfmt.DateTime to common.DateTime, remove test strfmt usage

* remove api tests, system-test dep on api test

multiple reasons to remove the api tests:

* awkward dependency with fn_go meant generating bindings on a branched fn to
vendor those to test new stuff. this is at a minimum not at all intuitive,
worth it, nor a fun way to spend the finite amount of time we have to live.
* api tests only tested a subset of functionality that the server/ api tests
already test, and we risk having tests where one tests some thing and the
other doesn't. let's not. we have too many test suites as it is, and these
pretty much only test that we updated the fn_go bindings, which is actually a
hassle as noted above and the cli will pretty quickly figure out anyway.
* fn_go relies on openapi, which relies on mgo, which is deprecated and we'd
like to remove as a dependency. openapi is a _huge_ dep built in a NIH
fashion, that cannot simply remove the mgo dep as users may be using it.
we've now stolen their date time and otherwise killed usage of it in fn core,
for fn_go it still exists but that's less of a problem.

* update deps

removals:

* easyjson
* mgo
* go-openapi
* mapstructure
* fn_go
* purell
* go-validator

also, had to lock docker. we shouldn't use docker on master anyway, they
strongly advise against that. had no luck with latest version rev, so i locked
it to what we were using before. until next time.

the rest is just playing dep roulette, those end up removing a ton tho

* fix exec test to work

* account for john le cache
This commit is contained in:
Reed Allman
2018-06-21 11:09:16 -07:00
committed by GitHub
parent aa5d7169f4
commit 51ff7caeb2
2635 changed files with 440440 additions and 402994 deletions

View File

@@ -3,7 +3,7 @@
"baseUrl": "https://chat.googleapis.com/",
"batchPath": "batch",
"canonicalName": "Hangouts Chat",
"description": "Create bots and extend the new Hangouts Chat.",
"description": "Enables bots to fetch information and perform actions in Hangouts Chat.",
"discoveryVersion": "v1",
"documentationLink": "https://developers.google.com/hangouts/chat",
"fullyEncodeReservedExpansion": true,
@@ -51,11 +51,6 @@
"location": "query",
"type": "string"
},
"bearer_token": {
"description": "OAuth bearer token.",
"location": "query",
"type": "string"
},
"callback": {
"description": "JSONP",
"location": "query",
@@ -76,12 +71,6 @@
"location": "query",
"type": "string"
},
"pp": {
"default": "true",
"description": "Pretty-print response.",
"location": "query",
"type": "boolean"
},
"prettyPrint": {
"default": "true",
"description": "Returns response with indentations and line breaks.",
@@ -106,158 +95,6 @@
},
"protocol": "rest",
"resources": {
"dms": {
"resources": {
"conversations": {
"resources": {
"messages": {
"methods": {
"create": {
"description": "Creates a message.",
"flatPath": "v1/dms/{dmsId}/conversations/{conversationsId}/messages",
"httpMethod": "POST",
"id": "chat.dms.conversations.messages.create",
"parameterOrder": [
"parent"
],
"parameters": {
"parent": {
"description": "Required. Space resource name, in the form \"spaces/*\".\nExample: spaces/AAAAMpdlehY",
"location": "path",
"pattern": "^dms/[^/]+/conversations/[^/]+$",
"required": true,
"type": "string"
},
"threadKey": {
"description": "Opaque thread identifier string that can be specified to group messages\ninto a single thread. If this is the first message with a given thread\nidentifier, a new thread is created. Subsequent messages with the same\nthread identifier will be posted into the same thread. This relieves bots\nand webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post\nfurther updates to it.\n\nHas no effect if thread field,\ncorresponding to an existing thread, is set in message.",
"location": "query",
"type": "string"
}
},
"path": "v1/{+parent}/messages",
"request": {
"$ref": "Message"
},
"response": {
"$ref": "Message"
}
}
}
}
}
},
"messages": {
"methods": {
"create": {
"description": "Creates a message.",
"flatPath": "v1/dms/{dmsId}/messages",
"httpMethod": "POST",
"id": "chat.dms.messages.create",
"parameterOrder": [
"parent"
],
"parameters": {
"parent": {
"description": "Required. Space resource name, in the form \"spaces/*\".\nExample: spaces/AAAAMpdlehY",
"location": "path",
"pattern": "^dms/[^/]+$",
"required": true,
"type": "string"
},
"threadKey": {
"description": "Opaque thread identifier string that can be specified to group messages\ninto a single thread. If this is the first message with a given thread\nidentifier, a new thread is created. Subsequent messages with the same\nthread identifier will be posted into the same thread. This relieves bots\nand webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post\nfurther updates to it.\n\nHas no effect if thread field,\ncorresponding to an existing thread, is set in message.",
"location": "query",
"type": "string"
}
},
"path": "v1/{+parent}/messages",
"request": {
"$ref": "Message"
},
"response": {
"$ref": "Message"
}
}
}
}
}
},
"rooms": {
"resources": {
"conversations": {
"resources": {
"messages": {
"methods": {
"create": {
"description": "Creates a message.",
"flatPath": "v1/rooms/{roomsId}/conversations/{conversationsId}/messages",
"httpMethod": "POST",
"id": "chat.rooms.conversations.messages.create",
"parameterOrder": [
"parent"
],
"parameters": {
"parent": {
"description": "Required. Space resource name, in the form \"spaces/*\".\nExample: spaces/AAAAMpdlehY",
"location": "path",
"pattern": "^rooms/[^/]+/conversations/[^/]+$",
"required": true,
"type": "string"
},
"threadKey": {
"description": "Opaque thread identifier string that can be specified to group messages\ninto a single thread. If this is the first message with a given thread\nidentifier, a new thread is created. Subsequent messages with the same\nthread identifier will be posted into the same thread. This relieves bots\nand webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post\nfurther updates to it.\n\nHas no effect if thread field,\ncorresponding to an existing thread, is set in message.",
"location": "query",
"type": "string"
}
},
"path": "v1/{+parent}/messages",
"request": {
"$ref": "Message"
},
"response": {
"$ref": "Message"
}
}
}
}
}
},
"messages": {
"methods": {
"create": {
"description": "Creates a message.",
"flatPath": "v1/rooms/{roomsId}/messages",
"httpMethod": "POST",
"id": "chat.rooms.messages.create",
"parameterOrder": [
"parent"
],
"parameters": {
"parent": {
"description": "Required. Space resource name, in the form \"spaces/*\".\nExample: spaces/AAAAMpdlehY",
"location": "path",
"pattern": "^rooms/[^/]+$",
"required": true,
"type": "string"
},
"threadKey": {
"description": "Opaque thread identifier string that can be specified to group messages\ninto a single thread. If this is the first message with a given thread\nidentifier, a new thread is created. Subsequent messages with the same\nthread identifier will be posted into the same thread. This relieves bots\nand webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post\nfurther updates to it.\n\nHas no effect if thread field,\ncorresponding to an existing thread, is set in message.",
"location": "query",
"type": "string"
}
},
"path": "v1/{+parent}/messages",
"request": {
"$ref": "Message"
},
"response": {
"$ref": "Message"
}
}
}
}
}
},
"spaces": {
"methods": {
"get": {
@@ -479,7 +316,7 @@
}
}
},
"revision": "20180321",
"revision": "20180606",
"rootUrl": "https://chat.googleapis.com/",
"schemas": {
"ActionParameter": {
@@ -648,6 +485,64 @@
},
"type": "object"
},
"DeprecatedEvent": {
"description": "Hangouts Chat events.",
"id": "DeprecatedEvent",
"properties": {
"action": {
"$ref": "FormAction",
"description": "The form action data associated with an interactive card that was clicked.\nOnly populated for\nCARD_CLICKED events.\nSee the [Interactive Cards guide](/hangouts/chat/how-tos/cards-onclick) for\nmore information."
},
"configCompleteRedirectUrl": {
"description": "The URL the bot should redirect the user to after they have completed an\nauthorization or configuration flow outside of Hangouts Chat. See the\n[Authorizing access to 3p services guide](/hangouts/chat/how-tos/auth-3p)\nfor more information.",
"type": "string"
},
"eventTime": {
"description": "The timestamp indicating when the event was dispatched.",
"format": "google-datetime",
"type": "string"
},
"message": {
"$ref": "Message",
"description": "The message that triggered the event."
},
"space": {
"$ref": "Space",
"description": "The room or DM in which the event occurred."
},
"threadKey": {
"description": "The bot-defined key for the thread related to the event. See the\nthread_key field of the\n`spaces.message.create` request for more information.",
"type": "string"
},
"token": {
"description": "A secret value that bots can use to verify if a request is from Google. The\ntoken is randomly generated by Google, remains static, and can be obtained\nfrom the Hangouts Chat API configuration page in the Cloud Console.\nDevelopers can revoke/regenerate it if needed from the same page.",
"type": "string"
},
"type": {
"description": "The type of the event.",
"enum": [
"UNSPECIFIED",
"MESSAGE",
"ADDED_TO_SPACE",
"REMOVED_FROM_SPACE",
"CARD_CLICKED"
],
"enumDescriptions": [
"Default value for the enum. DO NOT USE.",
"A message was sent in a room or direct message.",
"The bot was added to a room or DM.",
"The bot was removed from a room or DM.",
"The bot's interactive card was clicked."
],
"type": "string"
},
"user": {
"$ref": "User",
"description": "The user that triggered the event."
}
},
"type": "object"
},
"Empty": {
"description": "A generic empty message that you can re-use to avoid defining duplicated\nempty messages in your APIs. A typical example is to use it as the request\nor the response type of an API method. For instance:\n\n service Foo {\n rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);\n }\n\nThe JSON representation for `Empty` is empty JSON object `{}`.",
"id": "Empty",
@@ -971,6 +866,10 @@
},
"type": "array"
},
"argumentText": {
"description": "Plain-text body of the message with all bot mentions stripped out.",
"type": "string"
},
"cards": {
"description": "Rich, formatted and interactive cards that can be used to display UI\nelements such as: formatted texts, buttons, clickable images. Cards are\nnormally displayed below the plain-text body of the message.",
"items": {

View File

@@ -50,8 +50,6 @@ func New(client *http.Client) (*Service, error) {
return nil, errors.New("client is nil")
}
s := &Service{client: client, BasePath: basePath}
s.Dms = NewDmsService(s)
s.Rooms = NewRoomsService(s)
s.Spaces = NewSpacesService(s)
return s, nil
}
@@ -61,10 +59,6 @@ type Service struct {
BasePath string // API endpoint base URL
UserAgent string // optional additional User-Agent fragment
Dms *DmsService
Rooms *RoomsService
Spaces *SpacesService
}
@@ -75,96 +69,6 @@ func (s *Service) userAgent() string {
return googleapi.UserAgent + " " + s.UserAgent
}
func NewDmsService(s *Service) *DmsService {
rs := &DmsService{s: s}
rs.Conversations = NewDmsConversationsService(s)
rs.Messages = NewDmsMessagesService(s)
return rs
}
type DmsService struct {
s *Service
Conversations *DmsConversationsService
Messages *DmsMessagesService
}
func NewDmsConversationsService(s *Service) *DmsConversationsService {
rs := &DmsConversationsService{s: s}
rs.Messages = NewDmsConversationsMessagesService(s)
return rs
}
type DmsConversationsService struct {
s *Service
Messages *DmsConversationsMessagesService
}
func NewDmsConversationsMessagesService(s *Service) *DmsConversationsMessagesService {
rs := &DmsConversationsMessagesService{s: s}
return rs
}
type DmsConversationsMessagesService struct {
s *Service
}
func NewDmsMessagesService(s *Service) *DmsMessagesService {
rs := &DmsMessagesService{s: s}
return rs
}
type DmsMessagesService struct {
s *Service
}
func NewRoomsService(s *Service) *RoomsService {
rs := &RoomsService{s: s}
rs.Conversations = NewRoomsConversationsService(s)
rs.Messages = NewRoomsMessagesService(s)
return rs
}
type RoomsService struct {
s *Service
Conversations *RoomsConversationsService
Messages *RoomsMessagesService
}
func NewRoomsConversationsService(s *Service) *RoomsConversationsService {
rs := &RoomsConversationsService{s: s}
rs.Messages = NewRoomsConversationsMessagesService(s)
return rs
}
type RoomsConversationsService struct {
s *Service
Messages *RoomsConversationsMessagesService
}
func NewRoomsConversationsMessagesService(s *Service) *RoomsConversationsMessagesService {
rs := &RoomsConversationsMessagesService{s: s}
return rs
}
type RoomsConversationsMessagesService struct {
s *Service
}
func NewRoomsMessagesService(s *Service) *RoomsMessagesService {
rs := &RoomsMessagesService{s: s}
return rs
}
type RoomsMessagesService struct {
s *Service
}
func NewSpacesService(s *Service) *SpacesService {
rs := &SpacesService{s: s}
rs.Members = NewSpacesMembersService(s)
@@ -496,6 +400,86 @@ func (s *CardHeader) MarshalJSON() ([]byte, error) {
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// DeprecatedEvent: Hangouts Chat events.
type DeprecatedEvent struct {
// Action: The form action data associated with an interactive card that
// was clicked.
// Only populated for
// CARD_CLICKED events.
// See the [Interactive Cards
// guide](/hangouts/chat/how-tos/cards-onclick) for
// more information.
Action *FormAction `json:"action,omitempty"`
// ConfigCompleteRedirectUrl: The URL the bot should redirect the user
// to after they have completed an
// authorization or configuration flow outside of Hangouts Chat. See
// the
// [Authorizing access to 3p services
// guide](/hangouts/chat/how-tos/auth-3p)
// for more information.
ConfigCompleteRedirectUrl string `json:"configCompleteRedirectUrl,omitempty"`
// EventTime: The timestamp indicating when the event was dispatched.
EventTime string `json:"eventTime,omitempty"`
// Message: The message that triggered the event.
Message *Message `json:"message,omitempty"`
// Space: The room or DM in which the event occurred.
Space *Space `json:"space,omitempty"`
// ThreadKey: The bot-defined key for the thread related to the event.
// See the
// thread_key field of the
// `spaces.message.create` request for more information.
ThreadKey string `json:"threadKey,omitempty"`
// Token: A secret value that bots can use to verify if a request is
// from Google. The
// token is randomly generated by Google, remains static, and can be
// obtained
// from the Hangouts Chat API configuration page in the Cloud
// Console.
// Developers can revoke/regenerate it if needed from the same page.
Token string `json:"token,omitempty"`
// Type: The type of the event.
//
// Possible values:
// "UNSPECIFIED" - Default value for the enum. DO NOT USE.
// "MESSAGE" - A message was sent in a room or direct message.
// "ADDED_TO_SPACE" - The bot was added to a room or DM.
// "REMOVED_FROM_SPACE" - The bot was removed from a room or DM.
// "CARD_CLICKED" - The bot's interactive card was clicked.
Type string `json:"type,omitempty"`
// User: The user that triggered the event.
User *User `json:"user,omitempty"`
// ForceSendFields is a list of field names (e.g. "Action") 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. "Action") 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 *DeprecatedEvent) MarshalJSON() ([]byte, error) {
type NoMethod DeprecatedEvent
raw := NoMethod(*s)
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// Empty: A generic empty message that you can re-use to avoid defining
// duplicated
// empty messages in your APIs. A typical example is to use it as the
@@ -903,6 +887,10 @@ type Message struct {
// this message.
Annotations []*Annotation `json:"annotations,omitempty"`
// ArgumentText: Plain-text body of the message with all bot mentions
// stripped out.
ArgumentText string `json:"argumentText,omitempty"`
// Cards: Rich, formatted and interactive cards that can be used to
// display UI
// elements such as: formatted texts, buttons, clickable images. Cards
@@ -1316,630 +1304,6 @@ func (s *WidgetMarkup) MarshalJSON() ([]byte, error) {
return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
}
// method id "chat.dms.conversations.messages.create":
type DmsConversationsMessagesCreateCall struct {
s *Service
parent string
message *Message
urlParams_ gensupport.URLParams
ctx_ context.Context
header_ http.Header
}
// Create: Creates a message.
func (r *DmsConversationsMessagesService) Create(parent string, message *Message) *DmsConversationsMessagesCreateCall {
c := &DmsConversationsMessagesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
c.parent = parent
c.message = message
return c
}
// ThreadKey sets the optional parameter "threadKey": Opaque thread
// identifier string that can be specified to group messages
// into a single thread. If this is the first message with a given
// thread
// identifier, a new thread is created. Subsequent messages with the
// same
// thread identifier will be posted into the same thread. This relieves
// bots
// and webhooks from having to store the Hangouts Chat thread ID of a
// thread (created earlier by them) to post
// further updates to it.
//
// Has no effect if thread field,
// corresponding to an existing thread, is set in message.
func (c *DmsConversationsMessagesCreateCall) ThreadKey(threadKey string) *DmsConversationsMessagesCreateCall {
c.urlParams_.Set("threadKey", threadKey)
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 *DmsConversationsMessagesCreateCall) Fields(s ...googleapi.Field) *DmsConversationsMessagesCreateCall {
c.urlParams_.Set("fields", googleapi.CombineFields(s))
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 *DmsConversationsMessagesCreateCall) Context(ctx context.Context) *DmsConversationsMessagesCreateCall {
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 *DmsConversationsMessagesCreateCall) Header() http.Header {
if c.header_ == nil {
c.header_ = make(http.Header)
}
return c.header_
}
func (c *DmsConversationsMessagesCreateCall) 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())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.message)
if err != nil {
return nil, err
}
reqHeaders.Set("Content-Type", "application/json")
c.urlParams_.Set("alt", alt)
urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/messages")
urls += "?" + c.urlParams_.Encode()
req, _ := http.NewRequest("POST", urls, body)
req.Header = reqHeaders
googleapi.Expand(req.URL, map[string]string{
"parent": c.parent,
})
return gensupport.SendRequest(c.ctx_, c.s.client, req)
}
// Do executes the "chat.dms.conversations.messages.create" call.
// Exactly one of *Message or error will be non-nil. Any non-2xx status
// code is an error. Response headers are in either
// *Message.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 *DmsConversationsMessagesCreateCall) Do(opts ...googleapi.CallOption) (*Message, 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 := &Message{
ServerResponse: googleapi.ServerResponse{
Header: res.Header,
HTTPStatusCode: res.StatusCode,
},
}
target := &ret
if err := gensupport.DecodeResponse(target, res); err != nil {
return nil, err
}
return ret, nil
// {
// "description": "Creates a message.",
// "flatPath": "v1/dms/{dmsId}/conversations/{conversationsId}/messages",
// "httpMethod": "POST",
// "id": "chat.dms.conversations.messages.create",
// "parameterOrder": [
// "parent"
// ],
// "parameters": {
// "parent": {
// "description": "Required. Space resource name, in the form \"spaces/*\".\nExample: spaces/AAAAMpdlehY",
// "location": "path",
// "pattern": "^dms/[^/]+/conversations/[^/]+$",
// "required": true,
// "type": "string"
// },
// "threadKey": {
// "description": "Opaque thread identifier string that can be specified to group messages\ninto a single thread. If this is the first message with a given thread\nidentifier, a new thread is created. Subsequent messages with the same\nthread identifier will be posted into the same thread. This relieves bots\nand webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post\nfurther updates to it.\n\nHas no effect if thread field,\ncorresponding to an existing thread, is set in message.",
// "location": "query",
// "type": "string"
// }
// },
// "path": "v1/{+parent}/messages",
// "request": {
// "$ref": "Message"
// },
// "response": {
// "$ref": "Message"
// }
// }
}
// method id "chat.dms.messages.create":
type DmsMessagesCreateCall struct {
s *Service
parent string
message *Message
urlParams_ gensupport.URLParams
ctx_ context.Context
header_ http.Header
}
// Create: Creates a message.
func (r *DmsMessagesService) Create(parent string, message *Message) *DmsMessagesCreateCall {
c := &DmsMessagesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
c.parent = parent
c.message = message
return c
}
// ThreadKey sets the optional parameter "threadKey": Opaque thread
// identifier string that can be specified to group messages
// into a single thread. If this is the first message with a given
// thread
// identifier, a new thread is created. Subsequent messages with the
// same
// thread identifier will be posted into the same thread. This relieves
// bots
// and webhooks from having to store the Hangouts Chat thread ID of a
// thread (created earlier by them) to post
// further updates to it.
//
// Has no effect if thread field,
// corresponding to an existing thread, is set in message.
func (c *DmsMessagesCreateCall) ThreadKey(threadKey string) *DmsMessagesCreateCall {
c.urlParams_.Set("threadKey", threadKey)
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 *DmsMessagesCreateCall) Fields(s ...googleapi.Field) *DmsMessagesCreateCall {
c.urlParams_.Set("fields", googleapi.CombineFields(s))
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 *DmsMessagesCreateCall) Context(ctx context.Context) *DmsMessagesCreateCall {
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 *DmsMessagesCreateCall) Header() http.Header {
if c.header_ == nil {
c.header_ = make(http.Header)
}
return c.header_
}
func (c *DmsMessagesCreateCall) 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())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.message)
if err != nil {
return nil, err
}
reqHeaders.Set("Content-Type", "application/json")
c.urlParams_.Set("alt", alt)
urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/messages")
urls += "?" + c.urlParams_.Encode()
req, _ := http.NewRequest("POST", urls, body)
req.Header = reqHeaders
googleapi.Expand(req.URL, map[string]string{
"parent": c.parent,
})
return gensupport.SendRequest(c.ctx_, c.s.client, req)
}
// Do executes the "chat.dms.messages.create" call.
// Exactly one of *Message or error will be non-nil. Any non-2xx status
// code is an error. Response headers are in either
// *Message.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 *DmsMessagesCreateCall) Do(opts ...googleapi.CallOption) (*Message, 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 := &Message{
ServerResponse: googleapi.ServerResponse{
Header: res.Header,
HTTPStatusCode: res.StatusCode,
},
}
target := &ret
if err := gensupport.DecodeResponse(target, res); err != nil {
return nil, err
}
return ret, nil
// {
// "description": "Creates a message.",
// "flatPath": "v1/dms/{dmsId}/messages",
// "httpMethod": "POST",
// "id": "chat.dms.messages.create",
// "parameterOrder": [
// "parent"
// ],
// "parameters": {
// "parent": {
// "description": "Required. Space resource name, in the form \"spaces/*\".\nExample: spaces/AAAAMpdlehY",
// "location": "path",
// "pattern": "^dms/[^/]+$",
// "required": true,
// "type": "string"
// },
// "threadKey": {
// "description": "Opaque thread identifier string that can be specified to group messages\ninto a single thread. If this is the first message with a given thread\nidentifier, a new thread is created. Subsequent messages with the same\nthread identifier will be posted into the same thread. This relieves bots\nand webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post\nfurther updates to it.\n\nHas no effect if thread field,\ncorresponding to an existing thread, is set in message.",
// "location": "query",
// "type": "string"
// }
// },
// "path": "v1/{+parent}/messages",
// "request": {
// "$ref": "Message"
// },
// "response": {
// "$ref": "Message"
// }
// }
}
// method id "chat.rooms.conversations.messages.create":
type RoomsConversationsMessagesCreateCall struct {
s *Service
parent string
message *Message
urlParams_ gensupport.URLParams
ctx_ context.Context
header_ http.Header
}
// Create: Creates a message.
func (r *RoomsConversationsMessagesService) Create(parent string, message *Message) *RoomsConversationsMessagesCreateCall {
c := &RoomsConversationsMessagesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
c.parent = parent
c.message = message
return c
}
// ThreadKey sets the optional parameter "threadKey": Opaque thread
// identifier string that can be specified to group messages
// into a single thread. If this is the first message with a given
// thread
// identifier, a new thread is created. Subsequent messages with the
// same
// thread identifier will be posted into the same thread. This relieves
// bots
// and webhooks from having to store the Hangouts Chat thread ID of a
// thread (created earlier by them) to post
// further updates to it.
//
// Has no effect if thread field,
// corresponding to an existing thread, is set in message.
func (c *RoomsConversationsMessagesCreateCall) ThreadKey(threadKey string) *RoomsConversationsMessagesCreateCall {
c.urlParams_.Set("threadKey", threadKey)
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 *RoomsConversationsMessagesCreateCall) Fields(s ...googleapi.Field) *RoomsConversationsMessagesCreateCall {
c.urlParams_.Set("fields", googleapi.CombineFields(s))
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 *RoomsConversationsMessagesCreateCall) Context(ctx context.Context) *RoomsConversationsMessagesCreateCall {
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 *RoomsConversationsMessagesCreateCall) Header() http.Header {
if c.header_ == nil {
c.header_ = make(http.Header)
}
return c.header_
}
func (c *RoomsConversationsMessagesCreateCall) 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())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.message)
if err != nil {
return nil, err
}
reqHeaders.Set("Content-Type", "application/json")
c.urlParams_.Set("alt", alt)
urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/messages")
urls += "?" + c.urlParams_.Encode()
req, _ := http.NewRequest("POST", urls, body)
req.Header = reqHeaders
googleapi.Expand(req.URL, map[string]string{
"parent": c.parent,
})
return gensupport.SendRequest(c.ctx_, c.s.client, req)
}
// Do executes the "chat.rooms.conversations.messages.create" call.
// Exactly one of *Message or error will be non-nil. Any non-2xx status
// code is an error. Response headers are in either
// *Message.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 *RoomsConversationsMessagesCreateCall) Do(opts ...googleapi.CallOption) (*Message, 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 := &Message{
ServerResponse: googleapi.ServerResponse{
Header: res.Header,
HTTPStatusCode: res.StatusCode,
},
}
target := &ret
if err := gensupport.DecodeResponse(target, res); err != nil {
return nil, err
}
return ret, nil
// {
// "description": "Creates a message.",
// "flatPath": "v1/rooms/{roomsId}/conversations/{conversationsId}/messages",
// "httpMethod": "POST",
// "id": "chat.rooms.conversations.messages.create",
// "parameterOrder": [
// "parent"
// ],
// "parameters": {
// "parent": {
// "description": "Required. Space resource name, in the form \"spaces/*\".\nExample: spaces/AAAAMpdlehY",
// "location": "path",
// "pattern": "^rooms/[^/]+/conversations/[^/]+$",
// "required": true,
// "type": "string"
// },
// "threadKey": {
// "description": "Opaque thread identifier string that can be specified to group messages\ninto a single thread. If this is the first message with a given thread\nidentifier, a new thread is created. Subsequent messages with the same\nthread identifier will be posted into the same thread. This relieves bots\nand webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post\nfurther updates to it.\n\nHas no effect if thread field,\ncorresponding to an existing thread, is set in message.",
// "location": "query",
// "type": "string"
// }
// },
// "path": "v1/{+parent}/messages",
// "request": {
// "$ref": "Message"
// },
// "response": {
// "$ref": "Message"
// }
// }
}
// method id "chat.rooms.messages.create":
type RoomsMessagesCreateCall struct {
s *Service
parent string
message *Message
urlParams_ gensupport.URLParams
ctx_ context.Context
header_ http.Header
}
// Create: Creates a message.
func (r *RoomsMessagesService) Create(parent string, message *Message) *RoomsMessagesCreateCall {
c := &RoomsMessagesCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
c.parent = parent
c.message = message
return c
}
// ThreadKey sets the optional parameter "threadKey": Opaque thread
// identifier string that can be specified to group messages
// into a single thread. If this is the first message with a given
// thread
// identifier, a new thread is created. Subsequent messages with the
// same
// thread identifier will be posted into the same thread. This relieves
// bots
// and webhooks from having to store the Hangouts Chat thread ID of a
// thread (created earlier by them) to post
// further updates to it.
//
// Has no effect if thread field,
// corresponding to an existing thread, is set in message.
func (c *RoomsMessagesCreateCall) ThreadKey(threadKey string) *RoomsMessagesCreateCall {
c.urlParams_.Set("threadKey", threadKey)
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 *RoomsMessagesCreateCall) Fields(s ...googleapi.Field) *RoomsMessagesCreateCall {
c.urlParams_.Set("fields", googleapi.CombineFields(s))
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 *RoomsMessagesCreateCall) Context(ctx context.Context) *RoomsMessagesCreateCall {
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 *RoomsMessagesCreateCall) Header() http.Header {
if c.header_ == nil {
c.header_ = make(http.Header)
}
return c.header_
}
func (c *RoomsMessagesCreateCall) 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())
var body io.Reader = nil
body, err := googleapi.WithoutDataWrapper.JSONReader(c.message)
if err != nil {
return nil, err
}
reqHeaders.Set("Content-Type", "application/json")
c.urlParams_.Set("alt", alt)
urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/messages")
urls += "?" + c.urlParams_.Encode()
req, _ := http.NewRequest("POST", urls, body)
req.Header = reqHeaders
googleapi.Expand(req.URL, map[string]string{
"parent": c.parent,
})
return gensupport.SendRequest(c.ctx_, c.s.client, req)
}
// Do executes the "chat.rooms.messages.create" call.
// Exactly one of *Message or error will be non-nil. Any non-2xx status
// code is an error. Response headers are in either
// *Message.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 *RoomsMessagesCreateCall) Do(opts ...googleapi.CallOption) (*Message, 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 := &Message{
ServerResponse: googleapi.ServerResponse{
Header: res.Header,
HTTPStatusCode: res.StatusCode,
},
}
target := &ret
if err := gensupport.DecodeResponse(target, res); err != nil {
return nil, err
}
return ret, nil
// {
// "description": "Creates a message.",
// "flatPath": "v1/rooms/{roomsId}/messages",
// "httpMethod": "POST",
// "id": "chat.rooms.messages.create",
// "parameterOrder": [
// "parent"
// ],
// "parameters": {
// "parent": {
// "description": "Required. Space resource name, in the form \"spaces/*\".\nExample: spaces/AAAAMpdlehY",
// "location": "path",
// "pattern": "^rooms/[^/]+$",
// "required": true,
// "type": "string"
// },
// "threadKey": {
// "description": "Opaque thread identifier string that can be specified to group messages\ninto a single thread. If this is the first message with a given thread\nidentifier, a new thread is created. Subsequent messages with the same\nthread identifier will be posted into the same thread. This relieves bots\nand webhooks from having to store the Hangouts Chat thread ID of a thread (created earlier by them) to post\nfurther updates to it.\n\nHas no effect if thread field,\ncorresponding to an existing thread, is set in message.",
// "location": "query",
// "type": "string"
// }
// },
// "path": "v1/{+parent}/messages",
// "request": {
// "$ref": "Message"
// },
// "response": {
// "$ref": "Message"
// }
// }
}
// method id "chat.spaces.get":
type SpacesGetCall struct {