Files
teleport/lib/services/user_task.go
T
Marco Dinis 5477077da8 UserTasks: List by Integration service method (#47327)
This PR adds a new method that allows users to list UserTasks by
Integration.
Given this is our main use case when showing the UserTasks in the UI
(we'll be always showing UserTasks for a given integration), we created
a dedicated method in the gRPC.
We'll probably add more filters but they will always include the
integration (at least for the uses cases we have currently).
2024-10-09 08:46:06 +00:00

56 lines
2.5 KiB
Go

/*
* Teleport
* Copyright (C) 2024 Gravitational, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package services
import (
"context"
usertasksv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/usertasks/v1"
)
// UserTasks is the interface for managing user tasks resources.
type UserTasks interface {
// CreateUserTask creates a new user tasks resource.
CreateUserTask(context.Context, *usertasksv1.UserTask) (*usertasksv1.UserTask, error)
// UpsertUserTask creates or updates the user tasks resource.
UpsertUserTask(context.Context, *usertasksv1.UserTask) (*usertasksv1.UserTask, error)
// GetUserTask returns the user tasks resource by name.
GetUserTask(ctx context.Context, name string) (*usertasksv1.UserTask, error)
// ListUserTasks returns the user tasks resources.
ListUserTasks(ctx context.Context, pageSize int64, nextToken string) ([]*usertasksv1.UserTask, string, error)
// ListUserTasksByIntegration returns the user tasks resources filtered by integration.
ListUserTasksByIntegration(ctx context.Context, pageSize int64, nextToken string, integration string) ([]*usertasksv1.UserTask, string, error)
// UpdateUserTask updates the user tasks resource.
UpdateUserTask(context.Context, *usertasksv1.UserTask) (*usertasksv1.UserTask, error)
// DeleteUserTask deletes the user tasks resource by name.
DeleteUserTask(context.Context, string) error
// DeleteAllUserTasks deletes all user tasks.
DeleteAllUserTasks(context.Context) error
}
// MarshalUserTask marshals the UserTask object into a JSON byte array.
func MarshalUserTask(object *usertasksv1.UserTask, opts ...MarshalOption) ([]byte, error) {
return MarshalProtoResource(object, opts...)
}
// UnmarshalUserTask unmarshals the UserTask object from a JSON byte array.
func UnmarshalUserTask(data []byte, opts ...MarshalOption) (*usertasksv1.UserTask, error) {
return UnmarshalProtoResource[*usertasksv1.UserTask](data, opts...)
}