當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。