github.com/candidpartners/terraform@v0.9.5-0.20171005231213-29f5f88820f6/builtin/providers/netapp/data_source_cloud_workenv.go (about)

     1  package netapp
     2  
     3  import (
     4  	"github.com/hashicorp/terraform/helper/schema"
     5  )
     6  
     7  func dataSourceCloudWorkingEnvironment() *schema.Resource {
     8  	return &schema.Resource{
     9  		Read: dataSourceCloudWorkingEnvironmentRead,
    10  
    11  		Schema: map[string]*schema.Schema{
    12  			"name": &schema.Schema{
    13  				Type:     schema.TypeString,
    14  				Required: true,
    15  			},
    16  			"public_id": {
    17  				Type:     schema.TypeString,
    18  				Computed: true,
    19  			},
    20  			"tenant_id": {
    21  				Type:     schema.TypeString,
    22  				Computed: true,
    23  			},
    24  			"svm_name": {
    25  				Type:     schema.TypeString,
    26  				Computed: true,
    27  			},
    28  			"is_ha": {
    29  				Type:     schema.TypeString,
    30  				Computed: true,
    31  			},
    32  		},
    33  	}
    34  }
    35  
    36  func dataSourceCloudWorkingEnvironmentRead(d *schema.ResourceData, meta interface{}) error {
    37  	apis := meta.(*APIs)
    38  
    39  	workEnvName := d.Get("name").(string)
    40  
    41  	workenv, err := GetWorkingEnvironmentByName(apis, workEnvName)
    42  	if err != nil {
    43  		return err
    44  	}
    45  
    46  	d.SetId(workenv.PublicId)
    47  	d.Set("public_id", workenv.PublicId)
    48  	d.Set("name", workenv.Name)
    49  	d.Set("tenant_id", workenv.TenantId)
    50  	d.Set("svm_name", workenv.SvmName)
    51  	d.Set("is_ha", workenv.IsHA)
    52  
    53  	return nil
    54  }