hipchat

package
v0.0.0-...-35aebc9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2017 License: Apache-2.0 Imports: 19 Imported by: 65

Documentation

Overview

Package hipchat provides a client for using the HipChat API v2.

Index

Constants

View Source
const (
	// ScopeAdminGroup - Perform group administrative tasks
	ScopeAdminGroup = "admin_group"

	// ScopeAdminRoom - Perform room administrative tasks
	ScopeAdminRoom = "admin_room"

	// ScopeImportData - Import users, rooms, and chat history. Only available for select add-ons.
	ScopeImportData = "import_data"

	// ScopeManageRooms - Create, update, and remove rooms
	ScopeManageRooms = "manage_rooms"

	// ScopeSendMessage - Send private one-on-one messages
	ScopeSendMessage = "send_message"

	// ScopeSendNotification - Send room notifications
	ScopeSendNotification = "send_notification"

	// ScopeViewGroup - View users, rooms, and other group information
	ScopeViewGroup = "view_group"

	// ScopeViewMessages - View messages from chat rooms and private chats you have access to
	ScopeViewMessages = "view_messages"

	// ScopeViewRoom - View room information and participants, but not history
	ScopeViewRoom = "view_room"
)
View Source
const (
	// CardStyleFile represents a Card notification related to a file
	CardStyleFile = "file"

	// CardStyleImage represents a Card notification related to an image
	CardStyleImage = "image"

	// CardStyleApplication represents a Card notification related to an application
	CardStyleApplication = "application"

	// CardStyleLink represents a Card notification related to a link
	CardStyleLink = "link"

	// CardStyleMedia represents a Card notiifcation related to media
	CardStyleMedia = "media"
)
View Source
const (
	// UserPresenceShowAway show status away
	UserPresenceShowAway = "away"

	// UserPresenceShowChat show status available to chat
	UserPresenceShowChat = "chat"

	// UserPresenceShowDnd show status do not disturb
	UserPresenceShowDnd = "dnd"

	// UserPresenceShowXa show status xa?
	UserPresenceShowXa = "xa"
)

Variables

View Source
var AuthTest = false

AuthTest can be set to true to test an auth token.

HipChat API docs: https://www.hipchat.com/docs/apiv2/auth#auth_test

View Source
var AuthTestResponse = map[string]interface{}{}

AuthTestResponse will contain the server response of any API calls if AuthTest=true.

View Source
var DefaultRateLimitRetryPolicy = RetryPolicy{300, 1 * time.Second, 1 * time.Second, 500 * time.Millisecond, 0 * time.Millisecond}

DefaultRateLimitRetryPolicy defines the "up to 300 times, 1 second apart, randomly adding an additional up-to-500 milliseconds of delay" policy.

View Source
var NoRateLimitRetryPolicy = RetryPolicy{0, 1 * time.Second, 1 * time.Second, 500 * time.Millisecond, 0 * time.Millisecond}

NoRateLimitRetryPolicy defines the "never retry an API call" policy's values.

View Source
var RateLimitRetryPolicy = DefaultRateLimitRetryPolicy

RateLimitRetryPolicy can be set to a custom RetryPolicy's values, or to one of the two predefined ones: NoRateLimitRetryPolicy or DefaultRateLimitRetryPolicy

View Source
var RetryOnRateLimit = false

RetryOnRateLimit can be set to true to automatically retry the API call until it succeeds, subject to the RateLimitRetryPolicy settings. This behavior is only active when the API call returns 429 (StatusTooManyRequests).

Functions

This section is empty.

Types

type Activity

type Activity struct {
	Icon *Icon  `json:"icon,omitempty"`
	HTML string `json:"html,omitempty"`
}

Activity represents an activity that occurred

type AddMemberRequest

type AddMemberRequest struct {
	Roles []string `json:"roles,omitempty"`
}

AddMemberRequest represents a HipChat add member request

type Attribute

type Attribute struct {
	Label string         `json:"label,omitempty"`
	Value AttributeValue `json:"value"`
}

Attribute represents an attribute on a Card

type AttributeValue

type AttributeValue struct {
	URL   string `json:"url,omitempty"`
	Style string `json:"style,omitempty"`
	Type  string `json:"type,omitempty"`
	Label string `json:"label,omitempty"`
	Value string `json:"value,omitempty"`
	Icon  *Icon  `json:"icon,omitempty"`
}

