Skip to content

v6: ssl.CertificatePackListResponse and ssl.CertificatePackGetResponse are incomplete #4202

@Packetslave

Description

@Packetslave

CertificatePackListResponse is returned by CertificatePackService.List. Currently it is defined as type any (aka interface{}) and does not have methods attached to decode it into a proper data structure like the other *Response types do.

The same is true for CertificatePackGetResponse

This leads to "fun" code like this:

	for iter.Next() {
		pack := iter.Current().(map[string]any)
		certs := pack["certificates"].([]any)

		for _, cert := range certs {
			certMap := cert.(map[string]any)

			hosts := certMap["hosts"].([]any)
			hostsStrings := make([]string, len(hosts))
			for i, host := range hosts {
				hostsStrings[i] = host.(string)
			}
			certificates = append(certificates, Certificate{
				ID:        certMap["id"].(string),
				Hosts:     hostsStrings,
				Status:    certMap["status"].(string),
				ExpiresOn: certMap["expires_on"].(string),
			})
		}
	}

CertificatePackListResponse and CertificatePackGetResponse should have similar methods to CertificatePackEditResponse to decode them into proper structs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions