Files
threshold/internal/server/worker_storage_bucket_credential_state.go
T
shadowdaoandClaude Sonnet 5.5 962d708fdd Rename Go module paths to repo.anhonesthost.net/CyberCoveLLC/threshold
Rename root, api and sdk module paths (imports, go.mod, go_package,
ldflags, build scripts, buf configs) and regenerate protobuf/gateway
code with the project's pinned toolchain. Wire identifiers unchanged.
api gets a local replace for sdk; root/api/sdk require v0.1.0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 10:33:41 -07:00

77 lines
2.3 KiB
Go

// Copyright IBM Corp. 2020, 2026
// SPDX-License-Identifier: BUSL-1.1
package server
import (
"fmt"
plgpb "repo.anhonesthost.net/CyberCoveLLC/threshold/sdk/pbs/plugin"
)
type RemoteStorageState string
const (
RemoteStorageStateAvailable RemoteStorageState = "available"
RemoteStorageStateError RemoteStorageState = "error"
RemoteStorageStateUnknown RemoteStorageState = "unknown"
)
func (t RemoteStorageState) String() string {
switch t {
case RemoteStorageStateAvailable, RemoteStorageStateError:
return string(t)
}
return string(RemoteStorageStateUnknown)
}
type StorageBucketCredentialPermissionType string
func (s StorageBucketCredentialPermissionType) String() string {
return string(s)
}
type StorageBucketCredentialPermissionState string
func (s StorageBucketCredentialPermissionState) String() string {
return string(s)
}
// ParseStateType converts the string value of a storage bucket credential
// state value and converts it into a integer type.
func ParseStateType(s string) (plgpb.StateType, error) {
switch s {
case PermissionStateOk.String():
return plgpb.StateType_STATE_TYPE_OK, nil
case PermissionStateError.String():
return plgpb.StateType_STATE_TYPE_ERROR, nil
case PermissionStateUnknown.String():
return plgpb.StateType_STATE_TYPE_UNKNOWN, nil
default:
return plgpb.StateType_STATE_TYPE_UNSPECIFIED, fmt.Errorf("undefined state value")
}
}
// ParsePermissionState converts the state type value into a string value.
func ParsePermissionState(s plgpb.StateType) (string, error) {
switch s {
case plgpb.StateType_STATE_TYPE_OK:
return PermissionStateOk.String(), nil
case plgpb.StateType_STATE_TYPE_ERROR:
return PermissionStateError.String(), nil
case plgpb.StateType_STATE_TYPE_UNKNOWN:
return PermissionStateUnknown.String(), nil
default:
return "", fmt.Errorf("undefined state type")
}
}
const (
PermissionTypeWrite StorageBucketCredentialPermissionType = "write"
PermissionTypeRead StorageBucketCredentialPermissionType = "read"
PermissionTypeDelete StorageBucketCredentialPermissionType = "delete"
PermissionStateOk StorageBucketCredentialPermissionState = "ok"
PermissionStateError StorageBucketCredentialPermissionState = "error"
PermissionStateUnknown StorageBucketCredentialPermissionState = "unknown"
)