AttributeValue represents the value of an attribute

type Card

type Card struct {
	Style       string          `json:"style"`
	Description CardDescription `json:"description"`
	Format      string          `json:"format,omitempty"`
	URL         string          `json:"url,omitempty"`
	Title       string          `json:"title"`
	Thumbnail   *Thumbnail      `json:"thumbnail,omitempty"`
	Activity    *Activity       `json:"activity,omitempty"`
	Attributes  []Attribute     `json:"attributes,omitempty"`
	ID          string          `json:"id,omitempty"`
	Icon        *Icon           `json:"icon,omitempty"`
}

Card is used to send information as messages to Hipchat rooms

func (*Card) AddAttribute

func (c *Card) AddAttribute(mainLabel, subLabel, url, iconURL string)

AddAttribute adds an attribute to a Card

type CardDescription

type CardDescription struct {
	Format string
	Value  string
}

CardDescription represents the main content of the Card

func (CardDescription) MarshalJSON

func (c CardDescription) MarshalJSON() ([]byte, error)

MarshalJSON serializes a CardDescription into JSON

func (*CardDescription) UnmarshalJSON

func (c *CardDescription) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes a JSON-serialized CardDescription

type Client

type Client struct {
	BaseURL *url.URL

	LatestFloodControl LimitData
	LatestRateLimit    LimitData
	Room               *RoomService
	User               *UserService
	Emoticon           *EmoticonService
	// contains filtered or unexported fields
}

Client manages the communication with the HipChat API.

LatestFloodControl contains the response from the latest API call's response headers X-Floodcontrol-{Limit, Remaining, ResetTime} LatestRateLimit contains the response from the latest API call's response headers X-Ratelimit-{Limit, Remaining, ResetTime} Room gives access to the /room part of the API. User gives access to the /user part of the API. Emoticon gives access to the /emoticon part of the API.

func NewClient

func NewClient(authToken string) *Client

NewClient returns a new HipChat API client. You must provide a valid AuthToken retrieved from your HipChat account.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do performs the request, the json received in the response is decoded and stored in the value pointed by v. Do can be used to perform the request created with NewRequest, which should be used only for API requests not implemented in this library.

func (*Client) GenerateToken

func (c *Client) GenerateToken(credentials ClientCredentials, scopes []string) (*OAuthAccessToken, *http.Response, error)

GenerateToken returns back an access token for a given integration's client ID and client secret

HipChat API documentation: https://www.hipchat.com/docs/apiv2/method/generate_token

func (*Client) NewFileUploadRequest

func (c *Client) NewFileUploadRequest(method, urlStr string, v interface{}) (*http.Request, error)

NewFileUploadRequest creates an API request to upload a file. This method manually formats the request as multipart/related with a single part of content-type application/json and a second part containing the file to be sent. Relative URLs should always be specified without a preceding slash.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, opt interface{}, body interface{}) (*http.Request, error)

NewRequest creates an API request. This method can be used to performs API request not implemented in this library. Otherwise it should not be be used directly. Relative URLs should always be specified without a preceding slash.

func (*Client) SetHTTPClient

func (c *Client) SetHTTPClient(httpClient HTTPClient)

SetHTTPClient sets the http client for performing API requests. This method allows overriding the default http client with any implementation of the HTTPClient interface. It is typically used to have finer control of the http request. If a nil httpClient is provided, http.DefaultClient will be used.

type ClientCredentials

type ClientCredentials struct {
	ClientID     string
	ClientSecret string
}

ClientCredentials represents the OAuth2 client ID and secret for an integration

type Color

type Color string

Color is set of hard-coded string values for the HipChat API for notifications. cf: https://www.hipchat.com/docs/apiv2/method/send_room_notification

const (
	// ColorYellow is the color yellow
	ColorYellow Color = "yellow"
	// ColorGreen is the color green
	ColorGreen Color = "green"
	// ColorRed is the color red
	ColorRed Color = "red"
	// ColorPurple is the color purple
	ColorPurple Color = "purple"
	// ColorGray is the color gray
	ColorGray Color = "gray"
	// ColorRandom is the random "surprise me!" color
	ColorRandom Color = "random"
)

