github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/storage/ext.go (about)

     1  package storage
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/kyma-project/kyma-environment-broker/common/events"
     7  	"github.com/kyma-project/kyma-environment-broker/internal"
     8  	"github.com/kyma-project/kyma-environment-broker/internal/storage/dbmodel"
     9  	"github.com/kyma-project/kyma-environment-broker/internal/storage/predicate"
    10  )
    11  
    12  type Instances interface {
    13  	FindAllJoinedWithOperations(prct ...predicate.Predicate) ([]internal.InstanceWithOperation, error)
    14  	FindAllInstancesForRuntimes(runtimeIdList []string) ([]internal.Instance, error)
    15  	FindAllInstancesForSubAccounts(subAccountslist []string) ([]internal.Instance, error)
    16  	GetByID(instanceID string) (*internal.Instance, error)
    17  	Insert(instance internal.Instance) error
    18  	Update(instance internal.Instance) (*internal.Instance, error)
    19  	Delete(instanceID string) error
    20  	GetInstanceStats() (internal.InstanceStats, error)
    21  	GetERSContextStats() (internal.ERSContextStats, error)
    22  	GetNumberOfInstancesForGlobalAccountID(globalAccountID string) (int, error)
    23  	List(dbmodel.InstanceFilter) ([]internal.Instance, int, int, error)
    24  
    25  	// todo: remove after instances parameters migration is done
    26  	InsertWithoutEncryption(instance internal.Instance) error
    27  	UpdateWithoutEncryption(instance internal.Instance) (*internal.Instance, error)
    28  	ListWithoutDecryption(dbmodel.InstanceFilter) ([]internal.Instance, int, int, error)
    29  }
    30  
    31  //go:generate mockery --name=Operations --output=automock --outpkg=mocks --case=underscore
    32  type Operations interface {
    33  	Provisioning
    34  	Deprovisioning
    35  	UpgradeKyma
    36  	UpgradeCluster
    37  	Updating
    38  
    39  	GetLastOperation(instanceID string) (*internal.Operation, error)
    40  	GetOperationByID(operationID string) (*internal.Operation, error)
    41  	GetNotFinishedOperationsByType(operationType internal.OperationType) ([]internal.Operation, error)
    42  	GetOperationStatsByPlan() (map[string]internal.OperationStats, error)
    43  	GetOperationsForIDs(operationIDList []string) ([]internal.Operation, error)
    44  	GetOperationStatsForOrchestration(orchestrationID string) (map[string]int, error)
    45  	ListOperations(filter dbmodel.OperationFilter) ([]internal.Operation, int, int, error)
    46  
    47  	InsertOperation(operation internal.Operation) error
    48  	GetOperationByInstanceID(instanceID string) (*internal.Operation, error)
    49  	UpdateOperation(operation internal.Operation) (*internal.Operation, error)
    50  	ListOperationsByInstanceID(instanceID string) ([]internal.Operation, error)
    51  	ListOperationsByOrchestrationID(orchestrationID string, filter dbmodel.OperationFilter) ([]internal.Operation, int, int, error)
    52  	ListOperationsInTimeRange(from, to time.Time) ([]internal.Operation, error)
    53  }
    54  
    55  type Provisioning interface {
    56  	InsertProvisioningOperation(operation internal.ProvisioningOperation) error
    57  	GetProvisioningOperationByID(operationID string) (*internal.ProvisioningOperation, error)
    58  	GetProvisioningOperationByInstanceID(instanceID string) (*internal.ProvisioningOperation, error)
    59  	UpdateProvisioningOperation(operation internal.ProvisioningOperation) (*internal.ProvisioningOperation, error)
    60  	ListProvisioningOperationsByInstanceID(instanceID string) ([]internal.ProvisioningOperation, error)
    61  }
    62  
    63  type Deprovisioning interface {
    64  	InsertDeprovisioningOperation(operation internal.DeprovisioningOperation) error
    65  	GetDeprovisioningOperationByID(operationID string) (*internal.DeprovisioningOperation, error)
    66  	GetDeprovisioningOperationByInstanceID(instanceID string) (*internal.DeprovisioningOperation, error)
    67  	UpdateDeprovisioningOperation(operation internal.DeprovisioningOperation) (*internal.DeprovisioningOperation, error)
    68  	ListDeprovisioningOperationsByInstanceID(instanceID string) ([]internal.DeprovisioningOperation, error)
    69  	ListDeprovisioningOperations() ([]internal.DeprovisioningOperation, error)
    70  }
    71  
    72  type Orchestrations interface {
    73  	Insert(orchestration internal.Orchestration) error
    74  	Update(orchestration internal.Orchestration) error
    75  	GetByID(orchestrationID string) (*internal.Orchestration, error)
    76  	List(filter dbmodel.OrchestrationFilter) ([]internal.Orchestration, int, int, error)
    77  }
    78  
    79  type RuntimeStates interface {
    80  	Insert(runtimeState internal.RuntimeState) error
    81  	GetByOperationID(operationID string) (internal.RuntimeState, error)
    82  	ListByRuntimeID(runtimeID string) ([]internal.RuntimeState, error)
    83  	GetLatestByRuntimeID(runtimeID string) (internal.RuntimeState, error)
    84  	GetLatestWithReconcilerInputByRuntimeID(runtimeID string) (internal.RuntimeState, error)
    85  	GetLatestWithKymaVersionByRuntimeID(runtimeID string) (internal.RuntimeState, error)
    86  	GetLatestWithOIDCConfigByRuntimeID(runtimeID string) (internal.RuntimeState, error)
    87  }
    88  
    89  type UpgradeKyma interface {
    90  	InsertUpgradeKymaOperation(operation internal.UpgradeKymaOperation) error
    91  	UpdateUpgradeKymaOperation(operation internal.UpgradeKymaOperation) (*internal.UpgradeKymaOperation, error)
    92  	GetUpgradeKymaOperationByID(operationID string) (*internal.UpgradeKymaOperation, error)
    93  	GetUpgradeKymaOperationByInstanceID(instanceID string) (*internal.UpgradeKymaOperation, error)
    94  	ListUpgradeKymaOperations() ([]internal.UpgradeKymaOperation, error)
    95  	ListUpgradeKymaOperationsByInstanceID(instanceID string) ([]internal.UpgradeKymaOperation, error)
    96  	ListUpgradeKymaOperationsByOrchestrationID(orchestrationID string, filter dbmodel.OperationFilter) ([]internal.UpgradeKymaOperation, int, int, error)
    97  }
    98  
    99  type UpgradeCluster interface {
   100  	InsertUpgradeClusterOperation(operation internal.UpgradeClusterOperation) error
   101  	UpdateUpgradeClusterOperation(operation internal.UpgradeClusterOperation) (*internal.UpgradeClusterOperation, error)
   102  	GetUpgradeClusterOperationByID(operationID string) (*internal.UpgradeClusterOperation, error)
   103  	ListUpgradeClusterOperationsByInstanceID(instanceID string) ([]internal.UpgradeClusterOperation, error)
   104  	ListUpgradeClusterOperationsByOrchestrationID(orchestrationID string, filter dbmodel.OperationFilter) ([]internal.UpgradeClusterOperation, int, int, error)
   105  }
   106  
   107  type Updating interface {
   108  	InsertUpdatingOperation(operation internal.UpdatingOperation) error
   109  	GetUpdatingOperationByID(operationID string) (*internal.UpdatingOperation, error)
   110  	ListUpdatingOperationsByInstanceID(instanceID string) ([]internal.UpdatingOperation, error)
   111  	UpdateUpdatingOperation(operation internal.UpdatingOperation) (*internal.UpdatingOperation, error)
   112  }
   113  
   114  type Events interface {
   115  	InsertEvent(level events.EventLevel, message, instanceID, operationID string)
   116  	ListEvents(filter events.EventFilter) ([]events.EventDTO, error)
   117  }