google-api-ruby-client/generated/google/apis/chat_v1/service.rb

345 lines
18 KiB
Ruby
Raw Normal View History

# Copyright 2015 Google Inc.
#
# 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.
require 'google/apis/core/base_service'
require 'google/apis/core/json_representation'
require 'google/apis/core/hashable'
require 'google/apis/errors'
module Google
module Apis
module ChatV1
# Hangouts Chat API
#
# Enables bots to fetch information and perform actions in the new Hangouts Chat.
#
# @example
# require 'google/apis/chat_v1'
#
# Chat = Google::Apis::ChatV1 # Alias the module
# service = Chat::HangoutsChatService.new
#
# @see https://developers.google.com/hangouts/chat
class HangoutsChatService < Google::Apis::Core::BaseService
# @return [String]
# API key. Your API key identifies your project and provides you with API access,
# quota, and reports. Required unless you provide an OAuth 2.0 token.
attr_accessor :key
# @return [String]
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
attr_accessor :quota_user
def initialize
super('https://chat.googleapis.com/', '')
@batch_path = 'batch'
end
# Returns a space.
# @param [String] name
# Required. Resource name of the space, in the form "spaces/*".
# Example: spaces/AAAAMpdlehY
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::ChatV1::Space] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::ChatV1::Space]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_space(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1/{+name}', options)
command.response_representation = Google::Apis::ChatV1::Space::Representation
command.response_class = Google::Apis::ChatV1::Space
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Lists spaces the caller is a member of.
# @param [Fixnum] page_size
# Requested page size. The value is capped at 1000.
# Server may return fewer results than requested.
# If unspecified, server will default to 100.
# @param [String] page_token
# A token identifying a page of results the server should return.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::ChatV1::ListSpacesResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::ChatV1::ListSpacesResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def list_spaces(page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1/spaces', options)
command.response_representation = Google::Apis::ChatV1::ListSpacesResponse::Representation
command.response_class = Google::Apis::ChatV1::ListSpacesResponse
command.query['pageSize'] = page_size unless page_size.nil?
command.query['pageToken'] = page_token unless page_token.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Returns a membership.
# @param [String] name
# Required. Resource name of the membership to be retrieved, in the form
# "spaces/*/members/*".
# Example: spaces/AAAAMpdlehY/members/105115627578887013105
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::ChatV1::Membership] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::ChatV1::Membership]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_space_member(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1/{+name}', options)
command.response_representation = Google::Apis::ChatV1::Membership::Representation
command.response_class = Google::Apis::ChatV1::Membership
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Lists human memberships in a space.
# @param [String] parent
# Required. The resource name of the space for which membership list is to be
# fetched, in the form "spaces/*".
# Example: spaces/AAAAMpdlehY
# @param [Fixnum] page_size
# Requested page size. The value is capped at 1000.
# Server may return fewer results than requested.
# If unspecified, server will default to 100.
# @param [String] page_token
# A token identifying a page of results the server should return.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::ChatV1::ListMembershipsResponse] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::ChatV1::ListMembershipsResponse]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def list_space_members(parent, page_size: nil, page_token: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1/{+parent}/members', options)
command.response_representation = Google::Apis::ChatV1::ListMembershipsResponse::Representation
command.response_class = Google::Apis::ChatV1::ListMembershipsResponse
command.params['parent'] = parent unless parent.nil?
command.query['pageSize'] = page_size unless page_size.nil?
command.query['pageToken'] = page_token unless page_token.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Creates a message.
# @param [String] parent
# Required. Space resource name, in the form "spaces/*".
# Example: spaces/AAAAMpdlehY
# @param [Google::Apis::ChatV1::Message] message_object
# @param [String] thread_key
# 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.
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::ChatV1::Message] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::ChatV1::Message]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def create_space_message(parent, message_object = nil, thread_key: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:post, 'v1/{+parent}/messages', options)
command.request_representation = Google::Apis::ChatV1::Message::Representation
command.request_object = message_object
command.response_representation = Google::Apis::ChatV1::Message::Representation
command.response_class = Google::Apis::ChatV1::Message
command.params['parent'] = parent unless parent.nil?
command.query['threadKey'] = thread_key unless thread_key.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Deletes a message.
# @param [String] name
# Required. Resource name of the message to be deleted, in the form
# "spaces/*/messages/*"
# Example: spaces/AAAAMpdlehY/messages/UMxbHmzDlr4.UMxbHmzDlr4
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::ChatV1::Empty] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::ChatV1::Empty]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def delete_space_message(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:delete, 'v1/{+name}', options)
command.response_representation = Google::Apis::ChatV1::Empty::Representation
command.response_class = Google::Apis::ChatV1::Empty
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Returns a message.
# @param [String] name
# Required. Resource name of the message to be retrieved, in the form
# "spaces/*/messages/*".
# Example: spaces/AAAAMpdlehY/messages/UMxbHmzDlr4.UMxbHmzDlr4
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::ChatV1::Message] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::ChatV1::Message]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def get_space_message(name, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:get, 'v1/{+name}', options)
command.response_representation = Google::Apis::ChatV1::Message::Representation
command.response_class = Google::Apis::ChatV1::Message
command.params['name'] = name unless name.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
# Updates a message.
# @param [String] name
# Resource name, in the form "spaces/*/messages/*".
# Example: spaces/AAAAMpdlehY/messages/UMxbHmzDlr4.UMxbHmzDlr4
# @param [Google::Apis::ChatV1::Message] message_object
# @param [String] update_mask
# Required. The field paths to be updated.
# Currently supported field paths: "text", "cards".
# @param [String] fields
# Selector specifying which fields to include in a partial response.
# @param [String] quota_user
# Available to use for quota purposes for server-side applications. Can be any
# arbitrary string assigned to a user, but should not exceed 40 characters.
# @param [Google::Apis::RequestOptions] options
# Request-specific options
#
# @yield [result, err] Result & error if block supplied
# @yieldparam result [Google::Apis::ChatV1::Message] parsed result object
# @yieldparam err [StandardError] error object if request failed
#
# @return [Google::Apis::ChatV1::Message]
#
# @raise [Google::Apis::ServerError] An error occurred on the server and the request can be retried
# @raise [Google::Apis::ClientError] The request is invalid and should not be retried without modification
# @raise [Google::Apis::AuthorizationError] Authorization is required
def update_space_message(name, message_object = nil, update_mask: nil, fields: nil, quota_user: nil, options: nil, &block)
command = make_simple_command(:put, 'v1/{+name}', options)
command.request_representation = Google::Apis::ChatV1::Message::Representation
command.request_object = message_object
command.response_representation = Google::Apis::ChatV1::Message::Representation
command.response_class = Google::Apis::ChatV1::Message
command.params['name'] = name unless name.nil?
command.query['updateMask'] = update_mask unless update_mask.nil?
command.query['fields'] = fields unless fields.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
execute_or_queue_command(command, &block)
end
protected
def apply_command_defaults(command)
command.query['key'] = key unless key.nil?
command.query['quotaUser'] = quota_user unless quota_user.nil?
end
end
end
end
end