-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
97 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package aiven | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
type OpenSearchAccess int64 | ||
|
||
const ( | ||
Read OpenSearchAccess = iota | ||
Write | ||
ReadWrite | ||
Admin | ||
) | ||
|
||
var OpenSearchAccesses = []string{"read", "write", "readwrite", "admin"} | ||
|
||
func OpenSearchAccessFromString(access string) (OpenSearchAccess, error) { | ||
switch strings.ToLower(access) { | ||
case OpenSearchAccesses[0]: | ||
return Read, nil | ||
case OpenSearchAccesses[1]: | ||
return Write, nil | ||
case OpenSearchAccesses[2]: | ||
return ReadWrite, nil | ||
case OpenSearchAccesses[3]: | ||
return Admin, nil | ||
default: | ||
return -1, fmt.Errorf("unknown access: %v", access) | ||
} | ||
} | ||
|
||
func (p OpenSearchAccess) String() string { | ||
return OpenSearchAccesses[p] | ||
} |