mirror of
https://github.com/usual2970/certimate.git
synced 2025-06-16 09:29:52 +00:00
42 lines
900 B
Go
42 lines
900 B
Go
package cdn
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
)
|
|
|
|
type CreateCertRequest struct {
|
|
Name *string `json:"name,omitempty"`
|
|
Certs *string `json:"certs,omitempty"`
|
|
Key *string `json:"key,omitempty"`
|
|
}
|
|
|
|
type CreateCertResponse struct {
|
|
baseResult
|
|
|
|
ReturnObj *struct {
|
|
Id int32 `json:"id"`
|
|
} `json:"returnObj,omitempty"`
|
|
}
|
|
|
|
func (c *Client) CreateCert(req *CreateCertRequest) (*CreateCertResponse, error) {
|
|
return c.CreateCertWithContext(context.Background(), req)
|
|
}
|
|
|
|
func (c *Client) CreateCertWithContext(ctx context.Context, req *CreateCertRequest) (*CreateCertResponse, error) {
|
|
httpreq, err := c.newRequest(http.MethodPost, "/v1/cert/creat-cert")
|
|
if err != nil {
|
|
return nil, err
|
|
} else {
|
|
httpreq.SetBody(req)
|
|
httpreq.SetContext(ctx)
|
|
}
|
|
|
|
result := &CreateCertResponse{}
|
|
if _, err := c.doRequestWithResult(httpreq, result); err != nil {
|
|
return result, err
|
|
}
|
|
|
|
return result, nil
|
|
}
|