mirror of
https://github.com/certimate-go/certimate.git
synced 2026-06-13 21:01:32 +08:00
refactor: lightweight ucloud vendor packages
This commit is contained in:
parent
710966ab9c
commit
9625b8441a
@ -7,12 +7,12 @@ import (
|
||||
"log/slog"
|
||||
"strconv"
|
||||
|
||||
"github.com/ucloud/ucloud-sdk-go/services/ucdn"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/auth"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core"
|
||||
sslmgrsp "github.com/certimate-go/certimate/pkg/core/ssl-manager/providers/ucloud-ussl"
|
||||
usdkCdn "github.com/certimate-go/certimate/pkg/sdk3rd/ucloud/ucdn"
|
||||
)
|
||||
|
||||
type SSLDeployerProviderConfig struct {
|
||||
@ -29,7 +29,7 @@ type SSLDeployerProviderConfig struct {
|
||||
type SSLDeployerProvider struct {
|
||||
config *SSLDeployerProviderConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *ucdn.UCDNClient
|
||||
sdkClient *usdkCdn.UCDNClient
|
||||
sslManager core.SSLManager
|
||||
}
|
||||
|
||||
@ -123,13 +123,13 @@ func (d *SSLDeployerProvider) Deploy(ctx context.Context, certPEM string, privke
|
||||
return &core.SSLDeployResult{}, nil
|
||||
}
|
||||
|
||||
func createSDKClient(privateKey, publicKey string) (*ucdn.UCDNClient, error) {
|
||||
func createSDKClient(privateKey, publicKey string) (*usdkCdn.UCDNClient, error) {
|
||||
cfg := ucloud.NewConfig()
|
||||
|
||||
credential := auth.NewCredential()
|
||||
credential.PrivateKey = privateKey
|
||||
credential.PublicKey = publicKey
|
||||
|
||||
client := ucdn.NewClient(&cfg, &credential)
|
||||
client := usdkCdn.NewClient(&cfg, &credential)
|
||||
return client, nil
|
||||
}
|
||||
|
||||
32
pkg/sdk3rd/ucloud/ucdn/api_get_ucdn_domain_config.go
Normal file
32
pkg/sdk3rd/ucloud/ucdn/api_get_ucdn_domain_config.go
Normal file
@ -0,0 +1,32 @@
|
||||
package ucdn
|
||||
|
||||
import (
|
||||
ucloudcdn "github.com/ucloud/ucloud-sdk-go/services/ucdn"
|
||||
)
|
||||
|
||||
type GetUcdnDomainConfigRequest = ucloudcdn.GetUcdnDomainConfigRequest
|
||||
|
||||
type GetUcdnDomainConfigResponse = ucloudcdn.GetUcdnDomainConfigResponse
|
||||
|
||||
func (c *UCDNClient) NewGetUcdnDomainConfigRequest() *GetUcdnDomainConfigRequest {
|
||||
req := &GetUcdnDomainConfigRequest{}
|
||||
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
func (c *UCDNClient) GetUcdnDomainConfig(req *GetUcdnDomainConfigRequest) (*GetUcdnDomainConfigResponse, error) {
|
||||
var err error
|
||||
var res GetUcdnDomainConfigResponse
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("GetUcdnDomainConfig", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package ucdn
|
||||
|
||||
import (
|
||||
ucloudcdn "github.com/ucloud/ucloud-sdk-go/services/ucdn"
|
||||
)
|
||||
|
||||
type UpdateUcdnDomainHttpsConfigV2Request = ucloudcdn.UpdateUcdnDomainHttpsConfigV2Request
|
||||
|
||||
type UpdateUcdnDomainHttpsConfigV2Response = ucloudcdn.UpdateUcdnDomainHttpsConfigV2Response
|
||||
|
||||
func (c *UCDNClient) NewUpdateUcdnDomainHttpsConfigV2Request() *UpdateUcdnDomainHttpsConfigV2Request {
|
||||
req := &UpdateUcdnDomainHttpsConfigV2Request{}
|
||||
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
func (c *UCDNClient) UpdateUcdnDomainHttpsConfigV2(req *UpdateUcdnDomainHttpsConfigV2Request) (*UpdateUcdnDomainHttpsConfigV2Response, error) {
|
||||
var err error
|
||||
var res UpdateUcdnDomainHttpsConfigV2Response
|
||||
|
||||
reqCopier := *req
|
||||
|
||||
err = c.Client.InvokeAction("UpdateUcdnDomainHttpsConfigV2", &reqCopier, &res)
|
||||
if err != nil {
|
||||
return &res, err
|
||||
}
|
||||
|
||||
return &res, nil
|
||||
}
|
||||
18
pkg/sdk3rd/ucloud/ucdn/client.go
Normal file
18
pkg/sdk3rd/ucloud/ucdn/client.go
Normal file
@ -0,0 +1,18 @@
|
||||
package ucdn
|
||||
|
||||
import (
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud"
|
||||
"github.com/ucloud/ucloud-sdk-go/ucloud/auth"
|
||||
)
|
||||
|
||||
type UCDNClient struct {
|
||||
*ucloud.Client
|
||||
}
|
||||
|
||||
func NewClient(config *ucloud.Config, credential *auth.Credential) *UCDNClient {
|
||||
meta := ucloud.ClientMeta{Product: "UCDN"}
|
||||
client := ucloud.NewClientWithMeta(config, credential, meta)
|
||||
return &UCDNClient{
|
||||
client,
|
||||
}
|
||||
}
|
||||
7
pkg/sdk3rd/ucloud/ucdn/types.go
Normal file
7
pkg/sdk3rd/ucloud/ucdn/types.go
Normal file
@ -0,0 +1,7 @@
|
||||
package ucdn
|
||||
|
||||
import (
|
||||
ucloudcdn "github.com/ucloud/ucloud-sdk-go/services/ucdn"
|
||||
)
|
||||
|
||||
type DomainConfigInfo = ucloudcdn.DomainConfigInfo
|
||||
@ -23,7 +23,7 @@ func (c *UDNRClient) NewDeleteDomainDNSRequest() *DeleteDomainDNSRequest {
|
||||
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
req.SetRetryable(false)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ func (c *UDNRClient) NewQueryDomainDNSRequest() *QueryDomainDNSRequest {
|
||||
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
req.SetRetryable(false)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
|
||||
@ -23,7 +23,7 @@ func (c *UFileClient) NewAddUFileSSLCertRequest() *AddUFileSSLCertRequest {
|
||||
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
req.SetRetryable(false)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
|
||||
@ -24,7 +24,7 @@ func (c *USSLClient) NewDownloadCertificateRequest() *DownloadCertificateRequest
|
||||
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
req.SetRetryable(false)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ func (c *USSLClient) NewGetCertificateDetailInfoRequest() *GetCertificateDetailI
|
||||
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
req.SetRetryable(false)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ func (c *USSLClient) NewGetCertificateListRequest() *GetCertificateListRequest {
|
||||
|
||||
c.Client.SetupRequest(req)
|
||||
|
||||
req.SetRetryable(false)
|
||||
req.SetRetryable(true)
|
||||
return req
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user