@@ -55,6 +55,10 @@ const (
5555 operationCallPAMSessionTermination = "CallPAMSessionTermination"
5656 operationCallOrgRelayHeartBeat = "CallOrgRelayHeartBeat"
5757 operationCallInstanceRelayHeartBeat = "CallInstanceRelayHeartBeat"
58+ operationCallIssueCertificate = "CallIssueCertificate"
59+ operationCallRetrieveCertificate = "CallRetrieveCertificate"
60+ operationCallRenewCertificate = "CallRenewCertificate"
61+ operationCallGetCertificateRequest = "CallGetCertificateRequest"
5862)
5963
6064var ErrNotFound = errors .New ("resource not found" )
@@ -291,6 +295,45 @@ func CallGetProjectById(httpClient *resty.Client, id string) (Project, error) {
291295 return projectResponse .Project , nil
292296}
293297
298+ func CallGetProjectBySlug (httpClient * resty.Client , slug string ) (Project , error ) {
299+ var projectResponse GetProjectBySlugResponse
300+ response , err := httpClient .
301+ R ().
302+ SetResult (& projectResponse ).
303+ SetHeader ("User-Agent" , USER_AGENT ).
304+ Get (fmt .Sprintf ("%v/v1/projects/slug/%s" , config .INFISICAL_URL , slug ))
305+
306+ if err != nil {
307+ return Project {}, NewGenericRequestError ("CallGetProjectBySlug" , err )
308+ }
309+
310+ if response .IsError () {
311+ return Project {}, NewAPIErrorWithResponse ("CallGetProjectBySlug" , response , nil )
312+ }
313+
314+ return Project (projectResponse ), nil
315+ }
316+
317+ func CallGetCertificateProfileBySlug (httpClient * resty.Client , projectId , slug string ) (CertificateProfile , error ) {
318+ var profileResponse GetCertificateProfileResponse
319+ response , err := httpClient .
320+ R ().
321+ SetResult (& profileResponse ).
322+ SetHeader ("User-Agent" , USER_AGENT ).
323+ SetQueryParam ("projectId" , projectId ).
324+ Get (fmt .Sprintf ("%v/v1/cert-manager/certificate-profiles/slug/%s" , config .INFISICAL_URL , slug ))
325+
326+ if err != nil {
327+ return CertificateProfile {}, NewGenericRequestError ("CallGetCertificateProfileBySlug" , err )
328+ }
329+
330+ if response .IsError () {
331+ return CertificateProfile {}, NewAPIErrorWithResponse ("CallGetCertificateProfileBySlug" , response , nil )
332+ }
333+
334+ return profileResponse .CertificateProfile , nil
335+ }
336+
294337func CallIsAuthenticated (httpClient * resty.Client ) bool {
295338 var workSpacesResponse GetWorkSpacesResponse
296339 response , err := httpClient .
@@ -956,3 +999,81 @@ func CallPAMSessionTermination(httpClient *resty.Client, sessionId string) error
956999
9571000 return nil
9581001}
1002+
1003+ func CallIssueCertificate (httpClient * resty.Client , request IssueCertificateRequest ) (* CertificateResponse , error ) {
1004+ var resBody CertificateResponse
1005+ response , err := httpClient .
1006+ R ().
1007+ SetResult (& resBody ).
1008+ SetHeader ("User-Agent" , USER_AGENT ).
1009+ SetBody (request ).
1010+ Post (fmt .Sprintf ("%v/v1/cert-manager/certificates" , config .INFISICAL_URL ))
1011+
1012+ if err != nil {
1013+ return nil , NewGenericRequestError (operationCallIssueCertificate , err )
1014+ }
1015+
1016+ if response .IsError () {
1017+ return nil , NewAPIErrorWithResponse (operationCallIssueCertificate , response , nil )
1018+ }
1019+
1020+ return & resBody , nil
1021+ }
1022+
1023+ func CallRetrieveCertificate (httpClient * resty.Client , certificateId string ) (* RetrieveCertificateResponse , error ) {
1024+ var resBody RetrieveCertificateResponse
1025+ response , err := httpClient .
1026+ R ().
1027+ SetResult (& resBody ).
1028+ SetHeader ("User-Agent" , USER_AGENT ).
1029+ Get (fmt .Sprintf ("%v/v1/cert-manager/certificates/%s" , config .INFISICAL_URL , certificateId ))
1030+
1031+ if err != nil {
1032+ return nil , NewGenericRequestError (operationCallRetrieveCertificate , err )
1033+ }
1034+
1035+ if response .IsError () {
1036+ return nil , NewAPIErrorWithResponse (operationCallRetrieveCertificate , response , nil )
1037+ }
1038+
1039+ return & resBody , nil
1040+ }
1041+
1042+ func CallRenewCertificate (httpClient * resty.Client , certificateId string , request RenewCertificateRequest ) (* RenewCertificateResponse , error ) {
1043+ var resBody RenewCertificateResponse
1044+ response , err := httpClient .
1045+ R ().
1046+ SetResult (& resBody ).
1047+ SetHeader ("User-Agent" , USER_AGENT ).
1048+ SetBody (request ).
1049+ Post (fmt .Sprintf ("%v/v1/cert-manager/certificates/%s/renew" , config .INFISICAL_URL , certificateId ))
1050+
1051+ if err != nil {
1052+ return nil , NewGenericRequestError (operationCallRenewCertificate , err )
1053+ }
1054+
1055+ if response .IsError () {
1056+ return nil , NewAPIErrorWithResponse (operationCallRenewCertificate , response , nil )
1057+ }
1058+
1059+ return & resBody , nil
1060+ }
1061+
1062+ func CallGetCertificateRequest (httpClient * resty.Client , certificateRequestId string ) (* GetCertificateRequestResponse , error ) {
1063+ var resBody GetCertificateRequestResponse
1064+ response , err := httpClient .
1065+ R ().
1066+ SetResult (& resBody ).
1067+ SetHeader ("User-Agent" , USER_AGENT ).
1068+ Get (fmt .Sprintf ("%v/v1/cert-manager/certificates/certificate-requests/%s" , config .INFISICAL_URL , certificateRequestId ))
1069+
1070+ if err != nil {
1071+ return nil , NewGenericRequestError (operationCallGetCertificateRequest , err )
1072+ }
1073+
1074+ if response .IsError () {
1075+ return nil , NewAPIErrorWithResponse (operationCallGetCertificateRequest , response , nil )
1076+ }
1077+
1078+ return & resBody , nil
1079+ }
0 commit comments