-
Notifications
You must be signed in to change notification settings - Fork 1
/
dns_transfer_accept_v2.go
48 lines (38 loc) · 1.42 KB
/
dns_transfer_accept_v2.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package viettelidc
import (
"fmt"
"log"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack/dns/v2/transfer/accept"
)
// TransferAcceptCreateOpts represents the attributes used when creating a new transfer accept.
type TransferAcceptCreateOpts struct {
accept.CreateOpts
ValueSpecs map[string]string `json:"value_specs,omitempty"`
}
// ToTransferAcceptCreateMap casts a CreateOpts struct to a map.
// It overrides accept.ToTransferAcceptCreateMap to add the ValueSpecs field.
func (opts TransferAcceptCreateOpts) ToTransferAcceptCreateMap() (map[string]interface{}, error) {
b, err := BuildRequest(opts, "")
if err != nil {
return nil, err
}
if m, ok := b[""].(map[string]interface{}); ok {
return m, nil
}
return nil, fmt.Errorf("Expected map but got %T", b[""])
}
func dnsTransferAcceptV2RefreshFunc(dnsClient *gophercloud.ServiceClient, transferAcceptID string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
transferAccept, err := accept.Get(dnsClient, transferAcceptID).Extract()
if err != nil {
if _, ok := err.(gophercloud.ErrDefault404); ok {
return transferAccept, "DELETED", nil
}
return nil, "", err
}
log.Printf("[DEBUG] openstack_dns_transfer_accept_v2 %s current status: %s", transferAccept.ID, transferAccept.Status)
return transferAccept, transferAccept.Status, nil
}
}