chore: move '/internal/pkg' to '/pkg'
This commit is contained in:
43
pkg/sdk3rd/cdnfly/api_get_site.go
Normal file
43
pkg/sdk3rd/cdnfly/api_get_site.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package cdnfly
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
type GetSiteResponse struct {
|
||||
apiResponseBase
|
||||
|
||||
Data *struct {
|
||||
Id int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Domain string `json:"domain"`
|
||||
HttpsListen string `json:"https_listen"`
|
||||
} `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Client) GetSite(siteId string) (*GetSiteResponse, error) {
|
||||
return c.GetSiteWithContext(context.Background(), siteId)
|
||||
}
|
||||
|
||||
func (c *Client) GetSiteWithContext(ctx context.Context, siteId string) (*GetSiteResponse, error) {
|
||||
if siteId == "" {
|
||||
return nil, fmt.Errorf("sdkerr: unset siteId")
|
||||
}
|
||||
|
||||
httpreq, err := c.newRequest(http.MethodGet, fmt.Sprintf("/sites/%s", url.PathEscape(siteId)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
httpreq.SetContext(ctx)
|
||||
}
|
||||
|
||||
result := &GetSiteResponse{}
|
||||
if _, err := c.doRequestWithResult(httpreq, result); err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
Reference in New Issue
Block a user