Skip to content

Commit 4f1a10e

Browse files
authored
fix: naming consistency for Id (#24)
1 parent d842443 commit 4f1a10e

13 files changed

+130
-130
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.12.0
1+
0.12.1

entries.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Entries struct {
2121
}
2222

2323
type Entry struct {
24-
ID string `json:"id,omitempty"`
24+
Id string `json:"id,omitempty"`
2525
VaultId string `json:"vaultId,omitempty"`
2626
Name string `json:"name"`
2727
Path string `json:"path"`

entry_attachments.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99
)
1010

1111
type EntryAttachment struct {
12-
ID string `json:"id,omitempty"`
13-
IDString string `json:"idString"`
14-
EntryID string `json:"connectionID"`
15-
EntryIDString string `json:"connectionIDString"`
12+
Id string `json:"id,omitempty"`
13+
IdString string `json:"idString"`
14+
EntryId string `json:"connectionID"`
15+
EntryIdString string `json:"connectionIDString"`
1616
Description string `json:"description"`
1717
FileName string `json:"filename"`
1818
IsPrivate bool `json:"isPrivate"`
@@ -67,7 +67,7 @@ func (c *Client) newAttachmentRequest(attachment EntryAttachment) (string, error
6767
return "", fmt.Errorf("failed to unmarshal response body. error: %w", err)
6868
}
6969

70-
return attachment.ID, nil
70+
return attachment.Id, nil
7171
}
7272

7373
func (c *Client) uploadAttachment(fileBytes []byte, attachmentId string) error {

entry_certificate.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type EntryCertificateService service
1414

1515
// EntryCertificate represents a certificate entry.
1616
type EntryCertificate struct {
17-
ID string
17+
Id string
1818
VaultId string
1919
Name string
2020
Description string
@@ -31,7 +31,7 @@ type EntryCertificate struct {
3131
}
3232

3333
type rawEntryCertificate struct {
34-
ID string `json:"id,omitempty"`
34+
Id string `json:"id,omitempty"`
3535
VaultId string `json:"repositoryId"`
3636
Name string `json:"name"`
3737
Description string `json:"description"`
@@ -61,7 +61,7 @@ type entryCertificateData struct {
6161
// MarshalJSON implements the json.Marshaler interface.
6262
func (e EntryCertificate) MarshalJSON() ([]byte, error) {
6363
raw := rawEntryCertificate{
64-
ID: e.ID,
64+
Id: e.Id,
6565
VaultId: e.VaultId,
6666
Name: e.Name,
6767
Description: e.Description,
@@ -121,7 +121,7 @@ func (e *EntryCertificate) UnmarshalJSON(d []byte) error {
121121
}
122122
}
123123

124-
e.ID = raw.Data.ID
124+
e.Id = raw.Data.Id
125125
e.VaultId = raw.Data.VaultId
126126
e.Name = raw.Data.Name
127127
e.Description = raw.Data.Description
@@ -179,7 +179,7 @@ func (c *EntryCertificateService) GetFileContent(entryId string) ([]byte, error)
179179
// GetPassword returns the password of the entry specified by entry.
180180
func (c *EntryCertificateService) GetPassword(entry EntryCertificate) (EntryCertificate, error) {
181181
var entryPassword EntryCertificate
182-
reqUrl, err := url.JoinPath(c.client.baseUri, entryEndpoint, entry.ID, "/sensitive-data")
182+
reqUrl, err := url.JoinPath(c.client.baseUri, entryEndpoint, entry.Id, "/sensitive-data")
183183
if err != nil {
184184
return EntryCertificate{}, fmt.Errorf("failed to build entry url. error: %w", err)
185185
}
@@ -243,7 +243,7 @@ func (c *EntryCertificateService) new(entry EntryCertificate, content []byte) (E
243243

244244
if content != nil {
245245
attachment := EntryAttachment{
246-
EntryID: entry.ID,
246+
EntryId: entry.Id,
247247
FileName: entry.CertificateIdentifier,
248248
Size: len(content),
249249
IsPrivate: true,
@@ -265,7 +265,7 @@ func (c *EntryCertificateService) new(entry EntryCertificate, content []byte) (E
265265

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

entry_certificate_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var (
2525
func Test_EntryCertificate(t *testing.T) {
2626
testCertificateFilePath = os.Getenv("TEST_CERTIFICATE_FILE_PATH")
2727
testCertificateEntryId = os.Getenv("TEST_CERTIFICATE_ENTRY_ID")
28-
testCertificateEntry.ID = testCertificateEntryId
28+
testCertificateEntry.Id = testCertificateEntryId
2929
testCertificateEntry.VaultId = testVaultId
3030
location, err := time.LoadLocation("America/Montreal")
3131
if err != nil {
@@ -44,7 +44,7 @@ func Test_EntryCertificate(t *testing.T) {
4444
func test_GetCertificateEntry(t *testing.T) {
4545
testGetEntry := testCertificateEntry
4646

47-
entry, err := testClient.Entries.Certificate.Get(testGetEntry.ID)
47+
entry, err := testClient.Entries.Certificate.Get(testGetEntry.Id)
4848
if err != nil {
4949
t.Fatal(err)
5050
}
@@ -69,7 +69,7 @@ func test_GetCertificateEntry(t *testing.T) {
6969

7070
func test_NewCertificateEntryFile(t *testing.T) {
7171
entry := testCertificateEntry
72-
entry.ID = ""
72+
entry.Id = ""
7373
file, err := os.Open(testCertificateFilePath)
7474
if err != nil {
7575
t.Fatal(err)
@@ -93,7 +93,7 @@ func test_NewCertificateEntryFile(t *testing.T) {
9393
t.Fatal(err)
9494
}
9595

96-
returnedFileBytes, err := testClient.Entries.Certificate.GetFileContent(newEntry.ID)
96+
returnedFileBytes, err := testClient.Entries.Certificate.GetFileContent(newEntry.Id)
9797
if err != nil {
9898
t.Fatal(err)
9999
}
@@ -102,7 +102,7 @@ func test_NewCertificateEntryFile(t *testing.T) {
102102
t.Fatalf("fetched file content did not match test file content. Expected %#v, got %#v", fileBytes, returnedFileBytes)
103103
}
104104

105-
entry.ID = newEntry.ID
105+
entry.Id = newEntry.Id
106106
entry.data = newEntry.data
107107
newEntry, err = testClient.Entries.Certificate.GetPassword(newEntry)
108108
if err != nil {
@@ -124,15 +124,15 @@ func test_NewCertificateEntryFile(t *testing.T) {
124124

125125
func test_NewCertificateEntryURL(t *testing.T) {
126126
entry := testCertificateEntry
127-
entry.ID = ""
127+
entry.Id = ""
128128
entry.CertificateIdentifier = "https://devolutions.net/"
129129

130130
newEntry, err := testClient.Entries.Certificate.NewURL(entry)
131131
if err != nil {
132132
t.Fatal(err)
133133
}
134134

135-
entry.ID = newEntry.ID
135+
entry.Id = newEntry.Id
136136
entry.data = newEntry.data
137137
newEntry, err = testClient.Entries.Certificate.GetPassword(newEntry)
138138
if err != nil {
@@ -177,12 +177,12 @@ func test_UpdateCertificateEntry(t *testing.T) {
177177
}
178178

179179
func test_DeleteCertificateEntry(t *testing.T) {
180-
err := testClient.Entries.Certificate.Delete(testNewCertificateEntryURL.ID)
180+
err := testClient.Entries.Certificate.Delete(testNewCertificateEntryURL.Id)
181181
if err != nil {
182182
t.Fatal(err)
183183
}
184184

185-
err = testClient.Entries.Certificate.Delete(testNewCertificateEntryFile.ID)
185+
err = testClient.Entries.Certificate.Delete(testNewCertificateEntryFile.Id)
186186
if err != nil {
187187
t.Fatal(err)
188188
}

entry_credential.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ type EntryCredentialAccessCodeData struct {
2626
}
2727

2828
type EntryCredentialApiKeyData struct {
29-
ApiID string `json:"apiId,omitempty"`
29+
ApiId string `json:"apiId,omitempty"`
3030
ApiKey string `json:"apiKey,omitempty"`
31-
TenantID string `json:"tenantId,omitempty"`
31+
TenantId string `json:"tenantId,omitempty"`
3232
}
3333

3434
type EntryCredentialAzureServicePrincipalData struct {
35-
ClientID string `json:"clientId,omitempty"`
35+
ClientId string `json:"clientId,omitempty"`
3636
ClientSecret string `json:"clientSecret,omitempty"`
37-
TenantID string `json:"tenantId,omitempty"`
37+
TenantId string `json:"tenantId,omitempty"`
3838
}
3939

4040
type EntryCredentialConnectionStringData struct {
@@ -145,13 +145,13 @@ func (c *EntryCredentialService) validateEntry(entry *Entry) error {
145145

146146
// Get returns a single EntryCredential
147147
func (c *EntryCredentialService) Get(entry Entry) (Entry, error) {
148-
return c.GetById(entry.VaultId, entry.ID)
148+
return c.GetById(entry.VaultId, entry.Id)
149149
}
150150

151-
// Get returns a single EntryCredential based on vault ID and entry ID.
151+
// Get returns a single EntryCredential based on vault Id and entry Id.
152152
func (c *EntryCredentialService) GetById(vaultId string, entryId string) (Entry, error) {
153153
if vaultId == "" || entryId == "" {
154-
return Entry{}, fmt.Errorf("both entry ID and vault ID are required")
154+
return Entry{}, fmt.Errorf("both entry Id and vault Id are required")
155155
}
156156

157157
var entry Entry
@@ -234,8 +234,8 @@ func (c *EntryCredentialService) Update(entry Entry) (Entry, error) {
234234
return Entry{}, err
235235
}
236236

237-
if entry.ID == "" {
238-
return Entry{}, fmt.Errorf("entry ID is required for updates")
237+
if entry.Id == "" {
238+
return Entry{}, fmt.Errorf("entry Id is required for updates")
239239
}
240240

241241
updateEntryRequest := struct {
@@ -252,7 +252,7 @@ func (c *EntryCredentialService) Update(entry Entry) (Entry, error) {
252252
Tags: entry.Tags,
253253
}
254254

255-
entryUri := entryPublicEndpointReplacer(entry.VaultId, entry.ID)
255+
entryUri := entryPublicEndpointReplacer(entry.VaultId, entry.Id)
256256
reqUrl, err := url.JoinPath(c.client.baseUri, entryUri)
257257
if err != nil {
258258
return Entry{}, fmt.Errorf("failed to build entry url. error: %w", err)
@@ -268,7 +268,7 @@ func (c *EntryCredentialService) Update(entry Entry) (Entry, error) {
268268
return Entry{}, fmt.Errorf("error while updating entry. error: %w", err)
269269
}
270270

271-
entry, err = c.GetById(entry.VaultId, entry.ID)
271+
entry, err = c.GetById(entry.VaultId, entry.Id)
272272
if err != nil {
273273
return Entry{}, fmt.Errorf("update succeeded but failed to fetch updated entry: %w", err)
274274
}
@@ -278,13 +278,13 @@ func (c *EntryCredentialService) Update(entry Entry) (Entry, error) {
278278

279279
// Delete deletes an entry
280280
func (c *EntryCredentialService) Delete(e Entry) error {
281-
return c.DeleteByID(e.VaultId, e.ID)
281+
return c.DeleteById(e.VaultId, e.Id)
282282
}
283283

284-
// Delete deletes an entry based on vault ID and entry ID
285-
func (c *EntryCredentialService) DeleteByID(vaultId string, entryId string) error {
284+
// Delete deletes an entry based on vault Id and entry Id
285+
func (c *EntryCredentialService) DeleteById(vaultId string, entryId string) error {
286286
if vaultId == "" || entryId == "" {
287-
return fmt.Errorf("both entry ID and vault ID are required")
287+
return fmt.Errorf("both entry Id and vault Id are required")
288288
}
289289

290290
entryUri := entryPublicEndpointReplacer(vaultId, entryId)

0 commit comments

Comments
 (0)