Skip to content

Commit

Permalink
feat(entry_certificate): added getdatamode func
Browse files Browse the repository at this point in the history
  • Loading branch information
dion-gionet authored and randy-but-a-ro[bot] committed Jun 5, 2024
1 parent fba3532 commit f03a362
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.0
0.8.0
7 changes: 7 additions & 0 deletions dvlstypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,10 @@ const (
VaultSecurityLevelStandard VaultSecurityLevel = 0
VaultSecurityLevelHigh VaultSecurityLevel = 1
)

type EntryCertificateDataMode int

const (
EntryCertificateDataModeURL EntryCertificateDataMode = 3
EntryCertificateDataModeFile EntryCertificateDataMode = 2
)
10 changes: 9 additions & 1 deletion entry_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,14 @@ func (c *EntryCertificateService) new(entry EntryCertificate, content []byte) (E

// Update updates an EntryCertificate based on entry. Will replace all other fields whether included or not.
func (c *EntryCertificateService) Update(entry EntryCertificate) (EntryCertificate, error) {
_, err := c.Get(entry.ID)
oldEntry, err := c.Get(entry.ID)
if err != nil {
return EntryCertificate{}, fmt.Errorf("error while fetching entry. error: %w", err)
}

entry.data.Mode = oldEntry.data.Mode
entry.data.FileSize = oldEntry.data.FileSize

reqUrl, err := url.JoinPath(c.client.baseUri, entryEndpoint, "save")
if err != nil {
return EntryCertificate{}, fmt.Errorf("failed to build entry url. error: %w", err)
Expand Down Expand Up @@ -311,3 +314,8 @@ func (c *EntryCertificateService) Delete(entryId string) error {

return nil
}

// GetDataMode returns the data mode of the EntryCertificate. Can be either EntryCertificateDataModeURL or EntryCertificateDataModeFile.
func (c EntryCertificate) GetDataMode() EntryCertificateDataMode {
return EntryCertificateDataMode(c.data.Mode)
}

0 comments on commit f03a362

Please sign in to comment.