@@ -2,6 +2,7 @@ package api
22
33import (
44 "encoding/base64"
5+ "errors"
56 "fmt"
67 "net/http"
78 "strings"
@@ -55,6 +56,8 @@ const (
5556 operationCallInstanceRelayHeartBeat = "CallInstanceRelayHeartBeat"
5657)
5758
59+ var ErrNotFound = errors .New ("resource not found" )
60+
5861func CallGetEncryptedWorkspaceKey (httpClient * resty.Client , request GetEncryptedWorkspaceKeyRequest ) (GetEncryptedWorkspaceKeyResponse , error ) {
5962 endpoint := fmt .Sprintf ("%v/v2/workspace/%v/encrypted-key" , config .INFISICAL_URL , request .WorkspaceId )
6063 var result GetEncryptedWorkspaceKeyResponse
@@ -573,6 +576,31 @@ func CallCreateDynamicSecretLeaseV1(httpClient *resty.Client, request CreateDyna
573576 return createDynamicSecretLeaseResponse , nil
574577}
575578
579+ func CallGetDynamicSecretLeaseV1 (httpClient * resty.Client , request GetDynamicSecretLeaseV1Request ) (GetDynamicSecretLeaseV1Response , error ) {
580+ var getDynamicSecretLeaseResponse GetDynamicSecretLeaseV1Response
581+ response , err := httpClient .
582+ R ().
583+ SetResult (& getDynamicSecretLeaseResponse ).
584+ SetHeader ("User-Agent" , USER_AGENT ).
585+ SetQueryParam ("environmentSlug" , request .Environment ).
586+ SetQueryParam ("projectSlug" , request .ProjectSlug ).
587+ SetQueryParam ("secretPath" , request .SecretPath ).
588+ Get (fmt .Sprintf ("%v/v1/dynamic-secrets/leases/%s" , config .INFISICAL_URL , request .LeaseID ))
589+
590+ if err != nil {
591+ return GetDynamicSecretLeaseV1Response {}, fmt .Errorf ("CallGetDynamicSecretLeaseV1: Unable to complete api request [err=%w]" , err )
592+ }
593+
594+ if response .IsError () {
595+ if response .StatusCode () == http .StatusNotFound {
596+ return GetDynamicSecretLeaseV1Response {}, ErrNotFound
597+ }
598+ return GetDynamicSecretLeaseV1Response {}, fmt .Errorf ("CallGetDynamicSecretLeaseV1: Unsuccessful response [status-code=%v] [response=%v]" , response .StatusCode (), response .String ())
599+ }
600+
601+ return getDynamicSecretLeaseResponse , nil
602+ }
603+
576604func CallCreateRawSecretsV3 (httpClient * resty.Client , request CreateRawSecretV3Request ) error {
577605 response , err := httpClient .
578606 R ().
0 commit comments