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


Golang schema.ResourceData类代码示例

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


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


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