Example #1
0
// Get requests details on a single server, by ID.
func Get(client *gophercloud.ServiceClient, id string) GetResult {
	var result GetResult
	_, result.Err = client.Get(getURL(client, id), &result.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200, 203},
	})
	return result
}
Example #2
0
// MeterStatistics gathers statistics based on filters, groups, and period options
func MeterStatistics(client *gophercloud.ServiceClient, n string, optsBuilder MeterStatisticsOptsBuilder) statisticsResult {
	var (
		res  statisticsResult
		url  = statisticsURL(client, n)
		opts gophercloud.RequestOpts
		err  error
		kind OptsKind
	)

	if optsBuilder != nil {
		kind = optsBuilder.Kind()
	}

	switch kind {
	case QueryOpts:
		query, err := optsBuilder.ToMeterStatisticsQuery()
		url += query
	case BodyContentOpts:
		opts.JSONBody, err = optsBuilder.ToMeterStatisticsQuery()
	}

	if err != nil {
		res.Err = err
		return res
	}

	_, res.Err = client.Get(url, &res.Body, &opts)
	return res
}
Example #3
0
// Get requests the details of a single policy with the given ID.
func Get(client *gophercloud.ServiceClient, groupID, policyID string) GetResult {
	var result GetResult

	_, result.Err = client.Get(getURL(client, groupID, policyID), &result.Body, nil)

	return result
}
Example #4
0
// Get retreives data for the given stack resource.
func Get(c *gophercloud.ServiceClient, stackName, stackID, resourceName, eventID string) GetResult {
	var res GetResult
	_, res.Err = c.Get(getURL(c, stackName, stackID, resourceName, eventID), &res.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200},
	})
	return res
}
Example #5
0
//OpenstackGet gets a resource using OpenStack API
func OpenstackGet(client *gophercloud.ServiceClient, url string) (interface{}, error) {
	var response interface{}
	_, err := client.Get(url, &response, nil)
	if err != nil {
		return nil, err
	}
	return response, nil
}
Example #6
0
// Ping retrieves a ping to the server.
func Ping(c *gophercloud.ServiceClient) PingResult {
	var res PingResult
	_, res.Err = c.Get(pingURL(c), nil, &gophercloud.RequestOpts{
		OkCodes:     []int{204},
		MoreHeaders: map[string]string{"Accept": ""},
	})
	return res
}
Example #7
0
// Metadata retreives the metadata for the given stack resource.
func Metadata(c *gophercloud.ServiceClient, stackName, stackID, resourceName string) MetadataResult {
	var res MetadataResult

	// Send request to API
	_, res.Err = c.Get(metadataURL(c, stackName, stackID, resourceName), &res.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200},
	})
	return res
}
Example #8
0
// Schema retreives the schema for the given resource type.
func Schema(c *gophercloud.ServiceClient, resourceType string) SchemaResult {
	var res SchemaResult

	// Send request to API
	_, res.Err = c.Get(schemaURL(c, resourceType), &res.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200},
	})
	return res
}
Example #9
0
// Get is the operation responsible for providing detailed information
// regarding a specific load balancer which is configured and associated with
// your account. This operation is not capable of returning details for a load
// balancer which has been deleted.
func Get(c *gophercloud.ServiceClient, id int) GetResult {
	var res GetResult

	_, res.Err = c.Get(resourceURL(c, id), &res.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200},
	})

	return res
}
Example #10
0
// Template retreives the template representation for the given resource type.
func Template(c *gophercloud.ServiceClient, resourceType string) TemplateResult {
	var res TemplateResult

	// Send request to API
	_, res.Err = c.Get(templateURL(c, resourceType), &res.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200},
	})
	return res
}
Example #11
0
// GetDataByPoints retrieve metric data by resolution, for the specified tenant associated with RackspaceMetrics.
func GetDataByResolution(c *gophercloud.ServiceClient, metric string, opts QueryParams) GetResult {
	var res GetResult

	url := getURLForResolution(c, metric)
	query, _ := gophercloud.BuildQueryString(opts)
	url += query.String()
	_, res.Err = c.Get(url, &res.Body, nil)
	return res
}
Example #12
0
// Validates and retrieves information for user's token.
func Get(client *gophercloud.ServiceClient, token string) GetResult {
	var result GetResult
	_, result.Err = client.Get(GetURL(client, token), &result.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200, 203},
	})
	if result.Err != nil {
		return result
	}
	return result
}
Example #13
0
//TODO(nati) this should be implemented in openstack go client side package
func verifyV2Token(c *gophercloud.ServiceClient, token string) (interface{}, error) {
	var result interface{}
	_, err := c.Get(tokenURL(c, token), &result, &gophercloud.RequestOpts{
		OkCodes: []int{200, 203},
	})
	if err != nil {
		return nil, err
	}
	return result, nil
}
Example #14
0
// GetLimits retrieves the number of API transaction that are available for the specified tenant associated with RackspaceMetrics.
func GetLimits(c *gophercloud.ServiceClient) (Limits, error) {
	var res GetResult
	_, res.Err = c.Get(getLimits(c), &res.Body, &gophercloud.RequestOpts{
		OkCodes: []int{200, 404},
	})
	b := res.Body.(map[string]interface{})
	var limits Limits
	err := mapstructure.Decode(b["limits"], &limits)
	return limits, err
}
Example #15
0
//OpenstackEnsure keep resource status to sync
func OpenstackEnsure(client *gophercloud.ServiceClient, url string, postURL string, data interface{}) (interface{}, error) {
	var response interface{}
	resp, err := client.Get(url, &response, nil)
	if err != nil {
		if resp.StatusCode != http.StatusNotFound {
			return nil, err
		}
		return OpenstackPost(client, postURL, data)
	}
	return OpenstackPut(client, url, data)
}
Example #16
0
// Download retrieves file
func Download(client *gophercloud.ServiceClient, id string) GetImageDataResult {
	var res GetImageDataResult

	var resp *http.Response
	resp, res.Err = client.Get(imageDataURL(client, id), nil, &gophercloud.RequestOpts{
		OkCodes: []int{200},
	})

	res.Body = resp.Body

	return res
}
Example #17
0
// Get retrieves a specific service based on its URL or its unique ID. For
// example, both "96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0" and
// "https://global.cdn.api.rackspacecloud.com/v1.0/services/96737ae3-cfc1-4c72-be88-5d0e7cc9a3f0"
// are valid options for idOrURL.
func Get(c *gophercloud.ServiceClient, idOrURL string) GetResult {
	var url string
	if strings.Contains(idOrURL, "/") {
		url = idOrURL
	} else {
		url = getURL(c, idOrURL)
	}

	var res GetResult
	_, res.Err = c.Get(url, &res.Body, nil)
	return res
}
// Get validates and retrieves information about another token.
func Get(c *gophercloud.ServiceClient, token string) GetResult {
	var result GetResult
	var response *http.Response
	response, result.Err = c.Get(tokenURL(c), &result.Body, &gophercloud.RequestOpts{
		MoreHeaders: subjectTokenHeaders(c, token),
		OkCodes:     []int{200, 203},
	})
	if result.Err != nil {
		return result
	}
	result.Header = response.Header
	return result
}
Example #19
0
//GetEvents retrieves a list of events for the specified tenant associated with RackspaceMetrics.
func GetEvents(c *gophercloud.ServiceClient, opts QueryParams) ([]Event, error) {
	var res GetResult

	url := getEventURL(c)
	query, _ := gophercloud.BuildQueryString(opts)
	url += query.String()

	_, res.Err = c.Get(url, &res.Body, nil)
	b := res.Body.(interface{})
	var events []Event
	err := mapstructure.Decode(b, &events)
	return events, err
}
Example #20
0
// SearchMetric retrieves a list of available metrics for the specified tenant associated with RackspaceMetrics.
func SearchMetric(c *gophercloud.ServiceClient, opts QueryParams) ([]Metric, error) {
	var res GetResult

	url := getSearchURL(c)
	query, _ := gophercloud.BuildQueryString(opts)
	url += query.String()

	_, res.Err = c.Get(url, &res.Body, nil)
	b := res.Body.(interface{})
	var metrics []Metric
	err := mapstructure.Decode(b, &metrics)
	return metrics, err
}
Example #21
0
// List makes a request against the API to list meters accessible to you.
func MeterStatistics(client *gophercloud.ServiceClient, n string, opts MeterStatisticsOptsBuilder) StatisticsResult {
	var res StatisticsResult
	url := statisticsURL(client, n)

	if opts != nil {
		query, err := opts.ToMeterStatisticsQuery()
		if err != nil {
			res.Err = err
			return res
		}
		url += query
	}

	_, res.Err = client.Get(url, &res.Body, &gophercloud.RequestOpts{})
	return res
}
Example #22
0
// Show makes a request against the API to show a specific meter
func Show(client *gophercloud.ServiceClient, meterName string, opts ShowOptsBuilder) ShowResult {
	var res ShowResult
	url := showURL(client, meterName)

	if opts != nil {
		query, err := opts.ToShowQuery()
		if err != nil {
			res.Err = err
			return res
		}
		url += query
	}

	_, res.Err = client.Get(url, &res.Body, &gophercloud.RequestOpts{})
	return res
}
Example #23
0
// List makes a request against the API to list meters accessible to you.
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) listResult {
	var res listResult
	url := listURL(client)

	if opts != nil {
		query, err := opts.ToMeterListQuery()
		if err != nil {
			res.Err = err
			return res
		}
		url += query
	}

	_, res.Err = client.Get(url, &res.Body, &gophercloud.RequestOpts{})
	return res
}
Example #24
0
// IsLoggingEnabled returns true if the load balancer has connection logging
// enabled and false if not.
func IsLoggingEnabled(client *gophercloud.ServiceClient, id int) (bool, error) {
	var body interface{}

	_, err := client.Get(loggingURL(client, id), &body, nil)
	if err != nil {
		return false, err
	}

	var resp struct {
		CL struct {
			Enabled bool `mapstructure:"enabled"`
		} `mapstructure:"connectionLogging"`
	}

	err = mapstructure.Decode(body, &resp)
	return resp.CL.Enabled, err
}
Example #25
0
// IsContentCached will check to see whether the specified load balancer caches
// content. When content caching is enabled, recently-accessed files are stored
// on the load balancer for easy retrieval by web clients. Content caching
// improves the performance of high traffic web sites by temporarily storing
// data that was recently accessed. While it's cached, requests for that data
// are served by the load balancer, which in turn reduces load off the back-end
// nodes. The result is improved response times for those requests and less
// load on the web server.
func IsContentCached(client *gophercloud.ServiceClient, id int) (bool, error) {
	var body interface{}

	_, err := client.Get(cacheURL(client, id), &body, nil)
	if err != nil {
		return false, err
	}

	var resp struct {
		CC struct {
			Enabled bool `mapstructure:"enabled"`
		} `mapstructure:"contentCaching"`
	}

	err = mapstructure.Decode(body, &resp)
	return resp.CC.Enabled, err
}
Example #26
0
// Get requests details on a single user, either by ID.
func Get(client *gophercloud.ServiceClient, id string) GetResult {
	var result GetResult
	_, result.Err = client.Get(ResourceURL(client, id), &result.Body, nil)
	return result
}
Example #27
0
// Get retrieves a specific port based on its unique ID.
func Get(c *gophercloud.ServiceClient, id string) GetResult {
	var res GetResult
	_, res.Err = c.Get(getURL(c, id), &res.Body, nil)
	return res
}
// Get prepares http GET call on Cinder endpoint
func Get(client *gophercloud.ServiceClient, limits string) GetResult {
	var res GetResult
	_, err := client.Get(client.ResourceBaseURL()+limits, &res.Body, nil)
	res.Err = err
	return res
}
Example #29
0
// Get retrieves a particular Pool Member based on its unique ID.
func GetAssociateMember(c *gophercloud.ServiceClient, poolID string, memberID string) GetResult {
	var res GetResult
	_, res.Err = c.Get(memberResourceURL(c, poolID, memberID), &res.Body, nil)
	return res
}
Example #30
0
// Metadata requests all the metadata for the given server ID.
func Metadata(client *gophercloud.ServiceClient, id string) GetMetadataResult {
	var res GetMetadataResult
	_, res.Err = client.Get(metadataURL(client, id), &res.Body, nil)
	return res
}