2016-02-03 19:00:55 +01:00
|
|
|
package azure
|
|
|
|
|
2016-02-05 00:36:50 +01:00
|
|
|
// APICall must be implemented by structures which represent requests to the
|
2016-02-03 19:00:55 +01:00
|
|
|
// ARM API in order that the generic request handling layer has sufficient
|
|
|
|
// information to execute requests.
|
2016-02-05 00:36:50 +01:00
|
|
|
type APICall interface {
|
|
|
|
APIInfo() APIInfo
|
2016-02-03 19:00:55 +01:00
|
|
|
}
|
|
|
|
|
2016-02-05 00:36:50 +01:00
|
|
|
// APIInfo contains information about a request to the ARM API - which API
|
2016-02-03 19:00:55 +01:00
|
|
|
// version is required, the HTTP method to use, and a factory function for
|
|
|
|
// responses.
|
2016-02-05 00:36:50 +01:00
|
|
|
type APIInfo struct {
|
2016-02-05 12:28:48 +01:00
|
|
|
APIVersion string
|
|
|
|
Method string
|
|
|
|
URLPathFunc func() string
|
|
|
|
ResponseTypeFunc func() interface{}
|
|
|
|
RequestPropertiesFunc func() interface{}
|
2016-05-07 02:36:25 +02:00
|
|
|
HasBodyOverride bool
|
2016-02-03 19:00:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// HasBody returns true if the API Request should have a body. This is usually
|
|
|
|
// the case for PUT, PATCH or POST operations, but is not the case for GET operations.
|
|
|
|
// TODO(jen20): This may need revisiting at some point.
|
2016-02-05 00:36:50 +01:00
|
|
|
func (apiInfo APIInfo) HasBody() bool {
|
2016-05-07 02:36:25 +02:00
|
|
|
if apiInfo.HasBodyOverride == false {
|
|
|
|
return apiInfo.Method == "POST" || apiInfo.Method == "PUT" || apiInfo.Method == "PATCH"
|
|
|
|
}
|
|
|
|
return !(apiInfo.Method == "POST" || apiInfo.Method == "PUT" || apiInfo.Method == "PATCH")
|
2016-02-03 19:00:55 +01:00
|
|
|
}
|