github.com/demisto/mattermost-server@v4.9.0-rc3+incompatible/app/plugin/api.go (about)

     1  // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
     2  // See License.txt for license information.
     3  
     4  package plugin
     5  
     6  import (
     7  	"net/http"
     8  
     9  	"github.com/gorilla/mux"
    10  	"github.com/mattermost/mattermost-server/model"
    11  )
    12  
    13  type API interface {
    14  	// Loads the plugin's configuration
    15  	LoadPluginConfiguration(dest interface{}) error
    16  
    17  	// The plugin's router
    18  	PluginRouter() *mux.Router
    19  
    20  	// Gets a team by its name
    21  	GetTeamByName(name string) (*model.Team, *model.AppError)
    22  
    23  	// Gets a user by its name
    24  	GetUserByName(name string) (*model.User, *model.AppError)
    25  
    26  	// Gets a channel by its name
    27  	GetChannelByName(teamId, name string) (*model.Channel, *model.AppError)
    28  
    29  	// Gets a direct message channel
    30  	GetDirectChannel(userId1, userId2 string) (*model.Channel, *model.AppError)
    31  
    32  	// Creates a post
    33  	CreatePost(post *model.Post) (*model.Post, *model.AppError)
    34  
    35  	// Get LDAP attributes for a user
    36  	GetLdapUserAttributes(userId string, attributes []string) (map[string]string, *model.AppError)
    37  
    38  	// Temporary for built-in plugins, copied from api4/context.go ServeHTTP function.
    39  	// If a request has a valid token for an active session, the session is returned otherwise
    40  	// it errors.
    41  	GetSessionFromRequest(r *http.Request) (*model.Session, *model.AppError)
    42  
    43  	// Returns a localized string. If a request is given, its headers will be used to pick a locale.
    44  	I18n(id string, r *http.Request) string
    45  }