Refactor code and cleanup with stub completion
[aaf/sms.git] / sms-service / src / sms / backend / backend.go
1 /*
2  * Copyright 2018 Intel Corporation, Inc
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package backend
18
19 // SecretDomain is where Secrets are stored.
20 // A single domain can have any number of secrets
21 type SecretDomain struct {
22         UUID string `json:"uuid"`
23         Name string `json:"name"`
24 }
25
26 // SecretKeyValue is building block for a Secret
27 type SecretKeyValue struct {
28         Key   string `json:"name"`
29         Value string `json:"value"`
30 }
31
32 // Secret is the struct that defines the structure of a secret
33 // A single Secret can have any number of SecretKeyValue pairs
34 type Secret struct {
35         Name   string           `json:"name"`
36         Values []SecretKeyValue `json:"values"`
37 }
38
39 // SecretBackend interface that will be implemented for various secret backends
40 type SecretBackend interface {
41         Init() error
42
43         GetStatus() (bool, error)
44         GetSecretDomain(name string) (SecretDomain, error)
45         GetSecret(dom string, sec string) (Secret, error)
46
47         CreateSecretDomain(name string) (SecretDomain, error)
48         CreateSecret(dom string, sec Secret) (Secret, error)
49
50         DeleteSecretDomain(name string) error
51         DeleteSecret(dom string, name string) error
52 }
53
54 // InitSecretBackend returns an interface implementation
55 func InitSecretBackend() (SecretBackend, error) {
56         backendImpl := &Vault{}
57         err := backendImpl.Init()
58         if err != nil {
59                 return nil, err
60         }
61
62         return backendImpl, nil
63 }
64
65 // LoginBackend Interface that will be implemented for various login backends
66 type LoginBackend interface {
67 }