mirror of
https://github.com/woodchen-ink/certimate.git
synced 2025-07-19 01:41:55 +08:00
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package baishan
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
)
|
|
|
|
type GetDomainConfigRequest struct {
|
|
Domains *string `json:"domains,omitempty"`
|
|
Config *[]string `json:"config,omitempty"`
|
|
}
|
|
|
|
type GetDomainConfigResponse struct {
|
|
apiResponseBase
|
|
|
|
Data []*struct {
|
|
Domain string `json:"domain"`
|
|
Config *DomainConfig `json:"config"`
|
|
} `json:"data,omitempty"`
|
|
}
|
|
|
|
func (c *Client) GetDomainConfig(req *GetDomainConfigRequest) (*GetDomainConfigResponse, error) {
|
|
return c.GetDomainConfigWithContext(context.Background(), req)
|
|
}
|
|
|
|
func (c *Client) GetDomainConfigWithContext(ctx context.Context, req *GetDomainConfigRequest) (*GetDomainConfigResponse, error) {
|
|
httpreq, err := c.newRequest(http.MethodGet, "/v2/domain/config")
|
|
if err != nil {
|
|
return nil, err
|
|
} else {
|
|
if req.Domains != nil {
|
|
httpreq.SetQueryParam("domains", *req.Domains)
|
|
}
|
|
if req.Config != nil {
|
|
for _, config := range *req.Config {
|
|
httpreq.QueryParam.Add("config[]", config)
|
|
}
|
|
}
|
|
|
|
httpreq.SetContext(ctx)
|
|
}
|
|
|
|
result := &GetDomainConfigResponse{}
|
|
if _, err := c.doRequestWithResult(httpreq, result); err != nil {
|
|
return result, err
|
|
}
|
|
|
|
return result, nil
|
|
}
|