github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/apigw/v2/domain/AssignCertificate.go (about)

     1  package domain
     2  
     3  import (
     4  	"github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     7  )
     8  
     9  type CreateCertOpts struct {
    10  	GatewayID string `json:"-"`
    11  	GroupID   string `json:"-"`
    12  	DomainID  string `json:"-"`
    13  	// Certificate content.
    14  	Content string `json:"cert_content" required:"true"`
    15  	// Certificate name. It can contain 4 to 50 characters, starting with a letter.
    16  	// Only letters, digits, and underscores (_) are allowed.
    17  	Name string `json:"name" required:"true"`
    18  	// Private key.
    19  	PrivateKey string `json:"private_key" required:"true"`
    20  }
    21  
    22  func AssignCertificate(client *golangsdk.ServiceClient, opts CreateCertOpts) (*DomainCertResp, error) {
    23  	b, err := build.RequestBody(opts, "")
    24  	if err != nil {
    25  		return nil, err
    26  	}
    27  
    28  	// POST /v2/{project_id}/apigw/instances/{instance_id}/api-groups/{group_id}/domains/{domain_id}/certificate
    29  	raw, err := client.Post(client.ServiceURL("apigw", "instances", opts.GatewayID, "api-groups", opts.GroupID, "domains", opts.DomainID, "certificate"), b, nil, &golangsdk.RequestOpts{
    30  		OkCodes: []int{201},
    31  	})
    32  	if err != nil {
    33  		return nil, err
    34  	}
    35  
    36  	var res DomainCertResp
    37  
    38  	err = extract.Into(raw.Body, &res)
    39  	return &res, err
    40  }
    41  
    42  type DomainCertResp struct {
    43  	// Custom domain name.
    44  	UrlDomain string `json:"url_domain"`
    45  	// Domain ID.
    46  	DomainId string `json:"id"`
    47  	// CNAME resolution status.
    48  	// 1: not resolved
    49  	// 2: resolving
    50  	// 3: resolved
    51  	// 4: resolution failed
    52  	Status int `json:"status"`
    53  	// Minimum SSL version supported.
    54  	MinSslVersion string `json:"min_ssl_version"`
    55  	// Whether to enable HTTP redirection to HTTPS.
    56  	// The value false means disable and true means enable. The default value is false.
    57  	IsHttpRedirectToHttps bool `json:"is_http_redirect_to_https"`
    58  	// Whether to enable client certificate verification.
    59  	// This parameter is available only when a certificate is bound.
    60  	// It is enabled by default if trusted_root_ca exists, and disabled if trusted_root_ca does not exist.
    61  	VerifiedClientCertificateEnabled bool `json:"verified_client_certificate_enabled"`
    62  	// Certificate name.
    63  	Name string `json:"ssl_name"`
    64  	// Certificate ID.
    65  	ID string `json:"ssl_id"`
    66  }