MM-63285: Add property field methods to plugin API (#31035)
Co-authored-by: Claude <noreply@anthropic.com>
Этот коммит содержится в:
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/mattermost/mattermost/server/public/shared/httpservice"
|
||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||
"github.com/mattermost/mattermost/server/public/shared/timezones"
|
||||
"github.com/mattermost/mattermost/server/v8/channels/app/properties"
|
||||
"github.com/mattermost/mattermost/server/v8/einterfaces"
|
||||
"github.com/mattermost/mattermost/server/v8/platform/services/imageproxy"
|
||||
"github.com/mattermost/mattermost/server/v8/platform/services/searchengine"
|
||||
@@ -154,6 +155,10 @@ func (a *App) SetServer(srv *Server) {
|
||||
a.ch.srv = srv
|
||||
}
|
||||
|
||||
func (a *App) PropertyService() *properties.PropertyService {
|
||||
return a.Srv().propertyService
|
||||
}
|
||||
|
||||
func (a *App) UpdateExpiredDNDStatuses() ([]*model.Status, error) {
|
||||
return a.Srv().Store().Status().UpdateExpiredDNDStatuses()
|
||||
}
|
||||
|
||||
@@ -1486,3 +1486,87 @@ func (api *PluginAPI) DeleteGroupConstrainedMemberships() *model.AppError {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (api *PluginAPI) CreatePropertyField(field *model.PropertyField) (*model.PropertyField, error) {
|
||||
return api.app.PropertyService().CreatePropertyField(field)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetPropertyField(groupID, fieldID string) (*model.PropertyField, error) {
|
||||
return api.app.PropertyService().GetPropertyField(groupID, fieldID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetPropertyFields(groupID string, ids []string) ([]*model.PropertyField, error) {
|
||||
return api.app.PropertyService().GetPropertyFields(groupID, ids)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdatePropertyField(groupID string, field *model.PropertyField) (*model.PropertyField, error) {
|
||||
return api.app.PropertyService().UpdatePropertyField(groupID, field)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) DeletePropertyField(groupID, fieldID string) error {
|
||||
return api.app.PropertyService().DeletePropertyField(groupID, fieldID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) SearchPropertyFields(groupID, targetID string, opts model.PropertyFieldSearchOpts) ([]*model.PropertyField, error) {
|
||||
return api.app.PropertyService().SearchPropertyFields(groupID, targetID, opts)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) CreatePropertyValue(value *model.PropertyValue) (*model.PropertyValue, error) {
|
||||
return api.app.PropertyService().CreatePropertyValue(value)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetPropertyValue(groupID, valueID string) (*model.PropertyValue, error) {
|
||||
return api.app.PropertyService().GetPropertyValue(groupID, valueID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetPropertyValues(groupID string, ids []string) ([]*model.PropertyValue, error) {
|
||||
return api.app.PropertyService().GetPropertyValues(groupID, ids)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdatePropertyValue(groupID string, value *model.PropertyValue) (*model.PropertyValue, error) {
|
||||
return api.app.PropertyService().UpdatePropertyValue(groupID, value)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpsertPropertyValue(value *model.PropertyValue) (*model.PropertyValue, error) {
|
||||
return api.app.PropertyService().UpsertPropertyValue(value)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) DeletePropertyValue(groupID, valueID string) error {
|
||||
return api.app.PropertyService().DeletePropertyValue(groupID, valueID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) SearchPropertyValues(groupID, targetID string, opts model.PropertyValueSearchOpts) ([]*model.PropertyValue, error) {
|
||||
return api.app.PropertyService().SearchPropertyValues(groupID, targetID, opts)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) RegisterPropertyGroup(name string) (*model.PropertyGroup, error) {
|
||||
return api.app.PropertyService().RegisterPropertyGroup(name)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetPropertyGroup(name string) (*model.PropertyGroup, error) {
|
||||
return api.app.PropertyService().GetPropertyGroup(name)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) GetPropertyFieldByName(groupID, targetID, name string) (*model.PropertyField, error) {
|
||||
return api.app.PropertyService().GetPropertyFieldByName(groupID, targetID, name)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdatePropertyFields(groupID string, fields []*model.PropertyField) ([]*model.PropertyField, error) {
|
||||
return api.app.PropertyService().UpdatePropertyFields(groupID, fields)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpdatePropertyValues(groupID string, values []*model.PropertyValue) ([]*model.PropertyValue, error) {
|
||||
return api.app.PropertyService().UpdatePropertyValues(groupID, values)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) UpsertPropertyValues(values []*model.PropertyValue) ([]*model.PropertyValue, error) {
|
||||
return api.app.PropertyService().UpsertPropertyValues(values)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) DeletePropertyValuesForTarget(groupID, targetType, targetID string) error {
|
||||
return api.app.PropertyService().DeletePropertyValuesForTarget(groupID, targetType, targetID)
|
||||
}
|
||||
|
||||
func (api *PluginAPI) DeletePropertyValuesForField(groupID, fieldID string) error {
|
||||
return api.app.PropertyService().DeletePropertyValuesForField(groupID, fieldID)
|
||||
}
|
||||
|
||||
288
server/channels/app/plugin_properties_test.go
Обычный файл
288
server/channels/app/plugin_properties_test.go
Обычный файл
@@ -0,0 +1,288 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package app
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
)
|
||||
|
||||
func TestPluginProperties(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
t.Run("test property field methods", func(t *testing.T) {
|
||||
groupName := model.NewId()
|
||||
tearDown, pluginIDs, activationErrors := SetAppEnvironmentWithPlugins(t, []string{`
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mattermost/mattermost/server/public/plugin"
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
)
|
||||
|
||||
type MyPlugin struct {
|
||||
plugin.MattermostPlugin
|
||||
}
|
||||
|
||||
func (p *MyPlugin) OnActivate() error {
|
||||
// Register a property group
|
||||
group, err := p.API.RegisterPropertyGroup("` + groupName + `")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to register property group: %w", err)
|
||||
}
|
||||
|
||||
// Create a property field
|
||||
field := &model.PropertyField{
|
||||
GroupID: group.ID,
|
||||
Name: "Test Field",
|
||||
Type: model.PropertyFieldTypeText,
|
||||
TargetType: "user",
|
||||
}
|
||||
|
||||
createdField, err := p.API.CreatePropertyField(field)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create property field: %w", err)
|
||||
}
|
||||
|
||||
// Verify the field was created correctly
|
||||
retrievedField, err := p.API.GetPropertyField(group.ID, createdField.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get property field: %w", err)
|
||||
}
|
||||
if retrievedField.Name != "Test Field" {
|
||||
return fmt.Errorf("field name mismatch: expected 'Test Field', got '%s'", retrievedField.Name)
|
||||
}
|
||||
|
||||
// Update the field
|
||||
retrievedField.Name = "Updated Test Field"
|
||||
updatedField, err := p.API.UpdatePropertyField(group.ID, retrievedField)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update property field: %w", err)
|
||||
}
|
||||
if updatedField.Name != "Updated Test Field" {
|
||||
return fmt.Errorf("updated field name mismatch: expected 'Updated Test Field', got '%s'", updatedField.Name)
|
||||
}
|
||||
|
||||
// Search for fields
|
||||
fields, err := p.API.SearchPropertyFields(group.ID, "", model.PropertyFieldSearchOpts{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to search property fields: %w", err)
|
||||
}
|
||||
if len(fields) != 1 {
|
||||
return fmt.Errorf("unexpected number of fields: expected 1, got %d", len(fields))
|
||||
}
|
||||
|
||||
// Delete the field
|
||||
err = p.API.DeletePropertyField(group.ID, updatedField.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to delete property field: %w", err)
|
||||
}
|
||||
|
||||
// Verify deletion
|
||||
fields, err = p.API.SearchPropertyFields(group.ID, "", model.PropertyFieldSearchOpts{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to search property fields after deletion: %w", err)
|
||||
}
|
||||
if len(fields) != 0 {
|
||||
return fmt.Errorf("field still exists after deletion: found %d fields", len(fields))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
plugin.ClientMain(&MyPlugin{})
|
||||
}
|
||||
`}, th.App, th.NewPluginAPI)
|
||||
defer tearDown()
|
||||
require.Len(t, activationErrors, 1)
|
||||
require.Nil(t, nil, activationErrors[0])
|
||||
|
||||
// Clean up
|
||||
err2 := th.App.DisablePlugin(pluginIDs[0])
|
||||
require.Nil(t, err2)
|
||||
appErr := th.App.ch.RemovePlugin(pluginIDs[0])
|
||||
require.Nil(t, appErr)
|
||||
})
|
||||
|
||||
t.Run("test property value methods", func(t *testing.T) {
|
||||
groupName := model.NewId()
|
||||
tearDown, pluginIDs, activationErrors := SetAppEnvironmentWithPlugins(t, []string{`
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mattermost/mattermost/server/public/plugin"
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
)
|
||||
|
||||
type MyPlugin struct {
|
||||
plugin.MattermostPlugin
|
||||
}
|
||||
|
||||
func (p *MyPlugin) OnActivate() error {
|
||||
// Register a property group
|
||||
group, err := p.API.RegisterPropertyGroup("` + groupName + `")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to register property group: %w", err)
|
||||
}
|
||||
|
||||
// Create a property field
|
||||
field := &model.PropertyField{
|
||||
GroupID: group.ID,
|
||||
Name: "Test Field",
|
||||
Type: model.PropertyFieldTypeText,
|
||||
TargetType: "user",
|
||||
}
|
||||
|
||||
createdField, err := p.API.CreatePropertyField(field)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create property field: %w", err)
|
||||
}
|
||||
|
||||
// Create a property value
|
||||
targetId := model.NewId()
|
||||
valueJson := []byte("test-value")
|
||||
value := &model.PropertyValue{
|
||||
GroupID: group.ID,
|
||||
FieldID: createdField.ID,
|
||||
TargetID: targetId,
|
||||
TargetType: "user",
|
||||
Value: valueJson,
|
||||
}
|
||||
|
||||
createdValue, err := p.API.CreatePropertyValue(value)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create property value: %w", err)
|
||||
}
|
||||
|
||||
// Verify the value was created correctly
|
||||
retrievedValue, err := p.API.GetPropertyValue(group.ID, createdValue.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get property value: %w", err)
|
||||
}
|
||||
if string(retrievedValue.Value) != "test-value" {
|
||||
return fmt.Errorf("value mismatch: expected 'test-value', got '%s'", string(retrievedValue.Value))
|
||||
}
|
||||
|
||||
// Update the value
|
||||
retrievedValue.Value = []byte("updated-test-value")
|
||||
updatedValue, err := p.API.UpdatePropertyValue(group.ID, retrievedValue)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to update property value: %w", err)
|
||||
}
|
||||
if string(updatedValue.Value) != "updated-test-value" {
|
||||
return fmt.Errorf("updated value mismatch: expected 'updated-test-value', got '%s'", string(updatedValue.Value))
|
||||
}
|
||||
|
||||
// Upsert the value
|
||||
upsertValueJson := []byte("upserted-value")
|
||||
upsertValue := &model.PropertyValue{
|
||||
GroupID: group.ID,
|
||||
FieldID: createdField.ID,
|
||||
TargetID: model.NewId(),
|
||||
TargetType: "user",
|
||||
Value: upsertValueJson,
|
||||
}
|
||||
|
||||
_, err = p.API.UpsertPropertyValue(upsertValue)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to upsert property value: %w", err)
|
||||
}
|
||||
|
||||
// Search for values
|
||||
values, err := p.API.SearchPropertyValues(group.ID, targetId, model.PropertyValueSearchOpts{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to search property values: %w", err)
|
||||
}
|
||||
if len(values) != 1 {
|
||||
return fmt.Errorf("unexpected number of values: expected 1, got %d", len(values))
|
||||
}
|
||||
|
||||
// Delete the value
|
||||
err = p.API.DeletePropertyValue(group.ID, updatedValue.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to delete property value: %w", err)
|
||||
}
|
||||
|
||||
// Verify deletion
|
||||
values, err = p.API.SearchPropertyValues(group.ID, targetId, model.PropertyValueSearchOpts{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to search property values after deletion: %w", err)
|
||||
}
|
||||
if len(values) != 0 {
|
||||
return fmt.Errorf("value still exists after deletion: found %d values", len(values))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
plugin.ClientMain(&MyPlugin{})
|
||||
}
|
||||
`}, th.App, th.NewPluginAPI)
|
||||
defer tearDown()
|
||||
require.Len(t, activationErrors, 1)
|
||||
require.Nil(t, nil, activationErrors[0])
|
||||
|
||||
// Clean up
|
||||
err2 := th.App.DisablePlugin(pluginIDs[0])
|
||||
require.Nil(t, err2)
|
||||
appErr := th.App.ch.RemovePlugin(pluginIDs[0])
|
||||
require.Nil(t, appErr)
|
||||
})
|
||||
|
||||
t.Run("test property group methods", func(t *testing.T) {
|
||||
groupName := model.NewId()
|
||||
tearDown, pluginIDs, activationErrors := SetAppEnvironmentWithPlugins(t, []string{`
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mattermost/mattermost/server/public/plugin"
|
||||
)
|
||||
|
||||
type MyPlugin struct {
|
||||
plugin.MattermostPlugin
|
||||
}
|
||||
|
||||
func (p *MyPlugin) OnActivate() error {
|
||||
// Register a property group
|
||||
group, err := p.API.RegisterPropertyGroup("` + groupName + `")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to register property group: %w", err)
|
||||
}
|
||||
|
||||
// Get the registered group
|
||||
retrievedGroup, err := p.API.GetPropertyGroup(group.Name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get property group: %w", err)
|
||||
}
|
||||
if retrievedGroup.ID != group.ID {
|
||||
return fmt.Errorf("group ID mismatch: expected '%s', got '%s'", group.ID, retrievedGroup.ID)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
plugin.ClientMain(&MyPlugin{})
|
||||
}
|
||||
`}, th.App, th.NewPluginAPI)
|
||||
defer tearDown()
|
||||
require.Len(t, activationErrors, 1)
|
||||
require.Nil(t, nil, activationErrors[0])
|
||||
|
||||
// Clean up
|
||||
err2 := th.App.DisablePlugin(pluginIDs[0])
|
||||
require.Nil(t, err2)
|
||||
appErr := th.App.ch.RemovePlugin(pluginIDs[0])
|
||||
require.Nil(t, appErr)
|
||||
})
|
||||
}
|
||||
@@ -239,3 +239,77 @@ func (p PropertyOptions[T]) IsValid() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// PluginPropertyOption provides a simple implementation of PropertyOption for plugins
|
||||
// using a map[string]string for flexible key-value storage
|
||||
type PluginPropertyOption struct {
|
||||
Data map[string]string `json:"data"`
|
||||
}
|
||||
|
||||
func NewPluginPropertyOption(id, name string) *PluginPropertyOption {
|
||||
return &PluginPropertyOption{
|
||||
Data: map[string]string{
|
||||
"id": id,
|
||||
"name": name,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PluginPropertyOption) GetID() string {
|
||||
if p.Data == nil {
|
||||
return ""
|
||||
}
|
||||
return p.Data["id"]
|
||||
}
|
||||
|
||||
func (p *PluginPropertyOption) GetName() string {
|
||||
if p.Data == nil {
|
||||
return ""
|
||||
}
|
||||
return p.Data["name"]
|
||||
}
|
||||
|
||||
func (p *PluginPropertyOption) SetID(id string) {
|
||||
if p.Data == nil {
|
||||
p.Data = make(map[string]string)
|
||||
}
|
||||
p.Data["id"] = id
|
||||
}
|
||||
|
||||
func (p *PluginPropertyOption) IsValid() error {
|
||||
if p.Data == nil {
|
||||
return errors.New("data cannot be nil")
|
||||
}
|
||||
|
||||
id := p.GetID()
|
||||
if id == "" {
|
||||
return errors.New("id cannot be empty")
|
||||
}
|
||||
|
||||
if !IsValidId(id) {
|
||||
return errors.New("id is not a valid ID")
|
||||
}
|
||||
|
||||
name := p.GetName()
|
||||
if name == "" {
|
||||
return errors.New("name cannot be empty")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetValue retrieves a custom value from the option data
|
||||
func (p *PluginPropertyOption) GetValue(key string) string {
|
||||
if p.Data == nil {
|
||||
return ""
|
||||
}
|
||||
return p.Data[key]
|
||||
}
|
||||
|
||||
// SetValue sets a custom value in the option data
|
||||
func (p *PluginPropertyOption) SetValue(key, value string) {
|
||||
if p.Data == nil {
|
||||
p.Data = make(map[string]string)
|
||||
}
|
||||
p.Data[key] = value
|
||||
}
|
||||
|
||||
@@ -243,3 +243,138 @@ func TestPropertyFieldSearchCursor_IsValid(t *testing.T) {
|
||||
assert.Error(t, cursor.IsValid())
|
||||
})
|
||||
}
|
||||
|
||||
func TestPluginPropertyOption(t *testing.T) {
|
||||
t.Run("NewPluginPropertyOption", func(t *testing.T) {
|
||||
id := NewId()
|
||||
option := NewPluginPropertyOption(id, "test-name")
|
||||
|
||||
assert.Equal(t, id, option.GetID())
|
||||
assert.Equal(t, "test-name", option.GetName())
|
||||
assert.NoError(t, option.IsValid())
|
||||
})
|
||||
|
||||
t.Run("SetID", func(t *testing.T) {
|
||||
option := &PluginPropertyOption{}
|
||||
newId := NewId()
|
||||
option.SetID(newId)
|
||||
|
||||
assert.Equal(t, newId, option.GetID())
|
||||
})
|
||||
|
||||
t.Run("GetValue and SetValue", func(t *testing.T) {
|
||||
option := NewPluginPropertyOption(NewId(), "test-name")
|
||||
|
||||
option.SetValue("color", "red")
|
||||
option.SetValue("description", "test description")
|
||||
|
||||
assert.Equal(t, "red", option.GetValue("color"))
|
||||
assert.Equal(t, "test description", option.GetValue("description"))
|
||||
assert.Equal(t, "", option.GetValue("nonexistent"))
|
||||
})
|
||||
|
||||
t.Run("IsValid", func(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
option *PluginPropertyOption
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "valid option",
|
||||
option: NewPluginPropertyOption(NewId(), "test-name"),
|
||||
},
|
||||
{
|
||||
name: "nil data",
|
||||
option: &PluginPropertyOption{},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "empty id",
|
||||
option: &PluginPropertyOption{
|
||||
Data: map[string]string{"name": "test"},
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "empty name",
|
||||
option: &PluginPropertyOption{
|
||||
Data: map[string]string{"id": NewId()},
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "invalid id",
|
||||
option: &PluginPropertyOption{
|
||||
Data: map[string]string{
|
||||
"id": "invalid-id-format",
|
||||
"name": "test",
|
||||
},
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := tt.option.IsValid()
|
||||
if tt.wantErr {
|
||||
assert.Error(t, err)
|
||||
} else {
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("PropertyOptions with PluginPropertyOption", func(t *testing.T) {
|
||||
options := PropertyOptions[*PluginPropertyOption]{
|
||||
NewPluginPropertyOption(NewId(), "Option 1"),
|
||||
NewPluginPropertyOption(NewId(), "Option 2"),
|
||||
}
|
||||
|
||||
// Add custom data
|
||||
options[0].SetValue("color", "blue")
|
||||
options[1].SetValue("description", "Second option")
|
||||
|
||||
assert.NoError(t, options.IsValid())
|
||||
assert.Equal(t, "blue", options[0].GetValue("color"))
|
||||
assert.Equal(t, "Second option", options[1].GetValue("description"))
|
||||
})
|
||||
|
||||
t.Run("PropertyField with PluginPropertyOptions", func(t *testing.T) {
|
||||
fieldID := NewId()
|
||||
groupID := NewId()
|
||||
fieldName := "Test Field"
|
||||
fieldType := PropertyFieldTypeSelect
|
||||
|
||||
field := &PropertyField{
|
||||
ID: fieldID,
|
||||
GroupID: groupID,
|
||||
Name: fieldName,
|
||||
Type: fieldType,
|
||||
Attrs: make(StringInterface),
|
||||
}
|
||||
|
||||
options := PropertyOptions[*PluginPropertyOption]{
|
||||
NewPluginPropertyOption(NewId(), "Option 1"),
|
||||
NewPluginPropertyOption(NewId(), "Option 2"),
|
||||
}
|
||||
|
||||
field.Attrs[PropertyFieldAttributeOptions] = options
|
||||
|
||||
// Verify the field properties are set correctly
|
||||
assert.Equal(t, fieldID, field.ID)
|
||||
assert.Equal(t, groupID, field.GroupID)
|
||||
assert.Equal(t, fieldName, field.Name)
|
||||
assert.Equal(t, fieldType, field.Type)
|
||||
|
||||
// Test that we can retrieve the options
|
||||
if optionsFromField, err := NewPropertyOptionsFromFieldAttrs[*PluginPropertyOption](field.Attrs[PropertyFieldAttributeOptions]); err == nil {
|
||||
require.Len(t, optionsFromField, 2)
|
||||
assert.Equal(t, "Option 1", optionsFromField[0].GetName())
|
||||
assert.Equal(t, "Option 2", optionsFromField[1].GetName())
|
||||
} else {
|
||||
t.Fatalf("Failed to retrieve options from field: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1411,6 +1411,132 @@ type API interface {
|
||||
// @tag Group
|
||||
// Minimum server version: 10.9
|
||||
DeleteGroupConstrainedMemberships() *model.AppError
|
||||
|
||||
// CreatePropertyField creates a new property field.
|
||||
//
|
||||
// @tag PropertyField
|
||||
// Minimum server version: 10.10
|
||||
CreatePropertyField(field *model.PropertyField) (*model.PropertyField, error)
|
||||
|
||||
// GetPropertyField gets a property field by groupID and fieldID.
|
||||
//
|
||||
// @tag PropertyField
|
||||
// Minimum server version: 10.10
|
||||
GetPropertyField(groupID, fieldID string) (*model.PropertyField, error)
|
||||
|
||||
// GetPropertyFields gets multiple property fields by groupID and a list of IDs.
|
||||
//
|
||||
// @tag PropertyField
|
||||
// Minimum server version: 10.10
|
||||
GetPropertyFields(groupID string, ids []string) ([]*model.PropertyField, error)
|
||||
|
||||
// UpdatePropertyField updates an existing property field.
|
||||
//
|
||||
// @tag PropertyField
|
||||
// Minimum server version: 10.10
|
||||
UpdatePropertyField(groupID string, field *model.PropertyField) (*model.PropertyField, error)
|
||||
|
||||
// DeletePropertyField deletes a property field (soft delete).
|
||||
//
|
||||
// @tag PropertyField
|
||||
// Minimum server version: 10.10
|
||||
DeletePropertyField(groupID, fieldID string) error
|
||||
|
||||
// SearchPropertyFields searches for property fields with filtering options.
|
||||
//
|
||||
// @tag PropertyField
|
||||
// Minimum server version: 10.10
|
||||
SearchPropertyFields(groupID, targetID string, opts model.PropertyFieldSearchOpts) ([]*model.PropertyField, error)
|
||||
|
||||
// CreatePropertyValue creates a new property value.
|
||||
//
|
||||
// @tag PropertyValue
|
||||
// Minimum server version: 10.10
|
||||
CreatePropertyValue(value *model.PropertyValue) (*model.PropertyValue, error)
|
||||
|
||||
// GetPropertyValue gets a property value by groupID and valueID.
|
||||
//
|
||||
// @tag PropertyValue
|
||||
// Minimum server version: 10.10
|
||||
GetPropertyValue(groupID, valueID string) (*model.PropertyValue, error)
|
||||
|
||||
// GetPropertyValues gets multiple property values by groupID and a list of IDs.
|
||||
//
|
||||
// @tag PropertyValue
|
||||
// Minimum server version: 10.10
|
||||
GetPropertyValues(groupID string, ids []string) ([]*model.PropertyValue, error)
|
||||
|
||||
// UpdatePropertyValue updates an existing property value.
|
||||
//
|
||||
// @tag PropertyValue
|
||||
// Minimum server version: 10.10
|
||||
UpdatePropertyValue(groupID string, value *model.PropertyValue) (*model.PropertyValue, error)
|
||||
|
||||
// UpsertPropertyValue creates a new property value or updates if it already exists.
|
||||
//
|
||||
// @tag PropertyValue
|
||||
// Minimum server version: 10.10
|
||||
UpsertPropertyValue(value *model.PropertyValue) (*model.PropertyValue, error)
|
||||
|
||||
// DeletePropertyValue deletes a property value (soft delete).
|
||||
//
|
||||
// @tag PropertyValue
|
||||
// Minimum server version: 10.10
|
||||
DeletePropertyValue(groupID, valueID string) error
|
||||
|
||||
// SearchPropertyValues searches for property values with filtering options.
|
||||
//
|
||||
// @tag PropertyValue
|
||||
// Minimum server version: 10.10
|
||||
SearchPropertyValues(groupID, targetID string, opts model.PropertyValueSearchOpts) ([]*model.PropertyValue, error)
|
||||
|
||||
// RegisterPropertyGroup registers a new property group.
|
||||
//
|
||||
// @tag PropertyGroup
|
||||
// Minimum server version: 10.10
|
||||
RegisterPropertyGroup(name string) (*model.PropertyGroup, error)
|
||||
|
||||
// GetPropertyGroup gets a property group by name.
|
||||
//
|
||||
// @tag PropertyGroup
|
||||
// Minimum server version: 10.10
|
||||
GetPropertyGroup(name string) (*model.PropertyGroup, error)
|
||||
|
||||
// GetPropertyFieldByName gets a property field by groupID, targetID and name.
|
||||
//
|
||||
// @tag PropertyField
|
||||
// Minimum server version: 10.10
|
||||
GetPropertyFieldByName(groupID, targetID, name string) (*model.PropertyField, error)
|
||||
|
||||
// UpdatePropertyFields updates multiple property fields in a single operation.
|
||||
//
|
||||
// @tag PropertyField
|
||||
// Minimum server version: 10.10
|
||||
UpdatePropertyFields(groupID string, fields []*model.PropertyField) ([]*model.PropertyField, error)
|
||||
|
||||
// UpdatePropertyValues updates multiple property values in a single operation.
|
||||
//
|
||||
// @tag PropertyValue
|
||||
// Minimum server version: 10.10
|
||||
UpdatePropertyValues(groupID string, values []*model.PropertyValue) ([]*model.PropertyValue, error)
|
||||
|
||||
// UpsertPropertyValues creates or updates multiple property values in a single operation.
|
||||
//
|
||||
// @tag PropertyValue
|
||||
// Minimum server version: 10.10
|
||||
UpsertPropertyValues(values []*model.PropertyValue) ([]*model.PropertyValue, error)
|
||||
|
||||
// DeletePropertyValuesForTarget deletes all property values for a specific target.
|
||||
//
|
||||
// @tag PropertyValue
|
||||
// Minimum server version: 10.10
|
||||
DeletePropertyValuesForTarget(groupID, targetType, targetID string) error
|
||||
|
||||
// DeletePropertyValuesForField deletes all property values for a specific field.
|
||||
//
|
||||
// @tag PropertyValue
|
||||
// Minimum server version: 10.10
|
||||
DeletePropertyValuesForField(groupID, fieldID string) error
|
||||
}
|
||||
|
||||
var handshake = plugin.HandshakeConfig{
|
||||
|
||||
@@ -1497,3 +1497,150 @@ func (api *apiTimerLayer) DeleteGroupConstrainedMemberships() *model.AppError {
|
||||
api.recordTime(startTime, "DeleteGroupConstrainedMemberships", _returnsA == nil)
|
||||
return _returnsA
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) CreatePropertyField(field *model.PropertyField) (*model.PropertyField, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.CreatePropertyField(field)
|
||||
api.recordTime(startTime, "CreatePropertyField", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) GetPropertyField(groupID, fieldID string) (*model.PropertyField, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.GetPropertyField(groupID, fieldID)
|
||||
api.recordTime(startTime, "GetPropertyField", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) GetPropertyFields(groupID string, ids []string) ([]*model.PropertyField, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.GetPropertyFields(groupID, ids)
|
||||
api.recordTime(startTime, "GetPropertyFields", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) UpdatePropertyField(groupID string, field *model.PropertyField) (*model.PropertyField, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.UpdatePropertyField(groupID, field)
|
||||
api.recordTime(startTime, "UpdatePropertyField", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) DeletePropertyField(groupID, fieldID string) error {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA := api.apiImpl.DeletePropertyField(groupID, fieldID)
|
||||
api.recordTime(startTime, "DeletePropertyField", _returnsA == nil)
|
||||
return _returnsA
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) SearchPropertyFields(groupID, targetID string, opts model.PropertyFieldSearchOpts) ([]*model.PropertyField, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.SearchPropertyFields(groupID, targetID, opts)
|
||||
api.recordTime(startTime, "SearchPropertyFields", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) CreatePropertyValue(value *model.PropertyValue) (*model.PropertyValue, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.CreatePropertyValue(value)
|
||||
api.recordTime(startTime, "CreatePropertyValue", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) GetPropertyValue(groupID, valueID string) (*model.PropertyValue, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.GetPropertyValue(groupID, valueID)
|
||||
api.recordTime(startTime, "GetPropertyValue", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) GetPropertyValues(groupID string, ids []string) ([]*model.PropertyValue, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.GetPropertyValues(groupID, ids)
|
||||
api.recordTime(startTime, "GetPropertyValues", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) UpdatePropertyValue(groupID string, value *model.PropertyValue) (*model.PropertyValue, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.UpdatePropertyValue(groupID, value)
|
||||
api.recordTime(startTime, "UpdatePropertyValue", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) UpsertPropertyValue(value *model.PropertyValue) (*model.PropertyValue, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.UpsertPropertyValue(value)
|
||||
api.recordTime(startTime, "UpsertPropertyValue", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) DeletePropertyValue(groupID, valueID string) error {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA := api.apiImpl.DeletePropertyValue(groupID, valueID)
|
||||
api.recordTime(startTime, "DeletePropertyValue", _returnsA == nil)
|
||||
return _returnsA
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) SearchPropertyValues(groupID, targetID string, opts model.PropertyValueSearchOpts) ([]*model.PropertyValue, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.SearchPropertyValues(groupID, targetID, opts)
|
||||
api.recordTime(startTime, "SearchPropertyValues", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) RegisterPropertyGroup(name string) (*model.PropertyGroup, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.RegisterPropertyGroup(name)
|
||||
api.recordTime(startTime, "RegisterPropertyGroup", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) GetPropertyGroup(name string) (*model.PropertyGroup, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.GetPropertyGroup(name)
|
||||
api.recordTime(startTime, "GetPropertyGroup", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) GetPropertyFieldByName(groupID, targetID, name string) (*model.PropertyField, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.GetPropertyFieldByName(groupID, targetID, name)
|
||||
api.recordTime(startTime, "GetPropertyFieldByName", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) UpdatePropertyFields(groupID string, fields []*model.PropertyField) ([]*model.PropertyField, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.UpdatePropertyFields(groupID, fields)
|
||||
api.recordTime(startTime, "UpdatePropertyFields", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) UpdatePropertyValues(groupID string, values []*model.PropertyValue) ([]*model.PropertyValue, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.UpdatePropertyValues(groupID, values)
|
||||
api.recordTime(startTime, "UpdatePropertyValues", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) UpsertPropertyValues(values []*model.PropertyValue) ([]*model.PropertyValue, error) {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA, _returnsB := api.apiImpl.UpsertPropertyValues(values)
|
||||
api.recordTime(startTime, "UpsertPropertyValues", _returnsB == nil)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) DeletePropertyValuesForTarget(groupID, targetType, targetID string) error {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA := api.apiImpl.DeletePropertyValuesForTarget(groupID, targetType, targetID)
|
||||
api.recordTime(startTime, "DeletePropertyValuesForTarget", _returnsA == nil)
|
||||
return _returnsA
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) DeletePropertyValuesForField(groupID, fieldID string) error {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA := api.apiImpl.DeletePropertyValuesForField(groupID, fieldID)
|
||||
api.recordTime(startTime, "DeletePropertyValuesForField", _returnsA == nil)
|
||||
return _returnsA
|
||||
}
|
||||
|
||||
@@ -168,6 +168,7 @@ func init() {
|
||||
gob.Register(&model.AutocompleteStaticListArg{})
|
||||
gob.Register(&model.AutocompleteTextArg{})
|
||||
gob.Register(&model.PreviewPost{})
|
||||
gob.Register(model.PropertyOptions[*model.PluginPropertyOption]{})
|
||||
}
|
||||
|
||||
// These enforce compile time checks to make sure types implement the interface
|
||||
|
||||
@@ -7168,3 +7168,648 @@ func (s *apiRPCServer) DeleteGroupConstrainedMemberships(args *Z_DeleteGroupCons
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_CreatePropertyFieldArgs struct {
|
||||
A *model.PropertyField
|
||||
}
|
||||
|
||||
type Z_CreatePropertyFieldReturns struct {
|
||||
A *model.PropertyField
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) CreatePropertyField(field *model.PropertyField) (*model.PropertyField, error) {
|
||||
_args := &Z_CreatePropertyFieldArgs{field}
|
||||
_returns := &Z_CreatePropertyFieldReturns{}
|
||||
if err := g.client.Call("Plugin.CreatePropertyField", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to CreatePropertyField API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) CreatePropertyField(args *Z_CreatePropertyFieldArgs, returns *Z_CreatePropertyFieldReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
CreatePropertyField(field *model.PropertyField) (*model.PropertyField, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.CreatePropertyField(args.A)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API CreatePropertyField called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_GetPropertyFieldArgs struct {
|
||||
A string
|
||||
B string
|
||||
}
|
||||
|
||||
type Z_GetPropertyFieldReturns struct {
|
||||
A *model.PropertyField
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) GetPropertyField(groupID, fieldID string) (*model.PropertyField, error) {
|
||||
_args := &Z_GetPropertyFieldArgs{groupID, fieldID}
|
||||
_returns := &Z_GetPropertyFieldReturns{}
|
||||
if err := g.client.Call("Plugin.GetPropertyField", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to GetPropertyField API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) GetPropertyField(args *Z_GetPropertyFieldArgs, returns *Z_GetPropertyFieldReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
GetPropertyField(groupID, fieldID string) (*model.PropertyField, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.GetPropertyField(args.A, args.B)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API GetPropertyField called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_GetPropertyFieldsArgs struct {
|
||||
A string
|
||||
B []string
|
||||
}
|
||||
|
||||
type Z_GetPropertyFieldsReturns struct {
|
||||
A []*model.PropertyField
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) GetPropertyFields(groupID string, ids []string) ([]*model.PropertyField, error) {
|
||||
_args := &Z_GetPropertyFieldsArgs{groupID, ids}
|
||||
_returns := &Z_GetPropertyFieldsReturns{}
|
||||
if err := g.client.Call("Plugin.GetPropertyFields", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to GetPropertyFields API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) GetPropertyFields(args *Z_GetPropertyFieldsArgs, returns *Z_GetPropertyFieldsReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
GetPropertyFields(groupID string, ids []string) ([]*model.PropertyField, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.GetPropertyFields(args.A, args.B)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API GetPropertyFields called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_UpdatePropertyFieldArgs struct {
|
||||
A string
|
||||
B *model.PropertyField
|
||||
}
|
||||
|
||||
type Z_UpdatePropertyFieldReturns struct {
|
||||
A *model.PropertyField
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) UpdatePropertyField(groupID string, field *model.PropertyField) (*model.PropertyField, error) {
|
||||
_args := &Z_UpdatePropertyFieldArgs{groupID, field}
|
||||
_returns := &Z_UpdatePropertyFieldReturns{}
|
||||
if err := g.client.Call("Plugin.UpdatePropertyField", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to UpdatePropertyField API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) UpdatePropertyField(args *Z_UpdatePropertyFieldArgs, returns *Z_UpdatePropertyFieldReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
UpdatePropertyField(groupID string, field *model.PropertyField) (*model.PropertyField, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.UpdatePropertyField(args.A, args.B)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API UpdatePropertyField called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_DeletePropertyFieldArgs struct {
|
||||
A string
|
||||
B string
|
||||
}
|
||||
|
||||
type Z_DeletePropertyFieldReturns struct {
|
||||
A error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) DeletePropertyField(groupID, fieldID string) error {
|
||||
_args := &Z_DeletePropertyFieldArgs{groupID, fieldID}
|
||||
_returns := &Z_DeletePropertyFieldReturns{}
|
||||
if err := g.client.Call("Plugin.DeletePropertyField", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to DeletePropertyField API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) DeletePropertyField(args *Z_DeletePropertyFieldArgs, returns *Z_DeletePropertyFieldReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
DeletePropertyField(groupID, fieldID string) error
|
||||
}); ok {
|
||||
returns.A = hook.DeletePropertyField(args.A, args.B)
|
||||
returns.A = encodableError(returns.A)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API DeletePropertyField called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_SearchPropertyFieldsArgs struct {
|
||||
A string
|
||||
B string
|
||||
C model.PropertyFieldSearchOpts
|
||||
}
|
||||
|
||||
type Z_SearchPropertyFieldsReturns struct {
|
||||
A []*model.PropertyField
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) SearchPropertyFields(groupID, targetID string, opts model.PropertyFieldSearchOpts) ([]*model.PropertyField, error) {
|
||||
_args := &Z_SearchPropertyFieldsArgs{groupID, targetID, opts}
|
||||
_returns := &Z_SearchPropertyFieldsReturns{}
|
||||
if err := g.client.Call("Plugin.SearchPropertyFields", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to SearchPropertyFields API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) SearchPropertyFields(args *Z_SearchPropertyFieldsArgs, returns *Z_SearchPropertyFieldsReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
SearchPropertyFields(groupID, targetID string, opts model.PropertyFieldSearchOpts) ([]*model.PropertyField, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.SearchPropertyFields(args.A, args.B, args.C)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API SearchPropertyFields called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_CreatePropertyValueArgs struct {
|
||||
A *model.PropertyValue
|
||||
}
|
||||
|
||||
type Z_CreatePropertyValueReturns struct {
|
||||
A *model.PropertyValue
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) CreatePropertyValue(value *model.PropertyValue) (*model.PropertyValue, error) {
|
||||
_args := &Z_CreatePropertyValueArgs{value}
|
||||
_returns := &Z_CreatePropertyValueReturns{}
|
||||
if err := g.client.Call("Plugin.CreatePropertyValue", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to CreatePropertyValue API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) CreatePropertyValue(args *Z_CreatePropertyValueArgs, returns *Z_CreatePropertyValueReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
CreatePropertyValue(value *model.PropertyValue) (*model.PropertyValue, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.CreatePropertyValue(args.A)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API CreatePropertyValue called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_GetPropertyValueArgs struct {
|
||||
A string
|
||||
B string
|
||||
}
|
||||
|
||||
type Z_GetPropertyValueReturns struct {
|
||||
A *model.PropertyValue
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) GetPropertyValue(groupID, valueID string) (*model.PropertyValue, error) {
|
||||
_args := &Z_GetPropertyValueArgs{groupID, valueID}
|
||||
_returns := &Z_GetPropertyValueReturns{}
|
||||
if err := g.client.Call("Plugin.GetPropertyValue", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to GetPropertyValue API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) GetPropertyValue(args *Z_GetPropertyValueArgs, returns *Z_GetPropertyValueReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
GetPropertyValue(groupID, valueID string) (*model.PropertyValue, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.GetPropertyValue(args.A, args.B)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API GetPropertyValue called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_GetPropertyValuesArgs struct {
|
||||
A string
|
||||
B []string
|
||||
}
|
||||
|
||||
type Z_GetPropertyValuesReturns struct {
|
||||
A []*model.PropertyValue
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) GetPropertyValues(groupID string, ids []string) ([]*model.PropertyValue, error) {
|
||||
_args := &Z_GetPropertyValuesArgs{groupID, ids}
|
||||
_returns := &Z_GetPropertyValuesReturns{}
|
||||
if err := g.client.Call("Plugin.GetPropertyValues", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to GetPropertyValues API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) GetPropertyValues(args *Z_GetPropertyValuesArgs, returns *Z_GetPropertyValuesReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
GetPropertyValues(groupID string, ids []string) ([]*model.PropertyValue, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.GetPropertyValues(args.A, args.B)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API GetPropertyValues called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_UpdatePropertyValueArgs struct {
|
||||
A string
|
||||
B *model.PropertyValue
|
||||
}
|
||||
|
||||
type Z_UpdatePropertyValueReturns struct {
|
||||
A *model.PropertyValue
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) UpdatePropertyValue(groupID string, value *model.PropertyValue) (*model.PropertyValue, error) {
|
||||
_args := &Z_UpdatePropertyValueArgs{groupID, value}
|
||||
_returns := &Z_UpdatePropertyValueReturns{}
|
||||
if err := g.client.Call("Plugin.UpdatePropertyValue", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to UpdatePropertyValue API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) UpdatePropertyValue(args *Z_UpdatePropertyValueArgs, returns *Z_UpdatePropertyValueReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
UpdatePropertyValue(groupID string, value *model.PropertyValue) (*model.PropertyValue, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.UpdatePropertyValue(args.A, args.B)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API UpdatePropertyValue called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_UpsertPropertyValueArgs struct {
|
||||
A *model.PropertyValue
|
||||
}
|
||||
|
||||
type Z_UpsertPropertyValueReturns struct {
|
||||
A *model.PropertyValue
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) UpsertPropertyValue(value *model.PropertyValue) (*model.PropertyValue, error) {
|
||||
_args := &Z_UpsertPropertyValueArgs{value}
|
||||
_returns := &Z_UpsertPropertyValueReturns{}
|
||||
if err := g.client.Call("Plugin.UpsertPropertyValue", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to UpsertPropertyValue API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) UpsertPropertyValue(args *Z_UpsertPropertyValueArgs, returns *Z_UpsertPropertyValueReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
UpsertPropertyValue(value *model.PropertyValue) (*model.PropertyValue, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.UpsertPropertyValue(args.A)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API UpsertPropertyValue called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_DeletePropertyValueArgs struct {
|
||||
A string
|
||||
B string
|
||||
}
|
||||
|
||||
type Z_DeletePropertyValueReturns struct {
|
||||
A error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) DeletePropertyValue(groupID, valueID string) error {
|
||||
_args := &Z_DeletePropertyValueArgs{groupID, valueID}
|
||||
_returns := &Z_DeletePropertyValueReturns{}
|
||||
if err := g.client.Call("Plugin.DeletePropertyValue", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to DeletePropertyValue API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) DeletePropertyValue(args *Z_DeletePropertyValueArgs, returns *Z_DeletePropertyValueReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
DeletePropertyValue(groupID, valueID string) error
|
||||
}); ok {
|
||||
returns.A = hook.DeletePropertyValue(args.A, args.B)
|
||||
returns.A = encodableError(returns.A)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API DeletePropertyValue called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_SearchPropertyValuesArgs struct {
|
||||
A string
|
||||
B string
|
||||
C model.PropertyValueSearchOpts
|
||||
}
|
||||
|
||||
type Z_SearchPropertyValuesReturns struct {
|
||||
A []*model.PropertyValue
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) SearchPropertyValues(groupID, targetID string, opts model.PropertyValueSearchOpts) ([]*model.PropertyValue, error) {
|
||||
_args := &Z_SearchPropertyValuesArgs{groupID, targetID, opts}
|
||||
_returns := &Z_SearchPropertyValuesReturns{}
|
||||
if err := g.client.Call("Plugin.SearchPropertyValues", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to SearchPropertyValues API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) SearchPropertyValues(args *Z_SearchPropertyValuesArgs, returns *Z_SearchPropertyValuesReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
SearchPropertyValues(groupID, targetID string, opts model.PropertyValueSearchOpts) ([]*model.PropertyValue, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.SearchPropertyValues(args.A, args.B, args.C)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API SearchPropertyValues called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_RegisterPropertyGroupArgs struct {
|
||||
A string
|
||||
}
|
||||
|
||||
type Z_RegisterPropertyGroupReturns struct {
|
||||
A *model.PropertyGroup
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) RegisterPropertyGroup(name string) (*model.PropertyGroup, error) {
|
||||
_args := &Z_RegisterPropertyGroupArgs{name}
|
||||
_returns := &Z_RegisterPropertyGroupReturns{}
|
||||
if err := g.client.Call("Plugin.RegisterPropertyGroup", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to RegisterPropertyGroup API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) RegisterPropertyGroup(args *Z_RegisterPropertyGroupArgs, returns *Z_RegisterPropertyGroupReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
RegisterPropertyGroup(name string) (*model.PropertyGroup, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.RegisterPropertyGroup(args.A)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API RegisterPropertyGroup called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_GetPropertyGroupArgs struct {
|
||||
A string
|
||||
}
|
||||
|
||||
type Z_GetPropertyGroupReturns struct {
|
||||
A *model.PropertyGroup
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) GetPropertyGroup(name string) (*model.PropertyGroup, error) {
|
||||
_args := &Z_GetPropertyGroupArgs{name}
|
||||
_returns := &Z_GetPropertyGroupReturns{}
|
||||
if err := g.client.Call("Plugin.GetPropertyGroup", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to GetPropertyGroup API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) GetPropertyGroup(args *Z_GetPropertyGroupArgs, returns *Z_GetPropertyGroupReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
GetPropertyGroup(name string) (*model.PropertyGroup, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.GetPropertyGroup(args.A)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API GetPropertyGroup called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_GetPropertyFieldByNameArgs struct {
|
||||
A string
|
||||
B string
|
||||
C string
|
||||
}
|
||||
|
||||
type Z_GetPropertyFieldByNameReturns struct {
|
||||
A *model.PropertyField
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) GetPropertyFieldByName(groupID, targetID, name string) (*model.PropertyField, error) {
|
||||
_args := &Z_GetPropertyFieldByNameArgs{groupID, targetID, name}
|
||||
_returns := &Z_GetPropertyFieldByNameReturns{}
|
||||
if err := g.client.Call("Plugin.GetPropertyFieldByName", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to GetPropertyFieldByName API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) GetPropertyFieldByName(args *Z_GetPropertyFieldByNameArgs, returns *Z_GetPropertyFieldByNameReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
GetPropertyFieldByName(groupID, targetID, name string) (*model.PropertyField, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.GetPropertyFieldByName(args.A, args.B, args.C)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API GetPropertyFieldByName called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_UpdatePropertyFieldsArgs struct {
|
||||
A string
|
||||
B []*model.PropertyField
|
||||
}
|
||||
|
||||
type Z_UpdatePropertyFieldsReturns struct {
|
||||
A []*model.PropertyField
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) UpdatePropertyFields(groupID string, fields []*model.PropertyField) ([]*model.PropertyField, error) {
|
||||
_args := &Z_UpdatePropertyFieldsArgs{groupID, fields}
|
||||
_returns := &Z_UpdatePropertyFieldsReturns{}
|
||||
if err := g.client.Call("Plugin.UpdatePropertyFields", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to UpdatePropertyFields API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) UpdatePropertyFields(args *Z_UpdatePropertyFieldsArgs, returns *Z_UpdatePropertyFieldsReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
UpdatePropertyFields(groupID string, fields []*model.PropertyField) ([]*model.PropertyField, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.UpdatePropertyFields(args.A, args.B)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API UpdatePropertyFields called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_UpdatePropertyValuesArgs struct {
|
||||
A string
|
||||
B []*model.PropertyValue
|
||||
}
|
||||
|
||||
type Z_UpdatePropertyValuesReturns struct {
|
||||
A []*model.PropertyValue
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) UpdatePropertyValues(groupID string, values []*model.PropertyValue) ([]*model.PropertyValue, error) {
|
||||
_args := &Z_UpdatePropertyValuesArgs{groupID, values}
|
||||
_returns := &Z_UpdatePropertyValuesReturns{}
|
||||
if err := g.client.Call("Plugin.UpdatePropertyValues", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to UpdatePropertyValues API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) UpdatePropertyValues(args *Z_UpdatePropertyValuesArgs, returns *Z_UpdatePropertyValuesReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
UpdatePropertyValues(groupID string, values []*model.PropertyValue) ([]*model.PropertyValue, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.UpdatePropertyValues(args.A, args.B)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API UpdatePropertyValues called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_UpsertPropertyValuesArgs struct {
|
||||
A []*model.PropertyValue
|
||||
}
|
||||
|
||||
type Z_UpsertPropertyValuesReturns struct {
|
||||
A []*model.PropertyValue
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) UpsertPropertyValues(values []*model.PropertyValue) ([]*model.PropertyValue, error) {
|
||||
_args := &Z_UpsertPropertyValuesArgs{values}
|
||||
_returns := &Z_UpsertPropertyValuesReturns{}
|
||||
if err := g.client.Call("Plugin.UpsertPropertyValues", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to UpsertPropertyValues API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) UpsertPropertyValues(args *Z_UpsertPropertyValuesArgs, returns *Z_UpsertPropertyValuesReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
UpsertPropertyValues(values []*model.PropertyValue) ([]*model.PropertyValue, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.UpsertPropertyValues(args.A)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API UpsertPropertyValues called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_DeletePropertyValuesForTargetArgs struct {
|
||||
A string
|
||||
B string
|
||||
C string
|
||||
}
|
||||
|
||||
type Z_DeletePropertyValuesForTargetReturns struct {
|
||||
A error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) DeletePropertyValuesForTarget(groupID, targetType, targetID string) error {
|
||||
_args := &Z_DeletePropertyValuesForTargetArgs{groupID, targetType, targetID}
|
||||
_returns := &Z_DeletePropertyValuesForTargetReturns{}
|
||||
if err := g.client.Call("Plugin.DeletePropertyValuesForTarget", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to DeletePropertyValuesForTarget API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) DeletePropertyValuesForTarget(args *Z_DeletePropertyValuesForTargetArgs, returns *Z_DeletePropertyValuesForTargetReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
DeletePropertyValuesForTarget(groupID, targetType, targetID string) error
|
||||
}); ok {
|
||||
returns.A = hook.DeletePropertyValuesForTarget(args.A, args.B, args.C)
|
||||
returns.A = encodableError(returns.A)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API DeletePropertyValuesForTarget called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_DeletePropertyValuesForFieldArgs struct {
|
||||
A string
|
||||
B string
|
||||
}
|
||||
|
||||
type Z_DeletePropertyValuesForFieldReturns struct {
|
||||
A error
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) DeletePropertyValuesForField(groupID, fieldID string) error {
|
||||
_args := &Z_DeletePropertyValuesForFieldArgs{groupID, fieldID}
|
||||
_returns := &Z_DeletePropertyValuesForFieldReturns{}
|
||||
if err := g.client.Call("Plugin.DeletePropertyValuesForField", _args, _returns); err != nil {
|
||||
log.Printf("RPC call to DeletePropertyValuesForField API failed: %s", err.Error())
|
||||
}
|
||||
return _returns.A
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) DeletePropertyValuesForField(args *Z_DeletePropertyValuesForFieldArgs, returns *Z_DeletePropertyValuesForFieldReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
DeletePropertyValuesForField(groupID, fieldID string) error
|
||||
}); ok {
|
||||
returns.A = hook.DeletePropertyValuesForField(args.A, args.B)
|
||||
returns.A = encodableError(returns.A)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("API DeletePropertyValuesForField called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -388,6 +388,66 @@ func (_m *API) CreatePost(post *model.Post) (*model.Post, *model.AppError) {
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// CreatePropertyField provides a mock function with given fields: field
|
||||
func (_m *API) CreatePropertyField(field *model.PropertyField) (*model.PropertyField, error) {
|
||||
ret := _m.Called(field)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for CreatePropertyField")
|
||||
}
|
||||
|
||||
var r0 *model.PropertyField
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(*model.PropertyField) (*model.PropertyField, error)); ok {
|
||||
return rf(field)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(*model.PropertyField) *model.PropertyField); ok {
|
||||
r0 = rf(field)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.PropertyField)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(*model.PropertyField) error); ok {
|
||||
r1 = rf(field)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// CreatePropertyValue provides a mock function with given fields: value
|
||||
func (_m *API) CreatePropertyValue(value *model.PropertyValue) (*model.PropertyValue, error) {
|
||||
ret := _m.Called(value)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for CreatePropertyValue")
|
||||
}
|
||||
|
||||
var r0 *model.PropertyValue
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(*model.PropertyValue) (*model.PropertyValue, error)); ok {
|
||||
return rf(value)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(*model.PropertyValue) *model.PropertyValue); ok {
|
||||
r0 = rf(value)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.PropertyValue)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(*model.PropertyValue) error); ok {
|
||||
r1 = rf(value)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// CreateSession provides a mock function with given fields: session
|
||||
func (_m *API) CreateSession(session *model.Session) (*model.Session, *model.AppError) {
|
||||
ret := _m.Called(session)
|
||||
@@ -881,6 +941,78 @@ func (_m *API) DeletePreferencesForUser(userID string, preferences []model.Prefe
|
||||
return r0
|
||||
}
|
||||
|
||||
// DeletePropertyField provides a mock function with given fields: groupID, fieldID
|
||||
func (_m *API) DeletePropertyField(groupID string, fieldID string) error {
|
||||
ret := _m.Called(groupID, fieldID)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for DeletePropertyField")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string, string) error); ok {
|
||||
r0 = rf(groupID, fieldID)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// DeletePropertyValue provides a mock function with given fields: groupID, valueID
|
||||
func (_m *API) DeletePropertyValue(groupID string, valueID string) error {
|
||||
ret := _m.Called(groupID, valueID)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for DeletePropertyValue")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string, string) error); ok {
|
||||
r0 = rf(groupID, valueID)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// DeletePropertyValuesForField provides a mock function with given fields: groupID, fieldID
|
||||
func (_m *API) DeletePropertyValuesForField(groupID string, fieldID string) error {
|
||||
ret := _m.Called(groupID, fieldID)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for DeletePropertyValuesForField")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string, string) error); ok {
|
||||
r0 = rf(groupID, fieldID)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// DeletePropertyValuesForTarget provides a mock function with given fields: groupID, targetType, targetID
|
||||
func (_m *API) DeletePropertyValuesForTarget(groupID string, targetType string, targetID string) error {
|
||||
ret := _m.Called(groupID, targetType, targetID)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for DeletePropertyValuesForTarget")
|
||||
}
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string, string, string) error); ok {
|
||||
r0 = rf(groupID, targetType, targetID)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// DeleteTeam provides a mock function with given fields: teamID
|
||||
func (_m *API) DeleteTeam(teamID string) *model.AppError {
|
||||
ret := _m.Called(teamID)
|
||||
@@ -2654,6 +2786,186 @@ func (_m *API) GetProfileImage(userID string) ([]byte, *model.AppError) {
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPropertyField provides a mock function with given fields: groupID, fieldID
|
||||
func (_m *API) GetPropertyField(groupID string, fieldID string) (*model.PropertyField, error) {
|
||||
ret := _m.Called(groupID, fieldID)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetPropertyField")
|
||||
}
|
||||
|
||||
var r0 *model.PropertyField
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, string) (*model.PropertyField, error)); ok {
|
||||
return rf(groupID, fieldID)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, string) *model.PropertyField); ok {
|
||||
r0 = rf(groupID, fieldID)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.PropertyField)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, string) error); ok {
|
||||
r1 = rf(groupID, fieldID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPropertyFieldByName provides a mock function with given fields: groupID, targetID, name
|
||||
func (_m *API) GetPropertyFieldByName(groupID string, targetID string, name string) (*model.PropertyField, error) {
|
||||
ret := _m.Called(groupID, targetID, name)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetPropertyFieldByName")
|
||||
}
|
||||
|
||||
var r0 *model.PropertyField
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, string, string) (*model.PropertyField, error)); ok {
|
||||
return rf(groupID, targetID, name)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, string, string) *model.PropertyField); ok {
|
||||
r0 = rf(groupID, targetID, name)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.PropertyField)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, string, string) error); ok {
|
||||
r1 = rf(groupID, targetID, name)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPropertyFields provides a mock function with given fields: groupID, ids
|
||||
func (_m *API) GetPropertyFields(groupID string, ids []string) ([]*model.PropertyField, error) {
|
||||
ret := _m.Called(groupID, ids)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetPropertyFields")
|
||||
}
|
||||
|
||||
var r0 []*model.PropertyField
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, []string) ([]*model.PropertyField, error)); ok {
|
||||
return rf(groupID, ids)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, []string) []*model.PropertyField); ok {
|
||||
r0 = rf(groupID, ids)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*model.PropertyField)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, []string) error); ok {
|
||||
r1 = rf(groupID, ids)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPropertyGroup provides a mock function with given fields: name
|
||||
func (_m *API) GetPropertyGroup(name string) (*model.PropertyGroup, error) {
|
||||
ret := _m.Called(name)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetPropertyGroup")
|
||||
}
|
||||
|
||||
var r0 *model.PropertyGroup
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string) (*model.PropertyGroup, error)); ok {
|
||||
return rf(name)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string) *model.PropertyGroup); ok {
|
||||
r0 = rf(name)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.PropertyGroup)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(name)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPropertyValue provides a mock function with given fields: groupID, valueID
|
||||
func (_m *API) GetPropertyValue(groupID string, valueID string) (*model.PropertyValue, error) {
|
||||
ret := _m.Called(groupID, valueID)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetPropertyValue")
|
||||
}
|
||||
|
||||
var r0 *model.PropertyValue
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, string) (*model.PropertyValue, error)); ok {
|
||||
return rf(groupID, valueID)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, string) *model.PropertyValue); ok {
|
||||
r0 = rf(groupID, valueID)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.PropertyValue)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, string) error); ok {
|
||||
r1 = rf(groupID, valueID)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPropertyValues provides a mock function with given fields: groupID, ids
|
||||
func (_m *API) GetPropertyValues(groupID string, ids []string) ([]*model.PropertyValue, error) {
|
||||
ret := _m.Called(groupID, ids)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for GetPropertyValues")
|
||||
}
|
||||
|
||||
var r0 []*model.PropertyValue
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, []string) ([]*model.PropertyValue, error)); ok {
|
||||
return rf(groupID, ids)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, []string) []*model.PropertyValue); ok {
|
||||
r0 = rf(groupID, ids)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*model.PropertyValue)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, []string) error); ok {
|
||||
r1 = rf(groupID, ids)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GetPublicChannelsForTeam provides a mock function with given fields: teamID, page, perPage
|
||||
func (_m *API) GetPublicChannelsForTeam(teamID string, page int, perPage int) ([]*model.Channel, *model.AppError) {
|
||||
ret := _m.Called(teamID, page, perPage)
|
||||
@@ -4283,6 +4595,36 @@ func (_m *API) RegisterPluginForSharedChannels(opts model.RegisterPluginOpts) (s
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// RegisterPropertyGroup provides a mock function with given fields: name
|
||||
func (_m *API) RegisterPropertyGroup(name string) (*model.PropertyGroup, error) {
|
||||
ret := _m.Called(name)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for RegisterPropertyGroup")
|
||||
}
|
||||
|
||||
var r0 *model.PropertyGroup
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string) (*model.PropertyGroup, error)); ok {
|
||||
return rf(name)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string) *model.PropertyGroup); ok {
|
||||
r0 = rf(name)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.PropertyGroup)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(name)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// RemovePlugin provides a mock function with given fields: id
|
||||
func (_m *API) RemovePlugin(id string) *model.AppError {
|
||||
ret := _m.Called(id)
|
||||
@@ -4609,6 +4951,66 @@ func (_m *API) SearchPostsInTeamForUser(teamID string, userID string, searchPara
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// SearchPropertyFields provides a mock function with given fields: groupID, targetID, opts
|
||||
func (_m *API) SearchPropertyFields(groupID string, targetID string, opts model.PropertyFieldSearchOpts) ([]*model.PropertyField, error) {
|
||||
ret := _m.Called(groupID, targetID, opts)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for SearchPropertyFields")
|
||||
}
|
||||
|
||||
var r0 []*model.PropertyField
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, string, model.PropertyFieldSearchOpts) ([]*model.PropertyField, error)); ok {
|
||||
return rf(groupID, targetID, opts)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, string, model.PropertyFieldSearchOpts) []*model.PropertyField); ok {
|
||||
r0 = rf(groupID, targetID, opts)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*model.PropertyField)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, string, model.PropertyFieldSearchOpts) error); ok {
|
||||
r1 = rf(groupID, targetID, opts)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// SearchPropertyValues provides a mock function with given fields: groupID, targetID, opts
|
||||
func (_m *API) SearchPropertyValues(groupID string, targetID string, opts model.PropertyValueSearchOpts) ([]*model.PropertyValue, error) {
|
||||
ret := _m.Called(groupID, targetID, opts)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for SearchPropertyValues")
|
||||
}
|
||||
|
||||
var r0 []*model.PropertyValue
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, string, model.PropertyValueSearchOpts) ([]*model.PropertyValue, error)); ok {
|
||||
return rf(groupID, targetID, opts)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, string, model.PropertyValueSearchOpts) []*model.PropertyValue); ok {
|
||||
r0 = rf(groupID, targetID, opts)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*model.PropertyValue)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, string, model.PropertyValueSearchOpts) error); ok {
|
||||
r1 = rf(groupID, targetID, opts)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// SearchTeams provides a mock function with given fields: term
|
||||
func (_m *API) SearchTeams(term string) ([]*model.Team, *model.AppError) {
|
||||
ret := _m.Called(term)
|
||||
@@ -5313,6 +5715,126 @@ func (_m *API) UpdatePreferencesForUser(userID string, preferences []model.Prefe
|
||||
return r0
|
||||
}
|
||||
|
||||
// UpdatePropertyField provides a mock function with given fields: groupID, field
|
||||
func (_m *API) UpdatePropertyField(groupID string, field *model.PropertyField) (*model.PropertyField, error) {
|
||||
ret := _m.Called(groupID, field)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for UpdatePropertyField")
|
||||
}
|
||||
|
||||
var r0 *model.PropertyField
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, *model.PropertyField) (*model.PropertyField, error)); ok {
|
||||
return rf(groupID, field)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, *model.PropertyField) *model.PropertyField); ok {
|
||||
r0 = rf(groupID, field)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.PropertyField)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, *model.PropertyField) error); ok {
|
||||
r1 = rf(groupID, field)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// UpdatePropertyFields provides a mock function with given fields: groupID, fields
|
||||
func (_m *API) UpdatePropertyFields(groupID string, fields []*model.PropertyField) ([]*model.PropertyField, error) {
|
||||
ret := _m.Called(groupID, fields)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for UpdatePropertyFields")
|
||||
}
|
||||
|
||||
var r0 []*model.PropertyField
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, []*model.PropertyField) ([]*model.PropertyField, error)); ok {
|
||||
return rf(groupID, fields)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, []*model.PropertyField) []*model.PropertyField); ok {
|
||||
r0 = rf(groupID, fields)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*model.PropertyField)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, []*model.PropertyField) error); ok {
|
||||
r1 = rf(groupID, fields)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// UpdatePropertyValue provides a mock function with given fields: groupID, value
|
||||
func (_m *API) UpdatePropertyValue(groupID string, value *model.PropertyValue) (*model.PropertyValue, error) {
|
||||
ret := _m.Called(groupID, value)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for UpdatePropertyValue")
|
||||
}
|
||||
|
||||
var r0 *model.PropertyValue
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, *model.PropertyValue) (*model.PropertyValue, error)); ok {
|
||||
return rf(groupID, value)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, *model.PropertyValue) *model.PropertyValue); ok {
|
||||
r0 = rf(groupID, value)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.PropertyValue)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, *model.PropertyValue) error); ok {
|
||||
r1 = rf(groupID, value)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// UpdatePropertyValues provides a mock function with given fields: groupID, values
|
||||
func (_m *API) UpdatePropertyValues(groupID string, values []*model.PropertyValue) ([]*model.PropertyValue, error) {
|
||||
ret := _m.Called(groupID, values)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for UpdatePropertyValues")
|
||||
}
|
||||
|
||||
var r0 []*model.PropertyValue
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, []*model.PropertyValue) ([]*model.PropertyValue, error)); ok {
|
||||
return rf(groupID, values)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, []*model.PropertyValue) []*model.PropertyValue); ok {
|
||||
r0 = rf(groupID, values)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*model.PropertyValue)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, []*model.PropertyValue) error); ok {
|
||||
r1 = rf(groupID, values)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// UpdateSharedChannel provides a mock function with given fields: sc
|
||||
func (_m *API) UpdateSharedChannel(sc *model.SharedChannel) (*model.SharedChannel, error) {
|
||||
ret := _m.Called(sc)
|
||||
@@ -5751,6 +6273,66 @@ func (_m *API) UpsertGroupSyncable(groupSyncable *model.GroupSyncable) (*model.G
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// UpsertPropertyValue provides a mock function with given fields: value
|
||||
func (_m *API) UpsertPropertyValue(value *model.PropertyValue) (*model.PropertyValue, error) {
|
||||
ret := _m.Called(value)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for UpsertPropertyValue")
|
||||
}
|
||||
|
||||
var r0 *model.PropertyValue
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(*model.PropertyValue) (*model.PropertyValue, error)); ok {
|
||||
return rf(value)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(*model.PropertyValue) *model.PropertyValue); ok {
|
||||
r0 = rf(value)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*model.PropertyValue)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(*model.PropertyValue) error); ok {
|
||||
r1 = rf(value)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// UpsertPropertyValues provides a mock function with given fields: values
|
||||
func (_m *API) UpsertPropertyValues(values []*model.PropertyValue) ([]*model.PropertyValue, error) {
|
||||
ret := _m.Called(values)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for UpsertPropertyValues")
|
||||
}
|
||||
|
||||
var r0 []*model.PropertyValue
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func([]*model.PropertyValue) ([]*model.PropertyValue, error)); ok {
|
||||
return rf(values)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func([]*model.PropertyValue) []*model.PropertyValue); ok {
|
||||
r0 = rf(values)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]*model.PropertyValue)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func([]*model.PropertyValue) error); ok {
|
||||
r1 = rf(values)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// NewAPI creates a new instance of API. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewAPI(t interface {
|
||||
|
||||
@@ -25,6 +25,7 @@ type Client struct {
|
||||
Mail MailService
|
||||
Plugin PluginService
|
||||
Post PostService
|
||||
Property PropertyService
|
||||
Session SessionService
|
||||
Store *StoreService
|
||||
System SystemService
|
||||
@@ -55,6 +56,7 @@ func NewClient(api plugin.API, driver plugin.Driver) *Client {
|
||||
Mail: MailService{api: api},
|
||||
Plugin: PluginService{api: api},
|
||||
Post: PostService{api: api},
|
||||
Property: PropertyService{api: api},
|
||||
Session: SessionService{api: api},
|
||||
Store: &StoreService{
|
||||
api: api,
|
||||
|
||||
158
server/public/pluginapi/property.go
Обычный файл
158
server/public/pluginapi/property.go
Обычный файл
@@ -0,0 +1,158 @@
|
||||
package pluginapi
|
||||
|
||||
import (
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/plugin"
|
||||
)
|
||||
|
||||
// PropertyService exposes methods to manipulate property fields and values.
|
||||
type PropertyService struct {
|
||||
api plugin.API
|
||||
}
|
||||
|
||||
// CreatePropertyField creates a new property field.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) CreatePropertyField(field *model.PropertyField) (*model.PropertyField, error) {
|
||||
return p.api.CreatePropertyField(field)
|
||||
}
|
||||
|
||||
// GetPropertyField gets a property field by groupID and fieldID.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) GetPropertyField(groupID, fieldID string) (*model.PropertyField, error) {
|
||||
return p.api.GetPropertyField(groupID, fieldID)
|
||||
}
|
||||
|
||||
// GetPropertyFields gets multiple property fields by groupID and a list of IDs.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) GetPropertyFields(groupID string, ids []string) ([]*model.PropertyField, error) {
|
||||
return p.api.GetPropertyFields(groupID, ids)
|
||||
}
|
||||
|
||||
// UpdatePropertyField updates an existing property field.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) UpdatePropertyField(groupID string, field *model.PropertyField) (*model.PropertyField, error) {
|
||||
return p.api.UpdatePropertyField(groupID, field)
|
||||
}
|
||||
|
||||
// DeletePropertyField deletes a property field (soft delete).
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) DeletePropertyField(groupID, fieldID string) error {
|
||||
return p.api.DeletePropertyField(groupID, fieldID)
|
||||
}
|
||||
|
||||
// SearchPropertyFields searches for property fields with filtering options.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) SearchPropertyFields(groupID, targetID string, opts model.PropertyFieldSearchOpts) ([]*model.PropertyField, error) {
|
||||
return p.api.SearchPropertyFields(groupID, targetID, opts)
|
||||
}
|
||||
|
||||
// CreatePropertyValue creates a new property value.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) CreatePropertyValue(value *model.PropertyValue) (*model.PropertyValue, error) {
|
||||
return p.api.CreatePropertyValue(value)
|
||||
}
|
||||
|
||||
// GetPropertyValue gets a property value by groupID and valueID.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) GetPropertyValue(groupID, valueID string) (*model.PropertyValue, error) {
|
||||
return p.api.GetPropertyValue(groupID, valueID)
|
||||
}
|
||||
|
||||
// GetPropertyValues gets multiple property values by groupID and a list of IDs.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) GetPropertyValues(groupID string, ids []string) ([]*model.PropertyValue, error) {
|
||||
return p.api.GetPropertyValues(groupID, ids)
|
||||
}
|
||||
|
||||
// UpdatePropertyValue updates an existing property value.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) UpdatePropertyValue(groupID string, value *model.PropertyValue) (*model.PropertyValue, error) {
|
||||
return p.api.UpdatePropertyValue(groupID, value)
|
||||
}
|
||||
|
||||
// UpsertPropertyValue creates a new property value or updates it if it already exists.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) UpsertPropertyValue(value *model.PropertyValue) (*model.PropertyValue, error) {
|
||||
return p.api.UpsertPropertyValue(value)
|
||||
}
|
||||
|
||||
// DeletePropertyValue deletes a property value (soft delete).
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) DeletePropertyValue(groupID, valueID string) error {
|
||||
return p.api.DeletePropertyValue(groupID, valueID)
|
||||
}
|
||||
|
||||
// SearchPropertyValues searches for property values with filtering options.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) SearchPropertyValues(groupID, targetID string, opts model.PropertyValueSearchOpts) ([]*model.PropertyValue, error) {
|
||||
return p.api.SearchPropertyValues(groupID, targetID, opts)
|
||||
}
|
||||
|
||||
// RegisterPropertyGroup registers a new property group.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) RegisterPropertyGroup(name string) (*model.PropertyGroup, error) {
|
||||
return p.api.RegisterPropertyGroup(name)
|
||||
}
|
||||
|
||||
// GetPropertyGroup gets a property group by name.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) GetPropertyGroup(name string) (*model.PropertyGroup, error) {
|
||||
return p.api.GetPropertyGroup(name)
|
||||
}
|
||||
|
||||
// GetPropertyFieldByName gets a property field by groupID, targetID and name.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) GetPropertyFieldByName(groupID, targetID, name string) (*model.PropertyField, error) {
|
||||
return p.api.GetPropertyFieldByName(groupID, targetID, name)
|
||||
}
|
||||
|
||||
// UpdatePropertyFields updates multiple property fields in a single operation.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) UpdatePropertyFields(groupID string, fields []*model.PropertyField) ([]*model.PropertyField, error) {
|
||||
return p.api.UpdatePropertyFields(groupID, fields)
|
||||
}
|
||||
|
||||
// UpdatePropertyValues updates multiple property values in a single operation.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) UpdatePropertyValues(groupID string, values []*model.PropertyValue) ([]*model.PropertyValue, error) {
|
||||
return p.api.UpdatePropertyValues(groupID, values)
|
||||
}
|
||||
|
||||
// UpsertPropertyValues creates or updates multiple property values in a single operation.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) UpsertPropertyValues(values []*model.PropertyValue) ([]*model.PropertyValue, error) {
|
||||
return p.api.UpsertPropertyValues(values)
|
||||
}
|
||||
|
||||
// DeletePropertyValuesForTarget deletes all property values for a specific target.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) DeletePropertyValuesForTarget(groupID, targetType, targetID string) error {
|
||||
return p.api.DeletePropertyValuesForTarget(groupID, targetType, targetID)
|
||||
}
|
||||
|
||||
// DeletePropertyValuesForField deletes all property values for a specific field.
|
||||
//
|
||||
// Minimum server version: 10.10
|
||||
func (p *PropertyService) DeletePropertyValuesForField(groupID, fieldID string) error {
|
||||
return p.api.DeletePropertyValuesForField(groupID, fieldID)
|
||||
}
|
||||
428
server/public/pluginapi/property_test.go
Обычный файл
428
server/public/pluginapi/property_test.go
Обычный файл
@@ -0,0 +1,428 @@
|
||||
package pluginapi
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/mattermost/mattermost/server/public/model"
|
||||
"github.com/mattermost/mattermost/server/public/plugin/plugintest"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPropertyFieldAPI(t *testing.T) {
|
||||
t.Run("CreatePropertyField", func(t *testing.T) {
|
||||
// Setup
|
||||
api := &plugintest.API{}
|
||||
|
||||
// Mock the API call
|
||||
field := &model.PropertyField{
|
||||
ID: "field1",
|
||||
GroupID: "group1",
|
||||
Name: "Test Field",
|
||||
Type: model.PropertyFieldTypeText,
|
||||
}
|
||||
api.On("CreatePropertyField", field).Return(field, nil)
|
||||
|
||||
// Create the client
|
||||
client := NewClient(api, nil)
|
||||
|
||||
// Call the method
|
||||
result, err := client.Property.CreatePropertyField(field)
|
||||
|
||||
// Verify the results
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, field, result)
|
||||
api.AssertExpectations(t)
|
||||
})
|
||||
|
||||
t.Run("GetPropertyField", func(t *testing.T) {
|
||||
// Setup
|
||||
api := &plugintest.API{}
|
||||
|
||||
// Mock the API call
|
||||
field := &model.PropertyField{
|
||||
ID: "field1",
|
||||
GroupID: "group1",
|
||||
Name: "Test Field",
|
||||
Type: model.PropertyFieldTypeText,
|
||||
}
|
||||
api.On("GetPropertyField", "group1", "field1").Return(field, nil)
|
||||
|
||||
// Create the client
|
||||
client := NewClient(api, nil)
|
||||
|
||||
// Call the method
|
||||
result, err := client.Property.GetPropertyField("group1", "field1")
|
||||
|
||||
// Verify the results
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, field, result)
|
||||
api.AssertExpectations(t)
|
||||
})
|
||||
|
||||
t.Run("GetPropertyFields", func(t *testing.T) {
|
||||
// Setup
|
||||
api := &plugintest.API{}
|
||||
|
||||
// Mock the API call
|
||||
fields := []*model.PropertyField{
|
||||
{
|
||||
ID: "field1",
|
||||
GroupID: "group1",
|
||||
Name: "Test Field 1",
|
||||
Type: model.PropertyFieldTypeText,
|
||||
},
|
||||
{
|
||||
ID: "field2",
|
||||
GroupID: "group1",
|
||||
Name: "Test Field 2",
|
||||
Type: model.PropertyFieldTypeSelect,
|
||||
},
|
||||
}
|
||||
api.On("GetPropertyFields", "group1", []string{"field1", "field2"}).Return(fields, nil)
|
||||
|
||||
// Create the client
|
||||
client := NewClient(api, nil)
|
||||
|
||||
// Call the method
|
||||
result, err := client.Property.GetPropertyFields("group1", []string{"field1", "field2"})
|
||||
|
||||
// Verify the results
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, fields, result)
|
||||
api.AssertExpectations(t)
|
||||
})
|
||||
|
||||
t.Run("UpdatePropertyField", func(t *testing.T) {
|
||||
// Setup
|
||||
api := &plugintest.API{}
|
||||
|
||||
// Mock the API call
|
||||
field := &model.PropertyField{
|
||||
ID: "field1",
|
||||
GroupID: "group1",
|
||||
Name: "Updated Field",
|
||||
Type: model.PropertyFieldTypeText,
|
||||
}
|
||||
api.On("UpdatePropertyField", "group1", field).Return(field, nil)
|
||||
|
||||
// Create the client
|
||||
client := NewClient(api, nil)
|
||||
|
||||
// Call the method
|
||||
result, err := client.Property.UpdatePropertyField("group1", field)
|
||||
|
||||
// Verify the results
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, field, result)
|
||||
api.AssertExpectations(t)
|
||||
})
|
||||
|
||||
t.Run("DeletePropertyField", func(t *testing.T) {
|
||||
// Setup
|
||||
api := &plugintest.API{}
|
||||
|
||||
// Mock the API call
|
||||
api.On("DeletePropertyField", "group1", "field1").Return(nil)
|
||||
|
||||
// Create the client
|
||||
client := NewClient(api, nil)
|
||||
|
||||
// Call the method
|
||||
err := client.Property.DeletePropertyField("group1", "field1")
|
||||
|
||||
// Verify the results
|
||||
assert.NoError(t, err)
|
||||
api.AssertExpectations(t)
|
||||
})
|
||||
|
||||
t.Run("SearchPropertyFields", func(t *testing.T) {
|
||||
// Setup
|
||||
api := &plugintest.API{}
|
||||
|
||||
// Mock the API call
|
||||
opts := model.PropertyFieldSearchOpts{
|
||||
PerPage: 10,
|
||||
}
|
||||
fields := []*model.PropertyField{
|
||||
{
|
||||
ID: "field1",
|
||||
GroupID: "group1",
|
||||
Name: "Test Field 1",
|
||||
Type: model.PropertyFieldTypeText,
|
||||
},
|
||||
{
|
||||
ID: "field2",
|
||||
GroupID: "group1",
|
||||
Name: "Test Field 2",
|
||||
Type: model.PropertyFieldTypeSelect,
|
||||
},
|
||||
}
|
||||
api.On("SearchPropertyFields", "group1", "target1", opts).Return(fields, nil)
|
||||
|
||||
// Create the client
|
||||
client := NewClient(api, nil)
|
||||
|
||||
// Call the method
|
||||
result, err := client.Property.SearchPropertyFields("group1", "target1", opts)
|
||||
|
||||
// Verify the results
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, fields, result)
|
||||
api.AssertExpectations(t)
|
||||
})
|
||||
}
|
||||
|
||||
func TestPropertyValueAPI(t *testing.T) {
|
||||
t.Run("CreatePropertyValue", func(t *testing.T) {
|
||||
// Setup
|
||||
api := &plugintest.API{}
|
||||
|
||||
// Mock the API call
|
||||
value := &model.PropertyValue{
|
||||
ID: "value1",
|
||||
GroupID: "group1",
|
||||
FieldID: "field1",
|
||||
TargetID: "target1",
|
||||
TargetType: "post",
|
||||
Value: json.RawMessage(`"Test Value"`),
|
||||
}
|
||||
api.On("CreatePropertyValue", value).Return(value, nil)
|
||||
|
||||
// Create the client
|
||||
client := NewClient(api, nil)
|
||||
|
||||
// Call the method
|
||||
result, err := client.Property.CreatePropertyValue(value)
|
||||
|
||||
// Verify the results
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, value, result)
|
||||
api.AssertExpectations(t)
|
||||
})
|
||||
|
||||
t.Run("GetPropertyValue", func(t *testing.T) {
|
||||
// Setup
|
||||
api := &plugintest.API{}
|
||||
|
||||
// Mock the API call
|
||||
value := &model.PropertyValue{
|
||||
ID: "value1",
|
||||
GroupID: "group1",
|
||||
FieldID: "field1",
|
||||
TargetID: "target1",
|
||||
TargetType: "post",
|
||||
Value: json.RawMessage(`"Test Value"`),
|
||||
}
|
||||
api.On("GetPropertyValue", "group1", "value1").Return(value, nil)
|
||||
|
||||
// Create the client
|
||||
client := NewClient(api, nil)
|
||||
|
||||
// Call the method
|
||||
result, err := client.Property.GetPropertyValue("group1", "value1")
|
||||
|
||||
// Verify the results
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, value, result)
|
||||
api.AssertExpectations(t)
|
||||
})
|
||||
|
||||
t.Run("GetPropertyValues", func(t *testing.T) {
|
||||
// Setup
|
||||
api := &plugintest.API{}
|
||||
|
||||
// Mock the API call
|
||||
values := []*model.PropertyValue{
|
||||
{
|
||||
ID: "value1",
|
||||
GroupID: "group1",
|
||||
FieldID: "field1",
|
||||
TargetID: "target1",
|
||||
TargetType: "post",
|
||||
Value: json.RawMessage(`"Test Value 1"`),
|
||||
},
|
||||
{
|
||||
ID: "value2",
|
||||
GroupID: "group1",
|
||||
FieldID: "field2",
|
||||
TargetID: "target1",
|
||||
TargetType: "post",
|
||||
Value: json.RawMessage(`"Test Value 2"`),
|
||||
},
|
||||
}
|
||||
api.On("GetPropertyValues", "group1", []string{"value1", "value2"}).Return(values, nil)
|
||||
|
||||
// Create the client
|
||||
client := NewClient(api, nil)
|
||||
|
||||
// Call the method
|
||||
result, err := client.Property.GetPropertyValues("group1", []string{"value1", "value2"})
|
||||
|
||||
// Verify the results
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, values, result)
|
||||
api.AssertExpectations(t)
|
||||
})
|
||||
|
||||
t.Run("UpdatePropertyValue", func(t *testing.T) {
|
||||
// Setup
|
||||
api := &plugintest.API{}
|
||||
|
||||
// Mock the API call
|
||||
value := &model.PropertyValue{
|
||||
ID: "value1",
|
||||
GroupID: "group1",
|
||||
FieldID: "field1",
|
||||
TargetID: "target1",
|
||||
TargetType: "post",
|
||||
Value: json.RawMessage(`"Updated Value"`),
|
||||
}
|
||||
api.On("UpdatePropertyValue", "group1", value).Return(value, nil)
|
||||
|
||||
// Create the client
|
||||
client := NewClient(api, nil)
|
||||
|
||||
// Call the method
|
||||
result, err := client.Property.UpdatePropertyValue("group1", value)
|
||||
|
||||
// Verify the results
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, value, result)
|
||||
api.AssertExpectations(t)
|
||||
})
|
||||
|
||||
t.Run("UpsertPropertyValue", func(t *testing.T) {
|
||||
// Setup
|
||||
api := &plugintest.API{}
|
||||
|
||||
// Mock the API call
|
||||
value := &model.PropertyValue{
|
||||
ID: "value1",
|
||||
GroupID: "group1",
|
||||
FieldID: "field1",
|
||||
TargetID: "target1",
|
||||
TargetType: "post",
|
||||
Value: json.RawMessage(`"Upsert Value"`),
|
||||
}
|
||||
api.On("UpsertPropertyValue", value).Return(value, nil)
|
||||
|
||||
// Create the client
|
||||
client := NewClient(api, nil)
|
||||
|
||||
// Call the method
|
||||
result, err := client.Property.UpsertPropertyValue(value)
|
||||
|
||||
// Verify the results
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, value, result)
|
||||
api.AssertExpectations(t)
|
||||
})
|
||||
|
||||
t.Run("DeletePropertyValue", func(t *testing.T) {
|
||||
// Setup
|
||||
api := &plugintest.API{}
|
||||
|
||||
// Mock the API call
|
||||
api.On("DeletePropertyValue", "group1", "value1").Return(nil)
|
||||
|
||||
// Create the client
|
||||
client := NewClient(api, nil)
|
||||
|
||||
// Call the method
|
||||
err := client.Property.DeletePropertyValue("group1", "value1")
|
||||
|
||||
// Verify the results
|
||||
assert.NoError(t, err)
|
||||
api.AssertExpectations(t)
|
||||
})
|
||||
|
||||
t.Run("SearchPropertyValues", func(t *testing.T) {
|
||||
// Setup
|
||||
api := &plugintest.API{}
|
||||
|
||||
// Mock the API call
|
||||
opts := model.PropertyValueSearchOpts{
|
||||
PerPage: 10,
|
||||
}
|
||||
values := []*model.PropertyValue{
|
||||
{
|
||||
ID: "value1",
|
||||
GroupID: "group1",
|
||||
FieldID: "field1",
|
||||
TargetID: "target1",
|
||||
TargetType: "post",
|
||||
Value: json.RawMessage(`"Test Value 1"`),
|
||||
},
|
||||
{
|
||||
ID: "value2",
|
||||
GroupID: "group1",
|
||||
FieldID: "field2",
|
||||
TargetID: "target1",
|
||||
TargetType: "post",
|
||||
Value: json.RawMessage(`"Test Value 2"`),
|
||||
},
|
||||
}
|
||||
api.On("SearchPropertyValues", "group1", "target1", opts).Return(values, nil)
|
||||
|
||||
// Create the client
|
||||
client := NewClient(api, nil)
|
||||
|
||||
// Call the method
|
||||
result, err := client.Property.SearchPropertyValues("group1", "target1", opts)
|
||||
|
||||
// Verify the results
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, values, result)
|
||||
api.AssertExpectations(t)
|
||||
})
|
||||
}
|
||||
|
||||
func TestPropertyGroupAPI(t *testing.T) {
|
||||
t.Run("RegisterPropertyGroup", func(t *testing.T) {
|
||||
// Setup
|
||||
api := &plugintest.API{}
|
||||
|
||||
// Mock the API call
|
||||
group := &model.PropertyGroup{
|
||||
ID: "group1",
|
||||
Name: "Test Group",
|
||||
}
|
||||
api.On("RegisterPropertyGroup", "Test Group").Return(group, nil)
|
||||
|
||||
// Create the client
|
||||
client := NewClient(api, nil)
|
||||
|
||||
// Call the method
|
||||
result, err := client.Property.RegisterPropertyGroup("Test Group")
|
||||
|
||||
// Verify the results
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, group, result)
|
||||
api.AssertExpectations(t)
|
||||
})
|
||||
|
||||
t.Run("GetPropertyGroup", func(t *testing.T) {
|
||||
// Setup
|
||||
api := &plugintest.API{}
|
||||
|
||||
// Mock the API call
|
||||
group := &model.PropertyGroup{
|
||||
ID: "group1",
|
||||
Name: "Test Group",
|
||||
}
|
||||
api.On("GetPropertyGroup", "Test Group").Return(group, nil)
|
||||
|
||||
// Create the client
|
||||
client := NewClient(api, nil)
|
||||
|
||||
// Call the method
|
||||
result, err := client.Property.GetPropertyGroup("Test Group")
|
||||
|
||||
// Verify the results
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, group, result)
|
||||
api.AssertExpectations(t)
|
||||
})
|
||||
}
|
||||
Ссылка в новой задаче
Block a user