type CreateRoomRequest

type CreateRoomRequest struct {
	Topic       string `json:"topic,omitempty"`
	GuestAccess bool   `json:"guest_access,omitempty"`
	Name        string `json:"name,omitempty"`
	OwnerUserID string `json:"owner_user_id,omitempty"`
	Privacy     string `json:"privacy,omitempty"`
}

CreateRoomRequest represents a HipChat room creation request.

type CreateWebhookRequest

type CreateWebhookRequest struct {
	Name    string `json:"name"`
	Key     string `json:"key,omitempty"`
	Event   string `json:"event"`
	Pattern string `json:"pattern"`
	URL     string `json:"url"`
}

CreateWebhookRequest represents the body of the CreateWebhook method.

type Emoticon

type Emoticon struct {
	ID       int    `json:"id"`
	URL      string `json:"url"`
	Links    Links  `json:"links"`
	Shortcut string `json:"shortcut"`
}

Emoticon represents a hipchat emoticon.

type EmoticonService

type EmoticonService struct {
	// contains filtered or unexported fields
}

EmoticonService gives access to the emoticon related part of the API.

func (*EmoticonService) List

List returns the list of all the emoticons

HipChat api docs : https://www.hipchat.com/docs/apiv2/method/get_all_emoticons

type Emoticons

type Emoticons struct {
	Items      []Emoticon `json:"items"`
	StartIndex int        `json:"startIndex"`
	MaxResults int        `json:"maxResults"`
	Links      PageLinks  `json:"links"`
}

Emoticons represents a list of hipchat emoticons.

type EmoticonsListOptions

type EmoticonsListOptions struct {
	ListOptions

	// The type of emoticons to get (global, group or all)
	Type string `url:"type,omitempty"`
}

EmoticonsListOptions specifies the optionnal parameters of the EmoticonService.List method.

type ExpandOptions

type ExpandOptions struct {
	Expand string `url:"expand,omitempty"`
}

ExpandOptions specifies which Hipchat collections to automatically expand. This functionality is primarily used to reduce the total time to receive the data. It also reduces the sheer number of API calls from 1+N, to 1.

cf: https://developer.atlassian.com/hipchat/guide/hipchat-rest-api/api-title-expansion

type GlanceCondition

type GlanceCondition struct {
	Condition string            `json:"condition"`
	Params    map[string]string `json:"params"`
	Invert    bool              `json:"invert"`
}

GlanceCondition represents a condition to determine whether a glance is displayed

type GlanceContent

type GlanceContent struct {
	Status   *GlanceStatus  `json:"status,omitempty"`
	Metadata interface{}    `json:"metadata,omitempty"`
	Label    AttributeValue `json:"label"` // AttributeValue{Type, Label}
}

GlanceContent is a component of a Glance

type GlanceName

type GlanceName struct {
	Value string `json:"value"`
	I18n  string `json:"i18n,omitempty"`
}

GlanceName represents a glance name

type GlanceRequest

type GlanceRequest struct {
	Key        string             `json:"key"`
	Name       GlanceName         `json:"name"`
	Target     string             `json:"target"`
	QueryURL   string             `json:"queryUrl,omitempty"`
	Icon       Icon               `json:"icon"`
	Conditions []*GlanceCondition `json:"conditions,omitempty"`
}

GlanceRequest represents a HipChat room ui glance

type GlanceStatus

type GlanceStatus struct {
	Type  string      `json:"type"`  // "lozenge" | "icon"
	Value interface{} `json:"value"` // AttributeValue{Type, Label} | Icon{URL, URL2x}
}

GlanceStatus is a status field component of a GlanceContent

func (*GlanceStatus) UnmarshalJSON

func (gs *GlanceStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes a JSON-serialized GlanceStatus

type GlanceUpdate

type GlanceUpdate struct {
	Key     string        `json:"key"`
	Content GlanceContent `json:"content"`
}

GlanceUpdate represents a component of a HipChat room ui glance update

type GlanceUpdateRequest

type GlanceUpdateRequest struct {
	Glance []*GlanceUpdate `json:"glance"`
}

GlanceUpdateRequest represents a HipChat room ui glance update request

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (res *http.Response, err error)
}

HTTPClient is an interface that allows overriding the http behavior by providing custom http clients

