* api: remove PHP code samples

* api: remove Curl code samples

* api: remove Go code samples

* link out to marketplace exclusively for community-built drivers

* absolute path to V4_SRC

* programmatically extract x-codeSamples

* initial batch of examples

* Update api/server/main.go

Co-authored-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>

* Update api/server/main.go

Co-authored-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>

* Update api/server/main.go

Co-authored-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>

* updated examples

---------

Co-authored-by: Alejandro García Montoro <alejandro.garciamontoro@gmail.com>
Этот коммит содержится в:
Jesse Hallam
2023-08-03 12:45:10 -03:00
коммит произвёл GitHub
родитель 72b648cf81
Коммит 885802eae7
23 изменённых файлов: 847 добавлений и 5224 удалений

Просмотреть файл

@@ -38,33 +38,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: PHP
source: |
require 'vendor/autoload.php';
use \Gnello\Mattermost\Driver;
$container = new \Pimple\Container([
"driver" => [
"url" => "https://your-mattermost-url.com",
"login_id" => "email@domain.com",
"password" => "Password1",
]
]);
$driver = new Driver($container);
$driver->authenticate();
$resp = $driver->getBotModel()->createBot([
"username" => "userbot",
"display_name" => "AwesomeBot",
"description" => "test bot"
]);
if ($resp->getStatusCode() == 200) {
$createdBot = json_decode($resp->getBody());
}
get:
tags:
- bots
@@ -118,34 +91,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: PHP
source: |
require 'vendor/autoload.php';
use \Gnello\Mattermost\Driver;
$container = new \Pimple\Container([
"driver" => [
"url" => "https://your-mattermost-url.com",
"login_id" => "email@domain.com",
"password" => "Password1",
]
]);
$driver = new Driver($container);
$driver->authenticate();
$resp = $driver->getBotModel()->getBots([
"page" => 0,
"per_page" => 60,
"include_deleted" => true,
"only_orphaned" => true,
]);
if ($resp->getStatusCode() == 200) {
$bots = json_decode($resp->getBody());
}
"/api/v4/bots/{bot_user_id}":
put:
tags:
@@ -198,35 +143,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: PHP
source: |
require 'vendor/autoload.php';
use \Gnello\Mattermost\Driver;
$container = new \Pimple\Container([
"driver" => [
"url" => "https://your-mattermost-url.com",
"login_id" => "email@domain.com",
"password" => "Password1",
]
]);
$driver = new Driver($container);
$driver->authenticate();
$botUserID = "4xp9fdt77pncbef59f4k1qe83o";
$resp = $driver->getBotModel()->patchBot($botUserID, [
"username" => "userbot2",
"display_name" => "AwesomeBot2",
"description" => "test bot2"
]);
if ($resp->getStatusCode() == 200) {
$bot = json_decode($resp->getBody());
}
get:
tags:
- bots
@@ -265,33 +181,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: PHP
source: |
require 'vendor/autoload.php';
use \Gnello\Mattermost\Driver;
$container = new \Pimple\Container([
"driver" => [
"url" => "https://your-mattermost-url.com",
"login_id" => "email@domain.com",
"password" => "Password1",
]
]);
$driver = new Driver($container);
$driver->authenticate();
$botUserID = "4xp9fdt77pncbef59f4k1qe83o";
$resp = $driver->getBotModel()->getBot($botUserID, [
"include_deleted" => true,
]);
if ($resp->getStatusCode() == 200) {
$bot = json_decode($resp->getBody());
}
"/api/v4/bots/{bot_user_id}/disable":
post:
tags:
@@ -323,31 +212,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: PHP
source: |
require 'vendor/autoload.php';
use \Gnello\Mattermost\Driver;
$container = new \Pimple\Container([
"driver" => [
"url" => "https://your-mattermost-url.com",
"login_id" => "email@domain.com",
"password" => "Password1",
]
]);
$driver = new Driver($container);
$driver->authenticate();
$botUserID = "4xp9fdt77pncbef59f4k1qe83o";
$resp = $driver->getBotModel()->disableBot($botUserID);
if ($resp->getStatusCode() == 200) {
$disabledBot = json_decode($resp->getBody());
}
"/api/v4/bots/{bot_user_id}/enable":
post:
tags:
@@ -379,31 +243,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: PHP
source: |
require 'vendor/autoload.php';
use \Gnello\Mattermost\Driver;
$container = new \Pimple\Container([
"driver" => [
"url" => "https://your-mattermost-url.com",
"login_id" => "email@domain.com",
"password" => "Password1",
]
]);
$driver = new Driver($container);
$driver->authenticate();
$botUserID = "4xp9fdt77pncbef59f4k1qe83o";
$resp = $driver->getBotModel()->enableBot($botUserID);
if ($resp->getStatusCode() == 200) {
$enabledBot = json_decode($resp->getBody());
}
"/api/v4/bots/{bot_user_id}/assign/{user_id}":
post:
tags:
@@ -441,32 +280,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: PHP
source: |
require 'vendor/autoload.php';
use \Gnello\Mattermost\Driver;
$container = new \Pimple\Container([
"driver" => [
"url" => "https://your-mattermost-url.com",
"login_id" => "email@domain.com",
"password" => "Password1",
]
]);
$driver = new Driver($container);
$driver->authenticate();
$botUserID = "4xp9fdt77pncbef59f4k1qe83o";
$userID = "adWv1qPZmHdtxk7Lmqh6RtxWxS";
$resp = $driver->getBotModel()->assignBotToUser($botUserID, $userID);
if ($resp->getStatusCode() == 200) {
$assignedBot = json_decode($resp->getBody());
}
"/api/v4/bots/{bot_user_id}/icon":
get:
tags:
@@ -500,41 +313,6 @@
$ref: "#/components/responses/InternalServerError"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
botUserID := "4xp9fdt77pncbef59f4k1qe83o"
data, resp := Client.GetBotIconImage(botUserID)
- lang: PHP
source: |
require 'vendor/autoload.php';
use \Gnello\Mattermost\Driver;
$container = new \Pimple\Container([
"driver" => [
"url" => "https://your-mattermost-url.com",
"login_id" => "email@domain.com",
"password" => "Password1",
]
]);
$driver = new Driver($container);
$driver->authenticate();
$botUserID = "4xp9fdt77pncbef59f4k1qe83o";
$resp = $driver->getBotModel()->getBotIcon($botUserID);
if ($resp->getStatusCode() == 200) {
$data = json_decode($resp->getBody());
}
post:
tags:
- bots
@@ -587,62 +365,6 @@
$ref: "#/components/responses/InternalServerError"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import (
"io/ioutil"
"log"
"github.com/mattermost/mattermost-server/v5/model"
)
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
data, err := ioutil.ReadFile("icon_image.svg")
if err != nil {
log.Fatal(err)
}
botUserID := "4xp9fdt77pncbef59f4k1qe83o"
ok, resp := Client.SetBotIconImage(botUserID, data)
- lang: PHP
source: |
require 'vendor/autoload.php';
use \Gnello\Mattermost\Driver;
$container = new \Pimple\Container([
"driver" => [
"url" => "https://your-mattermost-url.com",
"login_id" => "email@domain.com",
"password" => "Password1",
]
]);
$driver = new Driver($container);
$driver->authenticate();
$botUserID = "4xp9fdt77pncbef59f4k1qe83o";
$resource = fopen("icon_image.svg", 'rb');
if ($resource === false) {
throw new \Exeption("Failure.");
}
$data = new \GuzzleHttp\Psr7\Stream($resource);
$resp = $driver->getBotModel()->setBotIcon($botUserID, [
"image" => $data,
]);
fclose($resource);
if ($resp->getStatusCode() == 200) {
$ok = json_decode($resp->getBody())->status;
}
delete:
tags:
- bots
@@ -679,41 +401,6 @@
$ref: "#/components/responses/InternalServerError"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
botUserID := "4xp9fdt77pncbef59f4k1qe83o"
ok, resp := Client.DeleteBotIconImage(botUserID)
- lang: PHP
source: |
require 'vendor/autoload.php';
use \Gnello\Mattermost\Driver;
$container = new \Pimple\Container([
"driver" => [
"url" => "https://your-mattermost-url.com",
"login_id" => "email@domain.com",
"password" => "Password1",
]
]);
$driver = new Driver($container);
$driver->authenticate();
$botUserID = "4xp9fdt77pncbef59f4k1qe83o";
$resp = $driver->getBotModel()->deleteBotIcon($botUserID);
if ($resp->getStatusCode() == 200) {
$ok = json_decode($resp->getBody())->status;
}
"/api/v4/bots/{bot_user_id}/convert_to_user":
post:
tags:
@@ -784,17 +471,3 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
userId := "BbaYBYDV5IDOZFiJGBSzkw1k5u"
patch := &model.UserPatch{}
patch.Email = model.NewString("test@domain.com")
patch.Username = model.NewString("testUsername")
patch.Password = model.NewString("password")
user, resp := Client.ConvertBotToUser(userId, userPatch, false)

