zero: generate error methods for response types (#5252)

This commit is contained in:
Joe Kralicky 2024-08-30 16:21:43 -04:00 committed by GitHub
parent ccd8a1d5a2
commit d149b2d178
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 362 additions and 132 deletions

View file

@ -1,8 +1,6 @@
package cluster
import (
"net/http"
"github.com/pomerium/pomerium/internal/zero/apierror"
)
@ -16,133 +14,3 @@ var (
_ apierror.APIResponse[DownloadBundleResponse] = (*DownloadClusterResourceBundleResp)(nil)
_ apierror.APIResponse[EmptyResponse] = (*ReportClusterResourceBundleStatusResp)(nil)
)
// GetBadRequestError implements apierror.APIResponse
func (r *ExchangeClusterIdentityTokenResp) GetBadRequestError() (string, bool) {
if r.JSON400 == nil {
return "", false
}
return r.JSON400.Error, true
}
// GetInternalServerError implements apierror.APIResponse
func (r *ExchangeClusterIdentityTokenResp) GetInternalServerError() (string, bool) {
if r.JSON500 == nil {
return "", false
}
return r.JSON500.Error, true
}
// GetValue implements apierror.APIResponse
func (r *ExchangeClusterIdentityTokenResp) GetValue() *ExchangeTokenResponse {
return r.JSON200
}
// GetHTTPResponse implements apierror.APIResponse
func (r *ExchangeClusterIdentityTokenResp) GetHTTPResponse() *http.Response {
return r.HTTPResponse
}
// GetBadRequestError implements apierror.APIResponse
func (r *GetClusterBootstrapConfigResp) GetBadRequestError() (string, bool) {
if r.JSON400 == nil {
return "", false
}
return r.JSON400.Error, true
}
// GetInternalServerError implements apierror.APIResponse
func (r *GetClusterBootstrapConfigResp) GetInternalServerError() (string, bool) {
if r.JSON500 == nil {
return "", false
}
return r.JSON500.Error, true
}
// GetValue implements apierror.APIResponse
func (r *GetClusterBootstrapConfigResp) GetValue() *BootstrapConfig {
return r.JSON200
}
// GetHTTPResponse implements apierror.APIResponse
func (r *GetClusterBootstrapConfigResp) GetHTTPResponse() *http.Response {
return r.HTTPResponse
}
// GetBadRequestError implements apierror.APIResponse
func (r *GetClusterResourceBundlesResp) GetBadRequestError() (string, bool) {
if r.JSON400 == nil {
return "", false
}
return r.JSON400.Error, true
}
// GetInternalServerError implements apierror.APIResponse
func (r *GetClusterResourceBundlesResp) GetInternalServerError() (string, bool) {
if r.JSON500 == nil {
return "", false
}
return r.JSON500.Error, true
}
// GetValue implements apierror.APIResponse
func (r *GetClusterResourceBundlesResp) GetValue() *GetBundlesResponse {
return r.JSON200
}
// GetHTTPResponse implements apierror.APIResponse
func (r *GetClusterResourceBundlesResp) GetHTTPResponse() *http.Response {
return r.HTTPResponse
}
// GetBadRequestError implements apierror.APIResponse
func (r *DownloadClusterResourceBundleResp) GetBadRequestError() (string, bool) {
if r.JSON400 == nil {
return "", false
}
return r.JSON400.Error, true
}
// GetInternalServerError implements apierror.APIResponse
func (r *DownloadClusterResourceBundleResp) GetInternalServerError() (string, bool) {
if r.JSON500 == nil {
return "", false
}
return r.JSON500.Error, true
}
// GetValue implements apierror.APIResponse
func (r *DownloadClusterResourceBundleResp) GetValue() *DownloadBundleResponse {
return r.JSON200
}
// GetHTTPResponse implements apierror.APIResponse
func (r *DownloadClusterResourceBundleResp) GetHTTPResponse() *http.Response {
return r.HTTPResponse
}
// GetBadRequestError implements apierror.APIResponse
func (r *ReportClusterResourceBundleStatusResp) GetBadRequestError() (string, bool) {
if r.JSON400 == nil {
return "", false
}
return r.JSON400.Error, true
}
// GetInternalServerError implements apierror.APIResponse
func (r *ReportClusterResourceBundleStatusResp) GetInternalServerError() (string, bool) {
if r.JSON500 == nil {
return "", false
}
return r.JSON500.Error, true
}
// GetValue implements apierror.APIResponse
func (r *ReportClusterResourceBundleStatusResp) GetValue() *EmptyResponse {
return &EmptyResponse{}
}
// GetHTTPResponse implements apierror.APIResponse
func (r *ReportClusterResourceBundleStatusResp) GetHTTPResponse() *http.Response {
return r.HTTPResponse
}