type History

type History struct {
	Items      []Message `json:"items"`
	StartIndex int       `json:"startIndex"`
	MaxResults int       `json:"maxResults"`
	Links      PageLinks `json:"links"`
}

History represents a HipChat room chat history.

type HistoryOptions

type HistoryOptions struct {
	ListOptions
	ExpandOptions

	// Either the latest date to fetch history for in ISO-8601 format, or 'recent' to fetch
	// the latest 75 messages. Paging isn't supported for 'recent', however they are real-time
	// values, whereas date queries may not include the most recent messages.
	Date string `url:"date,omitempty"`

	// Your timezone. Must be a supported timezone
	Timezone string `url:"timezone,omitempty"`

	// Reverse the output such that the oldest message is first.
	// For consistent paging, set to 'false'.
	Reverse bool `url:"reverse,omitempty"`

	// Either the earliest date to fetch history for the ISO-8601 format string,
	// or leave blank to disable this filter.
	// to be effective, the API call requires Date also be filled in with an ISO-8601 format string.
	EndDate string `url:"end-date,omitempty"`

	// Include records about deleted messages into results (body of a message isn't returned).  Set to 'true'.
	IncludeDeleted bool `url:"include_deleted,omitempty"`
}

HistoryOptions represents a HipChat room chat history request.

type ID

type ID struct {
	ID string `json:"id"`
}

ID represents a HipChat id. Use a separate struct because it can be a string or a int.

type Icon

type Icon struct {
	URL   string `json:"url"`
	URL2x string `json:"url@2x,omitempty"`
}

Icon represents an icon

type InviteRequest

type InviteRequest struct {
	Reason string `json:"reason"`
}

InviteRequest represents a hipchat invite to room request

type LatestHistoryOptions

type LatestHistoryOptions struct {

	// The maximum number of messages to return.
	MaxResults int `url:"max-results,omitempty"`

	// Your timezone. Must be a supported timezone.
	Timezone string `url:"timezone,omitempty"`

	// The id of the message that is oldest in the set of messages to be returned.
	// The server will not return any messages that chronologically precede this message.
	NotBefore string `url:"not-before,omitempty"`
}

LatestHistoryOptions represents a HipChat room chat latest history request.

type LimitData

type LimitData struct {
	Limit     int
	Remaining int
	ResetTime int
}

LimitData contains the latest Rate Limit or Flood Control data sent with every API call response.

Limit is the number of API calls per period of time Remaining is the current number of API calls that can be done before the ResetTime ResetTime is the UTC time in Unix epoch format for when the full Limit of API calls will be restored.

type Links struct {
	Self string `json:"self"`
}

Links represents the HipChat default links.

type ListOptions

type ListOptions struct {
	StartIndex int `url:"start-index,omitempty"`
	MaxResults int `url:"max-results,omitempty"`
}

ListOptions specifies the optional parameters to various List methods that support pagination.

For paginated results, StartIndex represents the first page to display. For paginated results, MaxResults reprensents the number of items per page. Default value is 100. Maximum value is 1000.

type ListWebhooksOptions

type ListWebhooksOptions struct {
	ListOptions
}

ListWebhooksOptions represents options for ListWebhooks method.

type Message

type Message struct {
	Date          string      `json:"date"`
	From          interface{} `json:"from"` // string | obj <- weak
	ID            string      `json:"id"`
	Mentions      []User      `json:"mentions"`
	Message       string      `json:"message"`
	MessageFormat string      `json:"message_format"`
	Type          string      `json:"type"`
}

Message represents a HipChat message.

type MessageRequest

type MessageRequest struct {
	Message       string `json:"message,omitempty"`
	Notify        bool   `json:"notify,omitempty"`
	MessageFormat string `json:"message_format,omitempty"`
}

MessageRequest represents a HipChat private message to user.

type NotificationRequest

type NotificationRequest struct {
	Color         Color  `json:"color,omitempty"`
	Message       string `json:"message,omitempty"`
	Notify        bool   `json:"notify,omitempty"`
	MessageFormat string `json:"message_format,omitempty"`
	From          string `json:"from,omitempty"`
	Card          *Card  `json:"card,omitempty"`
}

NotificationRequest represents a HipChat room notification request.