Просмотреть файл

@@ -22,16 +22,6 @@
$ref: "#/components/responses/NotFound"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetBrandImage
img, err := Client.GetBrandImage()
post:
tags:
- brand
@@ -70,26 +60,6 @@
$ref: "#/components/responses/TooLarge"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
file, err := os.Open("<Your image>")
if err != nil {
return err
}
defer file.Close()
data := &bytes.Buffer{}
if _, err := io.Copy(data, file); err != nil {
return err
}
ok, resp := Client.UploadBrandImage(data.Bytes())
delete:
tags:
- brand
@@ -117,13 +87,3 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// Delete brand image
resp := Client.DeleteBrandImage()

Просмотреть файл

@@ -124,22 +124,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
channel := &model.Channel{DisplayName: <YOUR CHANNEL DISPLAYNAME>, Name: <YOUR CHANNEL NAME>, Type: <CHANNEL TYPE OPEN/PRIVATE>, TeamId: <YOUR TEAM ID>}
// CreateChannel
rchannel, resp := Client.CreateChannel(channel)
/api/v4/channels/direct:
post:
tags:
@@ -176,15 +160,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// CreateDirectChannel
dm, resp := Client.CreateDirectChannel(<ID OF User1>, <ID OF User2>)
/api/v4/channels/group:
post:
tags:
@@ -220,17 +195,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
userIds := []string{<ID OF User1>, <ID OF User2>, <ID OF User3> ...}
// CreateGroupChannel
rgc, resp := Client.CreateGroupChannel(userIds)
/api/v4/channels/search:
post:
tags:
@@ -420,17 +384,6 @@
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
search := &model.ChannelSearch{Term: <MEMBER USERNAME>}
// SearchGroupChannels
channels, resp := Client.SearchGroupChannels(search)
"/api/v4/teams/{team_id}/channels/ids":
post:
tags:
@@ -472,22 +425,6 @@
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
channelIds := []string{<ID OF CHANNEL1>, <ID OF CHANNEL2>, ...}
// GetPublicChannelsByIdsForTeam
channels, resp := Client.GetPublicChannelsByIdsForTeam(<TEAMID>, channelIds)
"/api/v4/channels/{channel_id}/timezones":
get:
tags:
@@ -523,15 +460,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetChannelStats
stats, resp := Client.GetChannelTimezones(<CHANNELID>)
"/api/v4/channels/{channel_id}":
get:
tags:
@@ -562,15 +490,6 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetChannel
channel, resp := Client.GetChannel(<CHANNELID>, "")
put:
tags:
- channels
@@ -632,22 +551,6 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
channel := &model.Channel{DisplayName: <YOUR CHANNEL NEW DISPLAYNAME>, ChannelId: <CHANNELID>, TeamId: <YOUR TEAM ID>}
// UpdateChannel
updatedChannel, resp := Client.UpdateChannel(channel)
delete:
tags:
- channels
@@ -689,15 +592,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// DeleteChannel
pass, resp := Client.DeleteChannel(<CHANNELID>)
"/api/v4/channels/{channel_id}/patch":
put:
tags:
@@ -757,26 +651,6 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
patch := &model.ChannelPatch{
Name: new(string),
DisplayName: new(string),
Header: new(string),
Purpose: new(string),
}
*patch.Name = "<SOME_NEW_NAME>"
*patch.DisplayName = "<SOME_NEW_DISPLAYNAME>"
*patch.Header = "<SOME_NEW_HEADER>"
*patch.Purpose = "<SOME_NEW_PURPOSE>"
// PatchChannel
channel, resp := Client.PatchChannel(<CHANNELID>, patch)
"/api/v4/channels/{channel_id}/privacy":
put:
tags:
@@ -831,24 +705,6 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// Update channel's privacy to Public
updatedChannel, resp := Client.UpdateChannelPrivacy(<CHANNELID>, model.CHANNEL_OPEN)
// Update channel's privacy to Private
updatedChannel, resp := Client.UpdateChannelPrivacy(<CHANNELID>, model.CHANNEL_PRIVATE)
"/api/v4/channels/{channel_id}/restore":
post:
tags:
@@ -962,15 +818,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetChannelStats
stats, resp := Client.GetChannelStats(<CHANNELID>)
"/api/v4/channels/{channel_id}/pinned":
get:
tags:
@@ -998,15 +845,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetPinnedPosts
posts, resp := Client.GetPinnedPosts(<CHANNELID>, "")
"/api/v4/teams/{team_id}/channels":
get:
tags:
@@ -1056,18 +894,6 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetPublicChannelsForTeam
channels, resp := Client.GetPublicChannelsForTeam(<TEAMID>, 0, 100, "")
"/api/v4/teams/{team_id}/channels/private":
get:
tags:
@@ -1118,18 +944,6 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetPrivateChannelsForTeam
channels, resp := Client.GetPrivateChannelsForTeam(<TEAMID>, 0, 100, "")
"/api/v4/teams/{team_id}/channels/deleted":
get:
tags:
@@ -1326,17 +1140,6 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
search := &model.ChannelSearch{Term: <CHANNEL DISPLAYNAME>}
// SearchChannels
channels, resp := Client.SearchChannels(<TEAMID>, search)
"/api/v4/teams/{team_id}/channels/search_archived":
post:
tags:
@@ -1395,17 +1198,6 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
search := &model.ChannelSearch{Term: <CHANNEL DISPLAYNAME>}
// SearchChannels
channels, resp := Client.SearchArchivedChannels(<TEAMID>, search)
"/api/v4/teams/{team_id}/channels/name/{channel_name}":
get:
tags:
@@ -1448,19 +1240,6 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetChannelByName
channel, resp := Client.GetChannelByName(<CHANNEL NAME>, <TEAMID>, "")
"/api/v4/teams/name/{team_name}/channels/name/{channel_name}":
get:
tags:
@@ -1503,19 +1282,6 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetChannelByNameForTeamName
channel, resp = Client.GetChannelByNameForTeamName(<CHANNEL NAME>, <TEAM NAME>, "")
"/api/v4/channels/{channel_id}/members":
get:
tags:
@@ -1560,19 +1326,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetChannelMembers
members, resp := Client.GetChannelMembers(th.BasicChannel.Id, 0, 60, "")
post:
tags:
- channels
@@ -1615,24 +1368,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// AddChannelMember
cm, resp := Client.AddChannelMember(<CHANNEL ID>, <ID OF USER TO ADD>)
// AddChannelMemberWithRootId
cm, resp := Client.AddChannelMemberWithRootId(<CHANNEL ID>, <ID OF USER TO ADD>, <POST ROOT ID>)
"/api/v4/channels/{channel_id}/members/ids":
post:
tags:
@@ -1676,17 +1411,6 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
usersIds := []string{<Id of User1>, <Id of User2>, ...}
// GetChannelMembersByIds
cm, resp := Client.GetChannelMembersByIds(<CHANNELID>, usersIds)
"/api/v4/channels/{channel_id}/members/{user_id}":
get:
tags:
@@ -1723,15 +1447,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetChannelMember
member, resp := Client.GetChannelMember(<CHANNELID>, <USERID>, "")
delete:
tags:
- channels
@@ -1774,15 +1489,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// RemoveUserFromChannel
pass, resp := Client.RemoveUserFromChannel(<CHANNELID>, <USERID>)
"/api/v4/channels/{channel_id}/members/{user_id}/roles":
put:
tags:
@@ -1831,19 +1537,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// UpdateChannelRoles
pass, resp := Client.UpdateChannelRoles(<CHANNELID>, <USERIDTOPROMOTE>, "channel_admin channel_user")
"/api/v4/channels/{channel_id}/members/{user_id}/schemeRoles":
put:
tags:
@@ -1951,26 +1644,6 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
props := map[string]string{}
props[model.DESKTOP_NOTIFY_PROP] = model.CHANNEL_NOTIFY_MENTION
props[model.MARK_UNREAD_NOTIFY_PROP] = model.CHANNEL_MARK_UNREAD_MENTION
// UpdateChannelNotifyProps
pass, resp := Client.UpdateChannelNotifyProps(<CHANNELID>, <USERID>, props)
"/api/v4/channels/members/{user_id}/view":
post:
tags:
@@ -2034,18 +1707,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
view := &model.ChannelView{
ChannelId: <CHANNELID>,
}
// ViewChannel
pass, resp := Client.ViewChannel(<USERID>, view)
"/api/v4/users/{user_id}/teams/{team_id}/channels/members":
get:
tags:
@@ -2087,19 +1748,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetChannelMembersForUser
members, resp := Client.GetChannelMembersForUser(<USERID>, <TEAMID>, "")
"/api/v4/users/{user_id}/teams/{team_id}/channels":
get:
tags:
@@ -2154,19 +1802,6 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetChannelsForTeamForUser
channels, resp := Client.GetChannelsForTeamForUser(<TEAMID>, <USERID>, "")
"/api/v4/users/{user_id}/channels":
get:
tags:
@@ -2217,21 +1852,6 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v6/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
channels, response, err := Client.GetChannelsForUserWithLastDeleteAt("fc6suoon9pbbpmhrb9c967paxe", 0)
- lang: Curl
source: |
curl -X GET 'http://localhost:8065/api/v4/users/fc6suoon9pbbpmhrb9c967paxe/channels' \
-H 'Authorization: Bearer 9kg8nqrnxprd9jbykqeg4r51hw'
"/api/v4/users/{user_id}/channels/{channel_id}/unread":
get:
tags:
@@ -2272,19 +1892,6 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetChannelUnread
channelUnread, resp := Client.GetChannelUnread(<CHANNELID>, <USERID>)
"/api/v4/channels/{channel_id}/scheme":
put:
tags:
@@ -2337,23 +1944,6 @@
$ref: "#/components/responses/Forbidden"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
channelID := "4xp9fdt77pncbef59f4k1qe83o"
schemeID := "qjda3stwafbgpqjaxej3k76sga"
ok, resp := UpdateChannelScheme(channelID, schemeID)
- lang: curl
source: >
curl -X PUT \
https://your-mattermost-url.com/api/v4/channels/4xp9fdt77pncbef59f4k1qe83o/scheme \
-H 'Authorization: Bearer frn8fu5rtpyc5m4xy6q3oj4yur' \
-H 'Content-Type: application/json' \
-d '{"scheme_id": "qjda3stwafbgpqjaxej3k76sga"}'
"/api/v4/channels/{channel_id}/members_minus_group_members":
get:
tags:
@@ -2411,14 +2001,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: curl
source: >
curl -X GET \
'http://your-mattermost-url.com/api/v4/channels/3wyp678obid8pggjmhmhwpah1r/members_minus_group_members?group_ids=eoezijg8zffgjmch8icy5bjd1e,ugaw6wjc3tfxpcr1eq5u5k8dhe&page=0&per_page=100' \
-H 'Authorization: Bearer kno8tcdotpbx3dj1gzcbx9jrqy' \
-H 'Content-Type: application/json' \
-H 'X-Requested-With: XMLHttpRequest'
"/api/v4/channels/{channel_id}/member_counts_by_group":
get:
tags:
@@ -2455,14 +2037,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: curl
source: >
curl -X GET \
'http://your-mattermost-url.com/api/v4/channels/3wyp678obid8pggjmhmhwpah1r/member_counts_by_group?include_timezones=true' \
-H 'Authorization: Bearer kno8tcdotpbx3dj1gzcbx9jrqy' \
-H 'Content-Type: application/json' \
-H 'X-Requested-With: XMLHttpRequest'
"/api/v4/channels/{channel_id}/moderations":
get:
tags:

