當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ServiceClient.Request方法代碼示例

本文整理匯總了Golang中github.com/rackspace/rack/internal/github.com/rackspace/gophercloud.ServiceClient.Request方法的典型用法代碼示例。如果您正苦於以下問題:Golang ServiceClient.Request方法的具體用法?Golang ServiceClient.Request怎麽用?Golang ServiceClient.Request使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/rackspace/rack/internal/github.com/rackspace/gophercloud.ServiceClient的用法示例。


在下文中一共展示了ServiceClient.Request方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Update

// Update is a function that creates, updates, or deletes an object's metadata.
func Update(c *gophercloud.ServiceClient, containerName, objectName string, opts UpdateOptsBuilder) UpdateResult {
	var res UpdateResult
	h := c.AuthenticatedHeaders()

	if opts != nil {
		headers, err := opts.ToObjectUpdateMap()
		if err != nil {
			res.Err = err
			return res
		}

		for k, v := range headers {
			h[k] = v
		}
	}

	url := updateURL(c, containerName, objectName)
	resp, err := c.Request("POST", url, gophercloud.RequestOpts{
		MoreHeaders: h,
	})
	if resp != nil {
		res.Header = resp.Header
	}
	res.Err = err
	return res
}
開發者ID:reaperzn,項目名稱:rack,代碼行數:27,代碼來源:requests.go

示例2: Get

// Get retreives data for the given stack template.
func Get(c *gophercloud.ServiceClient, stackName, stackID string) GetResult {
	var res GetResult
	_, res.Err = c.Request("GET", getURL(c, stackName, stackID), gophercloud.RequestOpts{
		JSONResponse: &res.Body,
	})
	return res
}
開發者ID:pratikmallya,項目名稱:rack,代碼行數:8,代碼來源:requests.go

示例3: Copy

// Copy is a function that copies one object to another.
func Copy(c *gophercloud.ServiceClient, containerName, objectName string, opts CopyOptsBuilder) CopyResult {
	var res CopyResult
	h := c.AuthenticatedHeaders()

	headers, err := opts.ToObjectCopyMap()
	if err != nil {
		res.Err = err
		return res
	}

	for k, v := range headers {
		h[k] = v
	}

	url := copyURL(c, containerName, objectName)
	resp, err := c.Request("COPY", url, gophercloud.RequestOpts{
		MoreHeaders: h,
		OkCodes:     []int{201},
	})
	if resp != nil {
		res.Header = resp.Header
	}
	res.Err = err
	return res
}
開發者ID:reaperzn,項目名稱:rack,代碼行數:26,代碼來源:requests.go

示例4: Update

// Update is a function that creates, updates, or deletes an account's metadata.
// To extract the headers returned, call the Extract method on the UpdateResult.
func Update(c *gophercloud.ServiceClient, opts UpdateOptsBuilder) UpdateResult {
	var res UpdateResult
	h := make(map[string]string)

	if opts != nil {
		headers, err := opts.ToAccountUpdateMap()
		if err != nil {
			res.Err = err
			return res
		}
		for k, v := range headers {
			h[k] = v
		}
	}

	resp, err := c.Request("POST", updateURL(c), gophercloud.RequestOpts{
		MoreHeaders: h,
		OkCodes:     []int{201, 202, 204},
	})
	if resp != nil {
		res.Header = resp.Header
	}
	res.Err = err
	return res
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:27,代碼來源:requests.go

示例5: Download

// Download is a function that retrieves the content and metadata for an object.
// To extract just the content, pass the DownloadResult response to the
// ExtractContent function.
func Download(c *gophercloud.ServiceClient, containerName, objectName string, opts DownloadOptsBuilder) DownloadResult {
	var res DownloadResult

	url := downloadURL(c, containerName, objectName)
	h := c.AuthenticatedHeaders()

	if opts != nil {
		headers, query, err := opts.ToObjectDownloadParams()
		if err != nil {
			res.Err = err
			return res
		}

		for k, v := range headers {
			h[k] = v
		}

		url += query
	}

	resp, err := c.Request("GET", url, gophercloud.RequestOpts{
		MoreHeaders: h,
		OkCodes:     []int{200, 304},
	})
	if resp != nil {
		res.Header = resp.Header
		res.Body = resp.Body
	}
	res.Err = err

	return res
}
開發者ID:reaperzn,項目名稱:rack,代碼行數:35,代碼來源:requests.go

示例6: Create

// Create is a function that creates a new container.
func Create(c *gophercloud.ServiceClient, containerName string, opts CreateOptsBuilder) CreateResult {
	var res CreateResult
	h := c.AuthenticatedHeaders()

	if opts != nil {
		headers, err := opts.ToContainerCreateMap()
		if err != nil {
			res.Err = err
			return res
		}

		for k, v := range headers {
			h[k] = v
		}
	}

	resp, err := c.Request("PUT", createURL(c, containerName), gophercloud.RequestOpts{
		MoreHeaders:  h,
		OkCodes:      []int{201, 202, 204},
		ErrorContext: &ContainerError{},
	})
	if resp != nil {
		res.Header = resp.Header
	}
	res.Err = err
	return res
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:28,代碼來源:requests.go

示例7: Metadatum

// Metadatum requests the key-value pair with the given key for the given server ID.
func Metadatum(client *gophercloud.ServiceClient, id, key string) GetMetadatumResult {
	var res GetMetadatumResult
	_, res.Err = client.Request("GET", metadatumURL(client, id, key), gophercloud.RequestOpts{
		JSONResponse: &res.Body,
	})
	return res
}
開發者ID:ktbartholomew,項目名稱:rack,代碼行數:8,代碼來源:requests.go

示例8: Get

// Get is a function that retrieves an account's metadata. To extract just the
// custom metadata, call the ExtractMetadata method on the GetResult. To extract
// all the headers that are returned (including the metadata), call the
// ExtractHeader method on the GetResult.
func Get(c *gophercloud.ServiceClient, opts GetOptsBuilder) GetResult {
	var res GetResult
	h := c.AuthenticatedHeaders()

	if opts != nil {
		headers, err := opts.ToAccountGetMap()
		if err != nil {
			res.Err = err
			return res
		}

		for k, v := range headers {
			h[k] = v
		}
	}

	resp, err := c.Request("HEAD", getURL(c), gophercloud.RequestOpts{
		MoreHeaders: h,
		OkCodes:     []int{204},
	})
	if resp != nil {
		res.Header = resp.Header
	}
	res.Err = err
	return res
}
開發者ID:satyamkotakonda,項目名稱:rack,代碼行數:30,代碼來源:requests.go

示例9: Find

// Find retrieves stack events for the given stack name.
func Find(c *gophercloud.ServiceClient, stackName string) FindResult {
	var res FindResult

	_, res.Err = c.Request("GET", findURL(c, stackName), gophercloud.RequestOpts{
		JSONResponse: &res.Body,
	})
	return res
}
開發者ID:pratikmallya,項目名稱:rack,代碼行數:9,代碼來源:requests.go

示例10: Delete

// Delete will permanently delete a user from a specified database instance.
func Delete(client *gophercloud.ServiceClient, instanceID, userName string) DeleteResult {
	var res DeleteResult

	_, res.Err = client.Request("DELETE", userURL(client, instanceID, userName), gophercloud.RequestOpts{
		OkCodes: []int{202},
	})

	return res
}
開發者ID:ktbartholomew,項目名稱:rack,代碼行數:10,代碼來源:requests.go

示例11: RevokeAccess

/*
RevokeAccess will revoke access for the specified user to one or more databases
on a specified instance. For example:

	RevokeAccess(client, "instance_id", "user_name", "db_name")
*/
func RevokeAccess(client *gophercloud.ServiceClient, instanceID, userName, dbName string) RevokeAccessResult {
	var res RevokeAccessResult

	_, res.Err = client.Request("DELETE", dbURL(client, instanceID, userName, dbName), gophercloud.RequestOpts{
		OkCodes: []int{202},
	})

	return res
}
開發者ID:ktbartholomew,項目名稱:rack,代碼行數:15,代碼來源:requests.go

示例12: Get

// Get will retrieve the details for a particular user.
func Get(client *gophercloud.ServiceClient, instanceID, userName string) GetResult {
	var res GetResult

	_, res.Err = client.Request("GET", userURL(client, instanceID, userName), gophercloud.RequestOpts{
		JSONResponse: &res.Body,
		OkCodes:      []int{200},
	})

	return res
}
開發者ID:ktbartholomew,項目名稱:rack,代碼行數:11,代碼來源:requests.go

示例13: Get

// Get will retrieve information for a specified hardware flavor.
func Get(client *gophercloud.ServiceClient, id string) GetResult {
	var gr GetResult

	_, gr.Err = client.Request("GET", getURL(client, id), gophercloud.RequestOpts{
		JSONResponse: &gr.Body,
		OkCodes:      []int{200},
	})

	return gr
}
開發者ID:ktbartholomew,項目名稱:rack,代碼行數:11,代碼來源:requests.go

示例14: DetachReplica

// DetachReplica will detach a specified replica instance from its source
// instance, effectively allowing it to operate independently. Detaching a
// replica will restart the MySQL service on the instance.
func DetachReplica(client *gophercloud.ServiceClient, replicaID string) DetachResult {
	var res DetachResult

	_, res.Err = client.Request("PATCH", resourceURL(client, replicaID), gophercloud.RequestOpts{
		JSONBody: map[string]interface{}{"instance": map[string]string{"replica_of": "", "slave_of": ""}},
		OkCodes:  []int{202},
	})

	return res
}
開發者ID:ktbartholomew,項目名稱:rack,代碼行數:13,代碼來源:requests.go

示例15: GetDefaultConfig

// GetDefaultConfig lists the default configuration settings from the template
// that was applied to the specified instance. In a sense, this is the vanilla
// configuration setting applied to an instance. Further configuration can be
// applied by associating an instance with a configuration group.
func GetDefaultConfig(client *gophercloud.ServiceClient, id string) ConfigResult {
	var res ConfigResult

	_, res.Err = client.Request("GET", configURL(client, id), gophercloud.RequestOpts{
		JSONResponse: &res.Body,
		OkCodes:      []int{200},
	})

	return res
}
開發者ID:ktbartholomew,項目名稱:rack,代碼行數:14,代碼來源:requests.go


注:本文中的github.com/rackspace/rack/internal/github.com/rackspace/gophercloud.ServiceClient.Request方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。