type OAuthAccessToken

type OAuthAccessToken struct {
	AccessToken string `json:"access_token"`
	ExpiresIn   uint32 `json:"expires_in"`
	GroupID     uint32 `json:"group_id"`
	GroupName   string `json:"group_name"`
	Scope       string `json:"scope"`
	TokenType   string `json:"token_type"`
}

OAuthAccessToken represents a newly created Hipchat OAuth access token

func (*OAuthAccessToken) CreateClient

func (t *OAuthAccessToken) CreateClient() *Client

CreateClient creates a new client from this OAuth token

type PageLinks struct {
	Links
	Prev string `json:"prev"`
	Next string `json:"next"`
}

PageLinks represents the HipChat page links.

type RetryPolicy

type RetryPolicy struct {
	MaxRetries  int
	MinDelay    time.Duration
	MaxDelay    time.Duration
	JitterDelay time.Duration
	JitterBias  time.Duration
}

RetryPolicy defines a RetryPolicy.

MaxRetries is the maximum number of attempts to make before returning an error MinDelay is the initial delay between attempts. This value is multiplied by the current attempt number. MaxDelay is the largest delay between attempts. JitterDelay is the amount of random jitter to add to the delay. JitterBias is the amount of jitter to remove from the delay.

The use of Jitter avoids inadvertant and undesirable synchronization of network operations between otherwise unrelated clients. cf: https://brooker.co.za/blog/2015/03/21/backoff.html and https://www.awsarchitectureblog.com/2015/03/backoff.html

Using the values of JitterDelay = 250 milliseconds and a JitterBias of negative 125 milliseconds, would result in a uniformly distributed Jitter between -125 and +125 milliseconds, centered around the current trial Delay (between MinDelay and MaxDelay).

type Room

type Room struct {
	ID                int            `json:"id"`
	Links             RoomLinks      `json:"links"`
	Name              string         `json:"name"`
	XMPPJid           string         `json:"xmpp_jid"`
	Statistics        RoomStatistics `json:"statistics"`
	Created           string         `json:"created"`
	IsArchived        bool           `json:"is_archived"`
	Privacy           string         `json:"privacy"`
	IsGuestAccessible bool           `json:"is_guess_accessible"`
	Topic             string         `json:"topic"`
	Participants      []User         `json:"participants"`
	Owner             User           `json:"owner"`
	GuestAccessURL    string         `json:"guest_access_url"`
}

Room represents a HipChat room.

type RoomLinks struct {
	Links
	Webhooks     string `json:"webhooks"`
	Members      string `json:"members"`
	Participants string `json:"participants"`
}

RoomLinks represents the HipChat room links.

type RoomMessageRequest

type RoomMessageRequest struct {
	Message string `json:"message"`
}

RoomMessageRequest represents a Hipchat room message request.

type RoomService

type RoomService struct {
	// contains filtered or unexported fields
}

RoomService gives access to the room related methods of the API.

func (*RoomService) AddMember

func (r *RoomService) AddMember(roomID string, userID string, addMemberReq *AddMemberRequest) (*http.Response, error)

AddMember adds a member to a private room and sends member's unavailable presence to all room members asynchronously.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/add_member

func (*RoomService) Create

func (r *RoomService) Create(roomReq *CreateRoomRequest) (*Room, *http.Response, error)

Create creates a new room.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/create_room

func (*RoomService) CreateGlance

func (r *RoomService) CreateGlance(id string, glanceReq *GlanceRequest) (*http.Response, error)

CreateGlance creates a glance in the room specified by the id.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/create_room_glance

func (*RoomService) CreateWebhook

func (r *RoomService) CreateWebhook(id interface{}, roomReq *CreateWebhookRequest) (*Webhook, *http.Response, error)

CreateWebhook creates a new webhook.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/create_webhook

func (*RoomService) Delete

func (r *RoomService) Delete(id string) (*http.Response, error)

Delete deletes an existing room.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/delete_room

func (*RoomService) DeleteGlance

func (r *RoomService) DeleteGlance(id string, glanceReq *GlanceRequest) (*http.Response, error)

DeleteGlance deletes a glance in the room specified by the id.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/delete_room_glance

func (*RoomService) DeleteWebhook