Просмотреть файл

@@ -48,28 +48,6 @@
$ref: "#/components/responses/Forbidden"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
newCmd := &model.Command {
TeamId: <TEAMID>,
URL: "http://nowhere.com",
Method: model.COMMAND_METHOD_POST,
Trigger: "trigger",
AutoComplete: false,
Description: "Description",
DisplayName: "Display name",
IconURL: "IconURL",
Username: "Username"
}
// CreateCommand
createdCmd, resp := Client.CreateCommand(newCmd)
get:
tags:
- commands
@@ -111,22 +89,6 @@
$ref: "#/components/responses/Forbidden"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// ListCommands
// The second parameter is to set if you want only custom commands (true) or defaults commands (false)
listCommands, resp := Client.ListCommands(<TEAMID>, true)
"/api/v4/teams/{team_id}/commands/autocomplete":
get:
tags:
@@ -159,16 +121,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// ListAutocompleteCommands
listCommands, resp := Client.ListAutocompleteCommands(<TEAMID>)
'/api/v4/teams/{team_id}/commands/autocomplete_suggestions':
get:
tags:
@@ -208,18 +160,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: 'Go'
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// ListCommandAutocompleteSuggestions
teamID := "4xp9fdt77pncbef59f4k1qe83o"
userInput := "/jira"
listCommands, resp := Client.ListCommandAutocompleteSuggestions(userInput, teamID)
"/api/v4/commands/{command_id}":
get:
tags:
@@ -255,16 +195,6 @@
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetCommand
cmd, resp := Client.GetCommand(<COMMANDID>)
put:
tags:
- commands
@@ -302,24 +232,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
cmdToUpdate := &model.Command{
CreatorId: <USERID>,
TeamId: <TEAMID>,
URL: "<http://nowhere.com/change>",
Trigger: <NEWTRIGGERNAME>,
Id: <COMMANDID>,
}
// UpdateCommand
listCommands, resp := Client.UpdateCommand(cmdToUpdate)
delete:
tags:
- commands
@@ -353,16 +265,6 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// DeleteCommand
ok, resp := Client.DeleteCommand(<COMMANDID>)
"/api/v4/commands/{command_id}/move":
put:
tags:
@@ -410,16 +312,6 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// MoveCommand
ok, resp := Client.MoveCommand(<TEAMID>,<COMMANDID>)
"/api/v4/commands/{command_id}/regen_token":
put:
tags:
@@ -456,16 +348,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// RegenCommandToken
newToken, resp := Client.RegenCommandToken(<COMMANDID>)
/api/v4/commands/execute:
post:
tags:

Просмотреть файл

@@ -21,18 +21,6 @@
$ref: "#/components/responses/Forbidden"
"500":
$ref: "#/components/responses/InternalServerError"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
exports, response := Client.ListExports()
- lang: Curl
source: |
curl 'http://localhost:8065/api/v4/exports' \
-H 'Authorization: Bearer 9kg8nqrnxprd9jbykqeg4r51hw'
"/api/v4/exports/{export_name}":
get:
tags:
@@ -66,26 +54,6 @@
$ref: "#/components/responses/NotFound"
"500":
$ref: "#/components/responses/InternalServerError"
x-code-samples:
- lang: Go
source: |
import (
"os"
"github.com/mattermost/mattermost-server/v5/model"
}
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
outFile, _ := os.Create("export.zip")
n, response := Client.DownloadExport("export.zip", outFile, 0)
- lang: Curl
source: |
curl 'http://localhost:8065/api/v4/exports/export.zip' \
-H 'Authorization: Bearer 9kg8nqrnxprd9jbykqeg4r51hw'
delete:
tags:
- exports
@@ -116,17 +84,3 @@
$ref: "#/components/responses/Forbidden"
"500":
$ref: "#/components/responses/InternalServerError"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
ok, response := Client.DeleteExport("export.zip")
- lang: Curl
source: |
curl -X DELETE 'http://localhost:8065/api/v4/exports/export.zip' \
-H 'Authorization: Bearer 9kg8nqrnxprd9jbykqeg4r51hw'

Просмотреть файл

@@ -83,45 +83,6 @@
$ref: "#/components/responses/TooLarge"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
file, err := os.Open("file.png")
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
}
defer file.Close();
buf := bytes.NewBuffer(nil)
io.Copy(buf, file)
data := buf.Bytes()
channelID := "4xp9fdt77pncbef59f4k1qe83o"
filename := "file.png"
fileUploadResponse, response := Client.UploadFile(data, channelID, filename)
- lang: Curl
source: |
curl -F 'files=@PATH/TO/LOCAL/FILE' \
-F 'channel_id=CHANNEL_ID' \
--header 'authorization: Bearer c49adc55z3f53ck7xtp8ebq1ir'
https://your-mattermost-url.com/api/v4/files
"/api/v4/files/{file_id}":
get:
tags:
@@ -159,17 +120,6 @@
$ref: "#/components/responses/NotFound"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
fileID := "4xp9fdt77pncbef59f4k1qe83o"
data, resp := Client.GetFile(fileID)
"/api/v4/files/{file_id}/thumbnail":
get:
tags:
@@ -207,17 +157,6 @@
$ref: "#/components/responses/NotFound"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
fileID := "4xp9fdt77pncbef59f4k1qe83o"
data, resp := Client.GetFileThumbnail(fileID)
"/api/v4/files/{file_id}/preview":
get:
tags:
@@ -255,17 +194,6 @@
$ref: "#/components/responses/NotFound"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
fileID := "4xp9fdt77pncbef59f4k1qe83o"
data, resp := Client.GetFilePreview(fileID)
"/api/v4/files/{file_id}/link":
get:
tags:
@@ -315,17 +243,6 @@
$ref: "#/components/responses/NotFound"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
fileID := "4xp9fdt77pncbef59f4k1qe83o"
data, resp := Client.GetFileLink(fileID)
"/api/v4/files/{file_id}/info":
get:
tags:
@@ -369,17 +286,6 @@
$ref: "#/components/responses/NotFound"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
fileID := "4xp9fdt77pncbef59f4k1qe83o"
info, resp := Client.GetFileInfo(fileID)
"/files/{file_id}/public":
get:
tags:
@@ -499,22 +405,3 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
teamID := "zWEyrTZ7GZ22aBSfoX60iWryTY"
fileInfoList, resp := Client.SearchFiles(teamID, "filename", false)
- lang: curl
source: >
curl -X POST \
https://your-mattermost-url.com/api/v4/teams/zWEyrTZ7GZ22aBSfoX60iWryTY/files/search \
-H 'Authorization: Bearer frn8fu5rtpyc5m4xy6q3oj4yur' \
-H 'Content-Type: application/json' \
-d '{"terms": "filename", "is_or_search": false}'

Просмотреть файл

@@ -22,18 +22,3 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
imports, response := Client.ListImports()
- lang: Curl
source: |
curl 'http://localhost:8065/api/v4/imports' \
-H 'Authorization: Bearer 9kg8nqrnxprd9jbykqeg4r51hw'

Просмотреть файл

