当前位置: 首页>>代码示例>>Golang>>正文


Golang ResourceData.SetId方法代码示例

本文整理汇总了Golang中github.com/whitepages/terraform-provider-stingray/Godeps/_workspace/src/github.com/hashicorp/terraform/helper/schema.ResourceData.SetId方法的典型用法代码示例。如果您正苦于以下问题:Golang ResourceData.SetId方法的具体用法?Golang ResourceData.SetId怎么用?Golang ResourceData.SetId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/whitepages/terraform-provider-stingray/Godeps/_workspace/src/github.com/hashicorp/terraform/helper/schema.Res的用法示例。


在下文中一共展示了ResourceData.SetId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: resourceTrafficIPGroupRead

func resourceTrafficIPGroupRead(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client

	r, resp, err := c.GetTrafficIPGroup(d.Get("name").(string))
	if err != nil {
		if resp != nil && resp.StatusCode == 404 {
			// The resource doesn't exist anymore
			d.SetId("")

			return nil
		}

		return fmt.Errorf("Error reading resource: %s", err)
	}

	d.Set("enabled", bool(*r.Basic.Enabled))
	d.Set("hash_source_port", bool(*r.Basic.HashSourcePort))
	d.Set("ipaddresses", []string(*r.Basic.IPAddresses))
	d.Set("keeptogether", bool(*r.Basic.KeepTogether))
	d.Set("location", int(*r.Basic.Location))
	d.Set("machines", []string(*r.Basic.Machines))
	d.Set("mode", string(*r.Basic.Mode))
	d.Set("multicast", string(*r.Basic.Multicast))
	d.Set("note", string(*r.Basic.Note))
	d.Set("rhi_ospfv2_metric_base", int(*r.Basic.RHIOSPFV2MetricBase))
	d.Set("rhi_ospfv2_passive_metric_offset", int(*r.Basic.RHIOSPFV2PassiveMetricOffset))
	d.Set("slaves", []string(*r.Basic.Slaves))

	return nil
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:30,代码来源:resource_traffic_ip_group.go

示例2: resourceVirtualServerSet

func resourceVirtualServerSet(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client
	r := stingray.NewVirtualServer(d.Get("name").(string))

	setString(&r.ConnectionErrors.ErrorFile, d, "connection_errors_error_file")
	setInt(&r.Connection.KeepaliveTimeout, d, "connection_keepalive_timeout")
	setInt(&r.Connection.Timeout, d, "connection_timeout")
	setInt(&r.Basic.ConnectTimeout, d, "connect_timeout")
	setBool(&r.Basic.Enabled, d, "enabled")
	// NOTE: Set default for gzip_include_mime
	//
	// Default does not work for sets (only for primitive types),
	// so we must use GetOK. This means we will get the default
	// value if the parameter is unset OR set to the empty value.
	if _, ok := d.GetOk("gzip_include_mime"); ok {
		setStringSet(&r.Gzip.IncludeMIME, d, "gzip_include_mime")
	} else {
		r.Gzip.IncludeMIME = &[]string{"text/html", "text/plain"}
	}
	setBool(&r.Gzip.Enabled, d, "gzip_enabled")
	setString(&r.HTTP.LocationRewrite, d, "http_location_rewrite")
	setBool(&r.Basic.ListenOnAny, d, "listen_on_any")
	setStringSet(&r.Basic.ListenOnTrafficIPs, d, "listen_on_traffic_ips")
	setBool(&r.Log.Enabled, d, "log_enabled")
	setString(&r.Log.Filename, d, "log_filename")
	setString(&r.Log.Format, d, "log_format")
	setBool(&r.Log.ServerConnectionFailures, d, "log_server_connection_failures")
	setString(&r.Basic.Note, d, "note")
	setString(&r.Basic.Pool, d, "pool")
	setInt(&r.Basic.Port, d, "port")
	setString(&r.Basic.Protocol, d, "protocol")
	setBool(&r.RecentConnections.SaveAll, d, "recent_connections_save_all")
	setStringList(&r.Basic.RequestRules, d, "request_rules")
	setStringList(&r.Basic.ResponseRules, d, "response_rules")
	setBool(&r.SSL.AddHTTPHeaders, d, "ssl_add_http_headers")
	setBool(&r.Basic.SSLDecrypt, d, "ssl_decrypt")
	setString(&r.SSL.ServerCertDefault, d, "ssl_server_cert_default")
	setServerCertHostMappingTable(&r.SSL.ServerCertHostMapping, d, "ssl_server_cert_host_mapping")
	setString(&r.Syslog.Format, d, "syslog_format")
	setBool(&r.WebCache.Enabled, d, "web_cache_enabled")
	setInt(&r.WebCache.MaxTime, d, "web_cache_max_time")

	_, err := c.Set(r)
	if err != nil {
		return err
	}

	d.SetId(d.Get("name").(string))

	return nil
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:51,代码来源:resource_virtual_server.go

示例3: resourceMonitorScriptSet

func resourceMonitorScriptSet(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client
	r := stingray.NewMonitorScript(d.Get("name").(string))

	r.Content = []byte(d.Get("content").(string))

	_, err := c.Set(r)
	if err != nil {
		return err
	}

	d.SetId(d.Get("name").(string))

	return nil
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:15,代码来源:resource_monitor_script.go

示例4: resourceVirtualServerRead

func resourceVirtualServerRead(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client

	r, resp, err := c.GetVirtualServer(d.Get("name").(string))
	if err != nil {
		if resp != nil && resp.StatusCode == 404 {
			// The resource doesn't exist anymore
			d.SetId("")

			return nil
		}

		return fmt.Errorf("Error reading resource: %s", err)
	}

	d.Set("connection_errors_error_file", string(*r.ConnectionErrors.ErrorFile))
	d.Set("connection_keepalive_timeout", int(*r.Connection.KeepaliveTimeout))
	d.Set("connection_timeout", int(*r.Connection.Timeout))
	d.Set("connect_timeout", int(*r.Basic.ConnectTimeout))
	d.Set("enabled", bool(*r.Basic.Enabled))
	d.Set("gzip_enabled", bool(*r.Gzip.Enabled))
	d.Set("gzip_include_mime", []string(*r.Gzip.IncludeMIME))
	d.Set("http_location_rewrite", string(*r.HTTP.LocationRewrite))
	d.Set("listen_on_any", bool(*r.Basic.ListenOnAny))
	d.Set("listen_on_traffic_ips", []string(*r.Basic.ListenOnTrafficIPs))
	d.Set("log_enabled", bool(*r.Log.Enabled))
	d.Set("log_filename", string(*r.Log.Filename))
	d.Set("log_format", string(*r.Log.Format))
	d.Set("log_server_connection_failures", bool(*r.Log.ServerConnectionFailures))
	d.Set("note", string(*r.Basic.Note))
	d.Set("pool", string(*r.Basic.Pool))
	d.Set("port", int(*r.Basic.Port))
	d.Set("protocol", string(*r.Basic.Protocol))
	d.Set("recent_connections_save_all", bool(*r.RecentConnections.SaveAll))
	d.Set("request_rules", []string(*r.Basic.RequestRules))
	d.Set("response_rules", []string(*r.Basic.ResponseRules))
	d.Set("ssl_add_http_headers", bool(*r.SSL.AddHTTPHeaders))
	d.Set("ssl_decrypt", bool(*r.Basic.SSLDecrypt))
	d.Set("ssl_server_cert_default", string(*r.SSL.ServerCertDefault))
	d.Set("ssl_server_cert_host_mapping", flattenServerCertHostMappingTable(*r.SSL.ServerCertHostMapping))
	d.Set("syslog_format", string(*r.Syslog.Format))
	d.Set("web_cache_enabled", bool(*r.WebCache.Enabled))
	d.Set("web_cache_max_time", int(*r.WebCache.MaxTime))

	return nil
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:46,代码来源:resource_virtual_server.go

示例5: resourceRateSet

func resourceRateSet(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client
	r := stingray.NewRate(d.Get("name").(string))

	setInt(&r.Basic.MaxRatePerMinute, d, "max_rate_per_minute")
	setInt(&r.Basic.MaxRatePerSecond, d, "max_rate_per_second")
	setString(&r.Basic.Note, d, "note")

	_, err := c.Set(r)
	if err != nil {
		return err
	}

	d.SetId(d.Get("name").(string))

	return nil
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:17,代码来源:resource_rate.go

示例6: resourceMonitorRead

func resourceMonitorRead(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client

	r, resp, err := c.GetMonitor(d.Get("name").(string))
	if err != nil {
		if resp != nil && resp.StatusCode == 404 {
			// The resource doesn't exist anymore
			d.SetId("")

			return nil
		}

		return fmt.Errorf("Error reading resource: %s", err)
	}

	d.Set("back_off", bool(*r.Basic.BackOff))
	d.Set("delay", int(*r.Basic.Delay))
	d.Set("failures", int(*r.Basic.Failures))
	d.Set("http_authentication", string(*r.HTTP.Authentication))
	d.Set("http_body_regex", string(*r.HTTP.BodyRegex))
	d.Set("http_host_header", string(*r.HTTP.HostHeader))
	d.Set("http_path", string(*r.HTTP.Path))
	d.Set("http_status_regex", string(*r.HTTP.StatusRegex))
	d.Set("machine", string(*r.Basic.Machine))
	d.Set("note", string(*r.Basic.Note))
	d.Set("rtsp_body_regex", string(*r.RTSP.BodyRegex))
	d.Set("rtsp_path", string(*r.RTSP.Path))
	d.Set("rtsp_status_regex", string(*r.RTSP.StatusRegex))
	d.Set("scope", string(*r.Basic.Scope))
	d.Set("script_arguments", flattenScriptArgumentsTable(*r.Script.Arguments))
	d.Set("script_program", string(*r.Script.Program))
	d.Set("sip_body_regex", string(*r.SIP.BodyRegex))
	d.Set("sip_status_regex", string(*r.SIP.StatusRegex))
	d.Set("sip_transport", string(*r.SIP.Transport))
	d.Set("tcp_close_string", string(*r.TCP.CloseString))
	d.Set("tcp_max_response_len", int(*r.TCP.MaxResponseLen))
	d.Set("tcp_response_regex", string(*r.TCP.ResponseRegex))
	d.Set("tcp_write_string", string(*r.TCP.WriteString))
	d.Set("timeout", int(*r.Basic.Timeout))
	d.Set("type", string(*r.Basic.Type))
	d.Set("udp_accept_all", bool(*r.UDP.AcceptAll))
	d.Set("use_ssl", bool(*r.Basic.UseSSL))
	d.Set("verbose", bool(*r.Basic.Verbose))

	return nil
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:46,代码来源:resource_monitor.go

示例7: resourceSSLServerKeySet

func resourceSSLServerKeySet(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client
	r := stingray.NewSSLServerKey(d.Get("name").(string))

	setString(&r.Basic.Note, d, "note")
	setString(&r.Basic.Private, d, "private")
	setString(&r.Basic.Public, d, "public")
	setString(&r.Basic.Request, d, "request")

	_, err := c.Set(r)
	if err != nil {
		return err
	}

	d.SetId(d.Get("name").(string))

	return nil
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:18,代码来源:resource_ssl_server_key.go

示例8: resourceServiceLevelMonitorSet

func resourceServiceLevelMonitorSet(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client
	r := stingray.NewServiceLevelMonitor(d.Get("name").(string))

	setString(&r.Basic.Note, d, "note")
	setInt(&r.Basic.ResponseTime, d, "response_time")
	setInt(&r.Basic.SeriousThreshold, d, "serious_threshold")
	setInt(&r.Basic.WarningThreshold, d, "warning_threshold")

	_, err := c.Set(r)
	if err != nil {
		return err
	}

	d.SetId(d.Get("name").(string))

	return nil
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:18,代码来源:resource_service_level_monitor.go

示例9: resourceMonitorScriptRead

func resourceMonitorScriptRead(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client

	r, resp, err := c.GetMonitorScript(d.Get("name").(string))
	if err != nil {
		if resp != nil && resp.StatusCode == 404 {
			// The resource doesn't exist anymore
			d.SetId("")

			return nil
		}

		return fmt.Errorf("Error reading resource: %s", err)
	}

	d.Set("content", hashString(string(r.Content)))

	return nil
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:19,代码来源:resource_monitor_script.go

示例10: resourcePoolRead

func resourcePoolRead(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client

	r, resp, err := c.GetPool(d.Get("name").(string))
	if err != nil {
		if resp != nil && resp.StatusCode == 404 {
			// The resource doesn't exist anymore
			d.SetId("")

			return nil
		}

		return fmt.Errorf("Error reading resource: %s", err)
	}

	d.Set("bandwidth_class", string(*r.Basic.BandwidthClass))
	d.Set("connection_max_connect_time", int(*r.Connection.MaxConnectTime))
	d.Set("connection_max_connections_per_node", int(*r.Connection.MaxConnectionsPerNode))
	d.Set("connection_max_queue_size", int(*r.Connection.MaxQueueSize))
	d.Set("connection_max_reply_time", int(*r.Connection.MaxReplyTime))
	d.Set("connection_queue_timeout", int(*r.Connection.QueueTimeout))
	d.Set("failure_pool", string(*r.Basic.FailurePool))
	d.Set("load_balancing_algorithm", string(*r.LoadBalancing.Algorithm))
	d.Set("load_balancing_priority_enabled", bool(*r.LoadBalancing.PriorityEnabled))
	d.Set("load_balancing_priority_nodes", int(*r.LoadBalancing.PriorityNodes))
	d.Set("max_connection_attempts", int(*r.Basic.MaxConnectionAttempts))
	d.Set("max_idle_connections_pernode", int(*r.Basic.MaxIdleConnectionsPerNode))
	d.Set("max_timed_out_connection_attempts", int(*r.Basic.MaxTimedOutConnectionAttempts))
	d.Set("monitors", []string(*r.Basic.Monitors))
	d.Set("node_close_with_rst", bool(*r.Basic.NodeCloseWithRST))
	d.Set("node_connection_attempts", int(*r.Basic.NodeConnectionAttempts))
	d.Set("nodes", nodesTableToNodes(*r.Basic.NodesTable))
	d.Set("note", string(*r.Basic.Note))
	d.Set("passive_monitoring", bool(*r.Basic.PassiveMonitoring))
	d.Set("persistence_class", string(*r.Basic.PersistenceClass))
	d.Set("tcp_nagle", bool(*r.TCP.Nagle))
	d.Set("udp_accept_from", string(*r.UDP.AcceptFrom))
	d.Set("udp_accept_from_mask_class", string(*r.UDP.AcceptFromMask))
	d.Set("transparent", bool(*r.Basic.Transparent))

	return nil
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:42,代码来源:resource_pool.go

示例11: resourceMonitorSet

func resourceMonitorSet(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client
	r := stingray.NewMonitor(d.Get("name").(string))

	setBool(&r.Basic.BackOff, d, "back_off")
	setInt(&r.Basic.Delay, d, "delay")
	setInt(&r.Basic.Failures, d, "failures")
	setString(&r.HTTP.Authentication, d, "http_authentication")
	setString(&r.HTTP.BodyRegex, d, "http_body_regex")
	setString(&r.HTTP.HostHeader, d, "http_host_header")
	setString(&r.HTTP.Path, d, "http_path")
	setString(&r.HTTP.StatusRegex, d, "http_status_regex")
	setString(&r.Basic.Machine, d, "machine")
	setString(&r.Basic.Note, d, "note")
	setString(&r.RTSP.BodyRegex, d, "rtsp_body_regex")
	setString(&r.RTSP.Path, d, "rtsp_path")
	setString(&r.RTSP.StatusRegex, d, "rtsp_status_regex")
	setString(&r.Basic.Scope, d, "scope")
	setScriptArgumentsTable(&r.Script.Arguments, d, "script_arguments")
	setString(&r.Script.Program, d, "script_program")
	setString(&r.SIP.BodyRegex, d, "sip_body_regex")
	setString(&r.SIP.StatusRegex, d, "sip_status_regex")
	setString(&r.SIP.Transport, d, "sip_transports")
	setString(&r.TCP.CloseString, d, "tcp_close_string")
	setInt(&r.TCP.MaxResponseLen, d, "tcp_max_response_len")
	setString(&r.TCP.ResponseRegex, d, "tcp_response_regex")
	setString(&r.TCP.WriteString, d, "tcp_write_string")
	setInt(&r.Basic.Timeout, d, "timeout")
	setString(&r.Basic.Type, d, "type")
	setBool(&r.UDP.AcceptAll, d, "udp_accept_all")
	setBool(&r.Basic.UseSSL, d, "use_ssl")
	setBool(&r.Basic.Verbose, d, "verbose")

	_, err := c.Set(r)
	if err != nil {
		return err
	}

	d.SetId(d.Get("name").(string))

	return nil
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:42,代码来源:resource_monitor.go

示例12: resourceRateRead

func resourceRateRead(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client

	r, resp, err := c.GetRate(d.Get("name").(string))
	if err != nil {
		if resp != nil && resp.StatusCode == 404 {
			// The resource doesn't exist anymore
			d.SetId("")

			return nil
		}

		return fmt.Errorf("Error reading resource: %s", err)
	}

	d.Set("max_rate_per_minute", int(*r.Basic.MaxRatePerMinute))
	d.Set("max_rate_per_second", int(*r.Basic.MaxRatePerSecond))
	d.Set("note", string(*r.Basic.Note))

	return nil
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:21,代码来源:resource_rate.go

示例13: resourceSSLServerKeyRead

func resourceSSLServerKeyRead(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client

	r, resp, err := c.GetSSLServerKey(d.Get("name").(string))
	if err != nil {
		if resp != nil && resp.StatusCode == 404 {
			// The resource doesn't exist anymore
			d.SetId("")

			return nil
		}

		return fmt.Errorf("Error reading resource: %s", err)
	}

	d.Set("note", string(*r.Basic.Note))
	d.Set("private", string(*r.Basic.Private))
	d.Set("public", string(*r.Basic.Public))
	d.Set("request", string(*r.Basic.Request))

	return nil
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:22,代码来源:resource_ssl_server_key.go

示例14: resourceServiceLevelMonitorRead

func resourceServiceLevelMonitorRead(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client

	r, resp, err := c.GetServiceLevelMonitor(d.Get("name").(string))
	if err != nil {
		if resp != nil && resp.StatusCode == 404 {
			// The resource doesn't exist anymore
			d.SetId("")

			return nil
		}

		return fmt.Errorf("Error reading resource: %s", err)
	}

	d.Set("note", string(*r.Basic.Note))
	d.Set("response_time", int(*r.Basic.ResponseTime))
	d.Set("serious_threshold", int(*r.Basic.SeriousThreshold))
	d.Set("warning_threshold", int(*r.Basic.WarningThreshold))

	return nil
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:22,代码来源:resource_service_level_monitor.go

示例15: resourceTrafficIPGroupSet

func resourceTrafficIPGroupSet(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client
	r := stingray.NewTrafficIPGroup(d.Get("name").(string))

	setBool(&r.Basic.Enabled, d, "enabled")
	setBool(&r.Basic.HashSourcePort, d, "hash_source_port")
	setStringSet(&r.Basic.IPAddresses, d, "ipaddresses")
	setBool(&r.Basic.KeepTogether, d, "keeptogether")
	setInt(&r.Basic.Location, d, "location")
	setStringSet(&r.Basic.Machines, d, "machines")
	setString(&r.Basic.Mode, d, "mode")
	setString(&r.Basic.Multicast, d, "multicast")
	setString(&r.Basic.Note, d, "note")
	setInt(&r.Basic.RHIOSPFV2MetricBase, d, "rhi_ospfv2_metric_base")
	setInt(&r.Basic.RHIOSPFV2PassiveMetricOffset, d, "rhi_ospfv2_passive_metric_offset")
	setStringSet(&r.Basic.Slaves, d, "slaves")

	ns := meta.(*providerConfig).validNetworks
	if len(ns) > 0 && *r.Basic.IPAddresses != nil {
		for _, s := range *r.Basic.IPAddresses {
			ip := net.ParseIP(s)
			if ip == nil {
				return fmt.Errorf("Invalid IP address: %s", s)
			}
			if !ns.Contains(ip) {
				return fmt.Errorf("IP address %s is not in the valid networks", ip)
			}
		}
	}

	_, err := c.Set(r)
	if err != nil {
		return err
	}

	d.SetId(d.Get("name").(string))

	return nil
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:39,代码来源:resource_traffic_ip_group.go


注:本文中的github.com/whitepages/terraform-provider-stingray/Godeps/_workspace/src/github.com/hashicorp/terraform/helper/schema.ResourceData.SetId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。