Skip to content
Permalink
Browse files
Export the HTTPGETOnly field for direct access
As you would need both read and write access, it makes sense to just
export the field instead of writing a getter and setter.
  • Loading branch information
Sander van Harmelen committed Jul 15, 2015
1 parent 1ea251a commit 912b1697a0fd834f0c0a3874201ee31591b339fb
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 56 deletions.
@@ -43,13 +43,14 @@ func (e *CSError) Error() error {
}

type CloudStackClient struct {
client *http.Client // The http client for communicating
baseURL string // The base URL of the API
apiKey string // Api key
secret string // Secret key
httpgetonly bool // If `true` only use HTTP GET calls
async bool // Wait for async calls to finish
timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 60 seconds
HTTPGETOnly bool // If `true` only use HTTP GET calls

client *http.Client // The http client for communicating
baseURL string // The base URL of the API
apiKey string // Api key
secret string // Secret key
async bool // Wait for async calls to finish
timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 60 seconds

APIDiscovery *APIDiscoveryService
Account *AccountService
@@ -218,12 +219,6 @@ func NewAsyncClient(apiurl string, apikey string, secret string, verifyssl bool)
return cs
}

// Some cloud providers offer customized (proxied) access to the CloudStack API allowing only HTTP GET calls. So
// by calling this method with `true`, the CloudStack client will only make GET calls.
func (cs *CloudStackClient) HTTPGETOnly(httpGETOnly bool) {
cs.httpgetonly = httpGETOnly
}