func (r *RoomService) DeleteWebhook(id interface{}, webhookID interface{}) (*http.Response, error)

DeleteWebhook removes the given webhook.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/delete_webhook

func (*RoomService) Get

func (r *RoomService) Get(id string) (*Room, *http.Response, error)

Get returns the room specified by the id.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/get_room

func (*RoomService) GetStatistics

func (r *RoomService) GetStatistics(id string) (*RoomStatistics, *http.Response, error)

GetStatistics returns the room statistics pecified by the id.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/get_room_statistics

func (*RoomService) History

func (r *RoomService) History(id string, opt *HistoryOptions) (*History, *http.Response, error)

History fetches a room's chat history.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/view_room_history

func (*RoomService) Invite

func (r *RoomService) Invite(room string, user string, reason string) (*http.Response, error)

Invite someone to the Room.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/invite_user

func (*RoomService) Latest

func (r *RoomService) Latest(id string, opt *LatestHistoryOptions) (*History, *http.Response, error)

Latest fetches a room's chat history.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/view_recent_room_history

func (*RoomService) List

func (r *RoomService) List(opt *RoomsListOptions) (*Rooms, *http.Response, error)

List returns all the rooms authorized.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/get_all_rooms

func (*RoomService) ListWebhooks

func (r *RoomService) ListWebhooks(id interface{}, opt *ListWebhooksOptions) (*WebhookList, *http.Response, error)

ListWebhooks returns all the webhooks for a given room.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/get_all_webhooks

func (*RoomService) Message

func (r *RoomService) Message(id string, msgReq *RoomMessageRequest) (*http.Response, error)

Message sends a message to the room specified by the id.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/send_message

func (*RoomService) Notification

func (r *RoomService) Notification(id string, notifReq *NotificationRequest) (*http.Response, error)

Notification sends a notification to the room specified by the id.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/send_room_notification

func (*RoomService) RemoveMember

func (r *RoomService) RemoveMember(roomID string, userID string) (*http.Response, error)

RemoveMember removes a member from a private room

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/remove_member

func (*RoomService) SetTopic

func (r *RoomService) SetTopic(id string, topic string) (*http.Response, error)

SetTopic sets Room topic.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/set_topic

func (*RoomService) ShareFile

func (r *RoomService) ShareFile(id string, shareFileReq *ShareFileRequest) (*http.Response, error)

ShareFile sends a file to the room specified by the id.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/share_file_with_room

func (*RoomService) Update

func (r *RoomService) Update(id string, roomReq *UpdateRoomRequest) (*http.Response, error)

Update updates an existing room.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/update_room

func (*RoomService) UpdateGlance

func (r *RoomService) UpdateGlance(id string, glanceUpdateReq *GlanceUpdateRequest) (*http.Response, error)

UpdateGlance sends a glance update to the room specified by the id.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/room_addon_ui_update

type RoomStatistics

type RoomStatistics struct {
	Links        Links  `json:"links"`
	MessagesSent int    `json:"messages_sent,omitempty"`
	LastActive   string `json:"last_active,omitempty"`
}

RoomStatistics represents the HipChat room statistics.

type Rooms

type Rooms struct {
	Items      []Room    `json:"items"`
	StartIndex int       `json:"startIndex"`
	MaxResults int       `json:"maxResults"`
	Links      PageLinks `json:"links"`
}

Rooms represents a HipChat room list.

type RoomsListOptions

type RoomsListOptions struct {
	ListOptions
	ExpandOptions

	// Include private rooms in the result, API defaults to true
	IncludePrivate bool `url:"include-private,omitempty"`

	// Include archived rooms in the result, API defaults to false
	IncludeArchived bool `url:"include-archived,omitempty"`
}

RoomsListOptions specifies the optional parameters of the RoomService.List method.

type SetTopicRequest

type SetTopicRequest struct {
	Topic string `json:"topic"`
}

SetTopicRequest represents a hipchat update topic request

type ShareFileRequest

type ShareFileRequest struct {
	Path     string `json:"path"`
	Filename string `json:"filename,omitempty"`
	Message  string `json:"message,omitempty"`
}

ShareFileRequest represents a HipChat room file share request.

type Thumbnail

