mirror of
https://github.com/certimate-go/certimate.git
synced 2026-09-24 23:10:13 +08:00
refactor: lightweight huaweicloud vendor packages
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core"
|
||||
"github.com/certimate-go/certimate/pkg/core/ssl-deployer/providers/huaweicloud-cdn/internal"
|
||||
sslmgrsp "github.com/certimate-go/certimate/pkg/core/ssl-manager/providers/huaweicloud-scm"
|
||||
)
|
||||
|
||||
@@ -32,7 +33,7 @@ type SSLDeployerProviderConfig struct {
|
||||
type SSLDeployerProvider struct {
|
||||
config *SSLDeployerProviderConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *hccdn.CdnClient
|
||||
sdkClient *internal.CdnClient
|
||||
sslManager core.SSLManager
|
||||
}
|
||||
|
||||
@@ -129,7 +130,7 @@ func (d *SSLDeployerProvider) Deploy(ctx context.Context, certPEM string, privke
|
||||
return &core.SSLDeployResult{}, nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*hccdn.CdnClient, error) {
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.CdnClient, error) {
|
||||
if region == "" {
|
||||
region = "cn-north-1" // CDN 服务默认区域:华北一北京
|
||||
}
|
||||
@@ -155,7 +156,7 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*hccdn.CdnCli
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := hccdn.NewCdnClient(hcClient)
|
||||
client := internal.NewCdnClient(hcClient)
|
||||
return client, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
httpclient "github.com/huaweicloud/huaweicloud-sdk-go-v3/core"
|
||||
hwcdn "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdn/v2"
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/cdn/v2/model"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/huaweicloud/huaweicloud-sdk-go-v3/blob/master/services/cdn/v2/cdn_client.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type CdnClient struct {
|
||||
HcClient *httpclient.HcHttpClient
|
||||
}
|
||||
|
||||
func NewCdnClient(hcClient *httpclient.HcHttpClient) *CdnClient {
|
||||
return &CdnClient{HcClient: hcClient}
|
||||
}
|
||||
|
||||
func (c *CdnClient) ShowDomainFullConfig(request *model.ShowDomainFullConfigRequest) (*model.ShowDomainFullConfigResponse, error) {
|
||||
requestDef := hwcdn.GenReqDefForShowDomainFullConfig()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ShowDomainFullConfigResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *CdnClient) UpdateDomainMultiCertificates(request *model.UpdateDomainMultiCertificatesRequest) (*model.UpdateDomainMultiCertificatesResponse, error) {
|
||||
requestDef := hwcdn.GenReqDefForUpdateDomainMultiCertificates()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.UpdateDomainMultiCertificatesResponse), nil
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core"
|
||||
"github.com/certimate-go/certimate/pkg/core/ssl-deployer/providers/huaweicloud-elb/internal"
|
||||
sslmgrsp "github.com/certimate-go/certimate/pkg/core/ssl-manager/providers/huaweicloud-elb"
|
||||
)
|
||||
|
||||
@@ -46,7 +47,7 @@ type SSLDeployerProviderConfig struct {
|
||||
type SSLDeployerProvider struct {
|
||||
config *SSLDeployerProviderConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *hcelb.ElbClient
|
||||
sdkClient *internal.ElbClient
|
||||
sslManager core.SSLManager
|
||||
}
|
||||
|
||||
@@ -329,7 +330,7 @@ func (d *SSLDeployerProvider) modifyListenerCertificate(ctx context.Context, clo
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*hcelb.ElbClient, error) {
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.ElbClient, error) {
|
||||
projectId, err := getSdkProjectId(accessKeyId, secretAccessKey, region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -357,7 +358,7 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*hcelb.ElbCli
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := hcelb.NewElbClient(hcClient)
|
||||
client := internal.NewElbClient(hcClient)
|
||||
return client, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
httpclient "github.com/huaweicloud/huaweicloud-sdk-go-v3/core"
|
||||
hwelb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3"
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/huaweicloud/huaweicloud-sdk-go-v3/blob/master/services/elb/v3/elb_client.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type ElbClient struct {
|
||||
HcClient *httpclient.HcHttpClient
|
||||
}
|
||||
|
||||
func NewElbClient(hcClient *httpclient.HcHttpClient) *ElbClient {
|
||||
return &ElbClient{HcClient: hcClient}
|
||||
}
|
||||
|
||||
func (c *ElbClient) ListCertificates(request *model.ListCertificatesRequest) (*model.ListCertificatesResponse, error) {
|
||||
requestDef := hwelb.GenReqDefForListCertificates()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListCertificatesResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ElbClient) ListListeners(request *model.ListListenersRequest) (*model.ListListenersResponse, error) {
|
||||
requestDef := hwelb.GenReqDefForListListeners()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListListenersResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ElbClient) ShowCertificate(request *model.ShowCertificateRequest) (*model.ShowCertificateResponse, error) {
|
||||
requestDef := hwelb.GenReqDefForShowCertificate()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ShowCertificateResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ElbClient) ShowListener(request *model.ShowListenerRequest) (*model.ShowListenerResponse, error) {
|
||||
requestDef := hwelb.GenReqDefForShowListener()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ShowListenerResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ElbClient) ShowLoadBalancer(request *model.ShowLoadBalancerRequest) (*model.ShowLoadBalancerResponse, error) {
|
||||
requestDef := hwelb.GenReqDefForShowLoadBalancer()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ShowLoadBalancerResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ElbClient) UpdateCertificate(request *model.UpdateCertificateRequest) (*model.UpdateCertificateResponse, error) {
|
||||
requestDef := hwelb.GenReqDefForUpdateCertificate()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.UpdateCertificateResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ElbClient) UpdateListener(request *model.UpdateListenerRequest) (*model.UpdateListenerResponse, error) {
|
||||
requestDef := hwelb.GenReqDefForUpdateListener()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.UpdateListenerResponse), nil
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core"
|
||||
"github.com/certimate-go/certimate/pkg/core/ssl-deployer/providers/huaweicloud-waf/internal"
|
||||
sslmgrsp "github.com/certimate-go/certimate/pkg/core/ssl-manager/providers/huaweicloud-waf"
|
||||
)
|
||||
|
||||
@@ -43,7 +44,7 @@ type SSLDeployerProviderConfig struct {
|
||||
type SSLDeployerProvider struct {
|
||||
config *SSLDeployerProviderConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *hcwaf.WafClient
|
||||
sdkClient *internal.WafClient
|
||||
sslManager core.SSLManager
|
||||
}
|
||||
|
||||
@@ -307,7 +308,7 @@ func (d *SSLDeployerProvider) deployToPremiumHost(ctx context.Context, certPEM s
|
||||
return nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*hcwaf.WafClient, error) {
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.WafClient, error) {
|
||||
projectId, err := getSdkProjectId(accessKeyId, secretAccessKey, region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -335,7 +336,7 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*hcwaf.WafCli
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := hcwaf.NewWafClient(hcClient)
|
||||
client := internal.NewWafClient(hcClient)
|
||||
return client, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
httpclient "github.com/huaweicloud/huaweicloud-sdk-go-v3/core"
|
||||
hwwaf "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1"
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1/model"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/huaweicloud/huaweicloud-sdk-go-v3/blob/master/services/waf/v1/waf_client.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type WafClient struct {
|
||||
HcClient *httpclient.HcHttpClient
|
||||
}
|
||||
|
||||
func NewWafClient(hcClient *httpclient.HcHttpClient) *WafClient {
|
||||
return &WafClient{HcClient: hcClient}
|
||||
}
|
||||
|
||||
func (c *WafClient) ListHost(request *model.ListHostRequest) (*model.ListHostResponse, error) {
|
||||
requestDef := hwwaf.GenReqDefForListHost()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListHostResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *WafClient) ListPremiumHost(request *model.ListPremiumHostRequest) (*model.ListPremiumHostResponse, error) {
|
||||
requestDef := hwwaf.GenReqDefForListPremiumHost()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListPremiumHostResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *WafClient) ShowCertificate(request *model.ShowCertificateRequest) (*model.ShowCertificateResponse, error) {
|
||||
requestDef := hwwaf.GenReqDefForShowCertificate()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ShowCertificateResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *WafClient) UpdateCertificate(request *model.UpdateCertificateRequest) (*model.UpdateCertificateResponse, error) {
|
||||
requestDef := hwwaf.GenReqDefForUpdateCertificate()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.UpdateCertificateResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *WafClient) UpdateHost(request *model.UpdateHostRequest) (*model.UpdateHostResponse, error) {
|
||||
requestDef := hwwaf.GenReqDefForUpdateHost()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.UpdateHostResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *WafClient) UpdatePremiumHost(request *model.UpdatePremiumHostRequest) (*model.UpdatePremiumHostResponse, error) {
|
||||
requestDef := hwwaf.GenReqDefForUpdatePremiumHost()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.UpdatePremiumHostResponse), nil
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core"
|
||||
"github.com/certimate-go/certimate/pkg/core/ssl-manager/providers/huaweicloud-elb/internal"
|
||||
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
|
||||
)
|
||||
|
||||
@@ -35,7 +36,7 @@ type SSLManagerProviderConfig struct {
|
||||
type SSLManagerProvider struct {
|
||||
config *SSLManagerProviderConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *hcelb.ElbClient
|
||||
sdkClient *internal.ElbClient
|
||||
}
|
||||
|
||||
var _ core.SSLManager = (*SSLManagerProvider)(nil)
|
||||
@@ -143,7 +144,7 @@ func (m *SSLManagerProvider) Upload(ctx context.Context, certPEM string, privkey
|
||||
}, nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*hcelb.ElbClient, error) {
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.ElbClient, error) {
|
||||
if region == "" {
|
||||
region = "cn-north-4" // ELB 服务默认区域:华北四北京
|
||||
}
|
||||
@@ -169,7 +170,7 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*hcelb.ElbCli
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := hcelb.NewElbClient(hcClient)
|
||||
client := internal.NewElbClient(hcClient)
|
||||
return client, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
httpclient "github.com/huaweicloud/huaweicloud-sdk-go-v3/core"
|
||||
hwelb "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3"
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/elb/v3/model"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/huaweicloud/huaweicloud-sdk-go-v3/blob/master/services/elb/v3/elb_client.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type ElbClient struct {
|
||||
HcClient *httpclient.HcHttpClient
|
||||
}
|
||||
|
||||
func NewElbClient(hcClient *httpclient.HcHttpClient) *ElbClient {
|
||||
return &ElbClient{HcClient: hcClient}
|
||||
}
|
||||
|
||||
func (c *ElbClient) CreateCertificate(request *model.CreateCertificateRequest) (*model.CreateCertificateResponse, error) {
|
||||
requestDef := hwelb.GenReqDefForCreateCertificate()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.CreateCertificateResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ElbClient) ListCertificates(request *model.ListCertificatesRequest) (*model.ListCertificatesResponse, error) {
|
||||
requestDef := hwelb.GenReqDefForListCertificates()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListCertificatesResponse), nil
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core"
|
||||
"github.com/certimate-go/certimate/pkg/core/ssl-manager/providers/huaweicloud-scm/internal"
|
||||
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
|
||||
)
|
||||
|
||||
@@ -32,7 +33,7 @@ type SSLManagerProviderConfig struct {
|
||||
type SSLManagerProvider struct {
|
||||
config *SSLManagerProviderConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *hcscm.ScmClient
|
||||
sdkClient *internal.ScmClient
|
||||
}
|
||||
|
||||
var _ core.SSLManager = (*SSLManagerProvider)(nil)
|
||||
@@ -166,7 +167,7 @@ func (m *SSLManagerProvider) Upload(ctx context.Context, certPEM string, privkey
|
||||
}, nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*hcscm.ScmClient, error) {
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.ScmClient, error) {
|
||||
if region == "" {
|
||||
region = "cn-north-4" // SCM 服务默认区域:华北四北京
|
||||
}
|
||||
@@ -192,6 +193,6 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*hcscm.ScmCli
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := hcscm.NewScmClient(hcClient)
|
||||
client := internal.NewScmClient(hcClient)
|
||||
return client, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
httpclient "github.com/huaweicloud/huaweicloud-sdk-go-v3/core"
|
||||
hwscm "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3"
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/scm/v3/model"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/huaweicloud/huaweicloud-sdk-go-v3/blob/master/services/scm/v3/scm_client.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type ScmClient struct {
|
||||
HcClient *httpclient.HcHttpClient
|
||||
}
|
||||
|
||||
func NewScmClient(hcClient *httpclient.HcHttpClient) *ScmClient {
|
||||
return &ScmClient{HcClient: hcClient}
|
||||
}
|
||||
|
||||
func (c *ScmClient) ExportCertificate(request *model.ExportCertificateRequest) (*model.ExportCertificateResponse, error) {
|
||||
requestDef := hwscm.GenReqDefForExportCertificate()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ExportCertificateResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ScmClient) ImportCertificate(request *model.ImportCertificateRequest) (*model.ImportCertificateResponse, error) {
|
||||
requestDef := hwscm.GenReqDefForImportCertificate()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ImportCertificateResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ScmClient) ListCertificates(request *model.ListCertificatesRequest) (*model.ListCertificatesResponse, error) {
|
||||
requestDef := hwscm.GenReqDefForListCertificates()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListCertificatesResponse), nil
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/certimate-go/certimate/pkg/core"
|
||||
"github.com/certimate-go/certimate/pkg/core/ssl-manager/providers/huaweicloud-waf/internal"
|
||||
xcert "github.com/certimate-go/certimate/pkg/utils/cert"
|
||||
)
|
||||
|
||||
@@ -35,7 +36,7 @@ type SSLManagerProviderConfig struct {
|
||||
type SSLManagerProvider struct {
|
||||
config *SSLManagerProviderConfig
|
||||
logger *slog.Logger
|
||||
sdkClient *hcwaf.WafClient
|
||||
sdkClient *internal.WafClient
|
||||
}
|
||||
|
||||
var _ core.SSLManager = (*SSLManagerProvider)(nil)
|
||||
@@ -144,7 +145,7 @@ func (m *SSLManagerProvider) Upload(ctx context.Context, certPEM string, privkey
|
||||
}, nil
|
||||
}
|
||||
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*hcwaf.WafClient, error) {
|
||||
func createSDKClient(accessKeyId, secretAccessKey, region string) (*internal.WafClient, error) {
|
||||
projectId, err := getSdkProjectId(accessKeyId, secretAccessKey, region)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -172,7 +173,7 @@ func createSDKClient(accessKeyId, secretAccessKey, region string) (*hcwaf.WafCli
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := hcwaf.NewWafClient(hcClient)
|
||||
client := internal.NewWafClient(hcClient)
|
||||
return client, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package internal
|
||||
|
||||
import (
|
||||
httpclient "github.com/huaweicloud/huaweicloud-sdk-go-v3/core"
|
||||
hwwaf "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1"
|
||||
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/waf/v1/model"
|
||||
)
|
||||
|
||||
// This is a partial copy of https://github.com/huaweicloud/huaweicloud-sdk-go-v3/blob/master/services/waf/v1/waf_client.go
|
||||
// to lightweight the vendor packages in the built binary.
|
||||
type WafClient struct {
|
||||
HcClient *httpclient.HcHttpClient
|
||||
}
|
||||
|
||||
func NewWafClient(hcClient *httpclient.HcHttpClient) *WafClient {
|
||||
return &WafClient{HcClient: hcClient}
|
||||
}
|
||||
|
||||
func (c *WafClient) CreateCertificate(request *model.CreateCertificateRequest) (*model.CreateCertificateResponse, error) {
|
||||
requestDef := hwwaf.GenReqDefForCreateCertificate()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.CreateCertificateResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *WafClient) ListCertificates(request *model.ListCertificatesRequest) (*model.ListCertificatesResponse, error) {
|
||||
requestDef := hwwaf.GenReqDefForListCertificates()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ListCertificatesResponse), nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *WafClient) ShowCertificate(request *model.ShowCertificateRequest) (*model.ShowCertificateResponse, error) {
|
||||
requestDef := hwwaf.GenReqDefForShowCertificate()
|
||||
|
||||
if resp, err := c.HcClient.Sync(request, requestDef); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return resp.(*model.ShowCertificateResponse), nil
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user