• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang schema.ResourceData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: resourceTrafficIPGroupDelete

func resourceTrafficIPGroupDelete(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client
	r := stingray.NewTrafficIPGroup(d.Id())

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

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


示例2: resourceVirtualServerDelete

func resourceVirtualServerDelete(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client
	r := stingray.NewVirtualServer(d.Id())

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

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


示例3: resourceMonitorScriptDelete

func resourceMonitorScriptDelete(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client
	r := stingray.NewMonitorScript(d.Id())

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

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


示例4: resourceActionProgramDelete

func resourceActionProgramDelete(d *schema.ResourceData, meta interface{}) error {
	c := meta.(*providerConfig).client
	r := stingray.NewActionProgram(d.Id())

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

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


示例5: setNodesTable

func setNodesTable(target **stingray.NodesTable, d *schema.ResourceData, key string) {
	if _, ok := d.GetOk(key); ok {
		var nodes []string
		if v := d.Get(key).(*schema.Set); v.Len() > 0 {
			nodes = make([]string, v.Len())
			for i, v := range v.List() {
				nodes[i] = v.(string)
			}
		}
		nodesTable := nodesToNodesTable(nodes)
		*target = &nodesTable
	}
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:13,代码来源:resource_pool.go


示例6: 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


示例7: 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


示例8: 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


示例9: 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


示例10: 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


示例11: 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


示例12: 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


示例13: 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


示例14: 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


示例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


示例16: resourcePoolSet

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

	setString(&r.Basic.BandwidthClass, d, "bandwidth_class")
	setInt(&r.Connection.MaxConnectTime, d, "connection_max_connect_time")
	setInt(&r.Connection.MaxConnectionsPerNode, d, "connection_max_connections_per_node")
	setInt(&r.Connection.MaxQueueSize, d, "connection_max_queue_size")
	setInt(&r.Connection.MaxReplyTime, d, "connection_max_reply_time")
	setInt(&r.Connection.QueueTimeout, d, "connection_queue_timeout")
	setString(&r.Basic.FailurePool, d, "failure_pool")
	setString(&r.LoadBalancing.Algorithm, d, "load_balancing_algorithm")
	setBool(&r.LoadBalancing.PriorityEnabled, d, "load_balancing_priority_enabled")
	setInt(&r.LoadBalancing.PriorityNodes, d, "load_balancing_priority_nodes")
	setInt(&r.Basic.MaxConnectionAttempts, d, "max_connection_attempts")
	setInt(&r.Basic.MaxIdleConnectionsPerNode, d, "max_idle_connections_pernode")
	setInt(&r.Basic.MaxTimedOutConnectionAttempts, d, "max_timed_out_connection_attempts")
	setStringSet(&r.Basic.Monitors, d, "monitors")
	setBool(&r.Basic.NodeCloseWithRST, d, "node_close_with_rst")
	setInt(&r.Basic.NodeConnectionAttempts, d, "node_connection_attempts")
	setNodesTable(&r.Basic.NodesTable, d, "nodes")
	setString(&r.Basic.Note, d, "note")
	setBool(&r.Basic.PassiveMonitoring, d, "passive_monitoring")
	setString(&r.Basic.PersistenceClass, d, "persistence_class")
	setBool(&r.TCP.Nagle, d, "tcp_nagle")
	setBool(&r.Basic.Transparent, d, "transparent")
	setString(&r.UDP.AcceptFrom, d, "udp_accept_from")
	setString(&r.UDP.AcceptFromMask, d, "udp_accept_from_mask")

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

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

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


示例17: 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


示例18: setServerCertHostMappingTable

func setServerCertHostMappingTable(target **stingray.ServerCertHostMappingTable, d *schema.ResourceData, key string) {
	if _, ok := d.GetOk(key); ok {
		table := d.Get(key).(*schema.Set).List()
		*target, _ = expandServerCertHostMappingTable(table)
	}
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:6,代码来源:resource_virtual_server.go


示例19: setScriptArgumentsTable

func setScriptArgumentsTable(target **stingray.ScriptArgumentsTable, d *schema.ResourceData, key string) {
	if _, ok := d.GetOk(key); ok {
		table := d.Get(key).(*schema.Set).List()
		*target, _ = expandScriptArgumentsTable(table)
	}
}
开发者ID:svend,项目名称:terraform-provider-stingray,代码行数:6,代码来源:resource_monitor.go


示例20: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang terraform.MockResourceProvider类代码示例发布时间:2022-05-28
下一篇:
Golang hcl.Object类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap