This repository has been archived by the owner on May 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
ssl_endpoint.go
118 lines (101 loc) · 4.58 KB
/
ssl_endpoint.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// WARNING: This code is auto-generated from the Heroku Platform API JSON Schema
// by a Ruby script (gen/gen.rb). Changes should be made to the generation
// script rather than the generated files.
package heroku
import (
"time"
)
// SSL Endpoint is a public address serving custom SSL cert for HTTPS traffic to
// a Heroku app. Note that an app must have the ssl:endpoint addon installed
// before it can provision an SSL Endpoint using these APIs.
type SSLEndpoint struct {
// raw contents of the public certificate chain (eg: .crt or .pem file)
CertificateChain string `json:"certificate_chain"`
// canonical name record, the address to point a domain at
Cname string `json:"cname"`
// when endpoint was created
CreatedAt time.Time `json:"created_at"`
// unique identifier of this SSL endpoint
Id string `json:"id"`
// unique name for SSL endpoint
Name string `json:"name"`
// when endpoint was updated
UpdatedAt time.Time `json:"updated_at"`
}
// Create a new SSL endpoint.
//
// appIdentity is the unique identifier of the SSLEndpoint's App.
// certificateChain is the raw contents of the public certificate chain (eg:
// .crt or .pem file). privateKey is the contents of the private key (eg .key
// file). options is the struct of optional parameters for this action.
func (c *Client) SSLEndpointCreate(appIdentity string, certificateChain string, privateKey string, options *SSLEndpointCreateOpts) (*SSLEndpoint, error) {
params := struct {
CertificateChain string `json:"certificate_chain"`
PrivateKey string `json:"private_key"`
Preprocess *bool `json:"preprocess,omitempty"`
}{
CertificateChain: certificateChain,
PrivateKey: privateKey,
}
if options != nil {
params.Preprocess = options.Preprocess
}
var sslEndpointRes SSLEndpoint
return &sslEndpointRes, c.Post(&sslEndpointRes, "/apps/"+appIdentity+"/ssl-endpoints", params)
}
// SSLEndpointCreateOpts holds the optional parameters for SSLEndpointCreate
type SSLEndpointCreateOpts struct {
// allow Heroku to modify an uploaded public certificate chain if deemed advantageous by adding missing intermediaries, stripping unnecessary ones, etc.
Preprocess *bool `json:"preprocess,omitempty"`
}
// Delete existing SSL endpoint.
//
// appIdentity is the unique identifier of the SSLEndpoint's App.
// sslEndpointIdentity is the unique identifier of the SSLEndpoint.
func (c *Client) SSLEndpointDelete(appIdentity string, sslEndpointIdentity string) error {
return c.Delete("/apps/" + appIdentity + "/ssl-endpoints/" + sslEndpointIdentity)
}
// Info for existing SSL endpoint.
//
// appIdentity is the unique identifier of the SSLEndpoint's App.
// sslEndpointIdentity is the unique identifier of the SSLEndpoint.
func (c *Client) SSLEndpointInfo(appIdentity string, sslEndpointIdentity string) (*SSLEndpoint, error) {
var sslEndpoint SSLEndpoint
return &sslEndpoint, c.Get(&sslEndpoint, "/apps/"+appIdentity+"/ssl-endpoints/"+sslEndpointIdentity)
}
// List existing SSL endpoints.
//
// appIdentity is the unique identifier of the SSLEndpoint's App. lr is an
// optional ListRange that sets the Range options for the paginated list of
// results.
func (c *Client) SSLEndpointList(appIdentity string, lr *ListRange) ([]SSLEndpoint, error) {
req, err := c.NewRequest("GET", "/apps/"+appIdentity+"/ssl-endpoints", nil)
if err != nil {
return nil, err
}
if lr != nil {
lr.SetHeader(req)
}
var sslEndpointsRes []SSLEndpoint
return sslEndpointsRes, c.DoReq(req, &sslEndpointsRes)
}
// Update an existing SSL endpoint.
//
// appIdentity is the unique identifier of the SSLEndpoint's App.
// sslEndpointIdentity is the unique identifier of the SSLEndpoint. options is
// the struct of optional parameters for this action.
func (c *Client) SSLEndpointUpdate(appIdentity string, sslEndpointIdentity string, options *SSLEndpointUpdateOpts) (*SSLEndpoint, error) {
var sslEndpointRes SSLEndpoint
return &sslEndpointRes, c.Patch(&sslEndpointRes, "/apps/"+appIdentity+"/ssl-endpoints/"+sslEndpointIdentity, options)
}
// SSLEndpointUpdateOpts holds the optional parameters for SSLEndpointUpdate
type SSLEndpointUpdateOpts struct {
// raw contents of the public certificate chain (eg: .crt or .pem file)
CertificateChain *string `json:"certificate_chain,omitempty"`
// allow Heroku to modify an uploaded public certificate chain if deemed advantageous by adding missing intermediaries, stripping unnecessary ones, etc.
Preprocess *bool `json:"preprocess,omitempty"`
// contents of the private key (eg .key file)
PrivateKey *string `json:"private_key,omitempty"`
// indicates that a rollback should be performed
Rollback *bool `json:"rollback,omitempty"`
}