@@ -143,21 +143,29 @@ func GetEnrollment(location string) (*Enrollment, error) {
143143 return & response , nil
144144}
145145
146+ // ListEnrollments lists the names of each enrollment for the given contractID.
147+ //
148+ // API Docs: https://developer.akamai.com/api/core_features/certificate_provisioning_system/v2.html#getenrollments
149+ // Endpoint: GET /cps/v2/enrollments{contractId}
146150func ListEnrollments (params ListEnrollmentsQueryParams ) ([]Enrollment , error ) {
147- var enrollments []Enrollment
151+ // the returned JSON is a list in the enrollments parameter
152+ enrollmentsResponse := struct {
153+ Enrollments []Enrollment `json:"enrollments"`
154+ }{}
148155
149156 req , err := client .NewRequest (
150157 Config ,
151158 "GET" ,
152159 fmt .Sprintf (
153- "/cps/v2/enrollments?contractId={%s} " ,
160+ "/cps/v2/enrollments?contractId=%s " ,
154161 params .ContractID ,
155162 ),
156163 nil ,
157164 )
158165 if err != nil {
159166 return nil , err
160167 }
168+ req .Header .Set ("Accept" , "application/vnd.akamai.cps.enrollments.v7+json" )
161169
162170 res , err := client .Do (Config , req )
163171 if err != nil {
@@ -168,11 +176,11 @@ func ListEnrollments(params ListEnrollmentsQueryParams) ([]Enrollment, error) {
168176 return nil , client .NewAPIError (res )
169177 }
170178
171- if err = client .BodyJSON (res , enrollments ); err != nil {
179+ if err = client .BodyJSON (res , & enrollmentsResponse ); err != nil {
172180 return nil , err
173181 }
174182
175- return enrollments , nil
183+ return enrollmentsResponse . Enrollments , nil
176184}
177185
178186func (enrollment * Enrollment ) Exists (enrollments []Enrollment ) bool {
0 commit comments