@@ -61,15 +61,9 @@ tags:
* [Mattermost Golang Driver](https://github.com/mattermost/mattermost/blob/master/server/public/model/client4.go)
#### Community-built Drivers
* [PHP Driver](https://github.com/gnello/php-mattermost-driver) - built by [@gnello](https://github.com/gnello) and [@prixone](https://github.com/prixone)
* [Python Driver](https://github.com/Vaelor/python-mattermost-driver) - built by [@Vaelor](https://github.com/Vaelor)
For other community-built drivers and API wrappers, see [our app directory](https://mattermost.com/marketplace/).
For community-built drivers and API wrappers, see [our app directory](https://mattermost.com/marketplace/).
- name: authentication
description: >
There are multiple ways to authenticate against the Mattermost API.

Просмотреть файл

@@ -209,26 +209,6 @@
$ref: "#/components/responses/NotFound"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
appToUpdate := &model.OAuthApp{
Id: <APP ID>,
Name: <APP NAME>,
Description: <APP DESCRIPTION>,
IconURL: <URL TO APP ICON>,
CallbackUrls: [<CALLBACK URL1>, <CALLBACK URL2>],
Homepage: <URL TO APP HOMEPAGE>,
IsTrusted: <BOOLEAN>
}
// UpdateOAuthApp
updatedApp, resp := Client.UpdateOAuthApp(appToUpdate)
delete:
tags:
- OAuth

Просмотреть файл

@@ -49,38 +49,6 @@
$ref: "#/components/responses/TooLarge"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: >
import (
"bytes"
"io/ioutil"
"log"
"github.com/mattermost/mattermost-server/v5/model"
)
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
tarData, err := ioutil.ReadFile("plugin.tar.gz")
if err != nil {
log.Fatal("error while reading file")
}
// Not forced
manifest, resp := Client.UploadPlugin(bytes.NewReader(tarData))
// Forced
manifest, resp := Client.UploadPluginForced(bytes.NewReader(tarData))
get:
tags:
- plugins
@@ -121,15 +89,6 @@
$ref: "#/components/responses/Forbidden"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
pluginsResp, resp := Client.GetPlugins()
/api/v4/plugins/install_from_url:
post:
tags:
@@ -174,23 +133,6 @@
$ref: "#/components/responses/Forbidden"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import (
"github.com/mattermost/mattermost-server/v5/model"
)
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
url := "https://mysite.com/my-plugin.tar.gz"
// Not forced
manifest, resp := Client.InstallPluginFromUrl(url, false)
// Forced
manifest, resp := Client.InstallPluginFromUrl(url, true)
"/api/v4/plugins/{plugin_id}":
delete:
tags:
@@ -232,17 +174,6 @@
$ref: "#/components/responses/NotFound"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
pluginID := "com.mattermost.demo-plugin"
ok, resp = Client.RemovePlugin(pluginID)
"/api/v4/plugins/{plugin_id}/enable":
post:
tags:
@@ -284,17 +215,6 @@
$ref: "#/components/responses/NotFound"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
pluginID := "com.mattermost.demo-plugin"
ok, resp = Client.EnablePlugin(pluginID)
"/api/v4/plugins/{plugin_id}/disable":
post:
tags:
@@ -336,17 +256,6 @@
$ref: "#/components/responses/NotFound"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
pluginID := "com.mattermost.demo-plugin"
ok, resp = Client.DisablePlugin(pluginID)
/api/v4/plugins/webapp:
get:
tags:
@@ -377,14 +286,6 @@
$ref: "#/components/responses/Forbidden"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
manifests, resp := Client.GetWebappPlugins()
/api/v4/plugins/statuses:
get:
tags:
@@ -415,14 +316,6 @@
$ref: "#/components/responses/Forbidden"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
manifests, resp := Client.GetPluginStatuses()
/api/v4/plugins/marketplace:
post:
tags:
@@ -470,19 +363,6 @@
$ref: "#/components/responses/NotFound"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
plugin := &model.InstallMarketplacePluginRequest{
Id: "antivirus",
}
ok, resp = Client.InstallMarketplacePlugin(plugin)
get:
tags:
- plugins
@@ -548,23 +428,6 @@
$ref: "#/components/responses/Forbidden"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
filter := &model.MarketplacePluginFilter{
Page: 1,
PerPage: 10,
Filter: "antivirus",
ServerVersion: "0.1.2",
LocalOnly: true,
}
ok, resp = Client.GetMarketplacePlugins(filter)
/api/v4/plugins/marketplace/first_admin_visit:
get:
tags:

Просмотреть файл

@@ -127,21 +127,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
client := model.NewAPIv4Client("https://your-mattermost-url.com")
client.Login("email@domain.com", "Password1")
ephemeralPost := &model.PostEphemeral{
UserID: "<ID OF THE USER THAT WOULD RECEIVE THE POST>",
Post: &model.Post{
ChannelId: "<ID OF CHANNEL>",
Message: "<YOUR MESSAGE>",
},
}
createdPost, response := client.CreatePostEphemeral(ephemeralPost)
"/api/v4/posts/{post_id}":
get:
tags:

Просмотреть файл

@@ -25,15 +25,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
roles, resp := Client.GetAllRoles()
"/api/v4/roles/{role_id}":
get:
tags:
@@ -65,14 +56,6 @@
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
role, resp := Client.GetRole(<ROLEID>, "")
"/api/v4/roles/name/{role_name}":
get:
tags:
@@ -104,14 +87,6 @@
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
role, resp := Client.GetRoleByName(<ROLENAME>, "")
"/api/v4/roles/{role_id}/patch":
put:
tags:
@@ -202,13 +177,3 @@
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
roleNames := []string{<NAME OF ROLE1>, <NAME OF ROLE2>, ...}
roles, resp := Client.GetRolesByNames(roleNames)

Просмотреть файл

@@ -130,14 +130,6 @@
$ref: "#/components/responses/NotFound"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
scheme, resp := Client.GetScheme(<SCHEMEID>, "")
delete:
tags:
- schemes

Просмотреть файл

@@ -45,23 +45,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
teamID := "4xp9fdt77pncbef59f4k1qe83o"
shared_channels, err := Client.GetAllSharedChannels(teamID, 0, 100)
- lang: curl
source: |
curl -X POST \
'http://your-mattermost-url.com/api/v4/sharedchannels/4xp9fdt77pncbef59f4k1qe83o' \
-H 'Authorization: Bearer kno8tcdotpbx3dj1gzcbx9jrqy'
"/api/v4/sharedchannels/remote_info/{remote_id}":
get:
tags:
@@ -97,20 +80,3 @@
$ref: "#/components/responses/Forbidden"
"404":
$ref: "#/components/responses/NotFound"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
remoteID := "4xp9fdt77pncbef59f4k1qe83o"
info, err := Client.GetRemoteClusterInfo(remoteID)
- lang: curl
source: |
curl -X POST \
'http://your-mattermost-url.com/api/v4/sharedchannels/getremote/4xp9fdt77pncbef59f4k1qe83o' \
-H 'Authorization: Bearer kno8tcdotpbx3dj1gzcbx9jrqy'

Просмотреть файл

@@ -73,19 +73,6 @@
$ref: "#/components/schemas/SystemStatusResponse"
"500":
$ref: "#/components/responses/InternalServerError"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetPing
status, resp := Client.GetPing()
// Get server status with database and storage checks
status, resp = Client.GetPingWithServerStatus()
"/api/v4/system/notices/{teamId}":
get:
tags:
@@ -137,15 +124,6 @@
"500":
$ref: "#/components/responses/InternalServerError"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
notices, resp := Client.GetNotices(0, teamId, "mobile-android", "1.2.3", "enUS")
/api/v4/system/notices/view:
put:
tags:
@@ -178,17 +156,6 @@
$ref: "#/components/schemas/StatusOK"
"500":
$ref: "#/components/responses/InternalServerError"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
notices := []string{"id1","id2"}
resp := Client.MarkNoticesViewed(notices)
/api/v4/database/recycle:
post:
tags:
@@ -211,15 +178,6 @@
$ref: "#/components/schemas/StatusOK"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
ok, resp := Client.DatabaseRecycle()
/api/v4/email/test:
post:
tags:
@@ -253,25 +211,6 @@
$ref: "#/components/responses/Forbidden"
"500":
$ref: "#/components/responses/InternalServerError"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
config := model.Config{
EmailSettings: model.EmailSettings{
SMTPServer: <SMTPServer>,
SMTPPort: <SMTPPort>,
SMTPUsername: <SMTPUsername>,
SMTPPassword: <SMTPPassword>,
},
}
// TestEmail
ok, resp := Client.TestEmail(&config)
/api/v4/site_url/test:
post:
tags:
@@ -314,18 +253,6 @@
$ref: "#/components/responses/Forbidden"
"500":
$ref: "#/components/responses/InternalServerError"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
siteURL := "https://your-new-mattermost-url.com"
// TestSiteURL
ok, resp := Client.TestSiteURL(siteUrl)
/api/v4/file/s3_test:
post:
tags:
@@ -361,26 +288,6 @@
$ref: "#/components/responses/Forbidden"
"500":
$ref: "#/components/responses/InternalServerError"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
config := model.Config{
FileSettings: model.FileSettings{
DriverName: model.NewString(model.IMAGE_DRIVER_S3),
AmazonS3AccessKeyId: <AmazonS3AccessKeyId>,
AmazonS3SecretAccessKey: <AmazonS3SecretAccessKey>,
AmazonS3Bucket: <AmazonS3Bucket>,
AmazonS3Endpoint: <AmazonS3Endpoint>
},
}
// TestS3Connection
ok, resp := Client.TestS3Connection(&config)
/api/v4/config:
get:
tags:
@@ -402,16 +309,6 @@
$ref: "#/components/responses/BadRequest"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetConfig
config, resp := Client.GetConfig()
put:
tags:
- system
@@ -449,21 +346,6 @@
$ref: "#/components/responses/BadRequest"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetConfig
config, resp := Client.GetConfig()
config.TeamSettings.SiteName = "MyFancyName"
// UpdateConfig
updatedConfig, resp := Client.UpdateConfig(config)
/api/v4/config/reload:
post:
tags:
@@ -485,16 +367,6 @@
$ref: "#/components/responses/BadRequest"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// ReloadConfig
ok, resp := Client.ReloadConfig()
/api/v4/config/client:
get:
tags:
@@ -519,16 +391,6 @@
$ref: "#/components/responses/BadRequest"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetOldClientConfig
ok, resp := Client.GetOldClientConfig()
/api/v4/config/environment:
get:
tags:
@@ -604,21 +466,6 @@
$ref: "#/components/responses/BadRequest"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetConfig
config, resp := Client.GetConfig()
config.TeamSettings.SiteName = "MyFancyName"
// UpdateConfig
updatedConfig, resp := Client.PatchConfig(config)
/api/v4/license:
post:
tags:
@@ -659,26 +506,6 @@
$ref: "#/components/responses/Forbidden"
"413":
$ref: "#/components/responses/TooLarge"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
file, err := os.Open("<Your license file>")
if err != nil {
return err
}
defer file.Close()
data := &bytes.Buffer{}
if _, err := io.Copy(data, file); err != nil {
return err
}
ok, resp := Client.UploadLicenseFile(data.Bytes())
delete:
tags:
- system
@@ -728,16 +555,6 @@
$ref: "#/components/responses/BadRequest"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetOldClientLicense
license, resp := Client.GetOldClientLicense()
/api/v4/license/renewal:
get:
tags:
@@ -803,16 +620,6 @@
$ref: "#/components/responses/Unauthorized"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// RequestTrialLicense
resp := Client.RequestTrialLicense()
/api/v4/trial-license/prev:
get:
tags:
@@ -873,16 +680,6 @@
$ref: "#/components/schemas/Audit"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetAudits
audits, resp := Client.GetAudits(0, 100, "")
/api/v4/caches/invalidate:
post:
tags:
@@ -906,16 +703,6 @@
$ref: "#/components/schemas/StatusOK"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// InvalidateCaches
ok, resp := Client.InvalidateCaches()
/api/v4/logs:
get:
tags:
@@ -954,16 +741,6 @@
type: string
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// GetLogs
logs, resp := Client.GetLogs(0, 10)
post:
tags:
- system
@@ -1006,20 +783,6 @@
type: string
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
message := make(map[string]string)
message["level"] = "ERROR"
message["message"] = "this is a test"
// PostLog
_, resp := Client.PostLog(message)
/api/v4/analytics/old:
get:
tags:
@@ -1101,20 +864,6 @@
$ref: "#/components/responses/BadRequest"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
ok, resp := Client.SetServerBusy(300)
- lang: curl
source: |
curl -X POST \
'http://your-mattermost-url.com/api/v4/server_busy?seconds=3600' \
-H 'Authorization: Bearer kno8tcdotpbx3dj1gzcbx9jrqy'
get:
tags:
- system
@@ -1140,22 +889,6 @@
$ref: "#/components/schemas/Server_Busy"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
// expires is a time.Time
expires, resp := Client.GetServerBusyExpires()
- lang: curl
source: |
curl -X GET \
'http://your-mattermost-url.com/api/v4/server_busy' \
-H 'Authorization: Bearer kno8tcdotpbx3dj1gzcbx9jrqy' \
-H 'Content-Type: application/json'
delete:
tags:
- system
@@ -1181,20 +914,6 @@
$ref: "#/components/schemas/StatusOK"
"403":
$ref: "#/components/responses/Forbidden"
x-code-samples:
- lang: Go
source: |
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
ok, resp := Client.ClearServerBusy()
- lang: curl
source: |
curl -X DELETE \
'http://your-mattermost-url.com/api/v4/server_busy' \
-H 'Authorization: Bearer kno8tcdotpbx3dj1gzcbx9jrqy'
/api/v4/notifications/ack:
post:
tags:
@@ -1498,19 +1217,6 @@
type: array
items:
$ref: "#/components/schemas/IntegrityCheckResult"
x-code-samples:
- lang: Go
source: |
import (
"net"
"net/http"
"github.com/mattermost/mattermost-server/v5/model"
)
Client := model.NewAPIv4SocketClient(socketPath)
ok, resp := Client.CheckIntegrity()
/api/v4/system/support_packet:
get:
tags:

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@@ -52,29 +52,6 @@
$ref: "#/components/responses/TooLarge"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
us := &model.UploadSession{
ChannelId: "4i6jn8r483nnuqnibnmgz8jo4o",
Filename: "file.png",
FileSize: 512000,
}
us, response := Client.CreateUpload(us)
- lang: Curl
source: |
curl 'http://localhost:8065/api/v4/uploads' \
-H 'Authorization: Bearer 9kg8nqrnxprd9jbykqeg4r51hw' \
-H 'Content-Type: application/json' \
--data-binary '{"channel_id": "4i6jn8r483nnuqnibnmgz8jo4o", "filename": "test.png", "file_size": 512000}'
"/api/v4/uploads/{upload_id}":
get:
tags:
@@ -104,21 +81,6 @@
$ref: "#/components/responses/NotFound"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: >
import "github.com/mattermost/mattermost-server/v5/model"
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
us, response := Client.GetUpload("nuyrh9ymridqmenof7exe3a6aw")
- lang: Curl
source: |
curl 'http://localhost:8065/api/v4/uploads/nuyrh9ymridqmenof7exe3a6aw' \
-H 'Authorization: Bearer 9kg8nqrnxprd9jbykqeg4r51hw'
post:
tags:
- uploads
@@ -165,31 +127,3 @@
$ref: "#/components/responses/TooLarge"
"501":
$ref: "#/components/responses/NotImplemented"
x-code-samples:
- lang: Go
source: >
import (
"os"
"github.com/mattermost/mattermost-server/v5/model"
)
Client := model.NewAPIv4Client("https://your-mattermost-url.com")
Client.Login("email@domain.com", "Password1")
file, err := os.Open("file.png")
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
return
}
info, err := Client.UploadData(us, file)
- lang: Curl
source: |
# Binary file content in request's body
curl -X POST 'http://localhost:8065/api/v4/uploads/qyxbzmprrjbdpdaprsxm98m6qe' \
-H 'Authorization: Bearer 9kg8nqrnxprd9jbykqeg4r51hw' --data-binary @file.png
# multipart/form-data upload
curl 'http://localhost:8065/api/v4/uploads/qyxbzmprrjbdpdaprsxm98m6qe' \
-H 'Authorization: Bearer 9kg8nqrnxprd9jbykqeg4r51hw' -F data=@file.png

Разница между файлами не показана из-за своего большого размера Загрузить разницу