type Thumbnail struct {
	URL    string `json:"url"`
	URL2x  string `json:"url@2x,omitempty"`
	Width  uint   `json:"width,omitempty"`
	Height uint   `json:"height,omitempty"`
}

Thumbnail represents a thumbnail image

type UpdateRoomRequest

type UpdateRoomRequest struct {
	Name          string `json:"name"`
	Topic         string `json:"topic"`
	IsGuestAccess bool   `json:"is_guest_accessible"`
	IsArchived    bool   `json:"is_archived"`
	Privacy       string `json:"privacy"`
	Owner         ID     `json:"owner"`
}

UpdateRoomRequest represents a HipChat room update request.

type UpdateUserPresenceRequest

type UpdateUserPresenceRequest struct {
	Status string `json:"status"`
	Show   string `json:"show"`
}

UpdateUserPresenceRequest represents the HipChat user's presence update request body.

type UpdateUserRequest

type UpdateUserRequest struct {
	Name        string                    `json:"name"`
	Presence    UpdateUserPresenceRequest `json:"presence"`
	MentionName string                    `json:"mention_name"`
	Email       string                    `json:"email"`
}

UpdateUserRequest represents a HipChat user update request body.

type User

type User struct {
	XMPPJid      string       `json:"xmpp_jid"`
	IsDeleted    bool         `json:"is_deleted"`
	Name         string       `json:"name"`
	LastActive   string       `json:"last_active"`
	Title        string       `json:"title"`
	Presence     UserPresence `json:"presence"`
	Created      string       `json:"created"`
	ID           int          `json:"id"`
	MentionName  string       `json:"mention_name"`
	IsGroupAdmin bool         `json:"is_group_admin"`
	Timezone     string       `json:"timezone"`
	IsGuest      bool         `json:"is_guest"`
	Email        string       `json:"email"`
	PhotoURL     string       `json:"photo_url"`
	Links        Links        `json:"links"`
}

User represents the HipChat user.

type UserListOptions

type UserListOptions struct {
	ListOptions
	ExpandOptions
	// Include active guest users in response.
	IncludeGuests bool `url:"include-guests,omitempty"`
	// Include deleted users in response.
	IncludeDeleted bool `url:"include-deleted,omitempty"`
}

UserListOptions specified the parameters to the UserService.List method.

type UserPresence

type UserPresence struct {
	Status   string `json:"status"`
	Idle     int    `json:"idle"`
	Show     string `json:"show"`
	IsOnline bool   `json:"is_online"`
}

UserPresence represents the HipChat user's presence.

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

UserService gives access to the user related methods of the API.

func (*UserService) List

func (u *UserService) List(opt *UserListOptions) ([]User, *http.Response, error)

List returns all users in the group.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/get_all_users

func (*UserService) Message

func (u *UserService) Message(id string, msgReq *MessageRequest) (*http.Response, error)

Message sends a private message to the user specified by the id.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/private_message_user

func (*UserService) ShareFile

func (u *UserService) ShareFile(id string, shareFileReq *ShareFileRequest) (*http.Response, error)

ShareFile sends a file to the user specified by the id.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/share_file_with_user

func (*UserService) Update

func (u *UserService) Update(id string, user *UpdateUserRequest) (*http.Response, error)

Update a user

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/update_user

func (*UserService) View

func (u *UserService) View(id string) (*User, *http.Response, error)

View fetches a user's details.

HipChat API docs: https://www.hipchat.com/docs/apiv2/method/view_user

type Users

type Users struct {
	Items      []User `json:"items"`
	StartIndex int    `json:"start_index"`
	MaxResults int    `json:"max_results"`
	Links      Links  `json:"links"`
}

Users represents the API return of a collection of Users plus metadata

type Webhook

type Webhook struct {
	Links   Links  `json:"links"`
	Name    string `json:"name"`
	Key     string `json:"key,omitempty"`
	Event   string `json:"event"`
	Pattern string `json:"pattern"`
	URL     string `json:"url"`
	ID      int    `json:"id,omitempty"`
}

Webhook represents a HipChat webhook.

type WebhookList

type WebhookList struct {
	Webhooks   []Webhook `json:"items"`
	StartIndex int       `json:"startIndex"`
	MaxResults int       `json:"maxResults"`
	Links      PageLinks `json:"links"`
}

WebhookList represents a HipChat webhook list.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL