/
resource_citrixadc_locationfile_import.go
55 lines (48 loc) · 1.33 KB
/
resource_citrixadc_locationfile_import.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package citrixadc
import (
"github.com/citrix/adc-nitro-go/resource/config/basic"
"github.com/citrix/adc-nitro-go/service"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"log"
)
func resourceCitrixAdcLocationImportfile() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Create: createLocationfileImportFunc,
Read: schema.Noop,
Delete: schema.Noop,
Schema: map[string]*schema.Schema{
"format": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
},
"locationfile": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"src": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
},
}
}
func createLocationfileImportFunc(d *schema.ResourceData, meta interface{}) error {
log.Printf("[DEBUG] citrixadc-provider: In createLocationfileFunc")
client := meta.(*NetScalerNitroClient).client
locationfileName := resource.PrefixedUniqueId("tf-locationfile-")
locationfile := basic.Locationfile{
Src: d.Get("src").(string),
Locationfile: d.Get("locationfile").(string),
}
err := client.ActOnResource(service.Locationfile.Type(), locationfile, "import")
if err != nil {
return err
}
d.SetId(locationfileName)
return nil
}