chore: move '/internal/pkg' to '/pkg'
This commit is contained in:
42
pkg/sdk3rd/cdnfly/api_update_site.go
Normal file
42
pkg/sdk3rd/cdnfly/api_update_site.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package cdnfly
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
type UpdateSiteRequest struct {
|
||||
HttpsListen *string `json:"https_listen,omitempty"`
|
||||
Enable *bool `json:"enable,omitempty"`
|
||||
}
|
||||
|
||||
type UpdateSiteResponse struct {
|
||||
apiResponseBase
|
||||
}
|
||||
|
||||
func (c *Client) UpdateSite(siteId string, req *UpdateSiteRequest) (*UpdateSiteResponse, error) {
|
||||
return c.UpdateSiteWithContext(context.Background(), siteId, req)
|
||||
}
|
||||
|
||||
func (c *Client) UpdateSiteWithContext(ctx context.Context, siteId string, req *UpdateSiteRequest) (*UpdateSiteResponse, error) {
|
||||
if siteId == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset siteId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodPut, fmt.Sprintf("/sites/%s", url.PathEscape(siteId)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
httpreq.SetBody(req)
|
||||
httpreq.SetContext(ctx)
|
||||
}
|
||||
|
||||
result := &UpdateSiteResponse{}
|
||||
if _, err := c.doRequestWithResult(httpreq, result); err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user