Skip to content

Commit 0783686

Browse files
committed
Implement EditSSLOffloadProfile operation.
DimensionDataResearch/terraform-provider-ddcloud#104
1 parent 3faeebe commit 0783686

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

compute/ssl_offload_profiles.go

+49-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,19 @@ type SSLOffloadProfiles struct {
6464
PagedResult
6565
}
6666

67-
// Request body when createing an SSL-offload profile.
67+
// Request body when creating an SSL-offload profile.
6868
type createSSLOffloadProfile struct {
69+
Name string `json:"name"`
70+
Description string `json:"description"`
71+
Ciphers *string `json:"ciphers"`
72+
SSLDomainCertificateID string `json:"sslDomainCertificateId"`
73+
SSLCertificateChainID string `json:"sslCertificateChainId,omitempty"`
74+
NetworkDomainID string `json:"networkDomainId"`
75+
}
76+
77+
// Request body when editing an SSL-offload profile.
78+
type editSSLOffloadProfile struct {
79+
ID string `json:"id"`
6980
Name string `json:"name"`
7081
Description string `json:"description"`
7182
Ciphers string `json:"ciphers"`
@@ -169,7 +180,7 @@ func (client *Client) GetSSLOffloadProfile(id string) (pool *SSLOffloadProfile,
169180
}
170181

171182
// CreateSSLOffloadProfile creates an SSL-offload profile in a network domain.
172-
func (client *Client) CreateSSLOffloadProfile(networkDomainID string, name string, description string, ciphers string, sslDomainCertificateID string, sslCertificateChainID string) (offloadProfileID string, err error) {
183+
func (client *Client) CreateSSLOffloadProfile(networkDomainID string, name string, description string, ciphers *string, sslDomainCertificateID string, sslCertificateChainID string) (offloadProfileID string, err error) {
173184
organizationID, err := client.getOrganizationID()
174185
if err != nil {
175186
return "", err
@@ -209,6 +220,42 @@ func (client *Client) CreateSSLOffloadProfile(networkDomainID string, name strin
209220
return *sslOffloadProfileIDMessage, nil
210221
}
211222

223+
// EditSSLOffloadProfile updates an existing SSL-offload profile.
224+
func (client *Client) EditSSLOffloadProfile(sslOffloadProfile SSLOffloadProfile) error {
225+
organizationID, err := client.getOrganizationID()
226+
if err != nil {
227+
return err
228+
}
229+
230+
requestURI := fmt.Sprintf("%s/networkDomainVip/editSslOffloadProfile",
231+
url.QueryEscape(organizationID),
232+
)
233+
request, err := client.newRequestV26(requestURI, http.MethodPost, &editSSLOffloadProfile{
234+
ID: sslOffloadProfile.ID,
235+
Name: sslOffloadProfile.Name,
236+
Description: sslOffloadProfile.Description,
237+
Ciphers: sslOffloadProfile.Ciphers,
238+
SSLDomainCertificateID: sslOffloadProfile.SSLDomainCertificate.ID,
239+
SSLCertificateChainID: sslOffloadProfile.SSLCertificateChain.ID,
240+
NetworkDomainID: sslOffloadProfile.NetworkDomainID,
241+
})
242+
responseBody, statusCode, err := client.executeRequest(request)
243+
if err != nil {
244+
return err
245+
}
246+
247+
apiResponse, err := readAPIResponseAsJSON(responseBody, statusCode)
248+
if err != nil {
249+
return err
250+
}
251+
252+
if apiResponse.ResponseCode != ResponseCodeOK {
253+
return apiResponse.ToError("Request to edit SSL-offload profile '%s' ('%s') failed with status code %d (%s): %s", sslOffloadProfile.Name, sslOffloadProfile.ID, statusCode, apiResponse.ResponseCode, apiResponse.Message)
254+
}
255+
256+
return nil
257+
}
258+
212259
// DeleteSSLOffloadProfile deletes an existing SSL-offload profile.
213260
//
214261
// Returns an error if the operation was not successful.

0 commit comments

Comments
 (0)