Skip to content

Latest commit

 

History

History
519 lines (464 loc) · 40.2 KB

client.md

File metadata and controls

519 lines (464 loc) · 40.2 KB

Go API client for traq

traQ v3 API

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import traq "github.com/traPtitech/go-traq"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value sw.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), traq.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), traq.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using sw.ContextOperationServerIndices and sw.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), traq.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), traq.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://q.trap.jp/api/v3

Class Method HTTP request Description
ActivityApi GetActivityTimeline Get /activity/timeline アクテビティタイムラインを取得
ActivityApi GetOnlineUsers Get /activity/onlines オンラインユーザーリストを取得
AuthenticationApi GetMyExternalAccounts Get /users/me/ex-accounts 外部ログインアカウント一覧を取得
AuthenticationApi GetMySessions Get /users/me/sessions 自分のログインセッションリストを取得
AuthenticationApi LinkExternalAccount Post /users/me/ex-accounts/link 外部ログインアカウントを紐付ける
AuthenticationApi Login Post /# ログイン
AuthenticationApi Logout Post /logout ログアウト
AuthenticationApi RevokeMySession Delete /users/me/sessions/{sessionId} セッションを無効化
AuthenticationApi UnlinkExternalAccount Post /users/me/ex-accounts/unlink 外部ログインアカウントの紐付けを解除
BotApi ActivateBot Post /bots/{botId}/actions/activate BOTをアクティベート
BotApi ChangeBotIcon Put /bots/{botId}/icon BOTのアイコン画像を変更
BotApi ConnectBotWS Get /bots/ws WebSocket Mode BOT用通知ストリームに接続します
BotApi CreateBot Post /bots BOTを作成
BotApi DeleteBot Delete /bots/{botId} BOTを削除
BotApi EditBot Patch /bots/{botId} BOT情報を変更
BotApi GetBot Get /bots/{botId} BOT情報を取得
BotApi GetBotIcon Get /bots/{botId}/icon BOTのアイコン画像を取得
BotApi GetBotLogs Get /bots/{botId}/logs BOTのイベントログを取得
BotApi GetBots Get /bots BOTリストを取得
BotApi GetChannelBots Get /channels/{channelId}/bots チャンネル参加中のBOTのリストを取得
BotApi InactivateBot Post /bots/{botId}/actions/inactivate BOTをインアクティベート
BotApi LetBotJoinChannel Post /bots/{botId}/actions/join BOTをチャンネルに参加させる
BotApi LetBotLeaveChannel Post /bots/{botId}/actions/leave BOTをチャンネルから退出させる
BotApi ReissueBot Post /bots/{botId}/actions/reissue BOTのトークンを再発行
ChannelApi CreateChannel Post /channels チャンネルを作成
ChannelApi EditChannel Patch /channels/{channelId} チャンネル情報を変更
ChannelApi EditChannelSubscribers Patch /channels/{channelId}/subscribers チャンネルの通知購読者を編集
ChannelApi EditChannelTopic Put /channels/{channelId}/topic チャンネルトピックを編集
ChannelApi GetChannel Get /channels/{channelId} チャンネル情報を取得
ChannelApi GetChannelBots Get /channels/{channelId}/bots チャンネル参加中のBOTのリストを取得
ChannelApi GetChannelEvents Get /channels/{channelId}/events チャンネルイベントのリストを取得
ChannelApi GetChannelPath Get /channels/{channelId}/path 指定したチャンネルパスを取得
ChannelApi GetChannelPins Get /channels/{channelId}/pins チャンネルピンのリストを取得
ChannelApi GetChannelStats Get /channels/{channelId}/stats チャンネル統計情報を取得
ChannelApi GetChannelSubscribers Get /channels/{channelId}/subscribers チャンネルの通知購読者のリストを取得
ChannelApi GetChannelTopic Get /channels/{channelId}/topic チャンネルトピックを取得
ChannelApi GetChannelViewers Get /channels/{channelId}/viewers チャンネル閲覧者リストを取得
ChannelApi GetChannels Get /channels チャンネルリストを取得
ChannelApi GetMessages Get /channels/{channelId}/messages チャンネルメッセージのリストを取得
ChannelApi GetUserDMChannel Get /users/{userId}/dm-channel DMチャンネル情報を取得
ChannelApi PostMessage Post /channels/{channelId}/messages チャンネルにメッセージを投稿
ChannelApi SetChannelSubscribers Put /channels/{channelId}/subscribers チャンネルの通知購読者を設定
ClipApi ClipMessage Post /clip-folders/{folderId}/messages メッセージをクリップフォルダに追加
ClipApi CreateClipFolder Post /clip-folders クリップフォルダを作成
ClipApi DeleteClipFolder Delete /clip-folders/{folderId} クリップフォルダを削除
ClipApi EditClipFolder Patch /clip-folders/{folderId} クリップフォルダ情報を編集
ClipApi GetClipFolder Get /clip-folders/{folderId} クリップフォルダ情報を取得
ClipApi GetClipFolders Get /clip-folders クリップフォルダのリストを取得
ClipApi GetClips Get /clip-folders/{folderId}/messages フォルダ内のクリップのリストを取得
ClipApi GetMessageClips Get /messages/{messageId}/clips 自分のクリップを取得
ClipApi UnclipMessage Delete /clip-folders/{folderId}/messages/{messageId} メッセージをクリップフォルダから除外
FileApi DeleteFile Delete /files/{fileId} ファイルを削除
FileApi GetFile Get /files/{fileId} ファイルをダウンロード
FileApi GetFileMeta Get /files/{fileId}/meta ファイルメタを取得
FileApi GetFiles Get /files ファイルメタのリストを取得
FileApi GetThumbnailImage Get /files/{fileId}/thumbnail サムネイル画像を取得
FileApi PostFile Post /files ファイルをアップロード
GroupApi AddUserGroupAdmin Post /groups/{groupId}/admins グループ管理者を追加
GroupApi AddUserGroupMember Post /groups/{groupId}/members グループメンバーを追加
GroupApi ChangeUserGroupIcon Put /groups/{groupId}/icon ユーザーグループのアイコンを変更
GroupApi CreateUserGroup Post /groups ユーザーグループを作成
GroupApi DeleteUserGroup Delete /groups/{groupId} ユーザーグループを削除
GroupApi EditUserGroup Patch /groups/{groupId} ユーザーグループを編集
GroupApi EditUserGroupMember Patch /groups/{groupId}/members/{userId} グループメンバーを編集
GroupApi GetUserGroup Get /groups/{groupId} ユーザーグループを取得
GroupApi GetUserGroupAdmins Get /groups/{groupId}/admins グループ管理者を取得
GroupApi GetUserGroupMembers Get /groups/{groupId}/members グループメンバーを取得
GroupApi GetUserGroups Get /groups ユーザーグループのリストを取得
GroupApi RemoveUserGroupAdmin Delete /groups/{groupId}/admins/{userId} グループ管理者を削除
GroupApi RemoveUserGroupMember Delete /groups/{groupId}/members/{userId} グループメンバーを削除
GroupApi RemoveUserGroupMembers Delete /groups/{groupId}/members グループメンバーを一括削除
MeApi AddMyStar Post /users/me/stars チャンネルをスターに追加
MeApi AddMyUserTag Post /users/me/tags 自分にタグを追加
MeApi ChangeMyIcon Put /users/me/icon 自分のアイコン画像を変更
MeApi ChangeMyNotifyCitation Put /users/me/settings/notify-citation メッセージ引用通知の設定情報を変更
MeApi ChangeMyPassword Put /users/me/password 自分のパスワードを変更
MeApi EditMe Patch /users/me 自分のユーザー情報を変更
MeApi EditMyUserTag Patch /users/me/tags/{tagId} 自分のタグを編集
MeApi GetMe Get /users/me 自分のユーザー詳細を取得
MeApi GetMyChannelSubscriptions Get /users/me/subscriptions 自分のチャンネル購読状態を取得
MeApi GetMyExternalAccounts Get /users/me/ex-accounts 外部ログインアカウント一覧を取得
MeApi GetMyIcon Get /users/me/icon 自分のアイコン画像を取得
MeApi GetMyNotifyCitation Get /users/me/settings/notify-citation メッセージ引用通知の設定情報を取得
MeApi GetMyQRCode Get /users/me/qr-code QRコードを取得
MeApi GetMySessions Get /users/me/sessions 自分のログインセッションリストを取得
MeApi GetMyStampHistory Get /users/me/stamp-history スタンプ履歴を取得
MeApi GetMyStars Get /users/me/stars スターチャンネルリストを取得
MeApi GetMyTokens Get /users/me/tokens 有効トークンのリストを取得
MeApi GetMyUnreadChannels Get /users/me/unread 未読チャンネルを取得
MeApi GetMyUserTags Get /users/me/tags 自分のタグリストを取得
MeApi GetMyViewStates Get /users/me/view-states 自身のチャンネル閲覧状態一覧を取得
MeApi GetOIDCUserInfo Get /users/me/oidc 自分のユーザー詳細を取得 (OIDC UserInfo)
MeApi GetUserSettings Get /users/me/settings ユーザー設定を取得
MeApi LinkExternalAccount Post /users/me/ex-accounts/link 外部ログインアカウントを紐付ける
MeApi ReadChannel Delete /users/me/unread/{channelId} チャンネルを既読にする
MeApi RegisterFCMDevice Post /users/me/fcm-device FCMデバイスを登録
MeApi RemoveMyStar Delete /users/me/stars/{channelId} チャンネルをスターから削除します
MeApi RemoveMyUserTag Delete /users/me/tags/{tagId} 自分からタグを削除します
MeApi RevokeMySession Delete /users/me/sessions/{sessionId} セッションを無効化
MeApi RevokeMyToken Delete /users/me/tokens/{tokenId} トークンの認可を取り消す
MeApi SetChannelSubscribeLevel Put /users/me/subscriptions/{channelId} チャンネル購読レベルを設定
MeApi UnlinkExternalAccount Post /users/me/ex-accounts/unlink 外部ログインアカウントの紐付けを解除
MessageApi AddMessageStamp Post /messages/{messageId}/stamps/{stampId} スタンプを押す
MessageApi CreatePin Post /messages/{messageId}/pin ピン留めする
MessageApi DeleteMessage Delete /messages/{messageId} メッセージを削除
MessageApi EditMessage Put /messages/{messageId} メッセージを編集
MessageApi GetDirectMessages Get /users/{userId}/messages ダイレクトメッセージのリストを取得
MessageApi GetMessage Get /messages/{messageId} メッセージを取得
MessageApi GetMessageClips Get /messages/{messageId}/clips 自分のクリップを取得
MessageApi GetMessageStamps Get /messages/{messageId}/stamps メッセージのスタンプリストを取得
MessageApi GetMessages Get /channels/{channelId}/messages チャンネルメッセージのリストを取得
MessageApi GetPin Get /messages/{messageId}/pin ピン留めを取得
MessageApi PostDirectMessage Post /users/{userId}/messages ダイレクトメッセージを送信
MessageApi PostMessage Post /channels/{channelId}/messages チャンネルにメッセージを投稿
MessageApi RemoveMessageStamp Delete /messages/{messageId}/stamps/{stampId} スタンプを消す
MessageApi RemovePin Delete /messages/{messageId}/pin ピン留めを外す
MessageApi SearchMessages Get /messages メッセージを検索
NotificationApi EditChannelSubscribers Patch /channels/{channelId}/subscribers チャンネルの通知購読者を編集
NotificationApi GetChannelSubscribers Get /channels/{channelId}/subscribers チャンネルの通知購読者のリストを取得
NotificationApi GetMyChannelSubscriptions Get /users/me/subscriptions 自分のチャンネル購読状態を取得
NotificationApi GetMyUnreadChannels Get /users/me/unread 未読チャンネルを取得
NotificationApi GetMyViewStates Get /users/me/view-states 自身のチャンネル閲覧状態一覧を取得
NotificationApi ReadChannel Delete /users/me/unread/{channelId} チャンネルを既読にする
NotificationApi RegisterFCMDevice Post /users/me/fcm-device FCMデバイスを登録
NotificationApi SetChannelSubscribeLevel Put /users/me/subscriptions/{channelId} チャンネル購読レベルを設定
NotificationApi SetChannelSubscribers Put /channels/{channelId}/subscribers チャンネルの通知購読者を設定
NotificationApi Ws Get /ws WebSocket通知ストリームに接続します
Oauth2Api CreateClient Post /clients OAuth2クライアントを作成
Oauth2Api DeleteClient Delete /clients/{clientId} OAuth2クライアントを削除
Oauth2Api EditClient Patch /clients/{clientId} OAuth2クライアント情報を変更
Oauth2Api GetClient Get /clients/{clientId} OAuth2クライアント情報を取得
Oauth2Api GetClients Get /clients OAuth2クライアントのリストを取得
Oauth2Api GetMyTokens Get /users/me/tokens 有効トークンのリストを取得
Oauth2Api GetOAuth2Authorize Get /oauth2/authorize OAuth2 認可エンドポイント
Oauth2Api PostOAuth2Authorize Post /oauth2/authorize OAuth2 認可エンドポイント
Oauth2Api PostOAuth2AuthorizeDecide Post /oauth2/authorize/decide OAuth2 認可承諾API
Oauth2Api PostOAuth2Token Post /oauth2/token OAuth2 トークンエンドポイント
Oauth2Api RevokeClientTokens Delete /clients/{clientId}/tokens OAuthクライアントのトークンを削除
Oauth2Api RevokeMyToken Delete /users/me/tokens/{tokenId} トークンの認可を取り消す
Oauth2Api RevokeOAuth2Token Post /oauth2/revoke OAuth2 トークン無効化エンドポイント
OgpApi DeleteOgpCache Delete /ogp/cache OGP情報のキャッシュを削除
OgpApi GetOgp Get /ogp OGP情報を取得
PinApi CreatePin Post /messages/{messageId}/pin ピン留めする
PinApi GetChannelPins Get /channels/{channelId}/pins チャンネルピンのリストを取得
PinApi GetPin Get /messages/{messageId}/pin ピン留めを取得
PinApi RemovePin Delete /messages/{messageId}/pin ピン留めを外す
PublicApi GetPublicUserIcon Get /public/icon/{username} ユーザーのアイコン画像を取得
PublicApi GetServerVersion Get /version バージョンを取得
QallApi ChangeParticipantRole Patch /qall/rooms/{roomId}/participants ルームでの発言権限を変更
QallApi GetLiveKitToken Get /qall/token LiveKitトークンを取得
QallApi GetQallEndpoints Get /qall/endpoints LiveKitエンドポイントを取得
QallApi GetRoomMetadata Get /qall/rooms/{roomId}/metadata ルームのメタデータを取得
QallApi GetRooms Get /qall/rooms ルームと参加者の一覧を取得
QallApi GetSoundboardList Get /qall/soundboard サウンドボード用の音声一覧を取得
QallApi LiveKitWebhook Post /qall/webhook LiveKit Webhook受信
QallApi PostSoundboard Post /qall/soundboard サウンドボード用の短い音声ファイルをアップロード
QallApi PostSoundboardPlay Post /qall/soundboard/play アップロード済み音声を LiveKit ルームで再生
QallApi UpdateRoomMetadata Patch /qall/rooms/{roomId}/metadata ルームのメタデータを更新
StampApi AddMessageStamp Post /messages/{messageId}/stamps/{stampId} スタンプを押す
StampApi ChangeStampImage Put /stamps/{stampId}/image スタンプ画像を変更
StampApi CreateStamp Post /stamps スタンプを作成
StampApi CreateStampPalette Post /stamp-palettes スタンプパレットを作成
StampApi DeleteStamp Delete /stamps/{stampId} スタンプを削除
StampApi DeleteStampPalette Delete /stamp-palettes/{paletteId} スタンプパレットを削除
StampApi EditStamp Patch /stamps/{stampId} スタンプ情報を変更
StampApi EditStampPalette Patch /stamp-palettes/{paletteId} スタンプパレットを編集
StampApi GetMessageStamps Get /messages/{messageId}/stamps メッセージのスタンプリストを取得
StampApi GetMyStampHistory Get /users/me/stamp-history スタンプ履歴を取得
StampApi GetStamp Get /stamps/{stampId} スタンプ情報を取得
StampApi GetStampImage Get /stamps/{stampId}/image スタンプ画像を取得
StampApi GetStampPalette Get /stamp-palettes/{paletteId} スタンプパレットを取得
StampApi GetStampPalettes Get /stamp-palettes スタンプパレットのリストを取得
StampApi GetStampStats Get /stamps/{stampId}/stats スタンプ統計情報を取得
StampApi GetStamps Get /stamps スタンプリストを取得
StampApi RemoveMessageStamp Delete /messages/{messageId}/stamps/{stampId} スタンプを消す
StarApi AddMyStar Post /users/me/stars チャンネルをスターに追加
StarApi GetMyStars Get /users/me/stars スターチャンネルリストを取得
StarApi RemoveMyStar Delete /users/me/stars/{channelId} チャンネルをスターから削除します
UserApi AddUserTag Post /users/{userId}/tags ユーザーにタグを追加
UserApi ChangeUserIcon Put /users/{userId}/icon ユーザーのアイコン画像を変更します
UserApi ChangeUserPassword Put /users/{userId}/password ユーザーのパスワードを変更
UserApi CreateUser Post /users ユーザーを登録
UserApi EditUser Patch /users/{userId} ユーザー情報を変更
UserApi EditUserTag Patch /users/{userId}/tags/{tagId} ユーザーのタグを編集
UserApi GetDirectMessages Get /users/{userId}/messages ダイレクトメッセージのリストを取得
UserApi GetUser Get /users/{userId} ユーザー詳細情報を取得
UserApi GetUserDMChannel Get /users/{userId}/dm-channel DMチャンネル情報を取得
UserApi GetUserIcon Get /users/{userId}/icon ユーザーのアイコン画像を取得
UserApi GetUserStats Get /users/{userId}/stats ユーザー統計情報を取得
UserApi GetUserTags Get /users/{userId}/tags ユーザーのタグリストを取得
UserApi GetUsers Get /users ユーザーのリストを取得
UserApi PostDirectMessage Post /users/{userId}/messages ダイレクトメッセージを送信
UserApi RemoveUserTag Delete /users/{userId}/tags/{tagId} ユーザーからタグを削除します
UserTagApi AddMyUserTag Post /users/me/tags 自分にタグを追加
UserTagApi AddUserTag Post /users/{userId}/tags ユーザーにタグを追加
UserTagApi EditMyUserTag Patch /users/me/tags/{tagId} 自分のタグを編集
UserTagApi EditUserTag Patch /users/{userId}/tags/{tagId} ユーザーのタグを編集
UserTagApi GetMyUserTags Get /users/me/tags 自分のタグリストを取得
UserTagApi GetTag Get /tags/{tagId} タグ情報を取得
UserTagApi GetUserTags Get /users/{userId}/tags ユーザーのタグリストを取得
UserTagApi RemoveMyUserTag Delete /users/me/tags/{tagId} 自分からタグを削除します
UserTagApi RemoveUserTag Delete /users/{userId}/tags/{tagId} ユーザーからタグを削除します
WebhookApi ChangeWebhookIcon Put /webhooks/{webhookId}/icon Webhookのアイコンを変更
WebhookApi CreateWebhook Post /webhooks Webhookを新規作成
WebhookApi DeleteWebhook Delete /webhooks/{webhookId} Webhookを削除
WebhookApi EditWebhook Patch /webhooks/{webhookId} Webhook情報を変更
WebhookApi GetWebhook Get /webhooks/{webhookId} Webhook情報を取得
WebhookApi GetWebhookIcon Get /webhooks/{webhookId}/icon Webhookのアイコンを取得
WebhookApi GetWebhookMessages Get /webhooks/{webhookId}/messages Webhookの投稿メッセージのリストを取得
WebhookApi GetWebhooks Get /webhooks Webhook情報のリストを取得します
WebhookApi PostWebhook Post /webhooks/{webhookId} Webhookを送信
WebrtcApi GetWebRTCState Get /webrtc/state WebRTC状態を取得
WebrtcApi PostWebRTCAuthenticate Post /webrtc/authenticate Skyway用認証API

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

cookieAuth

  • Type: API key
  • API key parameter name: r_session
  • Location:

Note, each API key must be added to a map of map[string]APIKey where the key is: r_session and passed in as the auth context for each request.

OAuth2

  • Type: OAuth
  • Flow: accessCode
  • Authorization URL: /api/v3/oauth2/authorize
  • Scopes:
  • read: 読み取りスコープ
  • write: 書き込みスコープ
  • manage_bot: bot関連読み書きスコープ

Example

auth := context.WithValue(context.Background(), sw.ContextAccessToken, "ACCESSTOKENSTRING")
r, err := client.Service.Operation(auth, args)

Or via OAuth2 module to automatically refresh tokens and perform user authentication.

import "golang.org/x/oauth2"

/* Perform OAuth2 round trip request and obtain a token */

tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)

bearerAuth

  • Type: HTTP Bearer token authentication

Example

auth := context.WithValue(context.Background(), sw.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author