Add DNS Provider for Oracle Cloud (#808)

This commit is contained in:
Sugi 2019-02-26 23:41:02 +09:00 committed by Ludovic Fernandez
parent a144800896
commit af67943e94
89 changed files with 9842 additions and 0 deletions

View file

@ -117,6 +117,7 @@ git push -u origin my-feature
| NIFCloud | `nifcloud` | [documentation](https://mbaas.nifcloud.com/doc/current/rest/common/format.html) | - | | NIFCloud | `nifcloud` | [documentation](https://mbaas.nifcloud.com/doc/current/rest/common/format.html) | - |
| NS1 | `ns1` | [documentation](https://ns1.com/api) | [Go client](https://github.com/ns1/ns1-go) | | NS1 | `ns1` | [documentation](https://ns1.com/api) | [Go client](https://github.com/ns1/ns1-go) |
| Open Telekom Cloud | `otc` | [documentation](https://docs.otc.t-systems.com/en-us/dns/index.html) | - | | Open Telekom Cloud | `otc` | [documentation](https://docs.otc.t-systems.com/en-us/dns/index.html) | - |
| Oracle Cloud | `oraclecloud` | [documentation](https://docs.cloud.oracle.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm) | [Go Client](https://github.com/oracle/oci-go-sdk) |
| OVH | `ovh` | [documentation](https://eu.api.ovh.com/) | [Go client](https://github.com/ovh/go-ovh) | | OVH | `ovh` | [documentation](https://eu.api.ovh.com/) | [Go client](https://github.com/ovh/go-ovh) |
| PowerDNS | `pdns` | [documentation](https://doc.powerdns.com/md/httpapi/README/) | - | | PowerDNS | `pdns` | [documentation](https://doc.powerdns.com/md/httpapi/README/) | - |
| Rackspace | `rackspace` | [documentation](https://developer.rackspace.com/docs/cloud-dns/v1/) | - | | Rackspace | `rackspace` | [documentation](https://developer.rackspace.com/docs/cloud-dns/v1/) | - |

13
Gopkg.lock generated
View file

@ -379,6 +379,17 @@
revision = "d8152159450570012552f924a0ae6ab3d8c617e0" revision = "d8152159450570012552f924a0ae6ab3d8c617e0"
version = "v0.6.0" version = "v0.6.0"
[[projects]]
digest = "1:c665ac9fd8cedb7bea85380a441dec4e5de3c7d4574e18c6ba53dfe04cf50878"
name = "github.com/oracle/oci-go-sdk"
packages = [
"common",
"dns",
]
pruneopts = "NUT"
revision = "f1ecb80f81a9cfa7dbfc964a34a3c62323277a9d"
version = "v4.0.0"
[[projects]] [[projects]]
branch = "master" branch = "master"
digest = "1:02584222c11b07d1d61cd76cc73e78cbc72810384a7ea69c543246d60d3335f7" digest = "1:02584222c11b07d1d61cd76cc73e78cbc72810384a7ea69c543246d60d3335f7"
@ -692,6 +703,8 @@
"github.com/namedotcom/go/namecom", "github.com/namedotcom/go/namecom",
"github.com/nrdcg/auroradns", "github.com/nrdcg/auroradns",
"github.com/nrdcg/goinwx", "github.com/nrdcg/goinwx",
"github.com/oracle/oci-go-sdk/common",
"github.com/oracle/oci-go-sdk/dns",
"github.com/ovh/go-ovh/ovh", "github.com/ovh/go-ovh/ovh",
"github.com/rainycape/memcache", "github.com/rainycape/memcache",
"github.com/sacloud/libsacloud/api", "github.com/sacloud/libsacloud/api",

View file

@ -100,3 +100,8 @@
[[constraint]] [[constraint]]
version = "v0.7.3" version = "v0.7.3"
name = "github.com/akamai/AkamaiOPEN-edgegrid-golang" name = "github.com/akamai/AkamaiOPEN-edgegrid-golang"
[[constraint]]
version = "4.0.0"
name = "github.com/oracle/oci-go-sdk"

View file

@ -69,6 +69,7 @@ Here is an example bash command using the CloudFlare DNS provider:
fmt.Fprintln(w, "\tnetcup:\tNETCUP_CUSTOMER_NUMBER, NETCUP_API_KEY, NETCUP_API_PASSWORD") fmt.Fprintln(w, "\tnetcup:\tNETCUP_CUSTOMER_NUMBER, NETCUP_API_KEY, NETCUP_API_PASSWORD")
fmt.Fprintln(w, "\tnifcloud:\tNIFCLOUD_ACCESS_KEY_ID, NIFCLOUD_SECRET_ACCESS_KEY") fmt.Fprintln(w, "\tnifcloud:\tNIFCLOUD_ACCESS_KEY_ID, NIFCLOUD_SECRET_ACCESS_KEY")
fmt.Fprintln(w, "\tns1:\tNS1_API_KEY") fmt.Fprintln(w, "\tns1:\tNS1_API_KEY")
fmt.Fprintln(w, "\toraclecloud:\tOCI_PRIVKEY_BASE64, OCI_PRIVKEY_PASS, OCI_TENANCY_OCID, OCI_USER_OCID, OCI_PUBKEY_FINGERPRINT, OCI_REGION, OCI_COMPARTMENT_OCID")
fmt.Fprintln(w, "\totc:\tOTC_USER_NAME, OTC_PASSWORD, OTC_PROJECT_NAME, OTC_DOMAIN_NAME, OTC_IDENTITY_ENDPOINT") fmt.Fprintln(w, "\totc:\tOTC_USER_NAME, OTC_PASSWORD, OTC_PROJECT_NAME, OTC_DOMAIN_NAME, OTC_IDENTITY_ENDPOINT")
fmt.Fprintln(w, "\tovh:\tOVH_ENDPOINT, OVH_APPLICATION_KEY, OVH_APPLICATION_SECRET, OVH_CONSUMER_KEY") fmt.Fprintln(w, "\tovh:\tOVH_ENDPOINT, OVH_APPLICATION_KEY, OVH_APPLICATION_SECRET, OVH_CONSUMER_KEY")
fmt.Fprintln(w, "\tpdns:\tPDNS_API_KEY, PDNS_API_URL") fmt.Fprintln(w, "\tpdns:\tPDNS_API_KEY, PDNS_API_URL")
@ -122,6 +123,7 @@ Here is an example bash command using the CloudFlare DNS provider:
fmt.Fprintln(w, "\tnetcup:\tNETCUP_POLLING_INTERVAL, NETCUP_PROPAGATION_TIMEOUT, NETCUP_TTL, NETCUP_HTTP_TIMEOUT") fmt.Fprintln(w, "\tnetcup:\tNETCUP_POLLING_INTERVAL, NETCUP_PROPAGATION_TIMEOUT, NETCUP_TTL, NETCUP_HTTP_TIMEOUT")
fmt.Fprintln(w, "\tnifcloud:\tNIFCLOUD_POLLING_INTERVAL, NIFCLOUD_PROPAGATION_TIMEOUT, NIFCLOUD_TTL, NIFCLOUD_HTTP_TIMEOUT") fmt.Fprintln(w, "\tnifcloud:\tNIFCLOUD_POLLING_INTERVAL, NIFCLOUD_PROPAGATION_TIMEOUT, NIFCLOUD_TTL, NIFCLOUD_HTTP_TIMEOUT")
fmt.Fprintln(w, "\tns1:\tNS1_POLLING_INTERVAL, NS1_PROPAGATION_TIMEOUT, NS1_TTL, NS1_HTTP_TIMEOUT") fmt.Fprintln(w, "\tns1:\tNS1_POLLING_INTERVAL, NS1_PROPAGATION_TIMEOUT, NS1_TTL, NS1_HTTP_TIMEOUT")
fmt.Fprintln(w, "\toraclecloud:\tOCI_TTL, OCI_PROPAGATION_TIMEOUT, OCI_POLLING_INTERVAL")
fmt.Fprintln(w, "\totc:\tOTC_POLLING_INTERVAL, OTC_PROPAGATION_TIMEOUT, OTC_TTL, OTC_HTTP_TIMEOUT") fmt.Fprintln(w, "\totc:\tOTC_POLLING_INTERVAL, OTC_PROPAGATION_TIMEOUT, OTC_TTL, OTC_HTTP_TIMEOUT")
fmt.Fprintln(w, "\tovh:\tOVH_POLLING_INTERVAL, OVH_PROPAGATION_TIMEOUT, OVH_TTL, OVH_HTTP_TIMEOUT") fmt.Fprintln(w, "\tovh:\tOVH_POLLING_INTERVAL, OVH_PROPAGATION_TIMEOUT, OVH_TTL, OVH_HTTP_TIMEOUT")
fmt.Fprintln(w, "\tpdns:\tPDNS_POLLING_INTERVAL, PDNS_PROPAGATION_TIMEOUT, PDNS_TTL, PDNS_HTTP_TIMEOUT") fmt.Fprintln(w, "\tpdns:\tPDNS_POLLING_INTERVAL, PDNS_PROPAGATION_TIMEOUT, PDNS_TTL, PDNS_HTTP_TIMEOUT")

View file

@ -42,6 +42,7 @@ import (
"github.com/xenolf/lego/providers/dns/netcup" "github.com/xenolf/lego/providers/dns/netcup"
"github.com/xenolf/lego/providers/dns/nifcloud" "github.com/xenolf/lego/providers/dns/nifcloud"
"github.com/xenolf/lego/providers/dns/ns1" "github.com/xenolf/lego/providers/dns/ns1"
"github.com/xenolf/lego/providers/dns/oraclecloud"
"github.com/xenolf/lego/providers/dns/otc" "github.com/xenolf/lego/providers/dns/otc"
"github.com/xenolf/lego/providers/dns/ovh" "github.com/xenolf/lego/providers/dns/ovh"
"github.com/xenolf/lego/providers/dns/pdns" "github.com/xenolf/lego/providers/dns/pdns"
@ -137,6 +138,8 @@ func NewDNSChallengeProviderByName(name string) (challenge.Provider, error) {
return nifcloud.NewDNSProvider() return nifcloud.NewDNSProvider()
case "ns1": case "ns1":
return ns1.NewDNSProvider() return ns1.NewDNSProvider()
case "oraclecloud":
return oraclecloud.NewDNSProvider()
case "otc": case "otc":
return otc.NewDNSProvider() return otc.NewDNSProvider()
case "ovh": case "ovh":

View file

@ -0,0 +1,28 @@
# Export shell-env for OracleCloud
in Bash
```
export OCI_PRIVKEY_BASE64=`base64 ~/.oci/oci_api_key.pem`
export OCI_PRIVKEY_PASS="secret"
export OCI_TENANCY_OCID="ocid1.tenancy.oc1..secret"
export OCI_USER_OCID="ocid1.user.oc1..secret"
export OCI_PUBKEY_FINGERPRINT="00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00"
export OCI_REGION="us-phoenix-1"
export OCI_COMPARTMENT_OCID="ocid1.tenancy.oc1..secret"
```
in Fish
```
set IFS
set -x OCI_PRIVKEY_BASE64 (base64 ~/.oci/oci_api_key.pem)
set IFS \n" "\t
set -x OCI_PRIVKEY_PASS 'secret'
set -x OCI_TENANCY_OCID 'ocid1.tenancy.oc1..secret'
set -x OCI_USER_OCID 'ocid1.user.oc1..secret'
set -x OCI_PUBKEY_FINGERPRINT '00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00'
set -x OCI_REGION 'us-phoenix-1'
set -x OCI_COMPARTMENT_OCID 'ocid1.tenancy.oc1..secret'
```

View file

@ -0,0 +1,75 @@
package oraclecloud
import (
"crypto/rsa"
"encoding/base64"
"fmt"
"github.com/oracle/oci-go-sdk/common"
"github.com/xenolf/lego/platform/config/env"
)
const (
ociPrivkeyBase64 = "OCI_PRIVKEY_BASE64"
ociPrivkeyPass = "OCI_PRIVKEY_PASS"
ociTenancyOCID = "OCI_TENANCY_OCID"
ociUserOCID = "OCI_USER_OCID"
ociPubkeyFingerprint = "OCI_PUBKEY_FINGERPRINT"
ociRegion = "OCI_REGION"
)
type configProvider struct {
values map[string]string
privateKeyPassphrase string
}
func newConfigProvider(values map[string]string) *configProvider {
return &configProvider{
values: values,
privateKeyPassphrase: env.GetOrFile(ociPrivkeyPass),
}
}
func (p *configProvider) PrivateRSAKey() (*rsa.PrivateKey, error) {
privateKeyDecoded, err := base64.StdEncoding.DecodeString(p.values[ociPrivkeyBase64])
if err != nil {
return nil, err
}
return common.PrivateKeyFromBytes(privateKeyDecoded, common.String(p.privateKeyPassphrase))
}
func (p *configProvider) KeyID() (string, error) {
tenancy, err := p.TenancyOCID()
if err != nil {
return "", err
}
user, err := p.UserOCID()
if err != nil {
return "", err
}
fingerprint, err := p.KeyFingerprint()
if err != nil {
return "", err
}
return fmt.Sprintf("%s/%s/%s", tenancy, user, fingerprint), nil
}
func (p *configProvider) TenancyOCID() (value string, err error) {
return p.values[ociTenancyOCID], nil
}
func (p *configProvider) UserOCID() (string, error) {
return p.values[ociUserOCID], nil
}
func (p *configProvider) KeyFingerprint() (string, error) {
return p.values[ociPubkeyFingerprint], nil
}
func (p *configProvider) Region() (string, error) {
return p.values[ociRegion], nil
}

View file

@ -0,0 +1,169 @@
package oraclecloud
import (
"context"
"errors"
"fmt"
"net/http"
"time"
"github.com/oracle/oci-go-sdk/common"
"github.com/oracle/oci-go-sdk/dns"
"github.com/xenolf/lego/challenge/dns01"
"github.com/xenolf/lego/platform/config/env"
)
// Config is used to configure the creation of the DNSProvider
type Config struct {
CompartmentID string
OCIConfigProvider common.ConfigurationProvider
PropagationTimeout time.Duration
PollingInterval time.Duration
TTL int
HTTPClient *http.Client
}
// NewDefaultConfig returns a default configuration for the DNSProvider
func NewDefaultConfig() *Config {
return &Config{
TTL: env.GetOrDefaultInt("OCI_TTL", dns01.DefaultTTL),
PropagationTimeout: env.GetOrDefaultSecond("OCI_PROPAGATION_TIMEOUT", dns01.DefaultPropagationTimeout),
PollingInterval: env.GetOrDefaultSecond("OCI_POLLING_INTERVAL", dns01.DefaultPollingInterval),
HTTPClient: &http.Client{
Timeout: env.GetOrDefaultSecond("OCI_HTTP_TIMEOUT", 60*time.Second),
},
}
}
// DNSProvider is an implementation of the acme.ChallengeProvider interface.
type DNSProvider struct {
client *dns.DnsClient
config *Config
}
// NewDNSProvider returns a DNSProvider instance configured for OracleCloud.
func NewDNSProvider() (*DNSProvider, error) {
values, err := env.Get(ociPrivkeyBase64, ociTenancyOCID, ociUserOCID, ociPubkeyFingerprint, ociRegion, "OCI_COMPARTMENT_OCID")
if err != nil {
return nil, fmt.Errorf("oraclecloud: %v", err)
}
config := NewDefaultConfig()
config.CompartmentID = values["OCI_COMPARTMENT_OCID"]
config.OCIConfigProvider = newConfigProvider(values)
return NewDNSProviderConfig(config)
}
// NewDNSProviderConfig return a DNSProvider instance configured for OracleCloud.
func NewDNSProviderConfig(config *Config) (*DNSProvider, error) {
if config == nil {
return nil, errors.New("oraclecloud: the configuration of the DNS provider is nil")
}
if config.CompartmentID == "" {
return nil, errors.New("oraclecloud: CompartmentID is missing")
}
if config.OCIConfigProvider == nil {
return nil, errors.New("oraclecloud: OCIConfigProvider is missing")
}
client, err := dns.NewDnsClientWithConfigurationProvider(config.OCIConfigProvider)
if err != nil {
return nil, fmt.Errorf("oraclecloud: %v", err)
}
if config.HTTPClient != nil {
client.HTTPClient = config.HTTPClient
}
return &DNSProvider{client: &client, config: config}, nil
}
// Present creates a TXT record to fulfill the dns-01 challenge
func (d *DNSProvider) Present(domain, token, keyAuth string) error {
fqdn, value := dns01.GetRecord(domain, keyAuth)
// generate request to dns.PatchDomainRecordsRequest
recordOperation := dns.RecordOperation{
Domain: common.String(dns01.UnFqdn(fqdn)),
Rdata: common.String(value),
Rtype: common.String("TXT"),
Ttl: common.Int(30),
IsProtected: common.Bool(false),
}
request := dns.PatchDomainRecordsRequest{
CompartmentId: common.String(d.config.CompartmentID),
ZoneNameOrId: common.String(domain),
Domain: common.String(dns01.UnFqdn(fqdn)),
PatchDomainRecordsDetails: dns.PatchDomainRecordsDetails{
Items: []dns.RecordOperation{recordOperation},
},
}
_, err := d.client.PatchDomainRecords(context.Background(), request)
if err != nil {
return fmt.Errorf("oraclecloud: %v", err)
}
return nil
}
// CleanUp removes the TXT record matching the specified parameters
func (d *DNSProvider) CleanUp(domain, token, keyAuth string) error {
fqdn, value := dns01.GetRecord(domain, keyAuth)
// search to TXT record's hash to delete
getRequest := dns.GetDomainRecordsRequest{
ZoneNameOrId: common.String(domain),
Domain: common.String(dns01.UnFqdn(fqdn)),
CompartmentId: common.String(d.config.CompartmentID),
Rtype: common.String("TXT"),
}
ctx := context.Background()
domainRecords, err := d.client.GetDomainRecords(ctx, getRequest)
if err != nil {
return fmt.Errorf("oraclecloud: %v", err)
}
if *domainRecords.OpcTotalItems == 0 {
return fmt.Errorf("oraclecloud: no record to CleanUp")
}
var deleteHash *string
for _, record := range domainRecords.RecordCollection.Items {
if record.Rdata != nil && *record.Rdata == `"`+value+`"` {
deleteHash = record.RecordHash
break
}
}
if deleteHash == nil {
return fmt.Errorf("oraclecloud: no record to CleanUp")
}
recordOperation := dns.RecordOperation{
RecordHash: deleteHash,
Operation: dns.RecordOperationOperationRemove,
}
patchRequest := dns.PatchDomainRecordsRequest{
ZoneNameOrId: common.String(domain),
Domain: common.String(dns01.UnFqdn(fqdn)),
PatchDomainRecordsDetails: dns.PatchDomainRecordsDetails{
Items: []dns.RecordOperation{recordOperation},
},
CompartmentId: common.String(d.config.CompartmentID),
}
_, err = d.client.PatchDomainRecords(ctx, patchRequest)
if err != nil {
return fmt.Errorf("oraclecloud: %v", err)
}
return nil
}

View file

@ -0,0 +1,268 @@
package oraclecloud
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/base64"
"encoding/pem"
"testing"
"time"
"github.com/oracle/oci-go-sdk/common"
"github.com/stretchr/testify/require"
"github.com/xenolf/lego/platform/tester"
)
var envTest = tester.NewEnvTest(
ociPrivkeyBase64,
ociPrivkeyPass,
ociTenancyOCID,
ociUserOCID,
ociPubkeyFingerprint,
ociRegion,
"OCI_COMPARTMENT_OCID").
WithDomain("ORACLECLOUD_DOMAIN")
func TestNewDNSProvider(t *testing.T) {
testCases := []struct {
desc string
envVars map[string]string
expected string
}{
{
desc: "success",
envVars: map[string]string{
ociPrivkeyBase64: mustGeneratePrivateKey("secret1"),
ociPrivkeyPass: "secret1",
ociTenancyOCID: "ocid1.tenancy.oc1..secret",
ociUserOCID: "ocid1.user.oc1..secret",
ociPubkeyFingerprint: "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
ociRegion: "us-phoenix-1",
"OCI_COMPARTMENT_OCID": "123",
},
},
{
desc: "missing credentials",
envVars: map[string]string{},
expected: "oraclecloud: some credentials information are missing: OCI_PRIVKEY_BASE64,OCI_TENANCY_OCID,OCI_USER_OCID,OCI_PUBKEY_FINGERPRINT,OCI_REGION,OCI_COMPARTMENT_OCID",
},
{
desc: "missing CompartmentID",
envVars: map[string]string{
ociPrivkeyBase64: mustGeneratePrivateKey("secret"),
ociPrivkeyPass: "secret",
ociTenancyOCID: "ocid1.tenancy.oc1..secret",
ociUserOCID: "ocid1.user.oc1..secret",
ociPubkeyFingerprint: "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
ociRegion: "us-phoenix-1",
"OCI_COMPARTMENT_OCID": "",
},
expected: "oraclecloud: some credentials information are missing: OCI_COMPARTMENT_OCID",
},
{
desc: "missing OCI_PRIVKEY_BASE64",
envVars: map[string]string{
ociPrivkeyBase64: "",
ociPrivkeyPass: "secret",
ociTenancyOCID: "ocid1.tenancy.oc1..secret",
ociUserOCID: "ocid1.user.oc1..secret",
ociPubkeyFingerprint: "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
ociRegion: "us-phoenix-1",
"OCI_COMPARTMENT_OCID": "123",
},
expected: "oraclecloud: some credentials information are missing: OCI_PRIVKEY_BASE64",
},
{
desc: "missing OCI_PRIVKEY_PASS",
envVars: map[string]string{
ociPrivkeyBase64: mustGeneratePrivateKey("secret"),
ociPrivkeyPass: "",
ociTenancyOCID: "ocid1.tenancy.oc1..secret",
ociUserOCID: "ocid1.user.oc1..secret",
ociPubkeyFingerprint: "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
ociRegion: "us-phoenix-1",
"OCI_COMPARTMENT_OCID": "123",
},
expected: "oraclecloud: can not create client, bad configuration: x509: decryption password incorrect",
},
{
desc: "missing OCI_TENANCY_OCID",
envVars: map[string]string{
ociPrivkeyBase64: mustGeneratePrivateKey("secret"),
ociPrivkeyPass: "secret",
ociTenancyOCID: "",
ociUserOCID: "ocid1.user.oc1..secret",
ociPubkeyFingerprint: "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
ociRegion: "us-phoenix-1",
"OCI_COMPARTMENT_OCID": "123",
},
expected: "oraclecloud: some credentials information are missing: OCI_TENANCY_OCID",
},
{
desc: "missing OCI_USER_OCID",
envVars: map[string]string{
ociPrivkeyBase64: mustGeneratePrivateKey("secret"),
ociPrivkeyPass: "secret",
ociTenancyOCID: "ocid1.tenancy.oc1..secret",
ociUserOCID: "",
ociPubkeyFingerprint: "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
ociRegion: "us-phoenix-1",
"OCI_COMPARTMENT_OCID": "123",
},
expected: "oraclecloud: some credentials information are missing: OCI_USER_OCID",
},
{
desc: "missing OCI_PUBKEY_FINGERPRINT",
envVars: map[string]string{
ociPrivkeyBase64: mustGeneratePrivateKey("secret"),
ociPrivkeyPass: "secret",
ociTenancyOCID: "ocid1.tenancy.oc1..secret",
ociUserOCID: "ocid1.user.oc1..secret",
ociPubkeyFingerprint: "",
ociRegion: "us-phoenix-1",
"OCI_COMPARTMENT_OCID": "123",
},
expected: "oraclecloud: some credentials information are missing: OCI_PUBKEY_FINGERPRINT",
},
{
desc: "missing OCI_REGION",
envVars: map[string]string{
ociPrivkeyBase64: mustGeneratePrivateKey("secret"),
ociPrivkeyPass: "secret",
ociTenancyOCID: "ocid1.tenancy.oc1..secret",
ociUserOCID: "ocid1.user.oc1..secret",
ociPubkeyFingerprint: "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
ociRegion: "",
"OCI_COMPARTMENT_OCID": "123",
},
expected: "oraclecloud: some credentials information are missing: OCI_REGION",
},
{
desc: "missing OCI_REGION",
envVars: map[string]string{
ociPrivkeyBase64: mustGeneratePrivateKey("secret"),
ociPrivkeyPass: "secret",
ociTenancyOCID: "ocid1.tenancy.oc1..secret",
ociUserOCID: "ocid1.user.oc1..secret",
ociPubkeyFingerprint: "00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00",
ociRegion: "",
"OCI_COMPARTMENT_OCID": "123",
},
expected: "oraclecloud: some credentials information are missing: OCI_REGION",
},
}
for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) {
defer envTest.RestoreEnv()
envTest.ClearEnv()
envTest.Apply(test.envVars)
p, err := NewDNSProvider()
if len(test.expected) == 0 {
require.NoError(t, err)
require.NotNil(t, p)
require.NotNil(t, p.config)
require.NotNil(t, p.client)
} else {
require.EqualError(t, err, test.expected)
}
})
}
}
func TestNewDNSProviderConfig(t *testing.T) {
testCases := []struct {
desc string
compartmentID string
configurationProvider common.ConfigurationProvider
expected string
}{
{
desc: "invalid configuration",
configurationProvider: &configProvider{},
compartmentID: "123",
expected: "oraclecloud: can not create client, bad configuration: PEM data was not found in buffer",
},
{
desc: "OCIConfigProvider is missing",
compartmentID: "123",
expected: "oraclecloud: OCIConfigProvider is missing",
},
{
desc: "missing CompartmentID",
expected: "oraclecloud: CompartmentID is missing",
},
}
for _, test := range testCases {
t.Run(test.desc, func(t *testing.T) {
config := NewDefaultConfig()
config.CompartmentID = test.compartmentID
config.OCIConfigProvider = test.configurationProvider
p, err := NewDNSProviderConfig(config)
if len(test.expected) == 0 {
require.NoError(t, err)
require.NotNil(t, p)
require.NotNil(t, p.config)
require.NotNil(t, p.client)
} else {
require.EqualError(t, err, test.expected)
}
})
}
}
func TestLivePresent(t *testing.T) {
if !envTest.IsLiveTest() {
t.Skip("skipping live test")
}
envTest.RestoreEnv()
provider, err := NewDNSProvider()
require.NoError(t, err)
err = provider.Present(envTest.GetDomain(), "", "123d==")
require.NoError(t, err)
}
func TestLiveCleanUp(t *testing.T) {
if !envTest.IsLiveTest() {
t.Skip("skipping live test")
}
envTest.RestoreEnv()
provider, err := NewDNSProvider()
require.NoError(t, err)
time.Sleep(1 * time.Second)
err = provider.CleanUp(envTest.GetDomain(), "", "123d==")
require.NoError(t, err)
}
func mustGeneratePrivateKey(pwd string) string {
key, err := rsa.GenerateKey(rand.Reader, 512)
if err != nil {
panic(err)
}
block := &pem.Block{
Type: "RSA PRIVATE KEY",
Bytes: x509.MarshalPKCS1PrivateKey(key),
}
if pwd != "" {
block, err = x509.EncryptPEMBlock(rand.Reader, block.Type, block.Bytes, []byte(pwd), x509.PEMCipherAES256)
if err != nil {
panic(err)
}
}
return base64.StdEncoding.EncodeToString(pem.EncodeToMemory(block))
}

82
vendor/github.com/oracle/oci-go-sdk/LICENSE.txt generated vendored Normal file
View file

@ -0,0 +1,82 @@
Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 or Apache License 2.0. See below for license terms. You may choose either license.
 ____________________________
The Universal Permissive License (UPL), Version 1.0
Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
Subject to the condition set forth below, permission is hereby granted to any person obtaining a copy of this software, associated documentation and/or data (collectively the "Software"), free of charge and under any and all copyright rights in the Software, and any and all patent rights owned or freely licensable by each licensor hereunder covering either (i) the unmodified Software as contributed to or provided by such licensor, or (ii) the Larger Works (as defined below), to deal in both
(a) the Software, and
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if one is included with the Software (each a "Larger Work" to which the Software is contributed by such licensors),
without restriction, including without limitation the rights to copy, create derivative works of, display, perform, and distribute the Software and make, use, sell, offer for sale, import, export, have made, and have sold the Software and the Larger Work(s), and to sublicense the foregoing rights on either these or other terms.
This license is subject to the following condition:
The above copyright notice and either this complete permission notice or at a minimum a reference to the UPL must be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The Apache Software License, Version 2.0
Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); You may not use this product except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
You must give any other recipients of the Work or Derivative Works a copy of this License; and
You must cause any modified files to carry prominent notices stating that You changed the files; and
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

339
vendor/github.com/oracle/oci-go-sdk/common/client.go generated vendored Normal file
View file

@ -0,0 +1,339 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Package common provides supporting functions and structs used by service packages
package common
import (
"context"
"fmt"
"math/rand"
"net/http"
"net/http/httputil"
"net/url"
"os"
"os/user"
"path"
"runtime"
"strings"
"sync/atomic"
"time"
)
const (
// DefaultHostURLTemplate The default url template for service hosts
DefaultHostURLTemplate = "%s.%s.oraclecloud.com"
// requestHeaderAccept The key for passing a header to indicate Accept
requestHeaderAccept = "Accept"
// requestHeaderAuthorization The key for passing a header to indicate Authorization
requestHeaderAuthorization = "Authorization"
// requestHeaderContentLength The key for passing a header to indicate Content Length
requestHeaderContentLength = "Content-Length"
// requestHeaderContentType The key for passing a header to indicate Content Type
requestHeaderContentType = "Content-Type"
// requestHeaderDate The key for passing a header to indicate Date
requestHeaderDate = "Date"
// requestHeaderIfMatch The key for passing a header to indicate If Match
requestHeaderIfMatch = "if-match"
// requestHeaderOpcClientInfo The key for passing a header to indicate OPC Client Info
requestHeaderOpcClientInfo = "opc-client-info"
// requestHeaderOpcRetryToken The key for passing a header to indicate OPC Retry Token
requestHeaderOpcRetryToken = "opc-retry-token"
// requestHeaderOpcRequestID The key for unique Oracle-assigned identifier for the request.
requestHeaderOpcRequestID = "opc-request-id"
// requestHeaderOpcClientRequestID The key for unique Oracle-assigned identifier for the request.
requestHeaderOpcClientRequestID = "opc-client-request-id"
// requestHeaderUserAgent The key for passing a header to indicate User Agent
requestHeaderUserAgent = "User-Agent"
// requestHeaderXContentSHA256 The key for passing a header to indicate SHA256 hash
requestHeaderXContentSHA256 = "X-Content-SHA256"
// private constants
defaultScheme = "https"
defaultSDKMarker = "Oracle-GoSDK"
defaultUserAgentTemplate = "%s/%s (%s/%s; go/%s)" //SDK/SDKVersion (OS/OSVersion; Lang/LangVersion)
defaultTimeout = 60 * time.Second
defaultConfigFileName = "config"
defaultConfigDirName = ".oci"
secondaryConfigDirName = ".oraclebmc"
maxBodyLenForDebug = 1024 * 1000
)
// RequestInterceptor function used to customize the request before calling the underlying service
type RequestInterceptor func(*http.Request) error
// HTTPRequestDispatcher wraps the execution of a http request, it is generally implemented by
// http.Client.Do, but can be customized for testing
type HTTPRequestDispatcher interface {
Do(req *http.Request) (*http.Response, error)
}
// BaseClient struct implements all basic operations to call oci web services.
type BaseClient struct {
//HTTPClient performs the http network operations
HTTPClient HTTPRequestDispatcher
//Signer performs auth operation
Signer HTTPRequestSigner
//A request interceptor can be used to customize the request before signing and dispatching
Interceptor RequestInterceptor
//The host of the service
Host string
//The user agent
UserAgent string
//Base path for all operations of this client
BasePath string
}
func defaultUserAgent() string {
userAgent := fmt.Sprintf(defaultUserAgentTemplate, defaultSDKMarker, Version(), runtime.GOOS, runtime.GOARCH, runtime.Version())
return userAgent
}
var clientCounter int64
func getNextSeed() int64 {
newCounterValue := atomic.AddInt64(&clientCounter, 1)
return newCounterValue + time.Now().UnixNano()
}
func newBaseClient(signer HTTPRequestSigner, dispatcher HTTPRequestDispatcher) BaseClient {
rand.Seed(getNextSeed())
return BaseClient{
UserAgent: defaultUserAgent(),
Interceptor: nil,
Signer: signer,
HTTPClient: dispatcher,
}
}
func defaultHTTPDispatcher() http.Client {
httpClient := http.Client{
Timeout: defaultTimeout,
}
return httpClient
}
func defaultBaseClient(provider KeyProvider) BaseClient {
dispatcher := defaultHTTPDispatcher()
signer := DefaultRequestSigner(provider)
return newBaseClient(signer, &dispatcher)
}
//DefaultBaseClientWithSigner creates a default base client with a given signer
func DefaultBaseClientWithSigner(signer HTTPRequestSigner) BaseClient {
dispatcher := defaultHTTPDispatcher()
return newBaseClient(signer, &dispatcher)
}
// NewClientWithConfig Create a new client with a configuration provider, the configuration provider
// will be used for the default signer as well as reading the region
// This function does not check for valid regions to implement forward compatibility
func NewClientWithConfig(configProvider ConfigurationProvider) (client BaseClient, err error) {
var ok bool
if ok, err = IsConfigurationProviderValid(configProvider); !ok {
err = fmt.Errorf("can not create client, bad configuration: %s", err.Error())
return
}
client = defaultBaseClient(configProvider)
return
}
func getHomeFolder() string {
current, e := user.Current()
if e != nil {
//Give up and try to return something sensible
home := os.Getenv("HOME")
if home == "" {
home = os.Getenv("USERPROFILE")
}
return home
}
return current.HomeDir
}
// DefaultConfigProvider returns the default config provider. The default config provider
// will look for configurations in 3 places: file in $HOME/.oci/config, HOME/.obmcs/config and
// variables names starting with the string TF_VAR. If the same configuration is found in multiple
// places the provider will prefer the first one.
func DefaultConfigProvider() ConfigurationProvider {
homeFolder := getHomeFolder()
defaultConfigFile := path.Join(homeFolder, defaultConfigDirName, defaultConfigFileName)
secondaryConfigFile := path.Join(homeFolder, secondaryConfigDirName, defaultConfigFileName)
defaultFileProvider, _ := ConfigurationProviderFromFile(defaultConfigFile, "")
secondaryFileProvider, _ := ConfigurationProviderFromFile(secondaryConfigFile, "")
environmentProvider := environmentConfigurationProvider{EnvironmentVariablePrefix: "TF_VAR"}
provider, _ := ComposingConfigurationProvider([]ConfigurationProvider{defaultFileProvider, secondaryFileProvider, environmentProvider})
Debugf("Configuration provided by: %s", provider)
return provider
}
func (client *BaseClient) prepareRequest(request *http.Request) (err error) {
if client.UserAgent == "" {
return fmt.Errorf("user agent can not be blank")
}
if request.Header == nil {
request.Header = http.Header{}
}
request.Header.Set(requestHeaderUserAgent, client.UserAgent)
request.Header.Set(requestHeaderDate, time.Now().UTC().Format(http.TimeFormat))
if !strings.Contains(client.Host, "http") &&
!strings.Contains(client.Host, "https") {
client.Host = fmt.Sprintf("%s://%s", defaultScheme, client.Host)
}
clientURL, err := url.Parse(client.Host)
if err != nil {
return fmt.Errorf("host is invalid. %s", err.Error())
}
request.URL.Host = clientURL.Host
request.URL.Scheme = clientURL.Scheme
currentPath := request.URL.Path
if !strings.Contains(currentPath, fmt.Sprintf("/%s", client.BasePath)) {
request.URL.Path = path.Clean(fmt.Sprintf("/%s/%s", client.BasePath, currentPath))
}
return
}
func (client BaseClient) intercept(request *http.Request) (err error) {
if client.Interceptor != nil {
err = client.Interceptor(request)
}
return
}
func checkForSuccessfulResponse(res *http.Response) error {
familyStatusCode := res.StatusCode / 100
if familyStatusCode == 4 || familyStatusCode == 5 {
return newServiceFailureFromResponse(res)
}
return nil
}
// OCIRequest is any request made to an OCI service.
type OCIRequest interface {
// HTTPRequest assembles an HTTP request.
HTTPRequest(method, path string) (http.Request, error)
}
// RequestMetadata is metadata about an OCIRequest. This structure represents the behavior exhibited by the SDK when
// issuing (or reissuing) a request.
type RequestMetadata struct {
// RetryPolicy is the policy for reissuing the request. If no retry policy is set on the request,
// then the request will be issued exactly once.
RetryPolicy *RetryPolicy
}
// OCIResponse is the response from issuing a request to an OCI service.
type OCIResponse interface {
// HTTPResponse returns the raw HTTP response.
HTTPResponse() *http.Response
}
// OCIOperation is the generalization of a request-response cycle undergone by an OCI service.
type OCIOperation func(context.Context, OCIRequest) (OCIResponse, error)
//ClientCallDetails a set of settings used by the a single Call operation of the http Client
type ClientCallDetails struct {
Signer HTTPRequestSigner
}
// Call executes the http request with the given context
func (client BaseClient) Call(ctx context.Context, request *http.Request) (response *http.Response, err error) {
return client.CallWithDetails(ctx, request, ClientCallDetails{Signer: client.Signer})
}
// CallWithDetails executes the http request, the given context using details specified in the paremeters, this function
// provides a way to override some settings present in the client
func (client BaseClient) CallWithDetails(ctx context.Context, request *http.Request, details ClientCallDetails) (response *http.Response, err error) {
Debugln("Atempting to call downstream service")
request = request.WithContext(ctx)
err = client.prepareRequest(request)
if err != nil {
return
}
//Intercept
err = client.intercept(request)
if err != nil {
return
}
//Sign the request
err = details.Signer.Sign(request)
if err != nil {
return
}
IfDebug(func() {
dumpBody := true
if request.ContentLength > maxBodyLenForDebug {
Debugf("not dumping body too big\n")
dumpBody = false
}
dumpBody = dumpBody && defaultLogger.LogLevel() == verboseLogging
if dump, e := httputil.DumpRequestOut(request, dumpBody); e == nil {
Debugf("Dump Request %s", string(dump))
} else {
Debugf("%v\n", e)
}
})
//Execute the http request
response, err = client.HTTPClient.Do(request)
IfDebug(func() {
if err != nil {
Debugf("%v\n", err)
return
}
dumpBody := true
if response.ContentLength > maxBodyLenForDebug {
Debugf("not dumping body too big\n")
dumpBody = false
}
dumpBody = dumpBody && defaultLogger.LogLevel() == verboseLogging
if dump, e := httputil.DumpResponse(response, dumpBody); e == nil {
Debugf("Dump Response %s", string(dump))
} else {
Debugf("%v\n", e)
}
})
if err != nil {
return
}
err = checkForSuccessfulResponse(response)
return
}
//CloseBodyIfValid closes the body of an http response if the response and the body are valid
func CloseBodyIfValid(httpResponse *http.Response) {
if httpResponse != nil && httpResponse.Body != nil {
httpResponse.Body.Close()
}
}

137
vendor/github.com/oracle/oci-go-sdk/common/common.go generated vendored Normal file
View file

@ -0,0 +1,137 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
package common
import (
"fmt"
"regexp"
"strings"
)
//Region type for regions
type Region string
const (
//RegionSEA region SEA
RegionSEA Region = "sea"
//RegionCAToronto1 region for toronto
RegionCAToronto1 Region = "ca-toronto-1"
//RegionPHX region PHX
RegionPHX Region = "us-phoenix-1"
//RegionIAD region IAD
RegionIAD Region = "us-ashburn-1"
//RegionFRA region FRA
RegionFRA Region = "eu-frankfurt-1"
//RegionLHR region LHR
RegionLHR Region = "uk-london-1"
//RegionUSLangley1 region for langley
RegionUSLangley1 Region = "us-langley-1"
//RegionUSLuke1 region for luke
RegionUSLuke1 Region = "us-luke-1"
//RegionUSGovAshburn1 region for langley
RegionUSGovAshburn1 Region = "us-gov-ashburn-1"
//RegionUSGovChicago1 region for luke
RegionUSGovChicago1 Region = "us-gov-chicago-1"
//RegionUSGovPhoenix1 region for luke
RegionUSGovPhoenix1 Region = "us-gov-phoenix-1"
)
var realm = map[string]string{
"oc1": "oraclecloud.com",
"oc2": "oraclegovcloud.com",
"oc3": "oraclegovcloud.com",
}
var regionRealm = map[Region]string{
RegionPHX: "oc1",
RegionIAD: "oc1",
RegionFRA: "oc1",
RegionLHR: "oc1",
RegionCAToronto1: "oc1",
RegionUSLangley1: "oc2",
RegionUSLuke1: "oc2",
RegionUSGovAshburn1: "oc3",
RegionUSGovChicago1: "oc3",
RegionUSGovPhoenix1: "oc3",
}
// Endpoint returns a endpoint for a service
func (region Region) Endpoint(service string) string {
return fmt.Sprintf("%s.%s.%s", service, region, region.secondLevelDomain())
}
// EndpointForTemplate returns a endpoint for a service based on template
func (region Region) EndpointForTemplate(service string, serviceEndpointTemplate string) string {
if serviceEndpointTemplate == "" {
return region.Endpoint(service)
}
// replace service prefix
endpoint := strings.Replace(serviceEndpointTemplate, "{serviceEndpointPrefix}", service, 1)
// replace region
endpoint = strings.Replace(endpoint, "{region}", string(region), 1)
// replace second level domain
endpoint = strings.Replace(endpoint, "{secondLevelDomain}", region.secondLevelDomain(), 1)
return endpoint
}
func (region Region) secondLevelDomain() string {
if realmID, ok := regionRealm[region]; ok {
if secondLevelDomain, ok := realm[realmID]; ok {
return secondLevelDomain
}
}
Debugf("cannot find realm for region : %s, return default realm value.", region)
return realm["oc1"]
}
//StringToRegion convert a string to Region type
func StringToRegion(stringRegion string) (r Region) {
switch strings.ToLower(stringRegion) {
case "sea":
r = RegionSEA
case "ca-toronto-1":
r = RegionCAToronto1
case "phx", "us-phoenix-1":
r = RegionPHX
case "iad", "us-ashburn-1":
r = RegionIAD
case "fra", "eu-frankfurt-1":
r = RegionFRA
case "lhr", "uk-london-1":
r = RegionLHR
case "us-langley-1":
r = RegionUSLangley1
case "us-luke-1":
r = RegionUSLuke1
case "us-gov-ashburn-1":
r = RegionUSGovAshburn1
case "us-gov-chicago-1":
r = RegionUSGovChicago1
case "us-gov-phoenix-1":
r = RegionUSGovPhoenix1
default:
r = Region(stringRegion)
Debugf("region named: %s, is not recognized", stringRegion)
}
return
}
// canStringBeRegion test if the string can be a region, if it can, returns the string as is, otherwise it
// returns an error
var blankRegex = regexp.MustCompile("\\s")
func canStringBeRegion(stringRegion string) (region string, err error) {
if blankRegex.MatchString(stringRegion) || stringRegion == "" {
return "", fmt.Errorf("region can not be empty or have spaces")
}
return stringRegion, nil
}

View file

@ -0,0 +1,535 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
package common
import (
"crypto/rsa"
"errors"
"fmt"
"io/ioutil"
"os"
"path"
"regexp"
"strings"
)
// ConfigurationProvider wraps information about the account owner
type ConfigurationProvider interface {
KeyProvider
TenancyOCID() (string, error)
UserOCID() (string, error)
KeyFingerprint() (string, error)
Region() (string, error)
}
// IsConfigurationProviderValid Tests all parts of the configuration provider do not return an error
func IsConfigurationProviderValid(conf ConfigurationProvider) (ok bool, err error) {
baseFn := []func() (string, error){conf.TenancyOCID, conf.UserOCID, conf.KeyFingerprint, conf.Region, conf.KeyID}
for _, fn := range baseFn {
_, err = fn()
ok = err == nil
if err != nil {
return
}
}
_, err = conf.PrivateRSAKey()
ok = err == nil
if err != nil {
return
}
return true, nil
}
// rawConfigurationProvider allows a user to simply construct a configuration provider from raw values.
type rawConfigurationProvider struct {
tenancy string
user string
region string
fingerprint string
privateKey string
privateKeyPassphrase *string
}
// NewRawConfigurationProvider will create a rawConfigurationProvider
func NewRawConfigurationProvider(tenancy, user, region, fingerprint, privateKey string, privateKeyPassphrase *string) ConfigurationProvider {
return rawConfigurationProvider{tenancy, user, region, fingerprint, privateKey, privateKeyPassphrase}
}
func (p rawConfigurationProvider) PrivateRSAKey() (key *rsa.PrivateKey, err error) {
return PrivateKeyFromBytes([]byte(p.privateKey), p.privateKeyPassphrase)
}
func (p rawConfigurationProvider) KeyID() (keyID string, err error) {
tenancy, err := p.TenancyOCID()
if err != nil {
return
}
user, err := p.UserOCID()
if err != nil {
return
}
fingerprint, err := p.KeyFingerprint()
if err != nil {
return
}
return fmt.Sprintf("%s/%s/%s", tenancy, user, fingerprint), nil
}
func (p rawConfigurationProvider) TenancyOCID() (string, error) {
if p.tenancy == "" {
return "", fmt.Errorf("tenancy OCID can not be empty")
}
return p.tenancy, nil
}
func (p rawConfigurationProvider) UserOCID() (string, error) {
if p.user == "" {
return "", fmt.Errorf("user OCID can not be empty")
}
return p.user, nil
}
func (p rawConfigurationProvider) KeyFingerprint() (string, error) {
if p.fingerprint == "" {
return "", fmt.Errorf("fingerprint can not be empty")
}
return p.fingerprint, nil
}
func (p rawConfigurationProvider) Region() (string, error) {
return canStringBeRegion(p.region)
}
// environmentConfigurationProvider reads configuration from environment variables
type environmentConfigurationProvider struct {
PrivateKeyPassword string
EnvironmentVariablePrefix string
}
// ConfigurationProviderEnvironmentVariables creates a ConfigurationProvider from a uniform set of environment variables starting with a prefix
// The env variables should look like: [prefix]_private_key_path, [prefix]_tenancy_ocid, [prefix]_user_ocid, [prefix]_fingerprint
// [prefix]_region
func ConfigurationProviderEnvironmentVariables(environmentVariablePrefix, privateKeyPassword string) ConfigurationProvider {
return environmentConfigurationProvider{EnvironmentVariablePrefix: environmentVariablePrefix,
PrivateKeyPassword: privateKeyPassword}
}
func (p environmentConfigurationProvider) String() string {
return fmt.Sprintf("Configuration provided by environment variables prefixed with: %s", p.EnvironmentVariablePrefix)
}
func (p environmentConfigurationProvider) PrivateRSAKey() (key *rsa.PrivateKey, err error) {
environmentVariable := fmt.Sprintf("%s_%s", p.EnvironmentVariablePrefix, "private_key_path")
var ok bool
var value string
if value, ok = os.LookupEnv(environmentVariable); !ok {
return nil, fmt.Errorf("can not read PrivateKey from env variable: %s", environmentVariable)
}
expandedPath := expandPath(value)
pemFileContent, err := ioutil.ReadFile(expandedPath)
if err != nil {
Debugln("Can not read PrivateKey location from environment variable: " + environmentVariable)
return
}
key, err = PrivateKeyFromBytes(pemFileContent, &p.PrivateKeyPassword)
return
}
func (p environmentConfigurationProvider) KeyID() (keyID string, err error) {
ocid, err := p.TenancyOCID()
if err != nil {
return
}
userocid, err := p.UserOCID()
if err != nil {
return
}
fingerprint, err := p.KeyFingerprint()
if err != nil {
return
}
return fmt.Sprintf("%s/%s/%s", ocid, userocid, fingerprint), nil
}
func (p environmentConfigurationProvider) TenancyOCID() (value string, err error) {
environmentVariable := fmt.Sprintf("%s_%s", p.EnvironmentVariablePrefix, "tenancy_ocid")
var ok bool
if value, ok = os.LookupEnv(environmentVariable); !ok {
err = fmt.Errorf("can not read Tenancy from environment variable %s", environmentVariable)
}
return
}
func (p environmentConfigurationProvider) UserOCID() (value string, err error) {
environmentVariable := fmt.Sprintf("%s_%s", p.EnvironmentVariablePrefix, "user_ocid")
var ok bool
if value, ok = os.LookupEnv(environmentVariable); !ok {
err = fmt.Errorf("can not read user id from environment variable %s", environmentVariable)
}
return
}
func (p environmentConfigurationProvider) KeyFingerprint() (value string, err error) {
environmentVariable := fmt.Sprintf("%s_%s", p.EnvironmentVariablePrefix, "fingerprint")
var ok bool
if value, ok = os.LookupEnv(environmentVariable); !ok {
err = fmt.Errorf("can not read fingerprint from environment variable %s", environmentVariable)
}
return
}
func (p environmentConfigurationProvider) Region() (value string, err error) {
environmentVariable := fmt.Sprintf("%s_%s", p.EnvironmentVariablePrefix, "region")
var ok bool
if value, ok = os.LookupEnv(environmentVariable); !ok {
err = fmt.Errorf("can not read region from environment variable %s", environmentVariable)
return value, err
}
return canStringBeRegion(value)
}
// fileConfigurationProvider. reads configuration information from a file
type fileConfigurationProvider struct {
//The path to the configuration file
ConfigPath string
//The password for the private key
PrivateKeyPassword string
//The profile for the configuration
Profile string
//ConfigFileInfo
FileInfo *configFileInfo
}
// ConfigurationProviderFromFile creates a configuration provider from a configuration file
// by reading the "DEFAULT" profile
func ConfigurationProviderFromFile(configFilePath, privateKeyPassword string) (ConfigurationProvider, error) {
if configFilePath == "" {
return nil, fmt.Errorf("config file path can not be empty")
}
return fileConfigurationProvider{
ConfigPath: configFilePath,
PrivateKeyPassword: privateKeyPassword,
Profile: "DEFAULT"}, nil
}
// ConfigurationProviderFromFileWithProfile creates a configuration provider from a configuration file
// and the given profile
func ConfigurationProviderFromFileWithProfile(configFilePath, profile, privateKeyPassword string) (ConfigurationProvider, error) {
if configFilePath == "" {
return nil, fmt.Errorf("config file path can not be empty")
}
return fileConfigurationProvider{
ConfigPath: configFilePath,
PrivateKeyPassword: privateKeyPassword,
Profile: profile}, nil
}
type configFileInfo struct {
UserOcid, Fingerprint, KeyFilePath, TenancyOcid, Region, Passphrase string
PresentConfiguration byte
}
const (
hasTenancy = 1 << iota
hasUser
hasFingerprint
hasRegion
hasKeyFile
hasPassphrase
none
)
var profileRegex = regexp.MustCompile(`^\[(.*)\]`)
func parseConfigFile(data []byte, profile string) (info *configFileInfo, err error) {
if len(data) == 0 {
return nil, fmt.Errorf("configuration file content is empty")
}
content := string(data)
splitContent := strings.Split(content, "\n")
//Look for profile
for i, line := range splitContent {
if match := profileRegex.FindStringSubmatch(line); match != nil && len(match) > 1 && match[1] == profile {
start := i + 1
return parseConfigAtLine(start, splitContent)
}
}
return nil, fmt.Errorf("configuration file did not contain profile: %s", profile)
}
func parseConfigAtLine(start int, content []string) (info *configFileInfo, err error) {
var configurationPresent byte
info = &configFileInfo{}
for i := start; i < len(content); i++ {
line := content[i]
if profileRegex.MatchString(line) {
break
}
if !strings.Contains(line, "=") {
continue
}
splits := strings.Split(line, "=")
switch key, value := strings.TrimSpace(splits[0]), strings.TrimSpace(splits[1]); strings.ToLower(key) {
case "passphrase", "pass_phrase":
configurationPresent = configurationPresent | hasPassphrase
info.Passphrase = value
case "user":
configurationPresent = configurationPresent | hasUser
info.UserOcid = value
case "fingerprint":
configurationPresent = configurationPresent | hasFingerprint
info.Fingerprint = value
case "key_file":
configurationPresent = configurationPresent | hasKeyFile
info.KeyFilePath = value
case "tenancy":
configurationPresent = configurationPresent | hasTenancy
info.TenancyOcid = value
case "region":
configurationPresent = configurationPresent | hasRegion
info.Region = value
}
}
info.PresentConfiguration = configurationPresent
return
}
// cleans and expands the path if it contains a tilde , returns the expanded path or the input path as is if not expansion
// was performed
func expandPath(filepath string) (expandedPath string) {
cleanedPath := path.Clean(filepath)
expandedPath = cleanedPath
if strings.HasPrefix(cleanedPath, "~") {
rest := cleanedPath[2:]
expandedPath = path.Join(getHomeFolder(), rest)
}
return
}
func openConfigFile(configFilePath string) (data []byte, err error) {
expandedPath := expandPath(configFilePath)
data, err = ioutil.ReadFile(expandedPath)
if err != nil {
err = fmt.Errorf("can not read config file: %s due to: %s", configFilePath, err.Error())
}
return
}
func (p fileConfigurationProvider) String() string {
return fmt.Sprintf("Configuration provided by file: %s", p.ConfigPath)
}
func (p fileConfigurationProvider) readAndParseConfigFile() (info *configFileInfo, err error) {
if p.FileInfo != nil {
return p.FileInfo, nil
}
if p.ConfigPath == "" {
return nil, fmt.Errorf("configuration path can not be empty")
}
data, err := openConfigFile(p.ConfigPath)
if err != nil {
err = fmt.Errorf("error while parsing config file: %s. Due to: %s", p.ConfigPath, err.Error())
return
}
p.FileInfo, err = parseConfigFile(data, p.Profile)
return p.FileInfo, err
}
func presentOrError(value string, expectedConf, presentConf byte, confMissing string) (string, error) {
if presentConf&expectedConf == expectedConf {
return value, nil
}
return "", errors.New(confMissing + " configuration is missing from file")
}
func (p fileConfigurationProvider) TenancyOCID() (value string, err error) {
info, err := p.readAndParseConfigFile()
if err != nil {
err = fmt.Errorf("can not read tenancy configuration due to: %s", err.Error())
return
}
value, err = presentOrError(info.TenancyOcid, hasTenancy, info.PresentConfiguration, "tenancy")
return
}
func (p fileConfigurationProvider) UserOCID() (value string, err error) {
info, err := p.readAndParseConfigFile()
if err != nil {
err = fmt.Errorf("can not read tenancy configuration due to: %s", err.Error())
return
}
value, err = presentOrError(info.UserOcid, hasUser, info.PresentConfiguration, "user")
return
}
func (p fileConfigurationProvider) KeyFingerprint() (value string, err error) {
info, err := p.readAndParseConfigFile()
if err != nil {
err = fmt.Errorf("can not read tenancy configuration due to: %s", err.Error())
return
}
value, err = presentOrError(info.Fingerprint, hasFingerprint, info.PresentConfiguration, "fingerprint")
return
}
func (p fileConfigurationProvider) KeyID() (keyID string, err error) {
info, err := p.readAndParseConfigFile()
if err != nil {
err = fmt.Errorf("can not read tenancy configuration due to: %s", err.Error())
return
}
return fmt.Sprintf("%s/%s/%s", info.TenancyOcid, info.UserOcid, info.Fingerprint), nil
}
func (p fileConfigurationProvider) PrivateRSAKey() (key *rsa.PrivateKey, err error) {
info, err := p.readAndParseConfigFile()
if err != nil {
err = fmt.Errorf("can not read tenancy configuration due to: %s", err.Error())
return
}
filePath, err := presentOrError(info.KeyFilePath, hasKeyFile, info.PresentConfiguration, "key file path")
if err != nil {
return
}
expandedPath := expandPath(filePath)
pemFileContent, err := ioutil.ReadFile(expandedPath)
if err != nil {
err = fmt.Errorf("can not read PrivateKey from configuration file due to: %s", err.Error())
return
}
password := p.PrivateKeyPassword
if password == "" && ((info.PresentConfiguration & hasPassphrase) == hasPassphrase) {
password = info.Passphrase
}
key, err = PrivateKeyFromBytes(pemFileContent, &password)
return
}
func (p fileConfigurationProvider) Region() (value string, err error) {
info, err := p.readAndParseConfigFile()
if err != nil {
err = fmt.Errorf("can not read region configuration due to: %s", err.Error())
return
}
value, err = presentOrError(info.Region, hasRegion, info.PresentConfiguration, "region")
if err != nil {
return
}
return canStringBeRegion(value)
}
// A configuration provider that look for information in multiple configuration providers
type composingConfigurationProvider struct {
Providers []ConfigurationProvider
}
// ComposingConfigurationProvider creates a composing configuration provider with the given slice of configuration providers
// A composing provider will return the configuration of the first provider that has the required property
// if no provider has the property it will return an error.
func ComposingConfigurationProvider(providers []ConfigurationProvider) (ConfigurationProvider, error) {
if len(providers) == 0 {
return nil, fmt.Errorf("providers can not be an empty slice")
}
for i, p := range providers {
if p == nil {
return nil, fmt.Errorf("provider in position: %d is nil. ComposingConfiurationProvider does not support nil values", i)
}
}
return composingConfigurationProvider{Providers: providers}, nil
}
func (c composingConfigurationProvider) TenancyOCID() (string, error) {
for _, p := range c.Providers {
val, err := p.TenancyOCID()
if err == nil {
return val, nil
}
}
return "", fmt.Errorf("did not find a proper configuration for tenancy")
}
func (c composingConfigurationProvider) UserOCID() (string, error) {
for _, p := range c.Providers {
val, err := p.UserOCID()
if err == nil {
return val, nil
}
}
return "", fmt.Errorf("did not find a proper configuration for user")
}
func (c composingConfigurationProvider) KeyFingerprint() (string, error) {
for _, p := range c.Providers {
val, err := p.KeyFingerprint()
if err == nil {
return val, nil
}
}
return "", fmt.Errorf("did not find a proper configuration for keyFingerprint")
}
func (c composingConfigurationProvider) Region() (string, error) {
for _, p := range c.Providers {
val, err := p.Region()
if err == nil {
return val, nil
}
}
return "", fmt.Errorf("did not find a proper configuration for region")
}
func (c composingConfigurationProvider) KeyID() (string, error) {
for _, p := range c.Providers {
val, err := p.KeyID()
if err == nil {
return val, nil
}
}
return "", fmt.Errorf("did not find a proper configuration for key id")
}
func (c composingConfigurationProvider) PrivateRSAKey() (*rsa.PrivateKey, error) {
for _, p := range c.Providers {
val, err := p.PrivateRSAKey()
if err == nil {
return val, nil
}
}
return nil, fmt.Errorf("did not find a proper configuration for private key")
}

98
vendor/github.com/oracle/oci-go-sdk/common/errors.go generated vendored Normal file
View file

@ -0,0 +1,98 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
package common
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
// ServiceError models all potential errors generated the service call
type ServiceError interface {
// The http status code of the error
GetHTTPStatusCode() int
// The human-readable error string as sent by the service
GetMessage() string
// A short error code that defines the error, meant for programmatic parsing.
// See https://docs.us-phoenix-1.oraclecloud.com/Content/API/References/apierrors.htm
GetCode() string
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
GetOpcRequestID() string
}
type servicefailure struct {
StatusCode int
Code string `json:"code,omitempty"`
Message string `json:"message,omitempty"`
OpcRequestID string `json:"opc-request-id"`
}
func newServiceFailureFromResponse(response *http.Response) error {
var err error
se := servicefailure{
StatusCode: response.StatusCode,
Code: "BadErrorResponse",
OpcRequestID: response.Header.Get("opc-request-id")}
//If there is an error consume the body, entirely
body, err := ioutil.ReadAll(response.Body)
if err != nil {
se.Message = fmt.Sprintf("The body of the response was not readable, due to :%s", err.Error())
return se
}
err = json.Unmarshal(body, &se)
if err != nil {
Debugf("Error response could not be parsed due to: %s", err.Error())
se.Message = fmt.Sprintf("Failed to parse json from response body due to: %s. With response body %s.", err.Error(), string(body[:]))
return se
}
return se
}
func (se servicefailure) Error() string {
return fmt.Sprintf("Service error:%s. %s. http status code: %d. Opc request id: %s",
se.Code, se.Message, se.StatusCode, se.OpcRequestID)
}
func (se servicefailure) GetHTTPStatusCode() int {
return se.StatusCode
}
func (se servicefailure) GetMessage() string {
return se.Message
}
func (se servicefailure) GetCode() string {
return se.Code
}
func (se servicefailure) GetOpcRequestID() string {
return se.OpcRequestID
}
// IsServiceError returns false if the error is not service side, otherwise true
// additionally it returns an interface representing the ServiceError
func IsServiceError(err error) (failure ServiceError, ok bool) {
failure, ok = err.(servicefailure)
return
}
type deadlineExceededByBackoffError struct{}
func (deadlineExceededByBackoffError) Error() string {
return "now() + computed backoff duration exceeds request deadline"
}
// DeadlineExceededByBackoff is the error returned by Call() when GetNextDuration() returns a time.Duration that would
// force the user to wait past the request deadline before re-issuing a request. This enables us to exit early, since
// we cannot succeed based on the configured retry policy.
var DeadlineExceededByBackoff error = deadlineExceededByBackoffError{}

245
vendor/github.com/oracle/oci-go-sdk/common/helpers.go generated vendored Normal file
View file

@ -0,0 +1,245 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
package common
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"fmt"
"reflect"
"strconv"
"strings"
"time"
)
// String returns a pointer to the provided string
func String(value string) *string {
return &value
}
// Int returns a pointer to the provided int
func Int(value int) *int {
return &value
}
// Int64 returns a pointer to the provided int64
func Int64(value int64) *int64 {
return &value
}
// Uint returns a pointer to the provided uint
func Uint(value uint) *uint {
return &value
}
//Float32 returns a pointer to the provided float32
func Float32(value float32) *float32 {
return &value
}
//Float64 returns a pointer to the provided float64
func Float64(value float64) *float64 {
return &value
}
//Bool returns a pointer to the provided bool
func Bool(value bool) *bool {
return &value
}
//PointerString prints the values of pointers in a struct
//Producing a human friendly string for an struct with pointers.
//useful when debugging the values of a struct
func PointerString(datastruct interface{}) (representation string) {
val := reflect.ValueOf(datastruct)
typ := reflect.TypeOf(datastruct)
all := make([]string, 2)
all = append(all, "{")
for i := 0; i < typ.NumField(); i++ {
sf := typ.Field(i)
//unexported
if sf.PkgPath != "" && !sf.Anonymous {
continue
}
sv := val.Field(i)
stringValue := ""
if isNil(sv) {
stringValue = fmt.Sprintf("%s=<nil>", sf.Name)
} else {
if sv.Type().Kind() == reflect.Ptr {
sv = sv.Elem()
}
stringValue = fmt.Sprintf("%s=%v", sf.Name, sv)
}
all = append(all, stringValue)
}
all = append(all, "}")
representation = strings.TrimSpace(strings.Join(all, " "))
return
}
// SDKTime a struct that parses/renders to/from json using RFC339 date-time information
type SDKTime struct {
time.Time
}
// SDKDate a struct that parses/renders to/from json using only date information
type SDKDate struct {
//Date date information
Date time.Time
}
func sdkTimeFromTime(t time.Time) SDKTime {
return SDKTime{t}
}
func sdkDateFromTime(t time.Time) SDKDate {
return SDKDate{Date: t}
}
func formatTime(t SDKTime) string {
return t.Format(sdkTimeFormat)
}
func formatDate(t SDKDate) string {
return t.Date.Format(sdkDateFormat)
}
func now() *SDKTime {
t := SDKTime{time.Now()}
return &t
}
var timeType = reflect.TypeOf(SDKTime{})
var timeTypePtr = reflect.TypeOf(&SDKTime{})
var sdkDateType = reflect.TypeOf(SDKDate{})
var sdkDateTypePtr = reflect.TypeOf(&SDKDate{})
//Formats for sdk supported time representations
const sdkTimeFormat = time.RFC3339Nano
const rfc1123OptionalLeadingDigitsInDay = "Mon, _2 Jan 2006 15:04:05 MST"
const sdkDateFormat = "2006-01-02"
func tryParsingTimeWithValidFormatsForHeaders(data []byte, headerName string) (t time.Time, err error) {
header := strings.ToLower(headerName)
switch header {
case "lastmodified", "date":
t, err = tryParsing(data, time.RFC3339Nano, time.RFC3339, time.RFC1123, rfc1123OptionalLeadingDigitsInDay, time.RFC850, time.ANSIC)
return
default: //By default we parse with RFC3339
t, err = time.Parse(sdkTimeFormat, string(data))
return
}
}
func tryParsing(data []byte, layouts ...string) (tm time.Time, err error) {
datestring := string(data)
for _, l := range layouts {
tm, err = time.Parse(l, datestring)
if err == nil {
return
}
}
err = fmt.Errorf("Could not parse time: %s with formats: %s", datestring, layouts[:])
return
}
// String returns string representation of SDKDate
func (t *SDKDate) String() string {
return t.Date.Format(sdkDateFormat)
}
// NewSDKDateFromString parses the dateString into SDKDate
func NewSDKDateFromString(dateString string) (*SDKDate, error) {
parsedTime, err := time.Parse(sdkDateFormat, dateString)
if err != nil {
return nil, err
}
return &SDKDate{Date: parsedTime}, nil
}
// UnmarshalJSON unmarshals from json
func (t *SDKTime) UnmarshalJSON(data []byte) (e error) {
s := string(data)
if s == "null" {
t.Time = time.Time{}
} else {
//Try parsing with RFC3339
t.Time, e = time.Parse(`"`+sdkTimeFormat+`"`, string(data))
}
return
}
// MarshalJSON marshals to JSON
func (t *SDKTime) MarshalJSON() (buff []byte, e error) {
s := t.Format(sdkTimeFormat)
buff = []byte(`"` + s + `"`)
return
}
// UnmarshalJSON unmarshals from json
func (t *SDKDate) UnmarshalJSON(data []byte) (e error) {
if string(data) == `"null"` {
t.Date = time.Time{}
return
}
t.Date, e = tryParsing(data,
strconv.Quote(sdkDateFormat),
)
return
}
// MarshalJSON marshals to JSON
func (t *SDKDate) MarshalJSON() (buff []byte, e error) {
s := t.Date.Format(sdkDateFormat)
buff = []byte(strconv.Quote(s))
return
}
// PrivateKeyFromBytes is a helper function that will produce a RSA private
// key from bytes.
func PrivateKeyFromBytes(pemData []byte, password *string) (key *rsa.PrivateKey, e error) {
if pemBlock, _ := pem.Decode(pemData); pemBlock != nil {
decrypted := pemBlock.Bytes
if x509.IsEncryptedPEMBlock(pemBlock) {
if password == nil {
e = fmt.Errorf("private_key_password is required for encrypted private keys")
return
}
if decrypted, e = x509.DecryptPEMBlock(pemBlock, []byte(*password)); e != nil {
return
}
}
key, e = x509.ParsePKCS1PrivateKey(decrypted)
} else {
e = fmt.Errorf("PEM data was not found in buffer")
return
}
return
}
func generateRandUUID() (string, error) {
b := make([]byte, 16)
_, err := rand.Read(b)
if err != nil {
return "", err
}
uuid := fmt.Sprintf("%x%x%x%x%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:])
return uuid, nil
}
func makeACopy(original []string) []string {
tmp := make([]string, len(original))
copy(tmp, original)
return tmp
}

961
vendor/github.com/oracle/oci-go-sdk/common/http.go generated vendored Normal file
View file

@ -0,0 +1,961 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
package common
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"reflect"
"regexp"
"strconv"
"strings"
"time"
)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Request Marshaling
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
func isNil(v reflect.Value) bool {
return v.Kind() == reflect.Ptr && v.IsNil()
}
// Returns the string representation of a reflect.Value
// Only transforms primitive values
func toStringValue(v reflect.Value, field reflect.StructField) (string, error) {
if v.Kind() == reflect.Ptr {
if v.IsNil() {
return "", fmt.Errorf("can not marshal a nil pointer")
}
v = v.Elem()
}
if v.Type() == timeType {
t := v.Interface().(SDKTime)
return formatTime(t), nil
}
if v.Type() == sdkDateType {
t := v.Interface().(SDKDate)
return formatDate(t), nil
}
switch v.Kind() {
case reflect.Bool:
return strconv.FormatBool(v.Bool()), nil
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return strconv.FormatInt(v.Int(), 10), nil
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
return strconv.FormatUint(v.Uint(), 10), nil
case reflect.String:
return v.String(), nil
case reflect.Float32:
return strconv.FormatFloat(v.Float(), 'f', 6, 32), nil
case reflect.Float64:
return strconv.FormatFloat(v.Float(), 'f', 6, 64), nil
default:
return "", fmt.Errorf("marshaling structure to a http.Request does not support field named: %s of type: %v",
field.Name, v.Type().String())
}
}
func addBinaryBody(request *http.Request, value reflect.Value) (e error) {
readCloser, ok := value.Interface().(io.ReadCloser)
if !ok {
e = fmt.Errorf("body of the request needs to be an io.ReadCloser interface. Can not marshal body of binary request")
return
}
request.Body = readCloser
//Set the default content type to application/octet-stream if not set
if request.Header.Get(requestHeaderContentType) == "" {
request.Header.Set(requestHeaderContentType, "application/octet-stream")
}
return nil
}
// getTaggedNilFieldNameOrError, evaluates if a field with json and non mandatory tags is nil
// returns the json tag name, or an error if the tags are incorrectly present
func getTaggedNilFieldNameOrError(field reflect.StructField, fieldValue reflect.Value) (bool, string, error) {
currentTag := field.Tag
jsonTag := currentTag.Get("json")
if jsonTag == "" {
return false, "", fmt.Errorf("json tag is not valid for field %s", field.Name)
}
partsJSONTag := strings.Split(jsonTag, ",")
nameJSONField := partsJSONTag[0]
if _, ok := currentTag.Lookup("mandatory"); !ok {
//No mandatory field set, no-op
return false, nameJSONField, nil
}
isMandatory, err := strconv.ParseBool(currentTag.Get("mandatory"))
if err != nil {
return false, "", fmt.Errorf("mandatory tag is not valid for field %s", field.Name)
}
// If the field is marked as mandatory, no-op
if isMandatory {
return false, nameJSONField, nil
}
Debugf("Adjusting tag: mandatory is false and json tag is valid on field: %s", field.Name)
// If the field can not be nil, then no-op
if !isNillableType(&fieldValue) {
Debugf("WARNING json field is tagged with mandatory flags, but the type can not be nil, field name: %s", field.Name)
return false, nameJSONField, nil
}
// If field value is nil, tag it as omitEmpty
return fieldValue.IsNil(), nameJSONField, nil
}
// isNillableType returns true if the filed can be nil
func isNillableType(value *reflect.Value) bool {
k := value.Kind()
switch k {
case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.Interface, reflect.Slice:
return true
}
return false
}
// omitNilFieldsInJSON, removes json keys whose struct value is nil, and the field is tagged with the json and
// mandatory:false tags
func omitNilFieldsInJSON(data interface{}, value reflect.Value) (interface{}, error) {
switch value.Kind() {
case reflect.Struct:
jsonMap := data.(map[string]interface{})
fieldType := value.Type()
for i := 0; i < fieldType.NumField(); i++ {
currentField := fieldType.Field(i)
//unexported skip
if currentField.PkgPath != "" {
continue
}
//Does not have json tag, no-op
if _, ok := currentField.Tag.Lookup("json"); !ok {
continue
}
currentFieldValue := value.Field(i)
ok, jsonFieldName, err := getTaggedNilFieldNameOrError(currentField, currentFieldValue)
if err != nil {
return nil, fmt.Errorf("can not omit nil fields for field: %s, due to: %s",
currentField.Name, err.Error())
}
//Delete the struct field from the json representation
if ok {
delete(jsonMap, jsonFieldName)
continue
}
// Check to make sure the field is part of the json representation of the value
if _, contains := jsonMap[jsonFieldName]; !contains {
Debugf("Field %s is not present in json, omitting", jsonFieldName)
continue
}
if currentFieldValue.Type() == timeType || currentFieldValue.Type() == timeTypePtr ||
currentField.Type == sdkDateType || currentField.Type == sdkDateTypePtr {
continue
}
// does it need to be adjusted?
var adjustedValue interface{}
adjustedValue, err = omitNilFieldsInJSON(jsonMap[jsonFieldName], currentFieldValue)
if err != nil {
return nil, fmt.Errorf("can not omit nil fields for field: %s, due to: %s",
currentField.Name, err.Error())
}
jsonMap[jsonFieldName] = adjustedValue
}
return jsonMap, nil
case reflect.Slice, reflect.Array:
// Special case: a []byte may have been marshalled as a string
if data != nil && reflect.TypeOf(data).Kind() == reflect.String && value.Type().Elem().Kind() == reflect.Uint8 {
return data, nil
}
jsonList, ok := data.([]interface{})
if !ok {
return nil, fmt.Errorf("can not omit nil fields, data was expected to be a not-nil list")
}
newList := make([]interface{}, len(jsonList))
var err error
for i, val := range jsonList {
newList[i], err = omitNilFieldsInJSON(val, value.Index(i))
if err != nil {
return nil, err
}
}
return newList, nil
case reflect.Map:
jsonMap, ok := data.(map[string]interface{})
if !ok {
return nil, fmt.Errorf("can not omit nil fields, data was expected to be a not-nil map")
}
newMap := make(map[string]interface{}, len(jsonMap))
var err error
for key, val := range jsonMap {
newMap[key], err = omitNilFieldsInJSON(val, value.MapIndex(reflect.ValueOf(key)))
if err != nil {
return nil, err
}
}
return newMap, nil
case reflect.Ptr, reflect.Interface:
valPtr := value.Elem()
return omitNilFieldsInJSON(data, valPtr)
default:
//Otherwise no-op
return data, nil
}
}
// removeNilFieldsInJSONWithTaggedStruct remove struct fields tagged with json and mandatory false
// that are nil
func removeNilFieldsInJSONWithTaggedStruct(rawJSON []byte, value reflect.Value) ([]byte, error) {
var rawInterface interface{}
decoder := json.NewDecoder(bytes.NewBuffer(rawJSON))
decoder.UseNumber()
var err error
if err = decoder.Decode(&rawInterface); err != nil {
return nil, err
}
fixedMap, err := omitNilFieldsInJSON(rawInterface, value)
if err != nil {
return nil, err
}
return json.Marshal(fixedMap)
}
func addToBody(request *http.Request, value reflect.Value, field reflect.StructField) (e error) {
Debugln("Marshaling to body from field:", field.Name)
if request.Body != nil {
Logf("The body of the request is already set. Structure: %s will overwrite it\n", field.Name)
}
tag := field.Tag
encoding := tag.Get("encoding")
if encoding == "binary" {
return addBinaryBody(request, value)
}
rawJSON, e := json.Marshal(value.Interface())
if e != nil {
return
}
marshaled, e := removeNilFieldsInJSONWithTaggedStruct(rawJSON, value)
if e != nil {
return
}
bodyBytes := bytes.NewReader(marshaled)
request.ContentLength = int64(bodyBytes.Len())
request.Header.Set(requestHeaderContentLength, strconv.FormatInt(request.ContentLength, 10))
request.Header.Set(requestHeaderContentType, "application/json")
request.Body = ioutil.NopCloser(bodyBytes)
request.GetBody = func() (io.ReadCloser, error) {
return ioutil.NopCloser(bodyBytes), nil
}
return
}
func addToQuery(request *http.Request, value reflect.Value, field reflect.StructField) (e error) {
Debugln("Marshaling to query from field: ", field.Name)
if request.URL == nil {
request.URL = &url.URL{}
}
query := request.URL.Query()
var queryParameterValue, queryParameterName string
if queryParameterName = field.Tag.Get("name"); queryParameterName == "" {
return fmt.Errorf("marshaling request to a query requires the 'name' tag for field: %s ", field.Name)
}
mandatory, _ := strconv.ParseBool(strings.ToLower(field.Tag.Get("mandatory")))
//If mandatory and nil. Error out
if mandatory && isNil(value) {
return fmt.Errorf("marshaling request to a header requires not nil pointer for field: %s", field.Name)
}
//if not mandatory and nil. Omit
if !mandatory && isNil(value) {
Debugf("Query parameter value is not mandatory and is nil pointer in field: %s. Skipping query", field.Name)
return
}
encoding := strings.ToLower(field.Tag.Get("collectionFormat"))
var collectionFormatStringValues []string
switch encoding {
case "csv", "multi":
if value.Kind() != reflect.Slice && value.Kind() != reflect.Array {
e = fmt.Errorf("query parameter is tagged as csv or multi yet its type is neither an Array nor a Slice: %s", field.Name)
break
}
numOfElements := value.Len()
collectionFormatStringValues = make([]string, numOfElements)
for i := 0; i < numOfElements; i++ {
collectionFormatStringValues[i], e = toStringValue(value.Index(i), field)
if e != nil {
break
}
}
queryParameterValue = strings.Join(collectionFormatStringValues, ",")
case "":
queryParameterValue, e = toStringValue(value, field)
default:
e = fmt.Errorf("encoding of type %s is not supported for query param: %s", encoding, field.Name)
}
if e != nil {
return
}
//check for tag "omitEmpty", this is done to accomodate unset fields that do not
//support an empty string: enums in query params
if omitEmpty, present := field.Tag.Lookup("omitEmpty"); present {
omitEmptyBool, _ := strconv.ParseBool(strings.ToLower(omitEmpty))
if queryParameterValue != "" || !omitEmptyBool {
addToQueryForEncoding(&query, encoding, queryParameterName, queryParameterValue, collectionFormatStringValues)
} else {
Debugf("Omitting %s, is empty and omitEmpty tag is set", field.Name)
}
} else {
addToQueryForEncoding(&query, encoding, queryParameterName, queryParameterValue, collectionFormatStringValues)
}
request.URL.RawQuery = query.Encode()
return
}
func addToQueryForEncoding(query *url.Values, encoding string, queryParameterName string, queryParameterValue string, collectionFormatStringValues []string) {
if encoding == "multi" {
for _, stringValue := range collectionFormatStringValues {
query.Add(queryParameterName, stringValue)
}
} else {
query.Set(queryParameterName, queryParameterValue)
}
}
// Adds to the path of the url in the order they appear in the structure
func addToPath(request *http.Request, value reflect.Value, field reflect.StructField) (e error) {
var additionalURLPathPart string
if additionalURLPathPart, e = toStringValue(value, field); e != nil {
return fmt.Errorf("can not marshal to path in request for field %s. Due to %s", field.Name, e.Error())
}
// path should not be empty for any operations
if len(additionalURLPathPart) == 0 {
return fmt.Errorf("value cannot be empty for field %s in path", field.Name)
}
if request.URL == nil {
request.URL = &url.URL{}
request.URL.Path = ""
}
var currentURLPath = request.URL.Path
var templatedPathRegex, _ = regexp.Compile(".*{.+}.*")
if !templatedPathRegex.MatchString(currentURLPath) {
Debugln("Marshaling request to path by appending field:", field.Name)
allPath := []string{currentURLPath, additionalURLPathPart}
request.URL.Path = strings.Join(allPath, "/")
} else {
var fieldName string
if fieldName = field.Tag.Get("name"); fieldName == "" {
e = fmt.Errorf("marshaling request to path name and template requires a 'name' tag for field: %s", field.Name)
return
}
urlTemplate := currentURLPath
Debugln("Marshaling to path from field: ", field.Name, " in template: ", urlTemplate)
request.URL.Path = strings.Replace(urlTemplate, "{"+fieldName+"}", additionalURLPathPart, -1)
}
return
}
func setWellKnownHeaders(request *http.Request, headerName, headerValue string) (e error) {
switch strings.ToLower(headerName) {
case "content-length":
var len int
len, e = strconv.Atoi(headerValue)
if e != nil {
return
}
request.ContentLength = int64(len)
}
return nil
}
func addToHeader(request *http.Request, value reflect.Value, field reflect.StructField) (e error) {
Debugln("Marshaling to header from field: ", field.Name)
if request.Header == nil {
request.Header = http.Header{}
}
var headerName, headerValue string
if headerName = field.Tag.Get("name"); headerName == "" {
return fmt.Errorf("marshaling request to a header requires the 'name' tag for field: %s", field.Name)
}
mandatory, _ := strconv.ParseBool(strings.ToLower(field.Tag.Get("mandatory")))
//If mandatory and nil. Error out
if mandatory && isNil(value) {
return fmt.Errorf("marshaling request to a header requires not nil pointer for field: %s", field.Name)
}
// generate opc-request-id if header value is nil and header name matches
value = generateOpcRequestID(headerName, value)
//if not mandatory and nil. Omit
if !mandatory && isNil(value) {
Debugf("Header value is not mandatory and is nil pointer in field: %s. Skipping header", field.Name)
return
}
//Otherwise get value and set header
if headerValue, e = toStringValue(value, field); e != nil {
return
}
if e = setWellKnownHeaders(request, headerName, headerValue); e != nil {
return
}
request.Header.Add(headerName, headerValue)
return
}
// Header collection is a map of string to string that gets rendered as individual headers with a given prefix
func addToHeaderCollection(request *http.Request, value reflect.Value, field reflect.StructField) (e error) {
Debugln("Marshaling to header-collection from field:", field.Name)
if request.Header == nil {
request.Header = http.Header{}
}
var headerPrefix string
if headerPrefix = field.Tag.Get("prefix"); headerPrefix == "" {
return fmt.Errorf("marshaling request to a header requires the 'prefix' tag for field: %s", field.Name)
}
mandatory, _ := strconv.ParseBool(strings.ToLower(field.Tag.Get("mandatory")))
//If mandatory and nil. Error out
if mandatory && isNil(value) {
return fmt.Errorf("marshaling request to a header requires not nil pointer for field: %s", field.Name)
}
//if not mandatory and nil. Omit
if !mandatory && isNil(value) {
Debugf("Header value is not mandatory and is nil pointer in field: %s. Skipping header", field.Name)
return
}
//cast to map
headerValues, ok := value.Interface().(map[string]string)
if !ok {
e = fmt.Errorf("header fields need to be of type map[string]string")
return
}
for k, v := range headerValues {
headerName := fmt.Sprintf("%s%s", headerPrefix, k)
request.Header.Set(headerName, v)
}
return
}
// Makes sure the incoming structure is able to be marshalled
// to a request
func checkForValidRequestStruct(s interface{}) (*reflect.Value, error) {
val := reflect.ValueOf(s)
for val.Kind() == reflect.Ptr {
if val.IsNil() {
return nil, fmt.Errorf("can not marshal to request a pointer to structure")
}
val = val.Elem()
}
if s == nil {
return nil, fmt.Errorf("can not marshal to request a nil structure")
}
if val.Kind() != reflect.Struct {
return nil, fmt.Errorf("can not marshal to request, expects struct input. Got %v", val.Kind())
}
return &val, nil
}
// Populates the parts of a request by reading tags in the passed structure
// nested structs are followed recursively depth-first.
func structToRequestPart(request *http.Request, val reflect.Value) (err error) {
typ := val.Type()
for i := 0; i < typ.NumField(); i++ {
if err != nil {
return
}
sf := typ.Field(i)
//unexported
if sf.PkgPath != "" && !sf.Anonymous {
continue
}
sv := val.Field(i)
tag := sf.Tag.Get("contributesTo")
switch tag {
case "header":
err = addToHeader(request, sv, sf)
case "header-collection":
err = addToHeaderCollection(request, sv, sf)
case "path":
err = addToPath(request, sv, sf)
case "query":
err = addToQuery(request, sv, sf)
case "body":
err = addToBody(request, sv, sf)
case "":
Debugln(sf.Name, " does not contain contributes tag. Skipping.")
default:
err = fmt.Errorf("can not marshal field: %s. It needs to contain valid contributesTo tag", sf.Name)
}
}
//If headers are and the content type was not set, we default to application/json
if request.Header != nil && request.Header.Get(requestHeaderContentType) == "" {
request.Header.Set(requestHeaderContentType, "application/json")
}
return
}
// HTTPRequestMarshaller marshals a structure to an http request using tag values in the struct
// The marshaller tag should like the following
// type A struct {
// ANumber string `contributesTo="query" name="number"`
// TheBody `contributesTo="body"`
// }
// where the contributesTo tag can be: header, path, query, body
// and the 'name' tag is the name of the value used in the http request(not applicable for path)
// If path is specified as part of the tag, the values are appened to the url path
// in the order they appear in the structure
// The current implementation only supports primitive types, except for the body tag, which needs a struct type.
// The body of a request will be marshaled using the tags of the structure
func HTTPRequestMarshaller(requestStruct interface{}, httpRequest *http.Request) (err error) {
var val *reflect.Value
if val, err = checkForValidRequestStruct(requestStruct); err != nil {
return
}
Debugln("Marshaling to Request: ", val.Type().Name())
err = structToRequestPart(httpRequest, *val)
return
}
// MakeDefaultHTTPRequest creates the basic http request with the necessary headers set
func MakeDefaultHTTPRequest(method, path string) (httpRequest http.Request) {
httpRequest = http.Request{
Proto: "HTTP/1.1",
ProtoMajor: 1,
ProtoMinor: 1,
Header: make(http.Header),
URL: &url.URL{},
}
httpRequest.Header.Set(requestHeaderContentLength, "0")
httpRequest.Header.Set(requestHeaderDate, time.Now().UTC().Format(http.TimeFormat))
httpRequest.Header.Set(requestHeaderOpcClientInfo, strings.Join([]string{defaultSDKMarker, Version()}, "/"))
httpRequest.Header.Set(requestHeaderAccept, "*/*")
httpRequest.Method = method
httpRequest.URL.Path = path
return
}
// MakeDefaultHTTPRequestWithTaggedStruct creates an http request from an struct with tagged fields, see HTTPRequestMarshaller
// for more information
func MakeDefaultHTTPRequestWithTaggedStruct(method, path string, requestStruct interface{}) (httpRequest http.Request, err error) {
httpRequest = MakeDefaultHTTPRequest(method, path)
err = HTTPRequestMarshaller(requestStruct, &httpRequest)
return
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Request UnMarshaling
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Makes sure the incoming structure is able to be unmarshaled
// to a request
func checkForValidResponseStruct(s interface{}) (*reflect.Value, error) {
val := reflect.ValueOf(s)
for val.Kind() == reflect.Ptr {
if val.IsNil() {
return nil, fmt.Errorf("can not unmarshal to response a pointer to nil structure")
}
val = val.Elem()
}
if s == nil {
return nil, fmt.Errorf("can not unmarshal to response a nil structure")
}
if val.Kind() != reflect.Struct {
return nil, fmt.Errorf("can not unmarshal to response, expects struct input. Got %v", val.Kind())
}
return &val, nil
}
func intSizeFromKind(kind reflect.Kind) int {
switch kind {
case reflect.Int8, reflect.Uint8:
return 8
case reflect.Int16, reflect.Uint16:
return 16
case reflect.Int32, reflect.Uint32:
return 32
case reflect.Int64, reflect.Uint64:
return 64
case reflect.Int, reflect.Uint:
return strconv.IntSize
default:
Debugf("The type is not valid: %v. Returing int size for arch\n", kind.String())
return strconv.IntSize
}
}
func analyzeValue(stringValue string, kind reflect.Kind, field reflect.StructField) (val reflect.Value, valPointer reflect.Value, err error) {
switch kind {
case timeType.Kind():
var t time.Time
t, err = tryParsingTimeWithValidFormatsForHeaders([]byte(stringValue), field.Name)
if err != nil {
return
}
sdkTime := sdkTimeFromTime(t)
val = reflect.ValueOf(sdkTime)
valPointer = reflect.ValueOf(&sdkTime)
return
case sdkDateType.Kind():
var t time.Time
t, err = tryParsingTimeWithValidFormatsForHeaders([]byte(stringValue), field.Name)
if err != nil {
return
}
sdkDate := sdkDateFromTime(t)
val = reflect.ValueOf(sdkDate)
valPointer = reflect.ValueOf(&sdkDate)
return
case reflect.Bool:
var bVal bool
if bVal, err = strconv.ParseBool(stringValue); err != nil {
return
}
val = reflect.ValueOf(bVal)
valPointer = reflect.ValueOf(&bVal)
return
case reflect.Int:
size := intSizeFromKind(kind)
var iVal int64
if iVal, err = strconv.ParseInt(stringValue, 10, size); err != nil {
return
}
var iiVal int
iiVal = int(iVal)
val = reflect.ValueOf(iiVal)
valPointer = reflect.ValueOf(&iiVal)
return
case reflect.Int64:
size := intSizeFromKind(kind)
var iVal int64
if iVal, err = strconv.ParseInt(stringValue, 10, size); err != nil {
return
}
val = reflect.ValueOf(iVal)
valPointer = reflect.ValueOf(&iVal)
return
case reflect.Uint:
size := intSizeFromKind(kind)
var iVal uint64
if iVal, err = strconv.ParseUint(stringValue, 10, size); err != nil {
return
}
var uiVal uint
uiVal = uint(iVal)
val = reflect.ValueOf(uiVal)
valPointer = reflect.ValueOf(&uiVal)
return
case reflect.String:
val = reflect.ValueOf(stringValue)
valPointer = reflect.ValueOf(&stringValue)
case reflect.Float32:
var fVal float64
if fVal, err = strconv.ParseFloat(stringValue, 32); err != nil {
return
}
var ffVal float32
ffVal = float32(fVal)
val = reflect.ValueOf(ffVal)
valPointer = reflect.ValueOf(&ffVal)
return
case reflect.Float64:
var fVal float64
if fVal, err = strconv.ParseFloat(stringValue, 64); err != nil {
return
}
val = reflect.ValueOf(fVal)
valPointer = reflect.ValueOf(&fVal)
return
default:
err = fmt.Errorf("value for kind: %s not supported", kind)
}
return
}
// Sets the field of a struct, with the appropiate value of the string
// Only sets basic types
func fromStringValue(newValue string, val *reflect.Value, field reflect.StructField) (err error) {
if !val.CanSet() {
err = fmt.Errorf("can not set field name: %s of type: %v", field.Name, val.Type().String())
return
}
kind := val.Kind()
isPointer := false
if val.Kind() == reflect.Ptr {
isPointer = true
kind = field.Type.Elem().Kind()
}
value, valPtr, err := analyzeValue(newValue, kind, field)
if err != nil {
return
}
if !isPointer {
val.Set(value)
} else {
val.Set(valPtr)
}
return
}
// PolymorphicJSONUnmarshaler is the interface to unmarshal polymorphic json payloads
type PolymorphicJSONUnmarshaler interface {
UnmarshalPolymorphicJSON(data []byte) (interface{}, error)
}
func valueFromPolymorphicJSON(content []byte, unmarshaler PolymorphicJSONUnmarshaler) (val interface{}, err error) {
err = json.Unmarshal(content, unmarshaler)
if err != nil {
return
}
val, err = unmarshaler.UnmarshalPolymorphicJSON(content)
return
}
func valueFromJSONBody(response *http.Response, value *reflect.Value, unmarshaler PolymorphicJSONUnmarshaler) (val interface{}, err error) {
//Consumes the body, consider implementing it
//without body consumption
var content []byte
content, err = ioutil.ReadAll(response.Body)
if err != nil {
return
}
if unmarshaler != nil {
val, err = valueFromPolymorphicJSON(content, unmarshaler)
return
}
val = reflect.New(value.Type()).Interface()
err = json.Unmarshal(content, &val)
return
}
func addFromBody(response *http.Response, value *reflect.Value, field reflect.StructField, unmarshaler PolymorphicJSONUnmarshaler) (err error) {
Debugln("Unmarshaling from body to field: ", field.Name)
if response.Body == nil {
Debugln("Unmarshaling body skipped due to nil body content for field: ", field.Name)
return nil
}
tag := field.Tag
encoding := tag.Get("encoding")
var iVal interface{}
switch encoding {
case "binary":
value.Set(reflect.ValueOf(response.Body))
return
case "plain-text":
//Expects UTF-8
byteArr, e := ioutil.ReadAll(response.Body)
if e != nil {
return e
}
str := string(byteArr)
value.Set(reflect.ValueOf(&str))
return
default: //If the encoding is not set. we'll decode with json
iVal, err = valueFromJSONBody(response, value, unmarshaler)
if err != nil {
return
}
newVal := reflect.ValueOf(iVal)
if newVal.Kind() == reflect.Ptr {
newVal = newVal.Elem()
}
value.Set(newVal)
return
}
}
func addFromHeader(response *http.Response, value *reflect.Value, field reflect.StructField) (err error) {
Debugln("Unmarshaling from header to field: ", field.Name)
var headerName string
if headerName = field.Tag.Get("name"); headerName == "" {
return fmt.Errorf("unmarshaling response to a header requires the 'name' tag for field: %s", field.Name)
}
headerValue := response.Header.Get(headerName)
if headerValue == "" {
Debugf("Unmarshalling did not find header with name:%s", headerName)
return nil
}
if err = fromStringValue(headerValue, value, field); err != nil {
return fmt.Errorf("unmarshaling response to a header failed for field %s, due to %s", field.Name,
err.Error())
}
return
}
func addFromHeaderCollection(response *http.Response, value *reflect.Value, field reflect.StructField) error {
Debugln("Unmarshaling from header-collection to field:", field.Name)
var headerPrefix string
if headerPrefix = field.Tag.Get("prefix"); headerPrefix == "" {
return fmt.Errorf("Unmarshaling response to a header-collection requires the 'prefix' tag for field: %s", field.Name)
}
mapCollection := make(map[string]string)
for name, value := range response.Header {
nameLowerCase := strings.ToLower(name)
if strings.HasPrefix(nameLowerCase, headerPrefix) {
headerNoPrefix := strings.TrimPrefix(nameLowerCase, headerPrefix)
mapCollection[headerNoPrefix] = value[0]
}
}
Debugln("Marshalled header collection is:", mapCollection)
value.Set(reflect.ValueOf(mapCollection))
return nil
}
// Populates a struct from parts of a request by reading tags of the struct
func responseToStruct(response *http.Response, val *reflect.Value, unmarshaler PolymorphicJSONUnmarshaler) (err error) {
typ := val.Type()
for i := 0; i < typ.NumField(); i++ {
if err != nil {
return
}
sf := typ.Field(i)
//unexported
if sf.PkgPath != "" {
continue
}
sv := val.Field(i)
tag := sf.Tag.Get("presentIn")
switch tag {
case "header":
err = addFromHeader(response, &sv, sf)
case "header-collection":
err = addFromHeaderCollection(response, &sv, sf)
case "body":
err = addFromBody(response, &sv, sf, unmarshaler)
case "":
Debugln(sf.Name, " does not contain presentIn tag. Skipping")
default:
err = fmt.Errorf("can not unmarshal field: %s. It needs to contain valid presentIn tag", sf.Name)
}
}
return
}
// UnmarshalResponse hydrates the fields of a struct with the values of a http response, guided
// by the field tags. The directive tag is "presentIn" and it can be either
// - "header": Will look for the header tagged as "name" in the headers of the struct and set it value to that
// - "body": It will try to marshal the body from a json string to a struct tagged with 'presentIn: "body"'.
// Further this method will consume the body it should be safe to close it after this function
// Notice the current implementation only supports native types:int, strings, floats, bool as the field types
func UnmarshalResponse(httpResponse *http.Response, responseStruct interface{}) (err error) {
var val *reflect.Value
if val, err = checkForValidResponseStruct(responseStruct); err != nil {
return
}
if err = responseToStruct(httpResponse, val, nil); err != nil {
return
}
return nil
}
// UnmarshalResponseWithPolymorphicBody similar to UnmarshalResponse but assumes the body of the response
// contains polymorphic json. This function will use the unmarshaler argument to unmarshal json content
func UnmarshalResponseWithPolymorphicBody(httpResponse *http.Response, responseStruct interface{}, unmarshaler PolymorphicJSONUnmarshaler) (err error) {
var val *reflect.Value
if val, err = checkForValidResponseStruct(responseStruct); err != nil {
return
}
if err = responseToStruct(httpResponse, val, unmarshaler); err != nil {
return
}
return nil
}
// generate request id if user not provided and for each retry operation re-gen a new request id
func generateOpcRequestID(headerName string, value reflect.Value) (newValue reflect.Value) {
newValue = value
isNilValue := isNil(newValue)
isOpcRequestIDHeader := headerName == requestHeaderOpcRequestID || headerName == requestHeaderOpcClientRequestID
if isNilValue && isOpcRequestIDHeader {
requestID, err := generateRandUUID()
if err != nil {
// this will not fail the request, just skip add opc-request-id
Debugf("unable to generate opc-request-id. %s", err.Error())
} else {
newValue = reflect.ValueOf(String(requestID))
Debugf("add request id for header: %s, with value: %s", headerName, requestID)
}
}
return
}

View file

@ -0,0 +1,269 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
package common
import (
"bytes"
"crypto"
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"encoding/base64"
"fmt"
"io"
"io/ioutil"
"net/http"
"strings"
)
// HTTPRequestSigner the interface to sign a request
type HTTPRequestSigner interface {
Sign(r *http.Request) error
}
// KeyProvider interface that wraps information about the key's account owner
type KeyProvider interface {
PrivateRSAKey() (*rsa.PrivateKey, error)
KeyID() (string, error)
}
const signerVersion = "1"
// SignerBodyHashPredicate a function that allows to disable/enable body hashing
// of requests and headers associated with body content
type SignerBodyHashPredicate func(r *http.Request) bool
// ociRequestSigner implements the http-signatures-draft spec
// as described in https://tools.ietf.org/html/draft-cavage-http-signatures-08
type ociRequestSigner struct {
KeyProvider KeyProvider
GenericHeaders []string
BodyHeaders []string
ShouldHashBody SignerBodyHashPredicate
}
var (
defaultGenericHeaders = []string{"date", "(request-target)", "host"}
defaultBodyHeaders = []string{"content-length", "content-type", "x-content-sha256"}
defaultBodyHashPredicate = func(r *http.Request) bool {
return r.Method == http.MethodPost || r.Method == http.MethodPut || r.Method == http.MethodPatch
}
)
// DefaultGenericHeaders list of default generic headers that is used in signing
func DefaultGenericHeaders() []string {
return makeACopy(defaultGenericHeaders)
}
// DefaultBodyHeaders list of default body headers that is used in signing
func DefaultBodyHeaders() []string {
return makeACopy(defaultBodyHeaders)
}
// DefaultRequestSigner creates a signer with default parameters.
func DefaultRequestSigner(provider KeyProvider) HTTPRequestSigner {
return RequestSigner(provider, defaultGenericHeaders, defaultBodyHeaders)
}
// RequestSignerExcludeBody creates a signer without hash the body.
func RequestSignerExcludeBody(provider KeyProvider) HTTPRequestSigner {
bodyHashPredicate := func(r *http.Request) bool {
// week request signer will not hash the body
return false
}
return RequestSignerWithBodyHashingPredicate(provider, defaultGenericHeaders, defaultBodyHeaders, bodyHashPredicate)
}
// NewSignerFromOCIRequestSigner creates a copy of the request signer and attaches the new SignerBodyHashPredicate
// returns an error if the passed signer is not of type ociRequestSigner
func NewSignerFromOCIRequestSigner(oldSigner HTTPRequestSigner, predicate SignerBodyHashPredicate) (HTTPRequestSigner, error) {
if oldS, ok := oldSigner.(ociRequestSigner); ok {
s := ociRequestSigner{
KeyProvider: oldS.KeyProvider,
GenericHeaders: oldS.GenericHeaders,
BodyHeaders: oldS.BodyHeaders,
ShouldHashBody: predicate,
}
return s, nil
}
return nil, fmt.Errorf("can not create a signer, input signer needs to be of type ociRequestSigner")
}
// RequestSigner creates a signer that utilizes the specified headers for signing
// and the default predicate for using the body of the request as part of the signature
func RequestSigner(provider KeyProvider, genericHeaders, bodyHeaders []string) HTTPRequestSigner {
return ociRequestSigner{
KeyProvider: provider,
GenericHeaders: genericHeaders,
BodyHeaders: bodyHeaders,
ShouldHashBody: defaultBodyHashPredicate}
}
// RequestSignerWithBodyHashingPredicate creates a signer that utilizes the specified headers for signing, as well as a predicate for using
// the body of the request and bodyHeaders parameter as part of the signature
func RequestSignerWithBodyHashingPredicate(provider KeyProvider, genericHeaders, bodyHeaders []string, shouldHashBody SignerBodyHashPredicate) HTTPRequestSigner {
return ociRequestSigner{
KeyProvider: provider,
GenericHeaders: genericHeaders,
BodyHeaders: bodyHeaders,
ShouldHashBody: shouldHashBody}
}
func (signer ociRequestSigner) getSigningHeaders(r *http.Request) []string {
var result []string
result = append(result, signer.GenericHeaders...)
if signer.ShouldHashBody(r) {
result = append(result, signer.BodyHeaders...)
}
return result
}
func (signer ociRequestSigner) getSigningString(request *http.Request) string {
signingHeaders := signer.getSigningHeaders(request)
signingParts := make([]string, len(signingHeaders))
for i, part := range signingHeaders {
var value string
part = strings.ToLower(part)
switch part {
case "(request-target)":
value = getRequestTarget(request)
case "host":
value = request.URL.Host
if len(value) == 0 {
value = request.Host
}
default:
value = request.Header.Get(part)
}
signingParts[i] = fmt.Sprintf("%s: %s", part, value)
}
signingString := strings.Join(signingParts, "\n")
return signingString
}
func getRequestTarget(request *http.Request) string {
lowercaseMethod := strings.ToLower(request.Method)
return fmt.Sprintf("%s %s", lowercaseMethod, request.URL.RequestURI())
}
func calculateHashOfBody(request *http.Request) (err error) {
var hash string
hash, err = GetBodyHash(request)
if err != nil {
return
}
request.Header.Set(requestHeaderXContentSHA256, hash)
return
}
// drainBody reads all of b to memory and then returns two equivalent
// ReadClosers yielding the same bytes.
//
// It returns an error if the initial slurp of all bytes fails. It does not attempt
// to make the returned ReadClosers have identical error-matching behavior.
func drainBody(b io.ReadCloser) (r1, r2 io.ReadCloser, err error) {
if b == http.NoBody {
// No copying needed. Preserve the magic sentinel meaning of NoBody.
return http.NoBody, http.NoBody, nil
}
var buf bytes.Buffer
if _, err = buf.ReadFrom(b); err != nil {
return nil, b, err
}
if err = b.Close(); err != nil {
return nil, b, err
}
return ioutil.NopCloser(&buf), ioutil.NopCloser(bytes.NewReader(buf.Bytes())), nil
}
func hashAndEncode(data []byte) string {
hashedContent := sha256.Sum256(data)
hash := base64.StdEncoding.EncodeToString(hashedContent[:])
return hash
}
// GetBodyHash creates a base64 string from the hash of body the request
func GetBodyHash(request *http.Request) (hashString string, err error) {
if request.Body == nil {
request.ContentLength = 0
request.Header.Set(requestHeaderContentLength, fmt.Sprintf("%v", request.ContentLength))
return hashAndEncode([]byte("")), nil
}
var data []byte
bReader := request.Body
bReader, request.Body, err = drainBody(request.Body)
if err != nil {
return "", fmt.Errorf("can not read body of request while calculating body hash: %s", err.Error())
}
data, err = ioutil.ReadAll(bReader)
if err != nil {
return "", fmt.Errorf("can not read body of request while calculating body hash: %s", err.Error())
}
// Since the request can be coming from a binary body. Make an attempt to set the body length
request.ContentLength = int64(len(data))
request.Header.Set(requestHeaderContentLength, fmt.Sprintf("%v", request.ContentLength))
hashString = hashAndEncode(data)
return
}
func (signer ociRequestSigner) computeSignature(request *http.Request) (signature string, err error) {
signingString := signer.getSigningString(request)
hasher := sha256.New()
hasher.Write([]byte(signingString))
hashed := hasher.Sum(nil)
privateKey, err := signer.KeyProvider.PrivateRSAKey()
if err != nil {
return
}
var unencodedSig []byte
unencodedSig, e := rsa.SignPKCS1v15(rand.Reader, privateKey, crypto.SHA256, hashed)
if e != nil {
err = fmt.Errorf("can not compute signature while signing the request %s: ", e.Error())
return
}
signature = base64.StdEncoding.EncodeToString(unencodedSig)
return
}
// Sign signs the http request, by inspecting the necessary headers. Once signed
// the request will have the proper 'Authorization' header set, otherwise
// and error is returned
func (signer ociRequestSigner) Sign(request *http.Request) (err error) {
if signer.ShouldHashBody(request) {
err = calculateHashOfBody(request)
if err != nil {
return
}
}
var signature string
if signature, err = signer.computeSignature(request); err != nil {
return
}
signingHeaders := strings.Join(signer.getSigningHeaders(request), " ")
var keyID string
if keyID, err = signer.KeyProvider.KeyID(); err != nil {
return
}
authValue := fmt.Sprintf("Signature version=\"%s\",headers=\"%s\",keyId=\"%s\",algorithm=\"rsa-sha256\",signature=\"%s\"",
signerVersion, signingHeaders, keyID, signature)
request.Header.Set(requestHeaderAuthorization, authValue)
return
}

170
vendor/github.com/oracle/oci-go-sdk/common/log.go generated vendored Normal file
View file

@ -0,0 +1,170 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
package common
import (
"fmt"
"io/ioutil"
"log"
"os"
"strings"
"sync"
)
//sdkLogger an interface for logging in the SDK
type sdkLogger interface {
//LogLevel returns the log level of sdkLogger
LogLevel() int
//Log logs v with the provided format if the current log level is loglevel
Log(logLevel int, format string, v ...interface{}) error
}
//noLogging no logging messages
const noLogging = 0
//infoLogging minimal logging messages
const infoLogging = 1
//debugLogging some logging messages
const debugLogging = 2
//verboseLogging all logging messages
const verboseLogging = 3
//defaultSDKLogger the default implementation of the sdkLogger
type defaultSDKLogger struct {
currentLoggingLevel int
verboseLogger *log.Logger
debugLogger *log.Logger
infoLogger *log.Logger
nullLogger *log.Logger
}
//defaultLogger is the defaultLogger in the SDK
var defaultLogger sdkLogger
var loggerLock sync.Mutex
//initializes the SDK defaultLogger as a defaultLogger
func init() {
l, _ := newSDKLogger()
setSDKLogger(l)
}
//setSDKLogger sets the logger used by the sdk
func setSDKLogger(logger sdkLogger) {
loggerLock.Lock()
defaultLogger = logger
loggerLock.Unlock()
}
// newSDKLogger creates a defaultSDKLogger
// Debug logging is turned on/off by the presence of the environment variable "OCI_GO_SDK_DEBUG"
// The value of the "OCI_GO_SDK_DEBUG" environment variable controls the logging level.
// "null" outputs no log messages
// "i" or "info" outputs minimal log messages
// "d" or "debug" outputs some logs messages
// "v" or "verbose" outputs all logs messages, including body of requests
func newSDKLogger() (defaultSDKLogger, error) {
logger := defaultSDKLogger{}
logger.currentLoggingLevel = noLogging
logger.verboseLogger = log.New(os.Stderr, "VERBOSE ", log.Ldate|log.Lmicroseconds|log.Lshortfile)
logger.debugLogger = log.New(os.Stderr, "DEBUG ", log.Ldate|log.Lmicroseconds|log.Lshortfile)
logger.infoLogger = log.New(os.Stderr, "INFO ", log.Ldate|log.Lmicroseconds|log.Lshortfile)
logger.nullLogger = log.New(ioutil.Discard, "", log.Ldate|log.Lmicroseconds|log.Lshortfile)
configured, isLogEnabled := os.LookupEnv("OCI_GO_SDK_DEBUG")
// If env variable not present turn logging of
if !isLogEnabled {
logger.currentLoggingLevel = noLogging
} else {
switch strings.ToLower(configured) {
case "null":
logger.currentLoggingLevel = noLogging
break
case "i", "info":
logger.currentLoggingLevel = infoLogging
break
case "d", "debug":
logger.currentLoggingLevel = debugLogging
break
//1 here for backwards compatibility
case "v", "verbose", "1":
logger.currentLoggingLevel = verboseLogging
break
default:
logger.currentLoggingLevel = infoLogging
}
logger.infoLogger.Println("logger level set to: ", logger.currentLoggingLevel)
}
return logger, nil
}
func (l defaultSDKLogger) getLoggerForLevel(logLevel int) *log.Logger {
if logLevel > l.currentLoggingLevel {
return l.nullLogger
}
switch logLevel {
case noLogging:
return l.nullLogger
case infoLogging:
return l.infoLogger
case debugLogging:
return l.debugLogger
case verboseLogging:
return l.verboseLogger
default:
return l.nullLogger
}
}
//LogLevel returns the current debug level
func (l defaultSDKLogger) LogLevel() int {
return l.currentLoggingLevel
}
func (l defaultSDKLogger) Log(logLevel int, format string, v ...interface{}) error {
logger := l.getLoggerForLevel(logLevel)
logger.Output(4, fmt.Sprintf(format, v...))
return nil
}
//Logln logs v appending a new line at the end
//Deprecated
func Logln(v ...interface{}) {
defaultLogger.Log(infoLogging, "%v\n", v...)
}
// Logf logs v with the provided format
func Logf(format string, v ...interface{}) {
defaultLogger.Log(infoLogging, format, v...)
}
// Debugf logs v with the provided format if debug mode is set
func Debugf(format string, v ...interface{}) {
defaultLogger.Log(debugLogging, format, v...)
}
// Debug logs v if debug mode is set
func Debug(v ...interface{}) {
m := fmt.Sprint(v...)
defaultLogger.Log(debugLogging, "%s", m)
}
// Debugln logs v appending a new line if debug mode is set
func Debugln(v ...interface{}) {
m := fmt.Sprint(v...)
defaultLogger.Log(debugLogging, "%s\n", m)
}
// IfDebug executes closure if debug is enabled
func IfDebug(fn func()) {
if defaultLogger.LogLevel() >= debugLogging {
fn()
}
}

159
vendor/github.com/oracle/oci-go-sdk/common/retry.go generated vendored Normal file
View file

@ -0,0 +1,159 @@
package common
import (
"context"
"fmt"
"math/rand"
"runtime"
"time"
)
const (
// UnlimitedNumAttemptsValue is the value for indicating unlimited attempts for reaching success
UnlimitedNumAttemptsValue = uint(0)
// number of characters contained in the generated retry token
generatedRetryTokenLength = 32
)
// OCIRetryableRequest represents a request that can be reissued according to the specified policy.
type OCIRetryableRequest interface {
// Any retryable request must implement the OCIRequest interface
OCIRequest
// Each operation specifies default retry behavior. By passing no arguments to this method, the default retry
// behavior, as determined on a per-operation-basis, will be honored. Variadic retry policy option arguments
// passed to this method will override the default behavior.
RetryPolicy() *RetryPolicy
}
// OCIOperationResponse represents the output of an OCIOperation, with additional context of error message
// and operation attempt number.
type OCIOperationResponse struct {
// Response from OCI Operation
Response OCIResponse
// Error from OCI Operation
Error error
// Operation Attempt Number (one-based)
AttemptNumber uint
}
// NewOCIOperationResponse assembles an OCI Operation Response object.
func NewOCIOperationResponse(response OCIResponse, err error, attempt uint) OCIOperationResponse {
return OCIOperationResponse{
Response: response,
Error: err,
AttemptNumber: attempt,
}
}
// RetryPolicy is the class that holds all relevant information for retrying operations.
type RetryPolicy struct {
// MaximumNumberAttempts is the maximum number of times to retry a request. Zero indicates an unlimited
// number of attempts.
MaximumNumberAttempts uint
// ShouldRetryOperation inspects the http response, error, and operation attempt number, and
// - returns true if we should retry the operation
// - returns false otherwise
ShouldRetryOperation func(OCIOperationResponse) bool
// GetNextDuration computes the duration to pause between operation retries.
NextDuration func(OCIOperationResponse) time.Duration
}
// NoRetryPolicy is a helper method that assembles and returns a return policy that indicates an operation should
// never be retried (the operation is performed exactly once).
func NoRetryPolicy() RetryPolicy {
dontRetryOperation := func(OCIOperationResponse) bool { return false }
zeroNextDuration := func(OCIOperationResponse) time.Duration { return 0 * time.Second }
return NewRetryPolicy(uint(1), dontRetryOperation, zeroNextDuration)
}
// NewRetryPolicy is a helper method for assembling a Retry Policy object.
func NewRetryPolicy(attempts uint, retryOperation func(OCIOperationResponse) bool, nextDuration func(OCIOperationResponse) time.Duration) RetryPolicy {
return RetryPolicy{
MaximumNumberAttempts: attempts,
ShouldRetryOperation: retryOperation,
NextDuration: nextDuration,
}
}
// shouldContinueIssuingRequests returns true if we should continue retrying a request, based on the current attempt
// number and the maximum number of attempts specified, or false otherwise.
func shouldContinueIssuingRequests(current, maximum uint) bool {
return maximum == UnlimitedNumAttemptsValue || current <= maximum
}
// RetryToken generates a retry token that must be included on any request passed to the Retry method.
func RetryToken() string {
alphanumericChars := []rune("abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ")
retryToken := make([]rune, generatedRetryTokenLength)
for i := range retryToken {
retryToken[i] = alphanumericChars[rand.Intn(len(alphanumericChars))]
}
return string(retryToken)
}
// Retry is a package-level operation that executes the retryable request using the specified operation and retry policy.
func Retry(ctx context.Context, request OCIRetryableRequest, operation OCIOperation, policy RetryPolicy) (OCIResponse, error) {
type retrierResult struct {
response OCIResponse
err error
}
var response OCIResponse
var err error
retrierChannel := make(chan retrierResult)
go func() {
// Deal with panics more graciously
defer func() {
if r := recover(); r != nil {
stackBuffer := make([]byte, 1024)
bytesWritten := runtime.Stack(stackBuffer, false)
stack := string(stackBuffer[:bytesWritten])
retrierChannel <- retrierResult{nil, fmt.Errorf("panicked while retrying operation. Panic was: %s\nStack: %s", r, stack)}
}
}()
// use a one-based counter because it's easier to think about operation retry in terms of attempt numbering
for currentOperationAttempt := uint(1); shouldContinueIssuingRequests(currentOperationAttempt, policy.MaximumNumberAttempts); currentOperationAttempt++ {
Debugln(fmt.Sprintf("operation attempt #%v", currentOperationAttempt))
response, err = operation(ctx, request)
operationResponse := NewOCIOperationResponse(response, err, currentOperationAttempt)
if !policy.ShouldRetryOperation(operationResponse) {
// we should NOT retry operation based on response and/or error => return
retrierChannel <- retrierResult{response, err}
return
}
duration := policy.NextDuration(operationResponse)
//The following condition is kept for backwards compatibility reasons
if deadline, ok := ctx.Deadline(); ok && time.Now().Add(duration).After(deadline) {
// we want to retry the operation, but the policy is telling us to wait for a duration that exceeds
// the specified overall deadline for the operation => instead of waiting for however long that
// time period is and then aborting, abort now and save the cycles
retrierChannel <- retrierResult{response, DeadlineExceededByBackoff}
return
}
Debugln(fmt.Sprintf("waiting %v before retrying operation", duration))
// sleep before retrying the operation
<-time.After(duration)
}
retrierChannel <- retrierResult{nil, fmt.Errorf("maximum number of attempts exceeded (%v)", policy.MaximumNumberAttempts)}
}()
select {
case <-ctx.Done():
return response, ctx.Err()
case result := <-retrierChannel:
return result.response, result.err
}
}

36
vendor/github.com/oracle/oci-go-sdk/common/version.go generated vendored Normal file
View file

@ -0,0 +1,36 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated by go generate; DO NOT EDIT
package common
import (
"bytes"
"fmt"
"sync"
)
const (
major = "4"
minor = "0"
patch = "0"
tag = ""
)
var once sync.Once
var version string
// Version returns semantic version of the sdk
func Version() string {
once.Do(func() {
ver := fmt.Sprintf("%s.%s.%s", major, minor, patch)
verBuilder := bytes.NewBufferString(ver)
if tag != "" && tag != "-" {
_, err := verBuilder.WriteString(tag)
if err == nil {
verBuilder = bytes.NewBufferString(ver)
}
}
version = verBuilder.String()
})
return version
}

View file

@ -0,0 +1,42 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// CreateSteeringPolicyAttachmentDetails The body for defining an attachment between a steering policy and a domain.
// An attachment occludes all records at its domain that are of a covered rtype, constructing
// DNS responses from its steering policy rather than from those domain records.
// The attachment will cover every rtype that matches the rtype of an answer in its policy, and
// will cover all address rtypes (e.g., A and AAAA) if the policy includes at least one CNAME
// answer.
// A domain can have at most one attachment covering any given rtype.
type CreateSteeringPolicyAttachmentDetails struct {
// The OCID of the attached steering policy.
SteeringPolicyId *string `mandatory:"true" json:"steeringPolicyId"`
// The OCID of the attached zone.
ZoneId *string `mandatory:"true" json:"zoneId"`
// The attached domain within the attached zone.
DomainName *string `mandatory:"true" json:"domainName"`
// A user-friendly name for the steering policy attachment.
// Does not have to be unique, and it's changeable.
// Avoid entering confidential information.
DisplayName *string `mandatory:"false" json:"displayName"`
}
func (m CreateSteeringPolicyAttachmentDetails) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,75 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// CreateSteeringPolicyAttachmentRequest wrapper for the CreateSteeringPolicyAttachment operation
type CreateSteeringPolicyAttachmentRequest struct {
// Details for creating a new steering policy attachment.
CreateSteeringPolicyAttachmentDetails `contributesTo:"body"`
// A token that uniquely identifies a request so it can be retried in case
// of a timeout or server error without risk of executing that same action
// again. Retry tokens expire after 24 hours, but can be invalidated before
// then due to conflicting operations (for example, if a resource has been
// deleted and purged from the system, then a retry of the original creation
// request may be rejected).
OpcRetryToken *string `mandatory:"false" contributesTo:"header" name:"opc-retry-token"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request CreateSteeringPolicyAttachmentRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request CreateSteeringPolicyAttachmentRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request CreateSteeringPolicyAttachmentRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// CreateSteeringPolicyAttachmentResponse wrapper for the CreateSteeringPolicyAttachment operation
type CreateSteeringPolicyAttachmentResponse struct {
// The underlying http response
RawResponse *http.Response
// The SteeringPolicyAttachment instance
SteeringPolicyAttachment `presentIn:"body"`
// Unique Oracle-assigned identifier for the request. If you need to
// contact Oracle about a particular request, please provide the request
// ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the resource, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
}
func (response CreateSteeringPolicyAttachmentResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response CreateSteeringPolicyAttachmentResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,177 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"encoding/json"
"github.com/oracle/oci-go-sdk/common"
)
// CreateSteeringPolicyDetails The body for defining a new steering policy.
// *Warning:* Oracle recommends that you avoid using any confidential information when you supply string values using the API.
type CreateSteeringPolicyDetails struct {
// The OCID of the compartment containing the steering policy.
CompartmentId *string `mandatory:"true" json:"compartmentId"`
// A user-friendly name for the steering policy.
// Does not have to be unique, and it's changeable.
// Avoid entering confidential information.
DisplayName *string `mandatory:"true" json:"displayName"`
// The common pattern (or lack thereof) to which the steering policy adheres. This
// value restricts the possible configurations of rules, but thereby supports
// specifically tailored interfaces. Values other than "CUSTOM" require the rules to
// begin with an unconditional FILTER that keeps answers contingent upon
// `answer.isDisabled != true`, followed
// _if and only if the policy references a health check monitor_ by an unconditional
// HEALTH rule, and require the last rule to be an unconditional LIMIT.
// What must precede the LIMIT rule is determined by the template value:
// - FAILOVER requires exactly an unconditional PRIORITY rule that ranks answers by pool.
// Each answer pool must have a unique priority value assigned to it. Answer data must
// be defined in the `defaultAnswerData` property for the rule and the `cases` property
// must not be defined.
// - LOAD_BALANCE requires exactly an unconditional WEIGHTED rule that shuffles answers
// by name. Answer data must be defined in the `defaultAnswerData` property for the
// rule and the `cases` property must not be defined.
// - ROUTE_BY_GEO requires exactly one PRIORITY rule that ranks answers by pool using the
// geographical location of the client as a condition. Within that rule you may only
// use `query.client.geoKey` in the `caseCondition` expressions for defining the cases.
// For each case in the PRIORITY rule each answer pool must have a unique priority
// value assigned to it. Answer data can only be defined within cases and
// `defaultAnswerData` cannot be used in the PRIORITY rule.
// - ROUTE_BY_ASN requires exactly one PRIORITY rule that ranks answers by pool using the
// ASN of the client as a condition. Within that rule you may only use
// `query.client.asn` in the `caseCondition` expressions for defining the cases.
// For each case in the PRIORITY rule each answer pool must have a unique priority
// value assigned to it. Answer data can only be defined within cases and
// `defaultAnswerData` cannot be used in the PRIORITY rule.
// - ROUTE_BY_IP requires exactly one PRIORITY rule that ranks answers by pool using the
// IP subnet of the client as a condition. Within that rule you may only use
// `query.client.address` in the `caseCondition` expressions for defining the cases.
// For each case in the PRIORITY rule each answer pool must have a unique priority
// value assigned to it. Answer data can only be defined within cases and
// `defaultAnswerData` cannot be used in the PRIORITY rule.
// - CUSTOM allows an arbitrary configuration of rules.
// For an existing steering policy, the template value may be changed to any of the
// supported options but the resulting policy must conform to the requirements for the
// new template type or else a Bad Request error will be returned.
Template CreateSteeringPolicyDetailsTemplateEnum `mandatory:"true" json:"template"`
// The Time To Live for responses from the steering policy, in seconds.
// If not specified during creation, a value of 30 seconds will be used.
Ttl *int `mandatory:"false" json:"ttl"`
// The OCID of the health check monitor providing health data about the answers of the
// steering policy.
// A steering policy answer with `rdata` matching a monitored endpoint will use the health
// data of that endpoint.
// A steering policy answer with `rdata` not matching any monitored endpoint will be assumed
// healthy.
HealthCheckMonitorId *string `mandatory:"false" json:"healthCheckMonitorId"`
// Simple key-value pair that is applied without any predefined name, type, or scope.
// For more information, see Resource Tags (https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm).
// Example: `{"bar-key": "value"}`
FreeformTags map[string]string `mandatory:"false" json:"freeformTags"`
// Usage of predefined tag keys. These predefined keys are scoped to a namespace.
// Example: `{"foo-namespace": {"bar-key": "value"}}`
DefinedTags map[string]map[string]interface{} `mandatory:"false" json:"definedTags"`
// The set of all answers that can potentially issue from the steering policy.
Answers []SteeringPolicyAnswer `mandatory:"false" json:"answers"`
// The pipeline of rules that will be processed in sequence to reduce the pool of answers
// to a response for any given request.
// The first rule receives a shuffled list of all answers, and every other rule receives
// the list of answers emitted by the one preceding it. The last rule populates the
// response.
Rules []SteeringPolicyRule `mandatory:"false" json:"rules"`
}
func (m CreateSteeringPolicyDetails) String() string {
return common.PointerString(m)
}
// UnmarshalJSON unmarshals from json
func (m *CreateSteeringPolicyDetails) UnmarshalJSON(data []byte) (e error) {
model := struct {
Ttl *int `json:"ttl"`
HealthCheckMonitorId *string `json:"healthCheckMonitorId"`
FreeformTags map[string]string `json:"freeformTags"`
DefinedTags map[string]map[string]interface{} `json:"definedTags"`
Answers []SteeringPolicyAnswer `json:"answers"`
Rules []steeringpolicyrule `json:"rules"`
CompartmentId *string `json:"compartmentId"`
DisplayName *string `json:"displayName"`
Template CreateSteeringPolicyDetailsTemplateEnum `json:"template"`
}{}
e = json.Unmarshal(data, &model)
if e != nil {
return
}
m.Ttl = model.Ttl
m.HealthCheckMonitorId = model.HealthCheckMonitorId
m.FreeformTags = model.FreeformTags
m.DefinedTags = model.DefinedTags
m.Answers = make([]SteeringPolicyAnswer, len(model.Answers))
for i, n := range model.Answers {
m.Answers[i] = n
}
m.Rules = make([]SteeringPolicyRule, len(model.Rules))
for i, n := range model.Rules {
nn, err := n.UnmarshalPolymorphicJSON(n.JsonData)
if err != nil {
return err
}
if nn != nil {
m.Rules[i] = nn.(SteeringPolicyRule)
} else {
m.Rules[i] = nil
}
}
m.CompartmentId = model.CompartmentId
m.DisplayName = model.DisplayName
m.Template = model.Template
return
}
// CreateSteeringPolicyDetailsTemplateEnum Enum with underlying type: string
type CreateSteeringPolicyDetailsTemplateEnum string
// Set of constants representing the allowable values for CreateSteeringPolicyDetailsTemplateEnum
const (
CreateSteeringPolicyDetailsTemplateFailover CreateSteeringPolicyDetailsTemplateEnum = "FAILOVER"
CreateSteeringPolicyDetailsTemplateLoadBalance CreateSteeringPolicyDetailsTemplateEnum = "LOAD_BALANCE"
CreateSteeringPolicyDetailsTemplateRouteByGeo CreateSteeringPolicyDetailsTemplateEnum = "ROUTE_BY_GEO"
CreateSteeringPolicyDetailsTemplateRouteByAsn CreateSteeringPolicyDetailsTemplateEnum = "ROUTE_BY_ASN"
CreateSteeringPolicyDetailsTemplateRouteByIp CreateSteeringPolicyDetailsTemplateEnum = "ROUTE_BY_IP"
CreateSteeringPolicyDetailsTemplateCustom CreateSteeringPolicyDetailsTemplateEnum = "CUSTOM"
)
var mappingCreateSteeringPolicyDetailsTemplate = map[string]CreateSteeringPolicyDetailsTemplateEnum{
"FAILOVER": CreateSteeringPolicyDetailsTemplateFailover,
"LOAD_BALANCE": CreateSteeringPolicyDetailsTemplateLoadBalance,
"ROUTE_BY_GEO": CreateSteeringPolicyDetailsTemplateRouteByGeo,
"ROUTE_BY_ASN": CreateSteeringPolicyDetailsTemplateRouteByAsn,
"ROUTE_BY_IP": CreateSteeringPolicyDetailsTemplateRouteByIp,
"CUSTOM": CreateSteeringPolicyDetailsTemplateCustom,
}
// GetCreateSteeringPolicyDetailsTemplateEnumValues Enumerates the set of values for CreateSteeringPolicyDetailsTemplateEnum
func GetCreateSteeringPolicyDetailsTemplateEnumValues() []CreateSteeringPolicyDetailsTemplateEnum {
values := make([]CreateSteeringPolicyDetailsTemplateEnum, 0)
for _, v := range mappingCreateSteeringPolicyDetailsTemplate {
values = append(values, v)
}
return values
}

View file

@ -0,0 +1,75 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// CreateSteeringPolicyRequest wrapper for the CreateSteeringPolicy operation
type CreateSteeringPolicyRequest struct {
// Details for creating a new steering policy.
CreateSteeringPolicyDetails `contributesTo:"body"`
// A token that uniquely identifies a request so it can be retried in case
// of a timeout or server error without risk of executing that same action
// again. Retry tokens expire after 24 hours, but can be invalidated before
// then due to conflicting operations (for example, if a resource has been
// deleted and purged from the system, then a retry of the original creation
// request may be rejected).
OpcRetryToken *string `mandatory:"false" contributesTo:"header" name:"opc-retry-token"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request CreateSteeringPolicyRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request CreateSteeringPolicyRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request CreateSteeringPolicyRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// CreateSteeringPolicyResponse wrapper for the CreateSteeringPolicy operation
type CreateSteeringPolicyResponse struct {
// The underlying http response
RawResponse *http.Response
// The SteeringPolicy instance
SteeringPolicy `presentIn:"body"`
// Unique Oracle-assigned identifier for the request. If you need to
// contact Oracle about a particular request, please provide the request
// ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the resource, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
}
func (response CreateSteeringPolicyResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response CreateSteeringPolicyResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,68 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// CreateZoneDetails The body for defining a new zone.
// *Warning:* Oracle recommends that you avoid using any confidential information when you supply string values using the API.
type CreateZoneDetails struct {
// The name of the zone.
Name *string `mandatory:"true" json:"name"`
// The type of the zone. Must be either `PRIMARY` or `SECONDARY`.
ZoneType CreateZoneDetailsZoneTypeEnum `mandatory:"true" json:"zoneType"`
// The OCID of the compartment containing the zone.
CompartmentId *string `mandatory:"true" json:"compartmentId"`
// Simple key-value pair that is applied without any predefined name, type, or scope.
// For more information, see Resource Tags (https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm).
// Example: `{"bar-key": "value"}`
FreeformTags map[string]string `mandatory:"false" json:"freeformTags"`
// Usage of predefined tag keys. These predefined keys are scoped to a namespace.
// Example: `{"foo-namespace": {"bar-key": "value"}}`
DefinedTags map[string]map[string]interface{} `mandatory:"false" json:"definedTags"`
// External master servers for the zone. `externalMasters` becomes a
// required parameter when the `zoneType` value is `SECONDARY`.
ExternalMasters []ExternalMaster `mandatory:"false" json:"externalMasters"`
}
func (m CreateZoneDetails) String() string {
return common.PointerString(m)
}
// CreateZoneDetailsZoneTypeEnum Enum with underlying type: string
type CreateZoneDetailsZoneTypeEnum string
// Set of constants representing the allowable values for CreateZoneDetailsZoneTypeEnum
const (
CreateZoneDetailsZoneTypePrimary CreateZoneDetailsZoneTypeEnum = "PRIMARY"
CreateZoneDetailsZoneTypeSecondary CreateZoneDetailsZoneTypeEnum = "SECONDARY"
)
var mappingCreateZoneDetailsZoneType = map[string]CreateZoneDetailsZoneTypeEnum{
"PRIMARY": CreateZoneDetailsZoneTypePrimary,
"SECONDARY": CreateZoneDetailsZoneTypeSecondary,
}
// GetCreateZoneDetailsZoneTypeEnumValues Enumerates the set of values for CreateZoneDetailsZoneTypeEnum
func GetCreateZoneDetailsZoneTypeEnumValues() []CreateZoneDetailsZoneTypeEnum {
values := make([]CreateZoneDetailsZoneTypeEnum, 0)
for _, v := range mappingCreateZoneDetailsZoneType {
values = append(values, v)
}
return values
}

View file

@ -0,0 +1,69 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// CreateZoneRequest wrapper for the CreateZone operation
type CreateZoneRequest struct {
// Details for creating a new zone.
CreateZoneDetails `contributesTo:"body"`
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"false" contributesTo:"query" name:"compartmentId"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request CreateZoneRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request CreateZoneRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request CreateZoneRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// CreateZoneResponse wrapper for the CreateZone operation
type CreateZoneResponse struct {
// The underlying http response
RawResponse *http.Response
// The Zone instance
Zone `presentIn:"body"`
// Unique Oracle-assigned identifier for the request. If you need to
// contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the zone, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
}
func (response CreateZoneResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response CreateZoneResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,79 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// DeleteDomainRecordsRequest wrapper for the DeleteDomainRecords operation
type DeleteDomainRecordsRequest struct {
// The name or OCID of the target zone.
ZoneNameOrId *string `mandatory:"true" contributesTo:"path" name:"zoneNameOrId"`
// The target fully-qualified domain name (FQDN) within the target zone.
Domain *string `mandatory:"true" contributesTo:"path" name:"domain"`
// The `If-Match` header field makes the request method conditional on the
// existence of at least one current representation of the target resource,
// when the field-value is `*`, or having a current representation of the
// target resource that has an entity-tag matching a member of the list of
// entity-tags provided in the field-value.
IfMatch *string `mandatory:"false" contributesTo:"header" name:"If-Match"`
// The `If-Unmodified-Since` header field makes the request method
// conditional on the selected representation's last modification date being
// earlier than or equal to the date provided in the field-value. This
// field accomplishes the same purpose as If-Match for cases where the user
// agent does not have an entity-tag for the representation.
IfUnmodifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Unmodified-Since"`
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"false" contributesTo:"query" name:"compartmentId"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request DeleteDomainRecordsRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request DeleteDomainRecordsRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request DeleteDomainRecordsRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// DeleteDomainRecordsResponse wrapper for the DeleteDomainRecords operation
type DeleteDomainRecordsResponse struct {
// The underlying http response
RawResponse *http.Response
// Unique Oracle-assigned identifier for the request. If you need
// to contact Oracle about a particular request, please provide
// the request ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
}
func (response DeleteDomainRecordsResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response DeleteDomainRecordsResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,82 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// DeleteRRSetRequest wrapper for the DeleteRRSet operation
type DeleteRRSetRequest struct {
// The name or OCID of the target zone.
ZoneNameOrId *string `mandatory:"true" contributesTo:"path" name:"zoneNameOrId"`
// The target fully-qualified domain name (FQDN) within the target zone.
Domain *string `mandatory:"true" contributesTo:"path" name:"domain"`
// The type of the target RRSet within the target zone.
Rtype *string `mandatory:"true" contributesTo:"path" name:"rtype"`
// The `If-Match` header field makes the request method conditional on the
// existence of at least one current representation of the target resource,
// when the field-value is `*`, or having a current representation of the
// target resource that has an entity-tag matching a member of the list of
// entity-tags provided in the field-value.
IfMatch *string `mandatory:"false" contributesTo:"header" name:"If-Match"`
// The `If-Unmodified-Since` header field makes the request method
// conditional on the selected representation's last modification date being
// earlier than or equal to the date provided in the field-value. This
// field accomplishes the same purpose as If-Match for cases where the user
// agent does not have an entity-tag for the representation.
IfUnmodifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Unmodified-Since"`
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"false" contributesTo:"query" name:"compartmentId"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request DeleteRRSetRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request DeleteRRSetRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request DeleteRRSetRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// DeleteRRSetResponse wrapper for the DeleteRRSet operation
type DeleteRRSetResponse struct {
// The underlying http response
RawResponse *http.Response
// Unique Oracle-assigned identifier for the request. If you need
// to contact Oracle about a particular request, please provide
// the request ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
}
func (response DeleteRRSetResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response DeleteRRSetResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,73 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// DeleteSteeringPolicyAttachmentRequest wrapper for the DeleteSteeringPolicyAttachment operation
type DeleteSteeringPolicyAttachmentRequest struct {
// The OCID of the target steering policy attachment.
SteeringPolicyAttachmentId *string `mandatory:"true" contributesTo:"path" name:"steeringPolicyAttachmentId"`
// The `If-Match` header field makes the request method conditional on the
// existence of at least one current representation of the target resource,
// when the field-value is `*`, or having a current representation of the
// target resource that has an entity-tag matching a member of the list of
// entity-tags provided in the field-value.
IfMatch *string `mandatory:"false" contributesTo:"header" name:"If-Match"`
// The `If-Unmodified-Since` header field makes the request method
// conditional on the selected representation's last modification date being
// earlier than or equal to the date provided in the field-value. This
// field accomplishes the same purpose as If-Match for cases where the user
// agent does not have an entity-tag for the representation.
IfUnmodifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Unmodified-Since"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request DeleteSteeringPolicyAttachmentRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request DeleteSteeringPolicyAttachmentRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request DeleteSteeringPolicyAttachmentRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// DeleteSteeringPolicyAttachmentResponse wrapper for the DeleteSteeringPolicyAttachment operation
type DeleteSteeringPolicyAttachmentResponse struct {
// The underlying http response
RawResponse *http.Response
// Unique Oracle-assigned identifier for the request. If you need
// to contact Oracle about a particular request, please provide
// the request ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
}
func (response DeleteSteeringPolicyAttachmentResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response DeleteSteeringPolicyAttachmentResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,73 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// DeleteSteeringPolicyRequest wrapper for the DeleteSteeringPolicy operation
type DeleteSteeringPolicyRequest struct {
// The OCID of the target steering policy.
SteeringPolicyId *string `mandatory:"true" contributesTo:"path" name:"steeringPolicyId"`
// The `If-Match` header field makes the request method conditional on the
// existence of at least one current representation of the target resource,
// when the field-value is `*`, or having a current representation of the
// target resource that has an entity-tag matching a member of the list of
// entity-tags provided in the field-value.
IfMatch *string `mandatory:"false" contributesTo:"header" name:"If-Match"`
// The `If-Unmodified-Since` header field makes the request method
// conditional on the selected representation's last modification date being
// earlier than or equal to the date provided in the field-value. This
// field accomplishes the same purpose as If-Match for cases where the user
// agent does not have an entity-tag for the representation.
IfUnmodifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Unmodified-Since"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request DeleteSteeringPolicyRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request DeleteSteeringPolicyRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request DeleteSteeringPolicyRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// DeleteSteeringPolicyResponse wrapper for the DeleteSteeringPolicy operation
type DeleteSteeringPolicyResponse struct {
// The underlying http response
RawResponse *http.Response
// Unique Oracle-assigned identifier for the request. If you need
// to contact Oracle about a particular request, please provide
// the request ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
}
func (response DeleteSteeringPolicyResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response DeleteSteeringPolicyResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,76 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// DeleteZoneRequest wrapper for the DeleteZone operation
type DeleteZoneRequest struct {
// The name or OCID of the target zone.
ZoneNameOrId *string `mandatory:"true" contributesTo:"path" name:"zoneNameOrId"`
// The `If-Match` header field makes the request method conditional on the
// existence of at least one current representation of the target resource,
// when the field-value is `*`, or having a current representation of the
// target resource that has an entity-tag matching a member of the list of
// entity-tags provided in the field-value.
IfMatch *string `mandatory:"false" contributesTo:"header" name:"If-Match"`
// The `If-Unmodified-Since` header field makes the request method
// conditional on the selected representation's last modification date being
// earlier than or equal to the date provided in the field-value. This
// field accomplishes the same purpose as If-Match for cases where the user
// agent does not have an entity-tag for the representation.
IfUnmodifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Unmodified-Since"`
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"false" contributesTo:"query" name:"compartmentId"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request DeleteZoneRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request DeleteZoneRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request DeleteZoneRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// DeleteZoneResponse wrapper for the DeleteZone operation
type DeleteZoneResponse struct {
// The underlying http response
RawResponse *http.Response
// Unique Oracle-assigned identifier for the request. If you need
// to contact Oracle about a particular request, please provide
// the request ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
}
func (response DeleteZoneResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response DeleteZoneResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

1191
vendor/github.com/oracle/oci-go-sdk/dns/dns_client.go generated vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,31 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// ExternalMaster An external master name server used as the source of zone data.
type ExternalMaster struct {
// The server's IP address (IPv4 or IPv6).
Address *string `mandatory:"true" json:"address"`
// The server's port. Port value must be a value of 53, otherwise omit
// the port value.
Port *int `mandatory:"false" json:"port"`
Tsig *Tsig `mandatory:"false" json:"tsig"`
}
func (m ExternalMaster) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,158 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// GetDomainRecordsRequest wrapper for the GetDomainRecords operation
type GetDomainRecordsRequest struct {
// The name or OCID of the target zone.
ZoneNameOrId *string `mandatory:"true" contributesTo:"path" name:"zoneNameOrId"`
// The target fully-qualified domain name (FQDN) within the target zone.
Domain *string `mandatory:"true" contributesTo:"path" name:"domain"`
// The `If-None-Match` header field makes the request method conditional on
// the absence of any current representation of the target resource, when
// the field-value is `*`, or having a selected representation with an
// entity-tag that does not match any of those listed in the field-value.
IfNoneMatch *string `mandatory:"false" contributesTo:"header" name:"If-None-Match"`
// The `If-Modified-Since` header field makes a GET or HEAD request method
// conditional on the selected representation's modification date being more
// recent than the date provided in the field-value. Transfer of the
// selected representation's data is avoided if that data has not changed.
IfModifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Modified-Since"`
// The maximum number of items to return in a page of the collection.
Limit *int64 `mandatory:"false" contributesTo:"query" name:"limit"`
// The value of the `opc-next-page` response header from the previous "List" call.
Page *string `mandatory:"false" contributesTo:"query" name:"page"`
// The version of the zone for which data is requested.
ZoneVersion *string `mandatory:"false" contributesTo:"query" name:"zoneVersion"`
// Search by record type.
// Will match any record whose type (https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4) (case-insensitive) equals the provided value.
Rtype *string `mandatory:"false" contributesTo:"query" name:"rtype"`
// The field by which to sort records.
SortBy GetDomainRecordsSortByEnum `mandatory:"false" contributesTo:"query" name:"sortBy" omitEmpty:"true"`
// The order to sort the resources.
SortOrder GetDomainRecordsSortOrderEnum `mandatory:"false" contributesTo:"query" name:"sortOrder" omitEmpty:"true"`
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"false" contributesTo:"query" name:"compartmentId"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request GetDomainRecordsRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request GetDomainRecordsRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request GetDomainRecordsRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// GetDomainRecordsResponse wrapper for the GetDomainRecords operation
type GetDomainRecordsResponse struct {
// The underlying http response
RawResponse *http.Response
// A list of RecordCollection instances
RecordCollection `presentIn:"body"`
// For list pagination. When this header appears in the response, additional pages
// of results remain. For important details about how pagination works,
// see List Pagination (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/API/Concepts/usingapi.htm#nine).
OpcNextPage *string `presentIn:"header" name:"opc-next-page"`
// The total number of items that match the query.
OpcTotalItems *int `presentIn:"header" name:"opc-total-items"`
// Unique Oracle-assigned identifier for the request. If you need
// to contact Oracle about a particular request, please provide
// the request ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the record collection, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
}
func (response GetDomainRecordsResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response GetDomainRecordsResponse) HTTPResponse() *http.Response {
return response.RawResponse
}
// GetDomainRecordsSortByEnum Enum with underlying type: string
type GetDomainRecordsSortByEnum string
// Set of constants representing the allowable values for GetDomainRecordsSortByEnum
const (
GetDomainRecordsSortByRtype GetDomainRecordsSortByEnum = "rtype"
GetDomainRecordsSortByTtl GetDomainRecordsSortByEnum = "ttl"
)
var mappingGetDomainRecordsSortBy = map[string]GetDomainRecordsSortByEnum{
"rtype": GetDomainRecordsSortByRtype,
"ttl": GetDomainRecordsSortByTtl,
}
// GetGetDomainRecordsSortByEnumValues Enumerates the set of values for GetDomainRecordsSortByEnum
func GetGetDomainRecordsSortByEnumValues() []GetDomainRecordsSortByEnum {
values := make([]GetDomainRecordsSortByEnum, 0)
for _, v := range mappingGetDomainRecordsSortBy {
values = append(values, v)
}
return values
}
// GetDomainRecordsSortOrderEnum Enum with underlying type: string
type GetDomainRecordsSortOrderEnum string
// Set of constants representing the allowable values for GetDomainRecordsSortOrderEnum
const (
GetDomainRecordsSortOrderAsc GetDomainRecordsSortOrderEnum = "ASC"
GetDomainRecordsSortOrderDesc GetDomainRecordsSortOrderEnum = "DESC"
)
var mappingGetDomainRecordsSortOrder = map[string]GetDomainRecordsSortOrderEnum{
"ASC": GetDomainRecordsSortOrderAsc,
"DESC": GetDomainRecordsSortOrderDesc,
}
// GetGetDomainRecordsSortOrderEnumValues Enumerates the set of values for GetDomainRecordsSortOrderEnum
func GetGetDomainRecordsSortOrderEnumValues() []GetDomainRecordsSortOrderEnum {
values := make([]GetDomainRecordsSortOrderEnum, 0)
for _, v := range mappingGetDomainRecordsSortOrder {
values = append(values, v)
}
return values
}

View file

@ -0,0 +1,105 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// GetRRSetRequest wrapper for the GetRRSet operation
type GetRRSetRequest struct {
// The name or OCID of the target zone.
ZoneNameOrId *string `mandatory:"true" contributesTo:"path" name:"zoneNameOrId"`
// The target fully-qualified domain name (FQDN) within the target zone.
Domain *string `mandatory:"true" contributesTo:"path" name:"domain"`
// The type of the target RRSet within the target zone.
Rtype *string `mandatory:"true" contributesTo:"path" name:"rtype"`
// The `If-None-Match` header field makes the request method conditional on
// the absence of any current representation of the target resource, when
// the field-value is `*`, or having a selected representation with an
// entity-tag that does not match any of those listed in the field-value.
IfNoneMatch *string `mandatory:"false" contributesTo:"header" name:"If-None-Match"`
// The `If-Modified-Since` header field makes a GET or HEAD request method
// conditional on the selected representation's modification date being more
// recent than the date provided in the field-value. Transfer of the
// selected representation's data is avoided if that data has not changed.
IfModifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Modified-Since"`
// The maximum number of items to return in a page of the collection.
Limit *int64 `mandatory:"false" contributesTo:"query" name:"limit"`
// The value of the `opc-next-page` response header from the previous "List" call.
Page *string `mandatory:"false" contributesTo:"query" name:"page"`
// The version of the zone for which data is requested.
ZoneVersion *string `mandatory:"false" contributesTo:"query" name:"zoneVersion"`
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"false" contributesTo:"query" name:"compartmentId"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request GetRRSetRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request GetRRSetRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request GetRRSetRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// GetRRSetResponse wrapper for the GetRRSet operation
type GetRRSetResponse struct {
// The underlying http response
RawResponse *http.Response
// A list of RrSet instances
RrSet `presentIn:"body"`
// For list pagination. When this header appears in the response, additional pages
// of results remain. For important details about how pagination works,
// see List Pagination (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/API/Concepts/usingapi.htm#nine).
OpcNextPage *string `presentIn:"header" name:"opc-next-page"`
// The total number of items that match the query.
OpcTotalItems *int `presentIn:"header" name:"opc-total-items"`
// Unique Oracle-assigned identifier for the request. If you need
// to contact Oracle about a particular request, please provide
// the request ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the record collection, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
}
func (response GetRRSetResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response GetRRSetResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,85 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// GetSteeringPolicyAttachmentRequest wrapper for the GetSteeringPolicyAttachment operation
type GetSteeringPolicyAttachmentRequest struct {
// The OCID of the target steering policy attachment.
SteeringPolicyAttachmentId *string `mandatory:"true" contributesTo:"path" name:"steeringPolicyAttachmentId"`
// The `If-None-Match` header field makes the request method conditional on
// the absence of any current representation of the target resource, when
// the field-value is `*`, or having a selected representation with an
// entity-tag that does not match any of those listed in the field-value.
IfNoneMatch *string `mandatory:"false" contributesTo:"header" name:"If-None-Match"`
// The `If-Modified-Since` header field makes a GET or HEAD request method
// conditional on the selected representation's modification date being more
// recent than the date provided in the field-value. Transfer of the
// selected representation's data is avoided if that data has not changed.
IfModifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Modified-Since"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request GetSteeringPolicyAttachmentRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request GetSteeringPolicyAttachmentRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request GetSteeringPolicyAttachmentRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// GetSteeringPolicyAttachmentResponse wrapper for the GetSteeringPolicyAttachment operation
type GetSteeringPolicyAttachmentResponse struct {
// The underlying http response
RawResponse *http.Response
// The SteeringPolicyAttachment instance
SteeringPolicyAttachment `presentIn:"body"`
// Unique Oracle-assigned identifier for the request. If you need to
// contact Oracle about a particular request, please provide the request
// ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the resource, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
// Flag to indicate whether or not the object was modified. If this is true,
// the getter for the object itself will return null. Callers should check this
// if they specified one of the request params that might result in a conditional
// response (like 'if-match'/'if-none-match').
IsNotModified bool
}
func (response GetSteeringPolicyAttachmentResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response GetSteeringPolicyAttachmentResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,85 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// GetSteeringPolicyRequest wrapper for the GetSteeringPolicy operation
type GetSteeringPolicyRequest struct {
// The OCID of the target steering policy.
SteeringPolicyId *string `mandatory:"true" contributesTo:"path" name:"steeringPolicyId"`
// The `If-None-Match` header field makes the request method conditional on
// the absence of any current representation of the target resource, when
// the field-value is `*`, or having a selected representation with an
// entity-tag that does not match any of those listed in the field-value.
IfNoneMatch *string `mandatory:"false" contributesTo:"header" name:"If-None-Match"`
// The `If-Modified-Since` header field makes a GET or HEAD request method
// conditional on the selected representation's modification date being more
// recent than the date provided in the field-value. Transfer of the
// selected representation's data is avoided if that data has not changed.
IfModifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Modified-Since"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request GetSteeringPolicyRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request GetSteeringPolicyRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request GetSteeringPolicyRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// GetSteeringPolicyResponse wrapper for the GetSteeringPolicy operation
type GetSteeringPolicyResponse struct {
// The underlying http response
RawResponse *http.Response
// The SteeringPolicy instance
SteeringPolicy `presentIn:"body"`
// Unique Oracle-assigned identifier for the request. If you need to
// contact Oracle about a particular request, please provide the request
// ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the resource, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
// Flag to indicate whether or not the object was modified. If this is true,
// the getter for the object itself will return null. Callers should check this
// if they specified one of the request params that might result in a conditional
// response (like 'if-match'/'if-none-match').
IsNotModified bool
}
func (response GetSteeringPolicyResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response GetSteeringPolicyResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,165 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// GetZoneRecordsRequest wrapper for the GetZoneRecords operation
type GetZoneRecordsRequest struct {
// The name or OCID of the target zone.
ZoneNameOrId *string `mandatory:"true" contributesTo:"path" name:"zoneNameOrId"`
// The `If-None-Match` header field makes the request method conditional on
// the absence of any current representation of the target resource, when
// the field-value is `*`, or having a selected representation with an
// entity-tag that does not match any of those listed in the field-value.
IfNoneMatch *string `mandatory:"false" contributesTo:"header" name:"If-None-Match"`
// The `If-Modified-Since` header field makes a GET or HEAD request method
// conditional on the selected representation's modification date being more
// recent than the date provided in the field-value. Transfer of the
// selected representation's data is avoided if that data has not changed.
IfModifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Modified-Since"`
// The maximum number of items to return in a page of the collection.
Limit *int64 `mandatory:"false" contributesTo:"query" name:"limit"`
// The value of the `opc-next-page` response header from the previous "List" call.
Page *string `mandatory:"false" contributesTo:"query" name:"page"`
// The version of the zone for which data is requested.
ZoneVersion *string `mandatory:"false" contributesTo:"query" name:"zoneVersion"`
// Search by domain.
// Will match any record whose domain (case-insensitive) equals the provided value.
Domain *string `mandatory:"false" contributesTo:"query" name:"domain"`
// Search by domain.
// Will match any record whose domain (case-insensitive) contains the provided value.
DomainContains *string `mandatory:"false" contributesTo:"query" name:"domainContains"`
// Search by record type.
// Will match any record whose type (https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4) (case-insensitive) equals the provided value.
Rtype *string `mandatory:"false" contributesTo:"query" name:"rtype"`
// The field by which to sort records.
SortBy GetZoneRecordsSortByEnum `mandatory:"false" contributesTo:"query" name:"sortBy" omitEmpty:"true"`
// The order to sort the resources.
SortOrder GetZoneRecordsSortOrderEnum `mandatory:"false" contributesTo:"query" name:"sortOrder" omitEmpty:"true"`
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"false" contributesTo:"query" name:"compartmentId"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request GetZoneRecordsRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request GetZoneRecordsRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request GetZoneRecordsRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// GetZoneRecordsResponse wrapper for the GetZoneRecords operation
type GetZoneRecordsResponse struct {
// The underlying http response
RawResponse *http.Response
// A list of RecordCollection instances
RecordCollection `presentIn:"body"`
// For list pagination. When this header appears in the response, additional pages
// of results remain. For important details about how pagination works,
// see List Pagination (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/API/Concepts/usingapi.htm#nine).
OpcNextPage *string `presentIn:"header" name:"opc-next-page"`
// The total number of items that match the query.
OpcTotalItems *int `presentIn:"header" name:"opc-total-items"`
// Unique Oracle-assigned identifier for the request. If you need
// to contact Oracle about a particular request, please provide
// the request ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the record collection, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
}
func (response GetZoneRecordsResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response GetZoneRecordsResponse) HTTPResponse() *http.Response {
return response.RawResponse
}
// GetZoneRecordsSortByEnum Enum with underlying type: string
type GetZoneRecordsSortByEnum string
// Set of constants representing the allowable values for GetZoneRecordsSortByEnum
const (
GetZoneRecordsSortByDomain GetZoneRecordsSortByEnum = "domain"
GetZoneRecordsSortByRtype GetZoneRecordsSortByEnum = "rtype"
GetZoneRecordsSortByTtl GetZoneRecordsSortByEnum = "ttl"
)
var mappingGetZoneRecordsSortBy = map[string]GetZoneRecordsSortByEnum{
"domain": GetZoneRecordsSortByDomain,
"rtype": GetZoneRecordsSortByRtype,
"ttl": GetZoneRecordsSortByTtl,
}
// GetGetZoneRecordsSortByEnumValues Enumerates the set of values for GetZoneRecordsSortByEnum
func GetGetZoneRecordsSortByEnumValues() []GetZoneRecordsSortByEnum {
values := make([]GetZoneRecordsSortByEnum, 0)
for _, v := range mappingGetZoneRecordsSortBy {
values = append(values, v)
}
return values
}
// GetZoneRecordsSortOrderEnum Enum with underlying type: string
type GetZoneRecordsSortOrderEnum string
// Set of constants representing the allowable values for GetZoneRecordsSortOrderEnum
const (
GetZoneRecordsSortOrderAsc GetZoneRecordsSortOrderEnum = "ASC"
GetZoneRecordsSortOrderDesc GetZoneRecordsSortOrderEnum = "DESC"
)
var mappingGetZoneRecordsSortOrder = map[string]GetZoneRecordsSortOrderEnum{
"ASC": GetZoneRecordsSortOrderAsc,
"DESC": GetZoneRecordsSortOrderDesc,
}
// GetGetZoneRecordsSortOrderEnumValues Enumerates the set of values for GetZoneRecordsSortOrderEnum
func GetGetZoneRecordsSortOrderEnumValues() []GetZoneRecordsSortOrderEnum {
values := make([]GetZoneRecordsSortOrderEnum, 0)
for _, v := range mappingGetZoneRecordsSortOrder {
values = append(values, v)
}
return values
}

View file

@ -0,0 +1,81 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// GetZoneRequest wrapper for the GetZone operation
type GetZoneRequest struct {
// The name or OCID of the target zone.
ZoneNameOrId *string `mandatory:"true" contributesTo:"path" name:"zoneNameOrId"`
// The `If-None-Match` header field makes the request method conditional on
// the absence of any current representation of the target resource, when
// the field-value is `*`, or having a selected representation with an
// entity-tag that does not match any of those listed in the field-value.
IfNoneMatch *string `mandatory:"false" contributesTo:"header" name:"If-None-Match"`
// The `If-Modified-Since` header field makes a GET or HEAD request method
// conditional on the selected representation's modification date being more
// recent than the date provided in the field-value. Transfer of the
// selected representation's data is avoided if that data has not changed.
IfModifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Modified-Since"`
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"false" contributesTo:"query" name:"compartmentId"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request GetZoneRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request GetZoneRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request GetZoneRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// GetZoneResponse wrapper for the GetZone operation
type GetZoneResponse struct {
// The underlying http response
RawResponse *http.Response
// The Zone instance
Zone `presentIn:"body"`
// Unique Oracle-assigned identifier for the request. If you need to
// contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the zone, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
}
func (response GetZoneResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response GetZoneResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,159 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// ListSteeringPoliciesRequest wrapper for the ListSteeringPolicies operation
type ListSteeringPoliciesRequest struct {
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"true" contributesTo:"query" name:"compartmentId"`
// The maximum number of items to return in a page of the collection.
Limit *int64 `mandatory:"false" contributesTo:"query" name:"limit"`
// The value of the `opc-next-page` response header from the previous "List" call.
Page *string `mandatory:"false" contributesTo:"query" name:"page"`
// The OCID of a resource.
Id *string `mandatory:"false" contributesTo:"query" name:"id"`
// The displayName of a resource.
DisplayName *string `mandatory:"false" contributesTo:"query" name:"displayName"`
// The partial displayName of a resource. Will match any resource whose name
// (case-insensitive) contains the provided value.
DisplayNameContains *string `mandatory:"false" contributesTo:"query" name:"displayNameContains"`
// Search by health check monitor OCID.
// Will match any resource whose health check monitor id matches the provided value.
HealthCheckMonitorId *string `mandatory:"false" contributesTo:"query" name:"healthCheckMonitorId"`
// An RFC 3339 (https://www.ietf.org/rfc/rfc3339.txt) timestamp that states
// all returned resources were created on or after the indicated time.
TimeCreatedGreaterThanOrEqualTo *common.SDKTime `mandatory:"false" contributesTo:"query" name:"timeCreatedGreaterThanOrEqualTo"`
// An RFC 3339 (https://www.ietf.org/rfc/rfc3339.txt) timestamp that states
// all returned resources were created before the indicated time.
TimeCreatedLessThan *common.SDKTime `mandatory:"false" contributesTo:"query" name:"timeCreatedLessThan"`
// Search by template type.
// Will match any resource whose template type matches the provided value.
Template *string `mandatory:"false" contributesTo:"query" name:"template"`
// The state of a resource.
LifecycleState SteeringPolicySummaryLifecycleStateEnum `mandatory:"false" contributesTo:"query" name:"lifecycleState" omitEmpty:"true"`
// The field by which to sort steering policies.
SortBy ListSteeringPoliciesSortByEnum `mandatory:"false" contributesTo:"query" name:"sortBy" omitEmpty:"true"`
// The order to sort the resources.
SortOrder ListSteeringPoliciesSortOrderEnum `mandatory:"false" contributesTo:"query" name:"sortOrder" omitEmpty:"true"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request ListSteeringPoliciesRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request ListSteeringPoliciesRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request ListSteeringPoliciesRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// ListSteeringPoliciesResponse wrapper for the ListSteeringPolicies operation
type ListSteeringPoliciesResponse struct {
// The underlying http response
RawResponse *http.Response
// A list of []SteeringPolicySummary instances
Items []SteeringPolicySummary `presentIn:"body"`
// For list pagination. When this header appears in the response, additional pages
// of results remain. For important details about how pagination works,
// see List Pagination (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/API/Concepts/usingapi.htm#nine).
OpcNextPage *string `presentIn:"header" name:"opc-next-page"`
// The total number of items that match the query.
OpcTotalItems *int `presentIn:"header" name:"opc-total-items"`
// Unique Oracle-assigned identifier for the request. If you need to
// contact Oracle about a particular request, please provide the request
// ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
}
func (response ListSteeringPoliciesResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response ListSteeringPoliciesResponse) HTTPResponse() *http.Response {
return response.RawResponse
}
// ListSteeringPoliciesSortByEnum Enum with underlying type: string
type ListSteeringPoliciesSortByEnum string
// Set of constants representing the allowable values for ListSteeringPoliciesSortByEnum
const (
ListSteeringPoliciesSortByDisplayname ListSteeringPoliciesSortByEnum = "displayName"
ListSteeringPoliciesSortByTimecreated ListSteeringPoliciesSortByEnum = "timeCreated"
ListSteeringPoliciesSortByTemplate ListSteeringPoliciesSortByEnum = "template"
)
var mappingListSteeringPoliciesSortBy = map[string]ListSteeringPoliciesSortByEnum{
"displayName": ListSteeringPoliciesSortByDisplayname,
"timeCreated": ListSteeringPoliciesSortByTimecreated,
"template": ListSteeringPoliciesSortByTemplate,
}
// GetListSteeringPoliciesSortByEnumValues Enumerates the set of values for ListSteeringPoliciesSortByEnum
func GetListSteeringPoliciesSortByEnumValues() []ListSteeringPoliciesSortByEnum {
values := make([]ListSteeringPoliciesSortByEnum, 0)
for _, v := range mappingListSteeringPoliciesSortBy {
values = append(values, v)
}
return values
}
// ListSteeringPoliciesSortOrderEnum Enum with underlying type: string
type ListSteeringPoliciesSortOrderEnum string
// Set of constants representing the allowable values for ListSteeringPoliciesSortOrderEnum
const (
ListSteeringPoliciesSortOrderAsc ListSteeringPoliciesSortOrderEnum = "ASC"
ListSteeringPoliciesSortOrderDesc ListSteeringPoliciesSortOrderEnum = "DESC"
)
var mappingListSteeringPoliciesSortOrder = map[string]ListSteeringPoliciesSortOrderEnum{
"ASC": ListSteeringPoliciesSortOrderAsc,
"DESC": ListSteeringPoliciesSortOrderDesc,
}
// GetListSteeringPoliciesSortOrderEnumValues Enumerates the set of values for ListSteeringPoliciesSortOrderEnum
func GetListSteeringPoliciesSortOrderEnumValues() []ListSteeringPoliciesSortOrderEnum {
values := make([]ListSteeringPoliciesSortOrderEnum, 0)
for _, v := range mappingListSteeringPoliciesSortOrder {
values = append(values, v)
}
return values
}

View file

@ -0,0 +1,163 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// ListSteeringPolicyAttachmentsRequest wrapper for the ListSteeringPolicyAttachments operation
type ListSteeringPolicyAttachmentsRequest struct {
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"true" contributesTo:"query" name:"compartmentId"`
// The maximum number of items to return in a page of the collection.
Limit *int64 `mandatory:"false" contributesTo:"query" name:"limit"`
// The value of the `opc-next-page` response header from the previous "List" call.
Page *string `mandatory:"false" contributesTo:"query" name:"page"`
// The OCID of a resource.
Id *string `mandatory:"false" contributesTo:"query" name:"id"`
// The displayName of a resource.
DisplayName *string `mandatory:"false" contributesTo:"query" name:"displayName"`
// Search by steering policy OCID.
// Will match any resource whose steering policy id matches the provided value.
SteeringPolicyId *string `mandatory:"false" contributesTo:"query" name:"steeringPolicyId"`
// Search by zone OCID.
// Will match any resource whose zone id matches the provided value.
ZoneId *string `mandatory:"false" contributesTo:"query" name:"zoneId"`
// Search by domain.
// Will match any record whose domain (case-insensitive) equals the provided value.
Domain *string `mandatory:"false" contributesTo:"query" name:"domain"`
// Search by domain.
// Will match any record whose domain (case-insensitive) contains the provided value.
DomainContains *string `mandatory:"false" contributesTo:"query" name:"domainContains"`
// An RFC 3339 (https://www.ietf.org/rfc/rfc3339.txt) timestamp that states
// all returned resources were created on or after the indicated time.
TimeCreatedGreaterThanOrEqualTo *common.SDKTime `mandatory:"false" contributesTo:"query" name:"timeCreatedGreaterThanOrEqualTo"`
// An RFC 3339 (https://www.ietf.org/rfc/rfc3339.txt) timestamp that states
// all returned resources were created before the indicated time.
TimeCreatedLessThan *common.SDKTime `mandatory:"false" contributesTo:"query" name:"timeCreatedLessThan"`
// The state of a resource.
LifecycleState SteeringPolicyAttachmentSummaryLifecycleStateEnum `mandatory:"false" contributesTo:"query" name:"lifecycleState" omitEmpty:"true"`
// The field by which to sort steering policy attachments.
SortBy ListSteeringPolicyAttachmentsSortByEnum `mandatory:"false" contributesTo:"query" name:"sortBy" omitEmpty:"true"`
// The order to sort the resources.
SortOrder ListSteeringPolicyAttachmentsSortOrderEnum `mandatory:"false" contributesTo:"query" name:"sortOrder" omitEmpty:"true"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request ListSteeringPolicyAttachmentsRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request ListSteeringPolicyAttachmentsRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request ListSteeringPolicyAttachmentsRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// ListSteeringPolicyAttachmentsResponse wrapper for the ListSteeringPolicyAttachments operation
type ListSteeringPolicyAttachmentsResponse struct {
// The underlying http response
RawResponse *http.Response
// A list of []SteeringPolicyAttachmentSummary instances
Items []SteeringPolicyAttachmentSummary `presentIn:"body"`
// For list pagination. When this header appears in the response, additional pages
// of results remain. For important details about how pagination works,
// see List Pagination (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/API/Concepts/usingapi.htm#nine).
OpcNextPage *string `presentIn:"header" name:"opc-next-page"`
// The total number of items that match the query.
OpcTotalItems *int `presentIn:"header" name:"opc-total-items"`
// Unique Oracle-assigned identifier for the request. If you need to
// contact Oracle about a particular request, please provide the request
// ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
}
func (response ListSteeringPolicyAttachmentsResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response ListSteeringPolicyAttachmentsResponse) HTTPResponse() *http.Response {
return response.RawResponse
}
// ListSteeringPolicyAttachmentsSortByEnum Enum with underlying type: string
type ListSteeringPolicyAttachmentsSortByEnum string
// Set of constants representing the allowable values for ListSteeringPolicyAttachmentsSortByEnum
const (
ListSteeringPolicyAttachmentsSortByDisplayname ListSteeringPolicyAttachmentsSortByEnum = "displayName"
ListSteeringPolicyAttachmentsSortByTimecreated ListSteeringPolicyAttachmentsSortByEnum = "timeCreated"
ListSteeringPolicyAttachmentsSortByDomainname ListSteeringPolicyAttachmentsSortByEnum = "domainName"
)
var mappingListSteeringPolicyAttachmentsSortBy = map[string]ListSteeringPolicyAttachmentsSortByEnum{
"displayName": ListSteeringPolicyAttachmentsSortByDisplayname,
"timeCreated": ListSteeringPolicyAttachmentsSortByTimecreated,
"domainName": ListSteeringPolicyAttachmentsSortByDomainname,
}
// GetListSteeringPolicyAttachmentsSortByEnumValues Enumerates the set of values for ListSteeringPolicyAttachmentsSortByEnum
func GetListSteeringPolicyAttachmentsSortByEnumValues() []ListSteeringPolicyAttachmentsSortByEnum {
values := make([]ListSteeringPolicyAttachmentsSortByEnum, 0)
for _, v := range mappingListSteeringPolicyAttachmentsSortBy {
values = append(values, v)
}
return values
}
// ListSteeringPolicyAttachmentsSortOrderEnum Enum with underlying type: string
type ListSteeringPolicyAttachmentsSortOrderEnum string
// Set of constants representing the allowable values for ListSteeringPolicyAttachmentsSortOrderEnum
const (
ListSteeringPolicyAttachmentsSortOrderAsc ListSteeringPolicyAttachmentsSortOrderEnum = "ASC"
ListSteeringPolicyAttachmentsSortOrderDesc ListSteeringPolicyAttachmentsSortOrderEnum = "DESC"
)
var mappingListSteeringPolicyAttachmentsSortOrder = map[string]ListSteeringPolicyAttachmentsSortOrderEnum{
"ASC": ListSteeringPolicyAttachmentsSortOrderAsc,
"DESC": ListSteeringPolicyAttachmentsSortOrderDesc,
}
// GetListSteeringPolicyAttachmentsSortOrderEnumValues Enumerates the set of values for ListSteeringPolicyAttachmentsSortOrderEnum
func GetListSteeringPolicyAttachmentsSortOrderEnumValues() []ListSteeringPolicyAttachmentsSortOrderEnum {
values := make([]ListSteeringPolicyAttachmentsSortOrderEnum, 0)
for _, v := range mappingListSteeringPolicyAttachmentsSortOrder {
values = append(values, v)
}
return values
}

View file

@ -0,0 +1,205 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// ListZonesRequest wrapper for the ListZones operation
type ListZonesRequest struct {
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"true" contributesTo:"query" name:"compartmentId"`
// The maximum number of items to return in a page of the collection.
Limit *int64 `mandatory:"false" contributesTo:"query" name:"limit"`
// The value of the `opc-next-page` response header from the previous "List" call.
Page *string `mandatory:"false" contributesTo:"query" name:"page"`
// A case-sensitive filter for zone names.
// Will match any zone with a name that equals the provided value.
Name *string `mandatory:"false" contributesTo:"query" name:"name"`
// Search by zone name.
// Will match any zone whose name (case-insensitive) contains the provided value.
NameContains *string `mandatory:"false" contributesTo:"query" name:"nameContains"`
// Search by zone type, `PRIMARY` or `SECONDARY`.
// Will match any zone whose type equals the provided value.
ZoneType ListZonesZoneTypeEnum `mandatory:"false" contributesTo:"query" name:"zoneType" omitEmpty:"true"`
// An RFC 3339 (https://www.ietf.org/rfc/rfc3339.txt) timestamp that states
// all returned resources were created on or after the indicated time.
TimeCreatedGreaterThanOrEqualTo *common.SDKTime `mandatory:"false" contributesTo:"query" name:"timeCreatedGreaterThanOrEqualTo"`
// An RFC 3339 (https://www.ietf.org/rfc/rfc3339.txt) timestamp that states
// all returned resources were created before the indicated time.
TimeCreatedLessThan *common.SDKTime `mandatory:"false" contributesTo:"query" name:"timeCreatedLessThan"`
// The state of a resource.
LifecycleState ListZonesLifecycleStateEnum `mandatory:"false" contributesTo:"query" name:"lifecycleState" omitEmpty:"true"`
// The field by which to sort zones.
SortBy ListZonesSortByEnum `mandatory:"false" contributesTo:"query" name:"sortBy" omitEmpty:"true"`
// The order to sort the resources.
SortOrder ListZonesSortOrderEnum `mandatory:"false" contributesTo:"query" name:"sortOrder" omitEmpty:"true"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request ListZonesRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request ListZonesRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request ListZonesRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// ListZonesResponse wrapper for the ListZones operation
type ListZonesResponse struct {
// The underlying http response
RawResponse *http.Response
// A list of []ZoneSummary instances
Items []ZoneSummary `presentIn:"body"`
// For list pagination. When this header appears in the response, additional pages
// of results remain. For important details about how pagination works,
// see List Pagination (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/API/Concepts/usingapi.htm#nine).
OpcNextPage *string `presentIn:"header" name:"opc-next-page"`
// The total number of items that match the query.
OpcTotalItems *int `presentIn:"header" name:"opc-total-items"`
// Unique Oracle-assigned identifier for the request. If you need to
// contact Oracle about a particular request, please provide the request
// ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
}
func (response ListZonesResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response ListZonesResponse) HTTPResponse() *http.Response {
return response.RawResponse
}
// ListZonesZoneTypeEnum Enum with underlying type: string
type ListZonesZoneTypeEnum string
// Set of constants representing the allowable values for ListZonesZoneTypeEnum
const (
ListZonesZoneTypePrimary ListZonesZoneTypeEnum = "PRIMARY"
ListZonesZoneTypeSecondary ListZonesZoneTypeEnum = "SECONDARY"
)
var mappingListZonesZoneType = map[string]ListZonesZoneTypeEnum{
"PRIMARY": ListZonesZoneTypePrimary,
"SECONDARY": ListZonesZoneTypeSecondary,
}
// GetListZonesZoneTypeEnumValues Enumerates the set of values for ListZonesZoneTypeEnum
func GetListZonesZoneTypeEnumValues() []ListZonesZoneTypeEnum {
values := make([]ListZonesZoneTypeEnum, 0)
for _, v := range mappingListZonesZoneType {
values = append(values, v)
}
return values
}
// ListZonesLifecycleStateEnum Enum with underlying type: string
type ListZonesLifecycleStateEnum string
// Set of constants representing the allowable values for ListZonesLifecycleStateEnum
const (
ListZonesLifecycleStateActive ListZonesLifecycleStateEnum = "ACTIVE"
ListZonesLifecycleStateCreating ListZonesLifecycleStateEnum = "CREATING"
ListZonesLifecycleStateDeleted ListZonesLifecycleStateEnum = "DELETED"
ListZonesLifecycleStateDeleting ListZonesLifecycleStateEnum = "DELETING"
ListZonesLifecycleStateFailed ListZonesLifecycleStateEnum = "FAILED"
)
var mappingListZonesLifecycleState = map[string]ListZonesLifecycleStateEnum{
"ACTIVE": ListZonesLifecycleStateActive,
"CREATING": ListZonesLifecycleStateCreating,
"DELETED": ListZonesLifecycleStateDeleted,
"DELETING": ListZonesLifecycleStateDeleting,
"FAILED": ListZonesLifecycleStateFailed,
}
// GetListZonesLifecycleStateEnumValues Enumerates the set of values for ListZonesLifecycleStateEnum
func GetListZonesLifecycleStateEnumValues() []ListZonesLifecycleStateEnum {
values := make([]ListZonesLifecycleStateEnum, 0)
for _, v := range mappingListZonesLifecycleState {
values = append(values, v)
}
return values
}
// ListZonesSortByEnum Enum with underlying type: string
type ListZonesSortByEnum string
// Set of constants representing the allowable values for ListZonesSortByEnum
const (
ListZonesSortByName ListZonesSortByEnum = "name"
ListZonesSortByZonetype ListZonesSortByEnum = "zoneType"
ListZonesSortByTimecreated ListZonesSortByEnum = "timeCreated"
)
var mappingListZonesSortBy = map[string]ListZonesSortByEnum{
"name": ListZonesSortByName,
"zoneType": ListZonesSortByZonetype,
"timeCreated": ListZonesSortByTimecreated,
}
// GetListZonesSortByEnumValues Enumerates the set of values for ListZonesSortByEnum
func GetListZonesSortByEnumValues() []ListZonesSortByEnum {
values := make([]ListZonesSortByEnum, 0)
for _, v := range mappingListZonesSortBy {
values = append(values, v)
}
return values
}
// ListZonesSortOrderEnum Enum with underlying type: string
type ListZonesSortOrderEnum string
// Set of constants representing the allowable values for ListZonesSortOrderEnum
const (
ListZonesSortOrderAsc ListZonesSortOrderEnum = "ASC"
ListZonesSortOrderDesc ListZonesSortOrderEnum = "DESC"
)
var mappingListZonesSortOrder = map[string]ListZonesSortOrderEnum{
"ASC": ListZonesSortOrderAsc,
"DESC": ListZonesSortOrderDesc,
}
// GetListZonesSortOrderEnumValues Enumerates the set of values for ListZonesSortOrderEnum
func GetListZonesSortOrderEnumValues() []ListZonesSortOrderEnum {
values := make([]ListZonesSortOrderEnum, 0)
for _, v := range mappingListZonesSortOrder {
values = append(values, v)
}
return values
}

25
vendor/github.com/oracle/oci-go-sdk/dns/nameserver.go generated vendored Normal file
View file

@ -0,0 +1,25 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// Nameserver A server that has been set up to answer DNS queries for a zone.
type Nameserver struct {
// The hostname of the nameserver.
Hostname *string `mandatory:"true" json:"hostname"`
}
func (m Nameserver) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,23 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// PatchDomainRecordsDetails The representation of PatchDomainRecordsDetails
type PatchDomainRecordsDetails struct {
Items []RecordOperation `mandatory:"false" json:"items"`
}
func (m PatchDomainRecordsDetails) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,98 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// PatchDomainRecordsRequest wrapper for the PatchDomainRecords operation
type PatchDomainRecordsRequest struct {
// The name or OCID of the target zone.
ZoneNameOrId *string `mandatory:"true" contributesTo:"path" name:"zoneNameOrId"`
// The target fully-qualified domain name (FQDN) within the target zone.
Domain *string `mandatory:"true" contributesTo:"path" name:"domain"`
// Operations describing how to modify the collection of records.
PatchDomainRecordsDetails `contributesTo:"body"`
// The `If-Match` header field makes the request method conditional on the
// existence of at least one current representation of the target resource,
// when the field-value is `*`, or having a current representation of the
// target resource that has an entity-tag matching a member of the list of
// entity-tags provided in the field-value.
IfMatch *string `mandatory:"false" contributesTo:"header" name:"If-Match"`
// The `If-Unmodified-Since` header field makes the request method
// conditional on the selected representation's last modification date being
// earlier than or equal to the date provided in the field-value. This
// field accomplishes the same purpose as If-Match for cases where the user
// agent does not have an entity-tag for the representation.
IfUnmodifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Unmodified-Since"`
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"false" contributesTo:"query" name:"compartmentId"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request PatchDomainRecordsRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request PatchDomainRecordsRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request PatchDomainRecordsRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// PatchDomainRecordsResponse wrapper for the PatchDomainRecords operation
type PatchDomainRecordsResponse struct {
// The underlying http response
RawResponse *http.Response
// The RecordCollection instance
RecordCollection `presentIn:"body"`
// For list pagination. When this header appears in the response, additional pages
// of results remain. For important details about how pagination works,
// see List Pagination (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/API/Concepts/usingapi.htm#nine).
OpcNextPage *string `presentIn:"header" name:"opc-next-page"`
// The total number of items that match the query.
OpcTotalItems *int `presentIn:"header" name:"opc-total-items"`
// Unique Oracle-assigned identifier for the request. If you need
// to contact Oracle about a particular request, please provide
// the request ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the record collection, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
}
func (response PatchDomainRecordsResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response PatchDomainRecordsResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,101 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// PatchRRSetRequest wrapper for the PatchRRSet operation
type PatchRRSetRequest struct {
// The name or OCID of the target zone.
ZoneNameOrId *string `mandatory:"true" contributesTo:"path" name:"zoneNameOrId"`
// The target fully-qualified domain name (FQDN) within the target zone.
Domain *string `mandatory:"true" contributesTo:"path" name:"domain"`
// The type of the target RRSet within the target zone.
Rtype *string `mandatory:"true" contributesTo:"path" name:"rtype"`
// Operations describing how to modify the collection of records.
PatchRrSetDetails `contributesTo:"body"`
// The `If-Match` header field makes the request method conditional on the
// existence of at least one current representation of the target resource,
// when the field-value is `*`, or having a current representation of the
// target resource that has an entity-tag matching a member of the list of
// entity-tags provided in the field-value.
IfMatch *string `mandatory:"false" contributesTo:"header" name:"If-Match"`
// The `If-Unmodified-Since` header field makes the request method
// conditional on the selected representation's last modification date being
// earlier than or equal to the date provided in the field-value. This
// field accomplishes the same purpose as If-Match for cases where the user
// agent does not have an entity-tag for the representation.
IfUnmodifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Unmodified-Since"`
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"false" contributesTo:"query" name:"compartmentId"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request PatchRRSetRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request PatchRRSetRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request PatchRRSetRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// PatchRRSetResponse wrapper for the PatchRRSet operation
type PatchRRSetResponse struct {
// The underlying http response
RawResponse *http.Response
// The RecordCollection instance
RecordCollection `presentIn:"body"`
// For list pagination. When this header appears in the response, additional pages
// of results remain. For important details about how pagination works,
// see List Pagination (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/API/Concepts/usingapi.htm#nine).
OpcNextPage *string `presentIn:"header" name:"opc-next-page"`
// The total number of items that match the query.
OpcTotalItems *int `presentIn:"header" name:"opc-total-items"`
// Unique Oracle-assigned identifier for the request. If you need
// to contact Oracle about a particular request, please provide
// the request ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the record collection, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
}
func (response PatchRRSetResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response PatchRRSetResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,23 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// PatchRrSetDetails The representation of PatchRrSetDetails
type PatchRrSetDetails struct {
Items []RecordOperation `mandatory:"false" json:"items"`
}
func (m PatchRrSetDetails) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,23 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// PatchZoneRecordsDetails The representation of PatchZoneRecordsDetails
type PatchZoneRecordsDetails struct {
Items []RecordOperation `mandatory:"false" json:"items"`
}
func (m PatchZoneRecordsDetails) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,95 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// PatchZoneRecordsRequest wrapper for the PatchZoneRecords operation
type PatchZoneRecordsRequest struct {
// The name or OCID of the target zone.
ZoneNameOrId *string `mandatory:"true" contributesTo:"path" name:"zoneNameOrId"`
// The operations describing how to modify the collection of records.
PatchZoneRecordsDetails `contributesTo:"body"`
// The `If-Match` header field makes the request method conditional on the
// existence of at least one current representation of the target resource,
// when the field-value is `*`, or having a current representation of the
// target resource that has an entity-tag matching a member of the list of
// entity-tags provided in the field-value.
IfMatch *string `mandatory:"false" contributesTo:"header" name:"If-Match"`
// The `If-Unmodified-Since` header field makes the request method
// conditional on the selected representation's last modification date being
// earlier than or equal to the date provided in the field-value. This
// field accomplishes the same purpose as If-Match for cases where the user
// agent does not have an entity-tag for the representation.
IfUnmodifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Unmodified-Since"`
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"false" contributesTo:"query" name:"compartmentId"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request PatchZoneRecordsRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request PatchZoneRecordsRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request PatchZoneRecordsRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// PatchZoneRecordsResponse wrapper for the PatchZoneRecords operation
type PatchZoneRecordsResponse struct {
// The underlying http response
RawResponse *http.Response
// The RecordCollection instance
RecordCollection `presentIn:"body"`
// For list pagination. When this header appears in the response, additional pages
// of results remain. For important details about how pagination works,
// see List Pagination (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/API/Concepts/usingapi.htm#nine).
OpcNextPage *string `presentIn:"header" name:"opc-next-page"`
// The total number of items that match the query.
OpcTotalItems *int `presentIn:"header" name:"opc-total-items"`
// Unique Oracle-assigned identifier for the request. If you need
// to contact Oracle about a particular request, please provide
// the request ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the record collection, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
}
func (response PatchZoneRecordsResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response PatchZoneRecordsResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

49
vendor/github.com/oracle/oci-go-sdk/dns/record.go generated vendored Normal file
View file

@ -0,0 +1,49 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// Record A DNS resource record. For more information about DNS records, see RFC 1034 (https://tools.ietf.org/html/rfc1034#section-3.6).
type Record struct {
// The fully qualified domain name where the record can be located.
Domain *string `mandatory:"false" json:"domain"`
// A unique identifier for the record within its zone.
RecordHash *string `mandatory:"false" json:"recordHash"`
// A Boolean flag indicating whether or not parts of the record
// are unable to be explicitly managed.
IsProtected *bool `mandatory:"false" json:"isProtected"`
// The record's data, as whitespace-delimited tokens in
// type-specific presentation format. All RDATA is normalized and the
// returned presentation of your RDATA may differ from its initial input.
// For more information about RDATA, see Supported DNS Resource Record Types (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Reference/supporteddnsresource.htm)
Rdata *string `mandatory:"false" json:"rdata"`
// The latest version of the record's zone in which its RRSet differs
// from the preceding version.
RrsetVersion *string `mandatory:"false" json:"rrsetVersion"`
// The canonical name for the record's type, such as A or CNAME. For more
// information, see Resource Record (RR) TYPEs (https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4).
Rtype *string `mandatory:"false" json:"rtype"`
// The Time To Live for the record, in seconds.
Ttl *int `mandatory:"false" json:"ttl"`
}
func (m Record) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,23 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// RecordCollection A collection of DNS resource records.
type RecordCollection struct {
Items []Record `mandatory:"false" json:"items"`
}
func (m RecordCollection) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,49 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// RecordDetails A DNS resource record. For more information about records, see RFC 1034 (https://tools.ietf.org/html/rfc1034#section-3.6).
type RecordDetails struct {
// The fully qualified domain name where the record can be located.
Domain *string `mandatory:"true" json:"domain"`
// The record's data, as whitespace-delimited tokens in
// type-specific presentation format. All RDATA is normalized and the
// returned presentation of your RDATA may differ from its initial input.
// For more information about RDATA, see Supported DNS Resource Record Types (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Reference/supporteddnsresource.htm)
Rdata *string `mandatory:"true" json:"rdata"`
// The canonical name for the record's type, such as A or CNAME. For more
// information, see Resource Record (RR) TYPEs (https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4).
Rtype *string `mandatory:"true" json:"rtype"`
// The Time To Live for the record, in seconds.
Ttl *int `mandatory:"true" json:"ttl"`
// A unique identifier for the record within its zone.
RecordHash *string `mandatory:"false" json:"recordHash"`
// A Boolean flag indicating whether or not parts of the record
// are unable to be explicitly managed.
IsProtected *bool `mandatory:"false" json:"isProtected"`
// The latest version of the record's zone in which its RRSet differs
// from the preceding version.
RrsetVersion *string `mandatory:"false" json:"rrsetVersion"`
}
func (m RecordDetails) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,92 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// RecordOperation An extension of the existing record resource, describing either a
// precondition, an add, or a remove. Preconditions check all fields,
// including read-only data like `recordHash` and `rrsetVersion`.
type RecordOperation struct {
// The fully qualified domain name where the record can be located.
Domain *string `mandatory:"false" json:"domain"`
// A unique identifier for the record within its zone.
RecordHash *string `mandatory:"false" json:"recordHash"`
// A Boolean flag indicating whether or not parts of the record
// are unable to be explicitly managed.
IsProtected *bool `mandatory:"false" json:"isProtected"`
// The record's data, as whitespace-delimited tokens in
// type-specific presentation format. All RDATA is normalized and the
// returned presentation of your RDATA may differ from its initial input.
// For more information about RDATA, see Supported DNS Resource Record Types (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Reference/supporteddnsresource.htm)
Rdata *string `mandatory:"false" json:"rdata"`
// The latest version of the record's zone in which its RRSet differs
// from the preceding version.
RrsetVersion *string `mandatory:"false" json:"rrsetVersion"`
// The canonical name for the record's type, such as A or CNAME. For more
// information, see Resource Record (RR) TYPEs (https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4).
Rtype *string `mandatory:"false" json:"rtype"`
// The Time To Live for the record, in seconds.
Ttl *int `mandatory:"false" json:"ttl"`
// A description of how a record relates to a PATCH operation.
// - `REQUIRE` indicates a precondition that record data **must** already exist.
// - `PROHIBIT` indicates a precondition that record data **must not** already exist.
// - `ADD` indicates that record data **must** exist after successful application.
// - `REMOVE` indicates that record data **must not** exist after successful application.
// **Note:** `ADD` and `REMOVE` operations can succeed even if
// they require no changes when applied, such as when the described
// records are already present or absent.
// **Note:** `ADD` and `REMOVE` operations can describe changes for
// more than one record.
// **Example:** `{ "domain": "www.example.com", "rtype": "AAAA", "ttl": 60 }`
// specifies a new TTL for every record in the www.example.com AAAA RRSet.
Operation RecordOperationOperationEnum `mandatory:"false" json:"operation,omitempty"`
}
func (m RecordOperation) String() string {
return common.PointerString(m)
}
// RecordOperationOperationEnum Enum with underlying type: string
type RecordOperationOperationEnum string
// Set of constants representing the allowable values for RecordOperationOperationEnum
const (
RecordOperationOperationRequire RecordOperationOperationEnum = "REQUIRE"
RecordOperationOperationProhibit RecordOperationOperationEnum = "PROHIBIT"
RecordOperationOperationAdd RecordOperationOperationEnum = "ADD"
RecordOperationOperationRemove RecordOperationOperationEnum = "REMOVE"
)
var mappingRecordOperationOperation = map[string]RecordOperationOperationEnum{
"REQUIRE": RecordOperationOperationRequire,
"PROHIBIT": RecordOperationOperationProhibit,
"ADD": RecordOperationOperationAdd,
"REMOVE": RecordOperationOperationRemove,
}
// GetRecordOperationOperationEnumValues Enumerates the set of values for RecordOperationOperationEnum
func GetRecordOperationOperationEnumValues() []RecordOperationOperationEnum {
values := make([]RecordOperationOperationEnum, 0)
for _, v := range mappingRecordOperationOperation {
values = append(values, v)
}
return values
}

24
vendor/github.com/oracle/oci-go-sdk/dns/rr_set.go generated vendored Normal file
View file

@ -0,0 +1,24 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// RrSet A collection of DNS records of the same domain and type. For more
// information about record types, see Resource Record (RR) TYPEs (https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4).
type RrSet struct {
Items []Record `mandatory:"false" json:"items"`
}
func (m RrSet) String() string {
return common.PointerString(m)
}

22
vendor/github.com/oracle/oci-go-sdk/dns/sort_order.go generated vendored Normal file
View file

@ -0,0 +1,22 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// SortOrder The order to sort the resources.
type SortOrder struct {
}
func (m SortOrder) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,226 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"encoding/json"
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicy A DNS steering policy.
// *Warning:* Oracle recommends that you avoid using any confidential information when you supply string values using the API.
type SteeringPolicy struct {
// The OCID of the compartment containing the steering policy.
CompartmentId *string `mandatory:"false" json:"compartmentId"`
// A user-friendly name for the steering policy.
// Does not have to be unique, and it's changeable.
// Avoid entering confidential information.
DisplayName *string `mandatory:"false" json:"displayName"`
// The Time To Live for responses from the steering policy, in seconds.
// If not specified during creation, a value of 30 seconds will be used.
Ttl *int `mandatory:"false" json:"ttl"`
// The OCID of the health check monitor providing health data about the answers of the
// steering policy.
// A steering policy answer with `rdata` matching a monitored endpoint will use the health
// data of that endpoint.
// A steering policy answer with `rdata` not matching any monitored endpoint will be assumed
// healthy.
HealthCheckMonitorId *string `mandatory:"false" json:"healthCheckMonitorId"`
// The common pattern (or lack thereof) to which the steering policy adheres. This
// value restricts the possible configurations of rules, but thereby supports
// specifically tailored interfaces. Values other than "CUSTOM" require the rules to
// begin with an unconditional FILTER that keeps answers contingent upon
// `answer.isDisabled != true`, followed
// _if and only if the policy references a health check monitor_ by an unconditional
// HEALTH rule, and require the last rule to be an unconditional LIMIT.
// What must precede the LIMIT rule is determined by the template value:
// - FAILOVER requires exactly an unconditional PRIORITY rule that ranks answers by pool.
// Each answer pool must have a unique priority value assigned to it. Answer data must
// be defined in the `defaultAnswerData` property for the rule and the `cases` property
// must not be defined.
// - LOAD_BALANCE requires exactly an unconditional WEIGHTED rule that shuffles answers
// by name. Answer data must be defined in the `defaultAnswerData` property for the
// rule and the `cases` property must not be defined.
// - ROUTE_BY_GEO requires exactly one PRIORITY rule that ranks answers by pool using the
// geographical location of the client as a condition. Within that rule you may only
// use `query.client.geoKey` in the `caseCondition` expressions for defining the cases.
// For each case in the PRIORITY rule each answer pool must have a unique priority
// value assigned to it. Answer data can only be defined within cases and
// `defaultAnswerData` cannot be used in the PRIORITY rule.
// - ROUTE_BY_ASN requires exactly one PRIORITY rule that ranks answers by pool using the
// ASN of the client as a condition. Within that rule you may only use
// `query.client.asn` in the `caseCondition` expressions for defining the cases.
// For each case in the PRIORITY rule each answer pool must have a unique priority
// value assigned to it. Answer data can only be defined within cases and
// `defaultAnswerData` cannot be used in the PRIORITY rule.
// - ROUTE_BY_IP requires exactly one PRIORITY rule that ranks answers by pool using the
// IP subnet of the client as a condition. Within that rule you may only use
// `query.client.address` in the `caseCondition` expressions for defining the cases.
// For each case in the PRIORITY rule each answer pool must have a unique priority
// value assigned to it. Answer data can only be defined within cases and
// `defaultAnswerData` cannot be used in the PRIORITY rule.
// - CUSTOM allows an arbitrary configuration of rules.
// For an existing steering policy, the template value may be changed to any of the
// supported options but the resulting policy must conform to the requirements for the
// new template type or else a Bad Request error will be returned.
Template SteeringPolicyTemplateEnum `mandatory:"false" json:"template,omitempty"`
// Simple key-value pair that is applied without any predefined name, type, or scope.
// For more information, see Resource Tags (https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm).
// Example: `{"bar-key": "value"}`
FreeformTags map[string]string `mandatory:"false" json:"freeformTags"`
// Usage of predefined tag keys. These predefined keys are scoped to a namespace.
// Example: `{"foo-namespace": {"bar-key": "value"}}`
DefinedTags map[string]map[string]interface{} `mandatory:"false" json:"definedTags"`
// The set of all answers that can potentially issue from the steering policy.
Answers []SteeringPolicyAnswer `mandatory:"false" json:"answers"`
// The pipeline of rules that will be processed in sequence to reduce the pool of answers
// to a response for any given request.
// The first rule receives a shuffled list of all answers, and every other rule receives
// the list of answers emitted by the one preceding it. The last rule populates the
// response.
Rules []SteeringPolicyRule `mandatory:"false" json:"rules"`
// The canonical absolute URL of the resource.
Self *string `mandatory:"false" json:"self"`
// The OCID of the resource.
Id *string `mandatory:"false" json:"id"`
// The date and time the resource was created in "YYYY-MM-ddThh:mmZ" format
// with a Z offset, as defined by RFC 3339.
// **Example:** `2016-07-22T17:23:59:60Z`
TimeCreated *common.SDKTime `mandatory:"false" json:"timeCreated"`
// The current state of the resource.
LifecycleState SteeringPolicyLifecycleStateEnum `mandatory:"false" json:"lifecycleState,omitempty"`
}
func (m SteeringPolicy) String() string {
return common.PointerString(m)
}
// UnmarshalJSON unmarshals from json
func (m *SteeringPolicy) UnmarshalJSON(data []byte) (e error) {
model := struct {
CompartmentId *string `json:"compartmentId"`
DisplayName *string `json:"displayName"`
Ttl *int `json:"ttl"`
HealthCheckMonitorId *string `json:"healthCheckMonitorId"`
Template SteeringPolicyTemplateEnum `json:"template"`
FreeformTags map[string]string `json:"freeformTags"`
DefinedTags map[string]map[string]interface{} `json:"definedTags"`
Answers []SteeringPolicyAnswer `json:"answers"`
Rules []steeringpolicyrule `json:"rules"`
Self *string `json:"self"`
Id *string `json:"id"`
TimeCreated *common.SDKTime `json:"timeCreated"`
LifecycleState SteeringPolicyLifecycleStateEnum `json:"lifecycleState"`
}{}
e = json.Unmarshal(data, &model)
if e != nil {
return
}
m.CompartmentId = model.CompartmentId
m.DisplayName = model.DisplayName
m.Ttl = model.Ttl
m.HealthCheckMonitorId = model.HealthCheckMonitorId
m.Template = model.Template
m.FreeformTags = model.FreeformTags
m.DefinedTags = model.DefinedTags
m.Answers = make([]SteeringPolicyAnswer, len(model.Answers))
for i, n := range model.Answers {
m.Answers[i] = n
}
m.Rules = make([]SteeringPolicyRule, len(model.Rules))
for i, n := range model.Rules {
nn, err := n.UnmarshalPolymorphicJSON(n.JsonData)
if err != nil {
return err
}
if nn != nil {
m.Rules[i] = nn.(SteeringPolicyRule)
} else {
m.Rules[i] = nil
}
}
m.Self = model.Self
m.Id = model.Id
m.TimeCreated = model.TimeCreated
m.LifecycleState = model.LifecycleState
return
}
// SteeringPolicyTemplateEnum Enum with underlying type: string
type SteeringPolicyTemplateEnum string
// Set of constants representing the allowable values for SteeringPolicyTemplateEnum
const (
SteeringPolicyTemplateFailover SteeringPolicyTemplateEnum = "FAILOVER"
SteeringPolicyTemplateLoadBalance SteeringPolicyTemplateEnum = "LOAD_BALANCE"
SteeringPolicyTemplateRouteByGeo SteeringPolicyTemplateEnum = "ROUTE_BY_GEO"
SteeringPolicyTemplateRouteByAsn SteeringPolicyTemplateEnum = "ROUTE_BY_ASN"
SteeringPolicyTemplateRouteByIp SteeringPolicyTemplateEnum = "ROUTE_BY_IP"
SteeringPolicyTemplateCustom SteeringPolicyTemplateEnum = "CUSTOM"
)
var mappingSteeringPolicyTemplate = map[string]SteeringPolicyTemplateEnum{
"FAILOVER": SteeringPolicyTemplateFailover,
"LOAD_BALANCE": SteeringPolicyTemplateLoadBalance,
"ROUTE_BY_GEO": SteeringPolicyTemplateRouteByGeo,
"ROUTE_BY_ASN": SteeringPolicyTemplateRouteByAsn,
"ROUTE_BY_IP": SteeringPolicyTemplateRouteByIp,
"CUSTOM": SteeringPolicyTemplateCustom,
}
// GetSteeringPolicyTemplateEnumValues Enumerates the set of values for SteeringPolicyTemplateEnum
func GetSteeringPolicyTemplateEnumValues() []SteeringPolicyTemplateEnum {
values := make([]SteeringPolicyTemplateEnum, 0)
for _, v := range mappingSteeringPolicyTemplate {
values = append(values, v)
}
return values
}
// SteeringPolicyLifecycleStateEnum Enum with underlying type: string
type SteeringPolicyLifecycleStateEnum string
// Set of constants representing the allowable values for SteeringPolicyLifecycleStateEnum
const (
SteeringPolicyLifecycleStateActive SteeringPolicyLifecycleStateEnum = "ACTIVE"
SteeringPolicyLifecycleStateCreating SteeringPolicyLifecycleStateEnum = "CREATING"
SteeringPolicyLifecycleStateDeleted SteeringPolicyLifecycleStateEnum = "DELETED"
SteeringPolicyLifecycleStateDeleting SteeringPolicyLifecycleStateEnum = "DELETING"
)
var mappingSteeringPolicyLifecycleState = map[string]SteeringPolicyLifecycleStateEnum{
"ACTIVE": SteeringPolicyLifecycleStateActive,
"CREATING": SteeringPolicyLifecycleStateCreating,
"DELETED": SteeringPolicyLifecycleStateDeleted,
"DELETING": SteeringPolicyLifecycleStateDeleting,
}
// GetSteeringPolicyLifecycleStateEnumValues Enumerates the set of values for SteeringPolicyLifecycleStateEnum
func GetSteeringPolicyLifecycleStateEnumValues() []SteeringPolicyLifecycleStateEnum {
values := make([]SteeringPolicyLifecycleStateEnum, 0)
for _, v := range mappingSteeringPolicyLifecycleState {
values = append(values, v)
}
return values
}

View file

@ -0,0 +1,43 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicyAnswer DNS record data with metadata for processing in a steering policy.
// *Warning:* Oracle recommends that you avoid using any confidential information when you supply string values using the API.
type SteeringPolicyAnswer struct {
// A user-friendly name for the answer, unique within the steering policy.
Name *string `mandatory:"true" json:"name"`
// The canonical name for the record's type. Only A, AAAA, and CNAME are supported. For more
// information, see Resource Record (RR) TYPEs (https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4).
Rtype *string `mandatory:"true" json:"rtype"`
// The record's data, as whitespace-delimited tokens in
// type-specific presentation format.
Rdata *string `mandatory:"true" json:"rdata"`
// The freeform name of a group of one or more records (e.g., a data center or a geographic
// region) in which this one is included.
Pool *string `mandatory:"false" json:"pool"`
// Whether or not an answer should be excluded from responses, e.g. because the corresponding
// server is down for maintenance. Note, however, that such filtering is not automatic and
// will only take place if a rule implements it.
IsDisabled *bool `mandatory:"false" json:"isDisabled"`
}
func (m SteeringPolicyAnswer) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,86 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicyAttachment An attachment between a steering policy and a domain.
// An attachment occludes all records at its domain that are of a covered rtype, constructing
// DNS responses from its steering policy rather than from those domain records.
// A domain can have at most one attachment covering any given rtype.
type SteeringPolicyAttachment struct {
// The OCID of the attached steering policy.
SteeringPolicyId *string `mandatory:"false" json:"steeringPolicyId"`
// The OCID of the attached zone.
ZoneId *string `mandatory:"false" json:"zoneId"`
// The attached domain within the attached zone.
DomainName *string `mandatory:"false" json:"domainName"`
// A user-friendly name for the steering policy attachment.
// Does not have to be unique, and it's changeable.
// Avoid entering confidential information.
DisplayName *string `mandatory:"false" json:"displayName"`
// The record types covered by the attachment at the domain. The set of record types is
// determined by aggregating the record types from the answers defined in the steering
// policy.
Rtypes []string `mandatory:"false" json:"rtypes"`
// The OCID of the compartment containing the steering policy attachment.
CompartmentId *string `mandatory:"false" json:"compartmentId"`
// The canonical absolute URL of the resource.
Self *string `mandatory:"false" json:"self"`
// The OCID of the resource.
Id *string `mandatory:"false" json:"id"`
// The date and time the resource was created in "YYYY-MM-ddThh:mmZ" format
// with a Z offset, as defined by RFC 3339.
// **Example:** `2016-07-22T17:23:59:60Z`
TimeCreated *common.SDKTime `mandatory:"false" json:"timeCreated"`
// The current state of the resource.
LifecycleState SteeringPolicyAttachmentLifecycleStateEnum `mandatory:"false" json:"lifecycleState,omitempty"`
}
func (m SteeringPolicyAttachment) String() string {
return common.PointerString(m)
}
// SteeringPolicyAttachmentLifecycleStateEnum Enum with underlying type: string
type SteeringPolicyAttachmentLifecycleStateEnum string
// Set of constants representing the allowable values for SteeringPolicyAttachmentLifecycleStateEnum
const (
SteeringPolicyAttachmentLifecycleStateCreating SteeringPolicyAttachmentLifecycleStateEnum = "CREATING"
SteeringPolicyAttachmentLifecycleStateActive SteeringPolicyAttachmentLifecycleStateEnum = "ACTIVE"
SteeringPolicyAttachmentLifecycleStateDeleting SteeringPolicyAttachmentLifecycleStateEnum = "DELETING"
)
var mappingSteeringPolicyAttachmentLifecycleState = map[string]SteeringPolicyAttachmentLifecycleStateEnum{
"CREATING": SteeringPolicyAttachmentLifecycleStateCreating,
"ACTIVE": SteeringPolicyAttachmentLifecycleStateActive,
"DELETING": SteeringPolicyAttachmentLifecycleStateDeleting,
}
// GetSteeringPolicyAttachmentLifecycleStateEnumValues Enumerates the set of values for SteeringPolicyAttachmentLifecycleStateEnum
func GetSteeringPolicyAttachmentLifecycleStateEnumValues() []SteeringPolicyAttachmentLifecycleStateEnum {
values := make([]SteeringPolicyAttachmentLifecycleStateEnum, 0)
for _, v := range mappingSteeringPolicyAttachmentLifecycleState {
values = append(values, v)
}
return values
}

View file

@ -0,0 +1,83 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicyAttachmentSummary An attachment between a steering policy and a domain.
type SteeringPolicyAttachmentSummary struct {
// The OCID of the attached steering policy.
SteeringPolicyId *string `mandatory:"false" json:"steeringPolicyId"`
// The OCID of the attached zone.
ZoneId *string `mandatory:"false" json:"zoneId"`
// The attached domain within the attached zone.
DomainName *string `mandatory:"false" json:"domainName"`
// A user-friendly name for the steering policy attachment.
// Does not have to be unique, and it's changeable.
// Avoid entering confidential information.
DisplayName *string `mandatory:"false" json:"displayName"`
// The record types covered by the attachment at the domain. The set of record types is
// determined by aggregating the record types from the answers defined in the steering
// policy.
Rtypes []string `mandatory:"false" json:"rtypes"`
// The OCID of the compartment containing the steering policy attachment.
CompartmentId *string `mandatory:"false" json:"compartmentId"`
// The canonical absolute URL of the resource.
Self *string `mandatory:"false" json:"self"`
// The OCID of the resource.
Id *string `mandatory:"false" json:"id"`
// The date and time the resource was created in "YYYY-MM-ddThh:mmZ" format
// with a Z offset, as defined by RFC 3339.
// **Example:** `2016-07-22T17:23:59:60Z`
TimeCreated *common.SDKTime `mandatory:"false" json:"timeCreated"`
// The current state of the resource.
LifecycleState SteeringPolicyAttachmentSummaryLifecycleStateEnum `mandatory:"false" json:"lifecycleState,omitempty"`
}
func (m SteeringPolicyAttachmentSummary) String() string {
return common.PointerString(m)
}
// SteeringPolicyAttachmentSummaryLifecycleStateEnum Enum with underlying type: string
type SteeringPolicyAttachmentSummaryLifecycleStateEnum string
// Set of constants representing the allowable values for SteeringPolicyAttachmentSummaryLifecycleStateEnum
const (
SteeringPolicyAttachmentSummaryLifecycleStateCreating SteeringPolicyAttachmentSummaryLifecycleStateEnum = "CREATING"
SteeringPolicyAttachmentSummaryLifecycleStateActive SteeringPolicyAttachmentSummaryLifecycleStateEnum = "ACTIVE"
SteeringPolicyAttachmentSummaryLifecycleStateDeleting SteeringPolicyAttachmentSummaryLifecycleStateEnum = "DELETING"
)
var mappingSteeringPolicyAttachmentSummaryLifecycleState = map[string]SteeringPolicyAttachmentSummaryLifecycleStateEnum{
"CREATING": SteeringPolicyAttachmentSummaryLifecycleStateCreating,
"ACTIVE": SteeringPolicyAttachmentSummaryLifecycleStateActive,
"DELETING": SteeringPolicyAttachmentSummaryLifecycleStateDeleting,
}
// GetSteeringPolicyAttachmentSummaryLifecycleStateEnumValues Enumerates the set of values for SteeringPolicyAttachmentSummaryLifecycleStateEnum
func GetSteeringPolicyAttachmentSummaryLifecycleStateEnumValues() []SteeringPolicyAttachmentSummaryLifecycleStateEnum {
values := make([]SteeringPolicyAttachmentSummaryLifecycleStateEnum, 0)
for _, v := range mappingSteeringPolicyAttachmentSummaryLifecycleState {
values = append(values, v)
}
return values
}

View file

@ -0,0 +1,26 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicyFilterAnswerData The representation of SteeringPolicyFilterAnswerData
type SteeringPolicyFilterAnswerData struct {
AnswerCondition *string `mandatory:"false" json:"answerCondition"`
// Keep the answer if the value is `true`.
ShouldKeep *bool `mandatory:"false" json:"shouldKeep"`
}
func (m SteeringPolicyFilterAnswerData) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,53 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"encoding/json"
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicyFilterRule The representation of SteeringPolicyFilterRule
type SteeringPolicyFilterRule struct {
// Your description of the rule's purpose and/or behavior.
Description *string `mandatory:"false" json:"description"`
Cases []SteeringPolicyFilterRuleCase `mandatory:"false" json:"cases"`
// Defines a default set of answer conditions and values that are applied to an answer when
// `cases` is not defined for the rule or a matching case does not have any matching
// `answerCondition`s in its `answerData`. `defaultAnswerData` is **not** applied if `cases` is
// defined and there are no matching cases.
DefaultAnswerData []SteeringPolicyFilterAnswerData `mandatory:"false" json:"defaultAnswerData"`
}
//GetDescription returns Description
func (m SteeringPolicyFilterRule) GetDescription() *string {
return m.Description
}
func (m SteeringPolicyFilterRule) String() string {
return common.PointerString(m)
}
// MarshalJSON marshals to json representation
func (m SteeringPolicyFilterRule) MarshalJSON() (buff []byte, e error) {
type MarshalTypeSteeringPolicyFilterRule SteeringPolicyFilterRule
s := struct {
DiscriminatorParam string `json:"ruleType"`
MarshalTypeSteeringPolicyFilterRule
}{
"FILTER",
(MarshalTypeSteeringPolicyFilterRule)(m),
}
return json.Marshal(&s)
}

View file

@ -0,0 +1,25 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicyFilterRuleCase The representation of SteeringPolicyFilterRuleCase
type SteeringPolicyFilterRuleCase struct {
CaseCondition *string `mandatory:"false" json:"caseCondition"`
AnswerData []SteeringPolicyFilterAnswerData `mandatory:"false" json:"answerData"`
}
func (m SteeringPolicyFilterRuleCase) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,47 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"encoding/json"
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicyHealthRule The representation of SteeringPolicyHealthRule
type SteeringPolicyHealthRule struct {
// Your description of the rule's purpose and/or behavior.
Description *string `mandatory:"false" json:"description"`
Cases []SteeringPolicyHealthRuleCase `mandatory:"false" json:"cases"`
}
//GetDescription returns Description
func (m SteeringPolicyHealthRule) GetDescription() *string {
return m.Description
}
func (m SteeringPolicyHealthRule) String() string {
return common.PointerString(m)
}
// MarshalJSON marshals to json representation
func (m SteeringPolicyHealthRule) MarshalJSON() (buff []byte, e error) {
type MarshalTypeSteeringPolicyHealthRule SteeringPolicyHealthRule
s := struct {
DiscriminatorParam string `json:"ruleType"`
MarshalTypeSteeringPolicyHealthRule
}{
"HEALTH",
(MarshalTypeSteeringPolicyHealthRule)(m),
}
return json.Marshal(&s)
}

View file

@ -0,0 +1,23 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicyHealthRuleCase The representation of SteeringPolicyHealthRuleCase
type SteeringPolicyHealthRuleCase struct {
CaseCondition *string `mandatory:"false" json:"caseCondition"`
}
func (m SteeringPolicyHealthRuleCase) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,52 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"encoding/json"
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicyLimitRule The representation of SteeringPolicyLimitRule
type SteeringPolicyLimitRule struct {
// Your description of the rule's purpose and/or behavior.
Description *string `mandatory:"false" json:"description"`
Cases []SteeringPolicyLimitRuleCase `mandatory:"false" json:"cases"`
// Defines a default count if `cases` is not defined for the rule or a matching case does
// not define `count`. `defaultCount` is **not** applied if `cases` is defined and there
// are no matching cases.
DefaultCount *int `mandatory:"false" json:"defaultCount"`
}
//GetDescription returns Description
func (m SteeringPolicyLimitRule) GetDescription() *string {
return m.Description
}
func (m SteeringPolicyLimitRule) String() string {
return common.PointerString(m)
}
// MarshalJSON marshals to json representation
func (m SteeringPolicyLimitRule) MarshalJSON() (buff []byte, e error) {
type MarshalTypeSteeringPolicyLimitRule SteeringPolicyLimitRule
s := struct {
DiscriminatorParam string `json:"ruleType"`
MarshalTypeSteeringPolicyLimitRule
}{
"LIMIT",
(MarshalTypeSteeringPolicyLimitRule)(m),
}
return json.Marshal(&s)
}

View file

@ -0,0 +1,25 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicyLimitRuleCase The representation of SteeringPolicyLimitRuleCase
type SteeringPolicyLimitRuleCase struct {
Count *int `mandatory:"true" json:"count"`
CaseCondition *string `mandatory:"false" json:"caseCondition"`
}
func (m SteeringPolicyLimitRuleCase) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,25 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicyPriorityAnswerData The representation of SteeringPolicyPriorityAnswerData
type SteeringPolicyPriorityAnswerData struct {
AnswerCondition *string `mandatory:"false" json:"answerCondition"`
Value *int `mandatory:"false" json:"value"`
}
func (m SteeringPolicyPriorityAnswerData) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,53 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"encoding/json"
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicyPriorityRule The representation of SteeringPolicyPriorityRule
type SteeringPolicyPriorityRule struct {
// Your description of the rule's purpose and/or behavior.
Description *string `mandatory:"false" json:"description"`
Cases []SteeringPolicyPriorityRuleCase `mandatory:"false" json:"cases"`
// Defines a default set of answer conditions and values that are applied to an answer when
// `cases` is not defined for the rule or a matching case does not have any matching
// `answerCondition`s in its `answerData`. `defaultAnswerData` is **not** applied if `cases` is
// defined and there are no matching cases.
DefaultAnswerData []SteeringPolicyPriorityAnswerData `mandatory:"false" json:"defaultAnswerData"`
}
//GetDescription returns Description
func (m SteeringPolicyPriorityRule) GetDescription() *string {
return m.Description
}
func (m SteeringPolicyPriorityRule) String() string {
return common.PointerString(m)
}
// MarshalJSON marshals to json representation
func (m SteeringPolicyPriorityRule) MarshalJSON() (buff []byte, e error) {
type MarshalTypeSteeringPolicyPriorityRule SteeringPolicyPriorityRule
s := struct {
DiscriminatorParam string `json:"ruleType"`
MarshalTypeSteeringPolicyPriorityRule
}{
"PRIORITY",
(MarshalTypeSteeringPolicyPriorityRule)(m),
}
return json.Marshal(&s)
}

View file

@ -0,0 +1,25 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicyPriorityRuleCase The representation of SteeringPolicyPriorityRuleCase
type SteeringPolicyPriorityRuleCase struct {
CaseCondition *string `mandatory:"false" json:"caseCondition"`
AnswerData []SteeringPolicyPriorityAnswerData `mandatory:"false" json:"answerData"`
}
func (m SteeringPolicyPriorityRuleCase) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,101 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"encoding/json"
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicyRule Configuration for sorting and/or filtering the list of remaining candidate answers, subject to
// rule type and the values of type-specific parameters and/or data associated with answers.
// A rule may optionally include a sequence of cases, each with an optional `caseCondition`
// expression. If it does, the first case with a matching `caseCondition` or with no
// `caseCondition` at all is used to set rule parameter values and/or answer-associated data,
// and the rule will be ignored during processing of any request that does not match any case.
// Rules without a sequence of cases are processed unconditionally, and rules with an _empty_
// sequence of cases are **ignored** unconditionally.
// Data is associated with answers one-by-one in a similar fashion—for each answer, the first
// answerData item with a matching `answerCondition` or with no `answerCondition` at all is used
// to associate data with the answer, and the absence of any such item associates with the answer
// a default value. Rule-level default answer data is always processed, but case-level answer
// data will override it on a per-answer basis.
// To prevent empty responses, any attempt to filter away all answers is suppressed at runtime.
type SteeringPolicyRule interface {
// Your description of the rule's purpose and/or behavior.
GetDescription() *string
}
type steeringpolicyrule struct {
JsonData []byte
Description *string `mandatory:"false" json:"description"`
RuleType string `json:"ruleType"`
}
// UnmarshalJSON unmarshals json
func (m *steeringpolicyrule) UnmarshalJSON(data []byte) error {
m.JsonData = data
type Unmarshalersteeringpolicyrule steeringpolicyrule
s := struct {
Model Unmarshalersteeringpolicyrule
}{}
err := json.Unmarshal(data, &s.Model)
if err != nil {
return err
}
m.Description = s.Model.Description
m.RuleType = s.Model.RuleType
return err
}
// UnmarshalPolymorphicJSON unmarshals polymorphic json
func (m *steeringpolicyrule) UnmarshalPolymorphicJSON(data []byte) (interface{}, error) {
if data == nil || string(data) == "null" {
return nil, nil
}
var err error
switch m.RuleType {
case "FILTER":
mm := SteeringPolicyFilterRule{}
err = json.Unmarshal(data, &mm)
return mm, err
case "WEIGHTED":
mm := SteeringPolicyWeightedRule{}
err = json.Unmarshal(data, &mm)
return mm, err
case "LIMIT":
mm := SteeringPolicyLimitRule{}
err = json.Unmarshal(data, &mm)
return mm, err
case "HEALTH":
mm := SteeringPolicyHealthRule{}
err = json.Unmarshal(data, &mm)
return mm, err
case "PRIORITY":
mm := SteeringPolicyPriorityRule{}
err = json.Unmarshal(data, &mm)
return mm, err
default:
return *m, nil
}
}
//GetDescription returns Description
func (m steeringpolicyrule) GetDescription() *string {
return m.Description
}
func (m steeringpolicyrule) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,163 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicySummary A DNS steering policy.
// *Warning:* Oracle recommends that you avoid using any confidential information when you supply string values using the API.
type SteeringPolicySummary struct {
// The OCID of the compartment containing the steering policy.
CompartmentId *string `mandatory:"false" json:"compartmentId"`
// A user-friendly name for the steering policy.
// Does not have to be unique, and it's changeable.
// Avoid entering confidential information.
DisplayName *string `mandatory:"false" json:"displayName"`
// The Time To Live for responses from the steering policy, in seconds.
// If not specified during creation, a value of 30 seconds will be used.
Ttl *int `mandatory:"false" json:"ttl"`
// The OCID of the health check monitor providing health data about the answers of the
// steering policy.
// A steering policy answer with `rdata` matching a monitored endpoint will use the health
// data of that endpoint.
// A steering policy answer with `rdata` not matching any monitored endpoint will be assumed
// healthy.
HealthCheckMonitorId *string `mandatory:"false" json:"healthCheckMonitorId"`
// The common pattern (or lack thereof) to which the steering policy adheres. This
// value restricts the possible configurations of rules, but thereby supports
// specifically tailored interfaces. Values other than "CUSTOM" require the rules to
// begin with an unconditional FILTER that keeps answers contingent upon
// `answer.isDisabled != true`, followed
// _if and only if the policy references a health check monitor_ by an unconditional
// HEALTH rule, and require the last rule to be an unconditional LIMIT.
// What must precede the LIMIT rule is determined by the template value:
// - FAILOVER requires exactly an unconditional PRIORITY rule that ranks answers by pool.
// Each answer pool must have a unique priority value assigned to it. Answer data must
// be defined in the `defaultAnswerData` property for the rule and the `cases` property
// must not be defined.
// - LOAD_BALANCE requires exactly an unconditional WEIGHTED rule that shuffles answers
// by name. Answer data must be defined in the `defaultAnswerData` property for the
// rule and the `cases` property must not be defined.
// - ROUTE_BY_GEO requires exactly one PRIORITY rule that ranks answers by pool using the
// geographical location of the client as a condition. Within that rule you may only
// use `query.client.geoKey` in the `caseCondition` expressions for defining the cases.
// For each case in the PRIORITY rule each answer pool must have a unique priority
// value assigned to it. Answer data can only be defined within cases and
// `defaultAnswerData` cannot be used in the PRIORITY rule.
// - ROUTE_BY_ASN requires exactly one PRIORITY rule that ranks answers by pool using the
// ASN of the client as a condition. Within that rule you may only use
// `query.client.asn` in the `caseCondition` expressions for defining the cases.
// For each case in the PRIORITY rule each answer pool must have a unique priority
// value assigned to it. Answer data can only be defined within cases and
// `defaultAnswerData` cannot be used in the PRIORITY rule.
// - ROUTE_BY_IP requires exactly one PRIORITY rule that ranks answers by pool using the
// IP subnet of the client as a condition. Within that rule you may only use
// `query.client.address` in the `caseCondition` expressions for defining the cases.
// For each case in the PRIORITY rule each answer pool must have a unique priority
// value assigned to it. Answer data can only be defined within cases and
// `defaultAnswerData` cannot be used in the PRIORITY rule.
// - CUSTOM allows an arbitrary configuration of rules.
// For an existing steering policy, the template value may be changed to any of the
// supported options but the resulting policy must conform to the requirements for the
// new template type or else a Bad Request error will be returned.
Template SteeringPolicySummaryTemplateEnum `mandatory:"false" json:"template,omitempty"`
// Simple key-value pair that is applied without any predefined name, type, or scope.
// For more information, see Resource Tags (https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm).
// Example: `{"bar-key": "value"}`
FreeformTags map[string]string `mandatory:"false" json:"freeformTags"`
// Usage of predefined tag keys. These predefined keys are scoped to a namespace.
// Example: `{"foo-namespace": {"bar-key": "value"}}`
DefinedTags map[string]map[string]interface{} `mandatory:"false" json:"definedTags"`
// The canonical absolute URL of the resource.
Self *string `mandatory:"false" json:"self"`
// The OCID of the resource.
Id *string `mandatory:"false" json:"id"`
// The date and time the resource was created in "YYYY-MM-ddThh:mmZ" format
// with a Z offset, as defined by RFC 3339.
// **Example:** `2016-07-22T17:23:59:60Z`
TimeCreated *common.SDKTime `mandatory:"false" json:"timeCreated"`
// The current state of the resource.
LifecycleState SteeringPolicySummaryLifecycleStateEnum `mandatory:"false" json:"lifecycleState,omitempty"`
}
func (m SteeringPolicySummary) String() string {
return common.PointerString(m)
}
// SteeringPolicySummaryTemplateEnum Enum with underlying type: string
type SteeringPolicySummaryTemplateEnum string
// Set of constants representing the allowable values for SteeringPolicySummaryTemplateEnum
const (
SteeringPolicySummaryTemplateFailover SteeringPolicySummaryTemplateEnum = "FAILOVER"
SteeringPolicySummaryTemplateLoadBalance SteeringPolicySummaryTemplateEnum = "LOAD_BALANCE"
SteeringPolicySummaryTemplateRouteByGeo SteeringPolicySummaryTemplateEnum = "ROUTE_BY_GEO"
SteeringPolicySummaryTemplateRouteByAsn SteeringPolicySummaryTemplateEnum = "ROUTE_BY_ASN"
SteeringPolicySummaryTemplateRouteByIp SteeringPolicySummaryTemplateEnum = "ROUTE_BY_IP"
SteeringPolicySummaryTemplateCustom SteeringPolicySummaryTemplateEnum = "CUSTOM"
)
var mappingSteeringPolicySummaryTemplate = map[string]SteeringPolicySummaryTemplateEnum{
"FAILOVER": SteeringPolicySummaryTemplateFailover,
"LOAD_BALANCE": SteeringPolicySummaryTemplateLoadBalance,
"ROUTE_BY_GEO": SteeringPolicySummaryTemplateRouteByGeo,
"ROUTE_BY_ASN": SteeringPolicySummaryTemplateRouteByAsn,
"ROUTE_BY_IP": SteeringPolicySummaryTemplateRouteByIp,
"CUSTOM": SteeringPolicySummaryTemplateCustom,
}
// GetSteeringPolicySummaryTemplateEnumValues Enumerates the set of values for SteeringPolicySummaryTemplateEnum
func GetSteeringPolicySummaryTemplateEnumValues() []SteeringPolicySummaryTemplateEnum {
values := make([]SteeringPolicySummaryTemplateEnum, 0)
for _, v := range mappingSteeringPolicySummaryTemplate {
values = append(values, v)
}
return values
}
// SteeringPolicySummaryLifecycleStateEnum Enum with underlying type: string
type SteeringPolicySummaryLifecycleStateEnum string
// Set of constants representing the allowable values for SteeringPolicySummaryLifecycleStateEnum
const (
SteeringPolicySummaryLifecycleStateActive SteeringPolicySummaryLifecycleStateEnum = "ACTIVE"
SteeringPolicySummaryLifecycleStateCreating SteeringPolicySummaryLifecycleStateEnum = "CREATING"
SteeringPolicySummaryLifecycleStateDeleted SteeringPolicySummaryLifecycleStateEnum = "DELETED"
SteeringPolicySummaryLifecycleStateDeleting SteeringPolicySummaryLifecycleStateEnum = "DELETING"
)
var mappingSteeringPolicySummaryLifecycleState = map[string]SteeringPolicySummaryLifecycleStateEnum{
"ACTIVE": SteeringPolicySummaryLifecycleStateActive,
"CREATING": SteeringPolicySummaryLifecycleStateCreating,
"DELETED": SteeringPolicySummaryLifecycleStateDeleted,
"DELETING": SteeringPolicySummaryLifecycleStateDeleting,
}
// GetSteeringPolicySummaryLifecycleStateEnumValues Enumerates the set of values for SteeringPolicySummaryLifecycleStateEnum
func GetSteeringPolicySummaryLifecycleStateEnumValues() []SteeringPolicySummaryLifecycleStateEnum {
values := make([]SteeringPolicySummaryLifecycleStateEnum, 0)
for _, v := range mappingSteeringPolicySummaryLifecycleState {
values = append(values, v)
}
return values
}

View file

@ -0,0 +1,25 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicyWeightedAnswerData The representation of SteeringPolicyWeightedAnswerData
type SteeringPolicyWeightedAnswerData struct {
AnswerCondition *string `mandatory:"false" json:"answerCondition"`
Value *int `mandatory:"false" json:"value"`
}
func (m SteeringPolicyWeightedAnswerData) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,53 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"encoding/json"
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicyWeightedRule The representation of SteeringPolicyWeightedRule
type SteeringPolicyWeightedRule struct {
// Your description of the rule's purpose and/or behavior.
Description *string `mandatory:"false" json:"description"`
Cases []SteeringPolicyWeightedRuleCase `mandatory:"false" json:"cases"`
// Defines a default set of answer conditions and values that are applied to an answer when
// `cases` is not defined for the rule or a matching case does not have any matching
// `answerCondition`s in its `answerData`. `defaultAnswerData` is **not** applied if `cases` is
// defined and there are no matching cases.
DefaultAnswerData []SteeringPolicyWeightedAnswerData `mandatory:"false" json:"defaultAnswerData"`
}
//GetDescription returns Description
func (m SteeringPolicyWeightedRule) GetDescription() *string {
return m.Description
}
func (m SteeringPolicyWeightedRule) String() string {
return common.PointerString(m)
}
// MarshalJSON marshals to json representation
func (m SteeringPolicyWeightedRule) MarshalJSON() (buff []byte, e error) {
type MarshalTypeSteeringPolicyWeightedRule SteeringPolicyWeightedRule
s := struct {
DiscriminatorParam string `json:"ruleType"`
MarshalTypeSteeringPolicyWeightedRule
}{
"WEIGHTED",
(MarshalTypeSteeringPolicyWeightedRule)(m),
}
return json.Marshal(&s)
}

View file

@ -0,0 +1,25 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// SteeringPolicyWeightedRuleCase The representation of SteeringPolicyWeightedRuleCase
type SteeringPolicyWeightedRuleCase struct {
CaseCondition *string `mandatory:"false" json:"caseCondition"`
AnswerData []SteeringPolicyWeightedAnswerData `mandatory:"false" json:"answerData"`
}
func (m SteeringPolicyWeightedRuleCase) String() string {
return common.PointerString(m)
}

34
vendor/github.com/oracle/oci-go-sdk/dns/tsig.go generated vendored Normal file
View file

@ -0,0 +1,34 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// Tsig A TSIG (https://tools.ietf.org/html/rfc2845) key.
type Tsig struct {
// A domain name identifying the key for a given pair of hosts.
Name *string `mandatory:"true" json:"name"`
// A base64 string encoding the binary shared secret.
Secret *string `mandatory:"true" json:"secret"`
// TSIG Algorithms are encoded as domain names, but most consist of only one
// non-empty label, which is not required to be explicitly absolute.
// Applicable algorithms include: hmac-sha1, hmac-sha224, hmac-sha256,
// hmac-sha512. For more information on these algorithms, see RFC 4635 (https://tools.ietf.org/html/rfc4635#section-2).
Algorithm *string `mandatory:"true" json:"algorithm"`
}
func (m Tsig) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,23 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// UpdateDomainRecordsDetails The representation of UpdateDomainRecordsDetails
type UpdateDomainRecordsDetails struct {
Items []RecordDetails `mandatory:"false" json:"items"`
}
func (m UpdateDomainRecordsDetails) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,98 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// UpdateDomainRecordsRequest wrapper for the UpdateDomainRecords operation
type UpdateDomainRecordsRequest struct {
// The name or OCID of the target zone.
ZoneNameOrId *string `mandatory:"true" contributesTo:"path" name:"zoneNameOrId"`
// The target fully-qualified domain name (FQDN) within the target zone.
Domain *string `mandatory:"true" contributesTo:"path" name:"domain"`
// A full list of records for the domain.
UpdateDomainRecordsDetails `contributesTo:"body"`
// The `If-Match` header field makes the request method conditional on the
// existence of at least one current representation of the target resource,
// when the field-value is `*`, or having a current representation of the
// target resource that has an entity-tag matching a member of the list of
// entity-tags provided in the field-value.
IfMatch *string `mandatory:"false" contributesTo:"header" name:"If-Match"`
// The `If-Unmodified-Since` header field makes the request method
// conditional on the selected representation's last modification date being
// earlier than or equal to the date provided in the field-value. This
// field accomplishes the same purpose as If-Match for cases where the user
// agent does not have an entity-tag for the representation.
IfUnmodifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Unmodified-Since"`
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"false" contributesTo:"query" name:"compartmentId"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request UpdateDomainRecordsRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request UpdateDomainRecordsRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request UpdateDomainRecordsRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// UpdateDomainRecordsResponse wrapper for the UpdateDomainRecords operation
type UpdateDomainRecordsResponse struct {
// The underlying http response
RawResponse *http.Response
// The RecordCollection instance
RecordCollection `presentIn:"body"`
// For list pagination. When this header appears in the response, additional pages
// of results remain. For important details about how pagination works,
// see List Pagination (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/API/Concepts/usingapi.htm#nine).
OpcNextPage *string `presentIn:"header" name:"opc-next-page"`
// The total number of items that match the query.
OpcTotalItems *int `presentIn:"header" name:"opc-total-items"`
// Unique Oracle-assigned identifier for the request. If you need
// to contact Oracle about a particular request, please provide
// the request ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the record collection, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
}
func (response UpdateDomainRecordsResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response UpdateDomainRecordsResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,101 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// UpdateRRSetRequest wrapper for the UpdateRRSet operation
type UpdateRRSetRequest struct {
// The name or OCID of the target zone.
ZoneNameOrId *string `mandatory:"true" contributesTo:"path" name:"zoneNameOrId"`
// The target fully-qualified domain name (FQDN) within the target zone.
Domain *string `mandatory:"true" contributesTo:"path" name:"domain"`
// The type of the target RRSet within the target zone.
Rtype *string `mandatory:"true" contributesTo:"path" name:"rtype"`
// A full list of records for the RRSet.
UpdateRrSetDetails `contributesTo:"body"`
// The `If-Match` header field makes the request method conditional on the
// existence of at least one current representation of the target resource,
// when the field-value is `*`, or having a current representation of the
// target resource that has an entity-tag matching a member of the list of
// entity-tags provided in the field-value.
IfMatch *string `mandatory:"false" contributesTo:"header" name:"If-Match"`
// The `If-Unmodified-Since` header field makes the request method
// conditional on the selected representation's last modification date being
// earlier than or equal to the date provided in the field-value. This
// field accomplishes the same purpose as If-Match for cases where the user
// agent does not have an entity-tag for the representation.
IfUnmodifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Unmodified-Since"`
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"false" contributesTo:"query" name:"compartmentId"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request UpdateRRSetRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request UpdateRRSetRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request UpdateRRSetRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// UpdateRRSetResponse wrapper for the UpdateRRSet operation
type UpdateRRSetResponse struct {
// The underlying http response
RawResponse *http.Response
// The RecordCollection instance
RecordCollection `presentIn:"body"`
// For list pagination. When this header appears in the response, additional pages
// of results remain. For important details about how pagination works,
// see List Pagination (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/API/Concepts/usingapi.htm#nine).
OpcNextPage *string `presentIn:"header" name:"opc-next-page"`
// The total number of items that match the query.
OpcTotalItems *int `presentIn:"header" name:"opc-total-items"`
// Unique Oracle-assigned identifier for the request. If you need
// to contact Oracle about a particular request, please provide
// the request ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the record collection, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
}
func (response UpdateRRSetResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response UpdateRRSetResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,23 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// UpdateRrSetDetails The representation of UpdateRrSetDetails
type UpdateRrSetDetails struct {
Items []RecordDetails `mandatory:"false" json:"items"`
}
func (m UpdateRrSetDetails) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,27 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// UpdateSteeringPolicyAttachmentDetails The body for updating a steering policy attachment.
type UpdateSteeringPolicyAttachmentDetails struct {
// A user-friendly name for the steering policy attachment.
// Does not have to be unique, and it's changeable.
// Avoid entering confidential information.
DisplayName *string `mandatory:"false" json:"displayName"`
}
func (m UpdateSteeringPolicyAttachmentDetails) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,84 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// UpdateSteeringPolicyAttachmentRequest wrapper for the UpdateSteeringPolicyAttachment operation
type UpdateSteeringPolicyAttachmentRequest struct {
// The OCID of the target steering policy attachment.
SteeringPolicyAttachmentId *string `mandatory:"true" contributesTo:"path" name:"steeringPolicyAttachmentId"`
// New data for the steering policy attachment.
UpdateSteeringPolicyAttachmentDetails `contributesTo:"body"`
// The `If-Match` header field makes the request method conditional on the
// existence of at least one current representation of the target resource,
// when the field-value is `*`, or having a current representation of the
// target resource that has an entity-tag matching a member of the list of
// entity-tags provided in the field-value.
IfMatch *string `mandatory:"false" contributesTo:"header" name:"If-Match"`
// The `If-Unmodified-Since` header field makes the request method
// conditional on the selected representation's last modification date being
// earlier than or equal to the date provided in the field-value. This
// field accomplishes the same purpose as If-Match for cases where the user
// agent does not have an entity-tag for the representation.
IfUnmodifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Unmodified-Since"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request UpdateSteeringPolicyAttachmentRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request UpdateSteeringPolicyAttachmentRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request UpdateSteeringPolicyAttachmentRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// UpdateSteeringPolicyAttachmentResponse wrapper for the UpdateSteeringPolicyAttachment operation
type UpdateSteeringPolicyAttachmentResponse struct {
// The underlying http response
RawResponse *http.Response
// The SteeringPolicyAttachment instance
SteeringPolicyAttachment `presentIn:"body"`
// Unique Oracle-assigned identifier for the request. If you need to
// contact Oracle about a particular request, please provide the request
// ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the resource, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
}
func (response UpdateSteeringPolicyAttachmentResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response UpdateSteeringPolicyAttachmentResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,173 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"encoding/json"
"github.com/oracle/oci-go-sdk/common"
)
// UpdateSteeringPolicyDetails The body for updating a steering policy. New rules and answers provided in the request will
// replace the existing rules and answers in the policy.
// *Warning:* Oracle recommends that you avoid using any confidential information when you supply string values using the API.
type UpdateSteeringPolicyDetails struct {
// A user-friendly name for the steering policy.
// Does not have to be unique, and it's changeable.
// Avoid entering confidential information.
DisplayName *string `mandatory:"false" json:"displayName"`
// The Time To Live for responses from the steering policy, in seconds.
// If not specified during creation, a value of 30 seconds will be used.
Ttl *int `mandatory:"false" json:"ttl"`
// The OCID of the health check monitor providing health data about the answers of the
// steering policy.
// A steering policy answer with `rdata` matching a monitored endpoint will use the health
// data of that endpoint.
// A steering policy answer with `rdata` not matching any monitored endpoint will be assumed
// healthy.
HealthCheckMonitorId *string `mandatory:"false" json:"healthCheckMonitorId"`
// The common pattern (or lack thereof) to which the steering policy adheres. This
// value restricts the possible configurations of rules, but thereby supports
// specifically tailored interfaces. Values other than "CUSTOM" require the rules to
// begin with an unconditional FILTER that keeps answers contingent upon
// `answer.isDisabled != true`, followed
// _if and only if the policy references a health check monitor_ by an unconditional
// HEALTH rule, and require the last rule to be an unconditional LIMIT.
// What must precede the LIMIT rule is determined by the template value:
// - FAILOVER requires exactly an unconditional PRIORITY rule that ranks answers by pool.
// Each answer pool must have a unique priority value assigned to it. Answer data must
// be defined in the `defaultAnswerData` property for the rule and the `cases` property
// must not be defined.
// - LOAD_BALANCE requires exactly an unconditional WEIGHTED rule that shuffles answers
// by name. Answer data must be defined in the `defaultAnswerData` property for the
// rule and the `cases` property must not be defined.
// - ROUTE_BY_GEO requires exactly one PRIORITY rule that ranks answers by pool using the
// geographical location of the client as a condition. Within that rule you may only
// use `query.client.geoKey` in the `caseCondition` expressions for defining the cases.
// For each case in the PRIORITY rule each answer pool must have a unique priority
// value assigned to it. Answer data can only be defined within cases and
// `defaultAnswerData` cannot be used in the PRIORITY rule.
// - ROUTE_BY_ASN requires exactly one PRIORITY rule that ranks answers by pool using the
// ASN of the client as a condition. Within that rule you may only use
// `query.client.asn` in the `caseCondition` expressions for defining the cases.
// For each case in the PRIORITY rule each answer pool must have a unique priority
// value assigned to it. Answer data can only be defined within cases and
// `defaultAnswerData` cannot be used in the PRIORITY rule.
// - ROUTE_BY_IP requires exactly one PRIORITY rule that ranks answers by pool using the
// IP subnet of the client as a condition. Within that rule you may only use
// `query.client.address` in the `caseCondition` expressions for defining the cases.
// For each case in the PRIORITY rule each answer pool must have a unique priority
// value assigned to it. Answer data can only be defined within cases and
// `defaultAnswerData` cannot be used in the PRIORITY rule.
// - CUSTOM allows an arbitrary configuration of rules.
// For an existing steering policy, the template value may be changed to any of the
// supported options but the resulting policy must conform to the requirements for the
// new template type or else a Bad Request error will be returned.
Template UpdateSteeringPolicyDetailsTemplateEnum `mandatory:"false" json:"template,omitempty"`
// Simple key-value pair that is applied without any predefined name, type, or scope.
// For more information, see Resource Tags (https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm).
// Example: `{"bar-key": "value"}`
FreeformTags map[string]string `mandatory:"false" json:"freeformTags"`
// Usage of predefined tag keys. These predefined keys are scoped to a namespace.
// Example: `{"foo-namespace": {"bar-key": "value"}}`
DefinedTags map[string]map[string]interface{} `mandatory:"false" json:"definedTags"`
// The set of all answers that can potentially issue from the steering policy.
Answers []SteeringPolicyAnswer `mandatory:"false" json:"answers"`
// The pipeline of rules that will be processed in sequence to reduce the pool of answers
// to a response for any given request.
// The first rule receives a shuffled list of all answers, and every other rule receives
// the list of answers emitted by the one preceding it. The last rule populates the
// response.
Rules []SteeringPolicyRule `mandatory:"false" json:"rules"`
}
func (m UpdateSteeringPolicyDetails) String() string {
return common.PointerString(m)
}
// UnmarshalJSON unmarshals from json
func (m *UpdateSteeringPolicyDetails) UnmarshalJSON(data []byte) (e error) {
model := struct {
DisplayName *string `json:"displayName"`
Ttl *int `json:"ttl"`
HealthCheckMonitorId *string `json:"healthCheckMonitorId"`
Template UpdateSteeringPolicyDetailsTemplateEnum `json:"template"`
FreeformTags map[string]string `json:"freeformTags"`
DefinedTags map[string]map[string]interface{} `json:"definedTags"`
Answers []SteeringPolicyAnswer `json:"answers"`
Rules []steeringpolicyrule `json:"rules"`
}{}
e = json.Unmarshal(data, &model)
if e != nil {
return
}
m.DisplayName = model.DisplayName
m.Ttl = model.Ttl
m.HealthCheckMonitorId = model.HealthCheckMonitorId
m.Template = model.Template
m.FreeformTags = model.FreeformTags
m.DefinedTags = model.DefinedTags
m.Answers = make([]SteeringPolicyAnswer, len(model.Answers))
for i, n := range model.Answers {
m.Answers[i] = n
}
m.Rules = make([]SteeringPolicyRule, len(model.Rules))
for i, n := range model.Rules {
nn, err := n.UnmarshalPolymorphicJSON(n.JsonData)
if err != nil {
return err
}
if nn != nil {
m.Rules[i] = nn.(SteeringPolicyRule)
} else {
m.Rules[i] = nil
}
}
return
}
// UpdateSteeringPolicyDetailsTemplateEnum Enum with underlying type: string
type UpdateSteeringPolicyDetailsTemplateEnum string
// Set of constants representing the allowable values for UpdateSteeringPolicyDetailsTemplateEnum
const (
UpdateSteeringPolicyDetailsTemplateFailover UpdateSteeringPolicyDetailsTemplateEnum = "FAILOVER"
UpdateSteeringPolicyDetailsTemplateLoadBalance UpdateSteeringPolicyDetailsTemplateEnum = "LOAD_BALANCE"
UpdateSteeringPolicyDetailsTemplateRouteByGeo UpdateSteeringPolicyDetailsTemplateEnum = "ROUTE_BY_GEO"
UpdateSteeringPolicyDetailsTemplateRouteByAsn UpdateSteeringPolicyDetailsTemplateEnum = "ROUTE_BY_ASN"
UpdateSteeringPolicyDetailsTemplateRouteByIp UpdateSteeringPolicyDetailsTemplateEnum = "ROUTE_BY_IP"
UpdateSteeringPolicyDetailsTemplateCustom UpdateSteeringPolicyDetailsTemplateEnum = "CUSTOM"
)
var mappingUpdateSteeringPolicyDetailsTemplate = map[string]UpdateSteeringPolicyDetailsTemplateEnum{
"FAILOVER": UpdateSteeringPolicyDetailsTemplateFailover,
"LOAD_BALANCE": UpdateSteeringPolicyDetailsTemplateLoadBalance,
"ROUTE_BY_GEO": UpdateSteeringPolicyDetailsTemplateRouteByGeo,
"ROUTE_BY_ASN": UpdateSteeringPolicyDetailsTemplateRouteByAsn,
"ROUTE_BY_IP": UpdateSteeringPolicyDetailsTemplateRouteByIp,
"CUSTOM": UpdateSteeringPolicyDetailsTemplateCustom,
}
// GetUpdateSteeringPolicyDetailsTemplateEnumValues Enumerates the set of values for UpdateSteeringPolicyDetailsTemplateEnum
func GetUpdateSteeringPolicyDetailsTemplateEnumValues() []UpdateSteeringPolicyDetailsTemplateEnum {
values := make([]UpdateSteeringPolicyDetailsTemplateEnum, 0)
for _, v := range mappingUpdateSteeringPolicyDetailsTemplate {
values = append(values, v)
}
return values
}

View file

@ -0,0 +1,84 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// UpdateSteeringPolicyRequest wrapper for the UpdateSteeringPolicy operation
type UpdateSteeringPolicyRequest struct {
// The OCID of the target steering policy.
SteeringPolicyId *string `mandatory:"true" contributesTo:"path" name:"steeringPolicyId"`
// New data for the steering policy.
UpdateSteeringPolicyDetails `contributesTo:"body"`
// The `If-Match` header field makes the request method conditional on the
// existence of at least one current representation of the target resource,
// when the field-value is `*`, or having a current representation of the
// target resource that has an entity-tag matching a member of the list of
// entity-tags provided in the field-value.
IfMatch *string `mandatory:"false" contributesTo:"header" name:"If-Match"`
// The `If-Unmodified-Since` header field makes the request method
// conditional on the selected representation's last modification date being
// earlier than or equal to the date provided in the field-value. This
// field accomplishes the same purpose as If-Match for cases where the user
// agent does not have an entity-tag for the representation.
IfUnmodifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Unmodified-Since"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request UpdateSteeringPolicyRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request UpdateSteeringPolicyRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request UpdateSteeringPolicyRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// UpdateSteeringPolicyResponse wrapper for the UpdateSteeringPolicy operation
type UpdateSteeringPolicyResponse struct {
// The underlying http response
RawResponse *http.Response
// The SteeringPolicy instance
SteeringPolicy `presentIn:"body"`
// Unique Oracle-assigned identifier for the request. If you need to
// contact Oracle about a particular request, please provide the request
// ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the resource, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
}
func (response UpdateSteeringPolicyResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response UpdateSteeringPolicyResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,36 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// UpdateZoneDetails The body for updating a zone.
// *Warning:* Oracle recommends that you avoid using any confidential information when you supply string values using the API.
type UpdateZoneDetails struct {
// Simple key-value pair that is applied without any predefined name, type, or scope.
// For more information, see Resource Tags (https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm).
// Example: `{"bar-key": "value"}`
FreeformTags map[string]string `mandatory:"false" json:"freeformTags"`
// Usage of predefined tag keys. These predefined keys are scoped to a namespace.
// Example: `{"foo-namespace": {"bar-key": "value"}}`
DefinedTags map[string]map[string]interface{} `mandatory:"false" json:"definedTags"`
// External master servers for the zone. `externalMasters` becomes a
// required parameter when the `zoneType` value is `SECONDARY`.
ExternalMasters []ExternalMaster `mandatory:"false" json:"externalMasters"`
}
func (m UpdateZoneDetails) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,23 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// UpdateZoneRecordsDetails The representation of UpdateZoneRecordsDetails
type UpdateZoneRecordsDetails struct {
Items []RecordDetails `mandatory:"false" json:"items"`
}
func (m UpdateZoneRecordsDetails) String() string {
return common.PointerString(m)
}

View file

@ -0,0 +1,95 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// UpdateZoneRecordsRequest wrapper for the UpdateZoneRecords operation
type UpdateZoneRecordsRequest struct {
// The name or OCID of the target zone.
ZoneNameOrId *string `mandatory:"true" contributesTo:"path" name:"zoneNameOrId"`
// A full list of records for the zone.
UpdateZoneRecordsDetails `contributesTo:"body"`
// The `If-Match` header field makes the request method conditional on the
// existence of at least one current representation of the target resource,
// when the field-value is `*`, or having a current representation of the
// target resource that has an entity-tag matching a member of the list of
// entity-tags provided in the field-value.
IfMatch *string `mandatory:"false" contributesTo:"header" name:"If-Match"`
// The `If-Unmodified-Since` header field makes the request method
// conditional on the selected representation's last modification date being
// earlier than or equal to the date provided in the field-value. This
// field accomplishes the same purpose as If-Match for cases where the user
// agent does not have an entity-tag for the representation.
IfUnmodifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Unmodified-Since"`
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"false" contributesTo:"query" name:"compartmentId"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request UpdateZoneRecordsRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request UpdateZoneRecordsRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request UpdateZoneRecordsRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// UpdateZoneRecordsResponse wrapper for the UpdateZoneRecords operation
type UpdateZoneRecordsResponse struct {
// The underlying http response
RawResponse *http.Response
// The RecordCollection instance
RecordCollection `presentIn:"body"`
// For list pagination. When this header appears in the response, additional pages
// of results remain. For important details about how pagination works,
// see List Pagination (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/API/Concepts/usingapi.htm#nine).
OpcNextPage *string `presentIn:"header" name:"opc-next-page"`
// The total number of items that match the query.
OpcTotalItems *int `presentIn:"header" name:"opc-total-items"`
// Unique Oracle-assigned identifier for the request. If you need
// to contact Oracle about a particular request, please provide
// the request ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the record collection, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
}
func (response UpdateZoneRecordsResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response UpdateZoneRecordsResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

View file

@ -0,0 +1,86 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
package dns
import (
"github.com/oracle/oci-go-sdk/common"
"net/http"
)
// UpdateZoneRequest wrapper for the UpdateZone operation
type UpdateZoneRequest struct {
// The name or OCID of the target zone.
ZoneNameOrId *string `mandatory:"true" contributesTo:"path" name:"zoneNameOrId"`
// New data for the zone.
UpdateZoneDetails `contributesTo:"body"`
// The `If-Match` header field makes the request method conditional on the
// existence of at least one current representation of the target resource,
// when the field-value is `*`, or having a current representation of the
// target resource that has an entity-tag matching a member of the list of
// entity-tags provided in the field-value.
IfMatch *string `mandatory:"false" contributesTo:"header" name:"If-Match"`
// The `If-Unmodified-Since` header field makes the request method
// conditional on the selected representation's last modification date being
// earlier than or equal to the date provided in the field-value. This
// field accomplishes the same purpose as If-Match for cases where the user
// agent does not have an entity-tag for the representation.
IfUnmodifiedSince *string `mandatory:"false" contributesTo:"header" name:"If-Unmodified-Since"`
// The OCID of the compartment the resource belongs to.
CompartmentId *string `mandatory:"false" contributesTo:"query" name:"compartmentId"`
// Unique Oracle-assigned identifier for the request.
// If you need to contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `mandatory:"false" contributesTo:"header" name:"opc-request-id"`
// Metadata about the request. This information will not be transmitted to the service, but
// represents information that the SDK will consume to drive retry behavior.
RequestMetadata common.RequestMetadata
}
func (request UpdateZoneRequest) String() string {
return common.PointerString(request)
}
// HTTPRequest implements the OCIRequest interface
func (request UpdateZoneRequest) HTTPRequest(method, path string) (http.Request, error) {
return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request)
}
// RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy.
func (request UpdateZoneRequest) RetryPolicy() *common.RetryPolicy {
return request.RequestMetadata.RetryPolicy
}
// UpdateZoneResponse wrapper for the UpdateZone operation
type UpdateZoneResponse struct {
// The underlying http response
RawResponse *http.Response
// The Zone instance
Zone `presentIn:"body"`
// Unique Oracle-assigned identifier for the request. If you need to
// contact Oracle about a particular request, please provide the request ID.
OpcRequestId *string `presentIn:"header" name:"opc-request-id"`
// The current version of the zone, ending with a
// representation-specific suffix. This value may be used in If-Match
// and If-None-Match headers for later requests of the same resource.
ETag *string `presentIn:"header" name:"etag"`
}
func (response UpdateZoneResponse) String() string {
return common.PointerString(response)
}
// HTTPResponse implements the OCIResponse interface
func (response UpdateZoneResponse) HTTPResponse() *http.Response {
return response.RawResponse
}

122
vendor/github.com/oracle/oci-go-sdk/dns/zone.go generated vendored Normal file
View file

@ -0,0 +1,122 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// Zone A DNS zone.
// *Warning:* Oracle recommends that you avoid using any confidential information when you supply string values using the API.
type Zone struct {
// The name of the zone.
Name *string `mandatory:"false" json:"name"`
// The type of the zone. Must be either `PRIMARY` or `SECONDARY`.
ZoneType ZoneZoneTypeEnum `mandatory:"false" json:"zoneType,omitempty"`
// The OCID of the compartment containing the zone.
CompartmentId *string `mandatory:"false" json:"compartmentId"`
// Simple key-value pair that is applied without any predefined name, type, or scope.
// For more information, see Resource Tags (https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm).
// Example: `{"bar-key": "value"}`
FreeformTags map[string]string `mandatory:"false" json:"freeformTags"`
// Usage of predefined tag keys. These predefined keys are scoped to a namespace.
// Example: `{"foo-namespace": {"bar-key": "value"}}`
DefinedTags map[string]map[string]interface{} `mandatory:"false" json:"definedTags"`
// External master servers for the zone. `externalMasters` becomes a
// required parameter when the `zoneType` value is `SECONDARY`.
ExternalMasters []ExternalMaster `mandatory:"false" json:"externalMasters"`
// The canonical absolute URL of the resource.
Self *string `mandatory:"false" json:"self"`
// The OCID of the zone.
Id *string `mandatory:"false" json:"id"`
// The date and time the resource was created in "YYYY-MM-ddThh:mmZ" format
// with a Z offset, as defined by RFC 3339.
// **Example:** `2016-07-22T17:23:59:60Z`
TimeCreated *common.SDKTime `mandatory:"false" json:"timeCreated"`
// Version is the never-repeating, totally-orderable, version of the
// zone, from which the serial field of the zone's SOA record is
// derived.
Version *string `mandatory:"false" json:"version"`
// The current serial of the zone. As seen in the zone's SOA record.
Serial *int64 `mandatory:"false" json:"serial"`
// The current state of the zone resource.
LifecycleState ZoneLifecycleStateEnum `mandatory:"false" json:"lifecycleState,omitempty"`
// The authoritative nameservers for the zone.
Nameservers []Nameserver `mandatory:"false" json:"nameservers"`
}
func (m Zone) String() string {
return common.PointerString(m)
}
// ZoneZoneTypeEnum Enum with underlying type: string
type ZoneZoneTypeEnum string
// Set of constants representing the allowable values for ZoneZoneTypeEnum
const (
ZoneZoneTypePrimary ZoneZoneTypeEnum = "PRIMARY"
ZoneZoneTypeSecondary ZoneZoneTypeEnum = "SECONDARY"
)
var mappingZoneZoneType = map[string]ZoneZoneTypeEnum{
"PRIMARY": ZoneZoneTypePrimary,
"SECONDARY": ZoneZoneTypeSecondary,
}
// GetZoneZoneTypeEnumValues Enumerates the set of values for ZoneZoneTypeEnum
func GetZoneZoneTypeEnumValues() []ZoneZoneTypeEnum {
values := make([]ZoneZoneTypeEnum, 0)
for _, v := range mappingZoneZoneType {
values = append(values, v)
}
return values
}
// ZoneLifecycleStateEnum Enum with underlying type: string
type ZoneLifecycleStateEnum string
// Set of constants representing the allowable values for ZoneLifecycleStateEnum
const (
ZoneLifecycleStateActive ZoneLifecycleStateEnum = "ACTIVE"
ZoneLifecycleStateCreating ZoneLifecycleStateEnum = "CREATING"
ZoneLifecycleStateDeleted ZoneLifecycleStateEnum = "DELETED"
ZoneLifecycleStateDeleting ZoneLifecycleStateEnum = "DELETING"
ZoneLifecycleStateFailed ZoneLifecycleStateEnum = "FAILED"
)
var mappingZoneLifecycleState = map[string]ZoneLifecycleStateEnum{
"ACTIVE": ZoneLifecycleStateActive,
"CREATING": ZoneLifecycleStateCreating,
"DELETED": ZoneLifecycleStateDeleted,
"DELETING": ZoneLifecycleStateDeleting,
"FAILED": ZoneLifecycleStateFailed,
}
// GetZoneLifecycleStateEnumValues Enumerates the set of values for ZoneLifecycleStateEnum
func GetZoneLifecycleStateEnumValues() []ZoneLifecycleStateEnum {
values := make([]ZoneLifecycleStateEnum, 0)
for _, v := range mappingZoneLifecycleState {
values = append(values, v)
}
return values
}

115
vendor/github.com/oracle/oci-go-sdk/dns/zone_summary.go generated vendored Normal file
View file

@ -0,0 +1,115 @@
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
// Code generated. DO NOT EDIT.
// DNS API
//
// API for the DNS service. Use this API to manage DNS zones, records, and other DNS resources.
// For more information, see Overview of the DNS Service (https://docs.us-phoenix-1.oraclecloud.com/iaas/Content/DNS/Concepts/dnszonemanagement.htm).
//
package dns
import (
"github.com/oracle/oci-go-sdk/common"
)
// ZoneSummary A DNS zone.
// *Warning:* Oracle recommends that you avoid using any confidential information when you supply string values using the API.
type ZoneSummary struct {
// The name of the zone.
Name *string `mandatory:"false" json:"name"`
// The type of the zone. Must be either `PRIMARY` or `SECONDARY`.
ZoneType ZoneSummaryZoneTypeEnum `mandatory:"false" json:"zoneType,omitempty"`
// The OCID of the compartment containing the zone.
CompartmentId *string `mandatory:"false" json:"compartmentId"`
// Simple key-value pair that is applied without any predefined name, type, or scope.
// For more information, see Resource Tags (https://docs.us-phoenix-1.oraclecloud.com/Content/General/Concepts/resourcetags.htm).
// Example: `{"bar-key": "value"}`
FreeformTags map[string]string `mandatory:"false" json:"freeformTags"`
// Usage of predefined tag keys. These predefined keys are scoped to a namespace.
// Example: `{"foo-namespace": {"bar-key": "value"}}`
DefinedTags map[string]map[string]interface{} `mandatory:"false" json:"definedTags"`
// The canonical absolute URL of the resource.
Self *string `mandatory:"false" json:"self"`
// The OCID of the zone.
Id *string `mandatory:"false" json:"id"`
// The date and time the resource was created in "YYYY-MM-ddThh:mmZ" format
// with a Z offset, as defined by RFC 3339.
// **Example:** `2016-07-22T17:23:59:60Z`
TimeCreated *common.SDKTime `mandatory:"false" json:"timeCreated"`
// Version is the never-repeating, totally-orderable, version of the
// zone, from which the serial field of the zone's SOA record is
// derived.
Version *string `mandatory:"false" json:"version"`
// The current serial of the zone. As seen in the zone's SOA record.
Serial *int64 `mandatory:"false" json:"serial"`
// The current state of the zone resource.
LifecycleState ZoneSummaryLifecycleStateEnum `mandatory:"false" json:"lifecycleState,omitempty"`
}
func (m ZoneSummary) String() string {
return common.PointerString(m)
}
// ZoneSummaryZoneTypeEnum Enum with underlying type: string
type ZoneSummaryZoneTypeEnum string
// Set of constants representing the allowable values for ZoneSummaryZoneTypeEnum
const (
ZoneSummaryZoneTypePrimary ZoneSummaryZoneTypeEnum = "PRIMARY"
ZoneSummaryZoneTypeSecondary ZoneSummaryZoneTypeEnum = "SECONDARY"
)
var mappingZoneSummaryZoneType = map[string]ZoneSummaryZoneTypeEnum{
"PRIMARY": ZoneSummaryZoneTypePrimary,
"SECONDARY": ZoneSummaryZoneTypeSecondary,
}
// GetZoneSummaryZoneTypeEnumValues Enumerates the set of values for ZoneSummaryZoneTypeEnum
func GetZoneSummaryZoneTypeEnumValues() []ZoneSummaryZoneTypeEnum {
values := make([]ZoneSummaryZoneTypeEnum, 0)
for _, v := range mappingZoneSummaryZoneType {
values = append(values, v)
}
return values
}
// ZoneSummaryLifecycleStateEnum Enum with underlying type: string
type ZoneSummaryLifecycleStateEnum string
// Set of constants representing the allowable values for ZoneSummaryLifecycleStateEnum
const (
ZoneSummaryLifecycleStateActive ZoneSummaryLifecycleStateEnum = "ACTIVE"
ZoneSummaryLifecycleStateCreating ZoneSummaryLifecycleStateEnum = "CREATING"
ZoneSummaryLifecycleStateDeleted ZoneSummaryLifecycleStateEnum = "DELETED"
ZoneSummaryLifecycleStateDeleting ZoneSummaryLifecycleStateEnum = "DELETING"
ZoneSummaryLifecycleStateFailed ZoneSummaryLifecycleStateEnum = "FAILED"
)
var mappingZoneSummaryLifecycleState = map[string]ZoneSummaryLifecycleStateEnum{
"ACTIVE": ZoneSummaryLifecycleStateActive,
"CREATING": ZoneSummaryLifecycleStateCreating,
"DELETED": ZoneSummaryLifecycleStateDeleted,
"DELETING": ZoneSummaryLifecycleStateDeleting,
"FAILED": ZoneSummaryLifecycleStateFailed,
}
// GetZoneSummaryLifecycleStateEnumValues Enumerates the set of values for ZoneSummaryLifecycleStateEnum
func GetZoneSummaryLifecycleStateEnumValues() []ZoneSummaryLifecycleStateEnum {
values := make([]ZoneSummaryLifecycleStateEnum, 0)
for _, v := range mappingZoneSummaryLifecycleState {
values = append(values, v)
}
return values
}