// When using the async client an api call will wait for the async call to finish before returning. The default is to poll for 60
// seconds, to check if the async job is finished.
func (cs *CloudStackClient) AsyncTimeout(timeoutInSeconds int64) {
@@ -285,7 +280,7 @@ func (cs *CloudStackClient) newRequest(api string, params url.Values) (json.RawM

var err error
var resp *http.Response
if !cs.httpgetonly && (api == "deployVirtualMachine" || api == "updateVirtualMachine") {
if !cs.HTTPGETOnly && (api == "deployVirtualMachine" || api == "updateVirtualMachine") {
// The deployVirtualMachine API should be called using a POST call
// so we don't have to worry about the userdata size

@@ -43,13 +43,14 @@ func (e *CSError) Error() error {
}

type CloudStackClient struct {
client *http.Client // The http client for communicating
baseURL string // The base URL of the API
apiKey string // Api key
secret string // Secret key
httpgetonly bool // If `true` only use HTTP GET calls
async bool // Wait for async calls to finish
timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 60 seconds
HTTPGETOnly bool // If `true` only use HTTP GET calls

client *http.Client // The http client for communicating
baseURL string // The base URL of the API
apiKey string // Api key
secret string // Secret key
async bool // Wait for async calls to finish
timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 60 seconds

APIDiscovery *APIDiscoveryService
Account *AccountService
@@ -224,12 +225,6 @@ func NewAsyncClient(apiurl string, apikey string, secret string, verifyssl bool)
return cs
}

// Some cloud providers offer customized (proxied) access to the CloudStack API allowing only HTTP GET calls. So
// by calling this method with `true`, the CloudStack client will only make GET calls.
func (cs *CloudStackClient) HTTPGETOnly(httpGETOnly bool) {
cs.httpgetonly = httpGETOnly
}

// When using the async client an api call will wait for the async call to finish before returning. The default is to poll for 60
// seconds, to check if the async job is finished.
func (cs *CloudStackClient) AsyncTimeout(timeoutInSeconds int64) {
@@ -291,7 +286,7 @@ func (cs *CloudStackClient) newRequest(api string, params url.Values) (json.RawM

var err error
var resp *http.Response
if !cs.httpgetonly && (api == "deployVirtualMachine" || api == "updateVirtualMachine") {
if !cs.HTTPGETOnly && (api == "deployVirtualMachine" || api == "updateVirtualMachine") {
// The deployVirtualMachine API should be called using a POST call
// so we don't have to worry about the userdata size

@@ -43,13 +43,14 @@ func (e *CSError) Error() error {
}

type CloudStackClient struct {
client *http.Client // The http client for communicating
baseURL string // The base URL of the API
apiKey string // Api key
secret string // Secret key
httpgetonly bool // If `true` only use HTTP GET calls
async bool // Wait for async calls to finish
timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 60 seconds
HTTPGETOnly bool // If `true` only use HTTP GET calls

client *http.Client // The http client for communicating
baseURL string // The base URL of the API
apiKey string // Api key
secret string // Secret key
async bool // Wait for async calls to finish
timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 60 seconds

APIDiscovery *APIDiscoveryService
Account *AccountService
@@ -218,12 +219,6 @@ func NewAsyncClient(apiurl string, apikey string, secret string, verifyssl bool)
return cs
}

// Some cloud providers offer customized (proxied) access to the CloudStack API allowing only HTTP GET calls. So
// by calling this method with `true`, the CloudStack client will only make GET calls.
func (cs *CloudStackClient) HTTPGETOnly(httpGETOnly bool) {
cs.httpgetonly = httpGETOnly
}

// When using the async client an api call will wait for the async call to finish before returning. The default is to poll for 60
// seconds, to check if the async job is finished.
func (cs *CloudStackClient) AsyncTimeout(timeoutInSeconds int64) {
@@ -285,7 +280,7 @@ func (cs *CloudStackClient) newRequest(api string, params url.Values) (json.RawM

var err error
var resp *http.Response
if !cs.httpgetonly && (api == "deployVirtualMachine" || api == "updateVirtualMachine") {
if !cs.HTTPGETOnly && (api == "deployVirtualMachine" || api == "updateVirtualMachine") {
// The deployVirtualMachine API should be called using a POST call
// so we don't have to worry about the userdata size

@@ -258,13 +258,14 @@ func (as *allServices) GeneralCode() ([]byte, error) {
pn("}")
pn("")
pn("type CloudStackClient struct {")
pn(" client *http.Client // The http client for communicating")
pn(" baseURL string // The base URL of the API")
pn(" apiKey string // Api key")
pn(" secret string // Secret key")
pn(" httpgetonly bool // If `true` only use HTTP GET calls")
pn(" async bool // Wait for async calls to finish")
pn(" timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 60 seconds")
pn(" HTTPGETOnly bool // If `true` only use HTTP GET calls")
pn("")
pn(" client *http.Client // The http client for communicating")
pn(" baseURL string // The base URL of the API")
pn(" apiKey string // Api key")
pn(" secret string // Secret key")
pn(" async bool // Wait for async calls to finish")
pn(" timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 60 seconds")
pn("")
for _, s := range as.services {
pn(" %s *%s", strings.TrimSuffix(s.name, "Service"), s.name)
@@ -309,12 +310,6 @@ func (as *allServices) GeneralCode() ([]byte, error) {
pn(" return cs")
pn("}")
pn("")
pn("// Some cloud providers offer customized (proxied) access to the CloudStack API allowing only HTTP GET calls. So")
pn("// by calling this method with `true`, the CloudStack client will only make GET calls.")
pn("func (cs *CloudStackClient) HTTPGETOnly(httpGETOnly bool) {")
pn(" cs.httpgetonly = httpGETOnly")
pn("}")
pn("")
pn("// When using the async client an api call will wait for the async call to finish before returning. The default is to poll for 60")
pn("// seconds, to check if the async job is finished.")
pn("func (cs *CloudStackClient) AsyncTimeout(timeoutInSeconds int64) {")
@@ -376,7 +371,7 @@ func (as *allServices) GeneralCode() ([]byte, error) {
pn("")
pn(" var err error")
pn(" var resp *http.Response")
pn(" if !cs.httpgetonly && (api == \"deployVirtualMachine\" || api == \"updateVirtualMachine\") {")
pn(" if !cs.HTTPGETOnly && (api == \"deployVirtualMachine\" || api == \"updateVirtualMachine\") {")
pn(" // The deployVirtualMachine API should be called using a POST call")
pn(" // so we don't have to worry about the userdata size")
pn("")

0 comments on commit 912b169

Please sign in to comment.