Add webhook show, return info and some fixes
* Added a webhook show command. This gives us info about the webhook and
if it is installed.
* Return webhook info when installing the webhook
* Small typo fixes.
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
6051fa016c
commit
779afe980e
27 changed files with 1253 additions and 66 deletions
151
client/organizations/get_org_webhook_info_parameters.go
Normal file
151
client/organizations/get_org_webhook_info_parameters.go
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package organizations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewGetOrgWebhookInfoParams creates a new GetOrgWebhookInfoParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewGetOrgWebhookInfoParams() *GetOrgWebhookInfoParams {
|
||||
return &GetOrgWebhookInfoParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetOrgWebhookInfoParamsWithTimeout creates a new GetOrgWebhookInfoParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewGetOrgWebhookInfoParamsWithTimeout(timeout time.Duration) *GetOrgWebhookInfoParams {
|
||||
return &GetOrgWebhookInfoParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetOrgWebhookInfoParamsWithContext creates a new GetOrgWebhookInfoParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewGetOrgWebhookInfoParamsWithContext(ctx context.Context) *GetOrgWebhookInfoParams {
|
||||
return &GetOrgWebhookInfoParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetOrgWebhookInfoParamsWithHTTPClient creates a new GetOrgWebhookInfoParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewGetOrgWebhookInfoParamsWithHTTPClient(client *http.Client) *GetOrgWebhookInfoParams {
|
||||
return &GetOrgWebhookInfoParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
GetOrgWebhookInfoParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the get org webhook info operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type GetOrgWebhookInfoParams struct {
|
||||
|
||||
/* OrgID.
|
||||
|
||||
Organization ID.
|
||||
*/
|
||||
OrgID string
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the get org webhook info params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *GetOrgWebhookInfoParams) WithDefaults() *GetOrgWebhookInfoParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the get org webhook info params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *GetOrgWebhookInfoParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the get org webhook info params
|
||||
func (o *GetOrgWebhookInfoParams) WithTimeout(timeout time.Duration) *GetOrgWebhookInfoParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the get org webhook info params
|
||||
func (o *GetOrgWebhookInfoParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the get org webhook info params
|
||||
func (o *GetOrgWebhookInfoParams) WithContext(ctx context.Context) *GetOrgWebhookInfoParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the get org webhook info params
|
||||
func (o *GetOrgWebhookInfoParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the get org webhook info params
|
||||
func (o *GetOrgWebhookInfoParams) WithHTTPClient(client *http.Client) *GetOrgWebhookInfoParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the get org webhook info params
|
||||
func (o *GetOrgWebhookInfoParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithOrgID adds the orgID to the get org webhook info params
|
||||
func (o *GetOrgWebhookInfoParams) WithOrgID(orgID string) *GetOrgWebhookInfoParams {
|
||||
o.SetOrgID(orgID)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetOrgID adds the orgId to the get org webhook info params
|
||||
func (o *GetOrgWebhookInfoParams) SetOrgID(orgID string) {
|
||||
o.OrgID = orgID
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *GetOrgWebhookInfoParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
// path param orgID
|
||||
if err := r.SetPathParam("orgID", o.OrgID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
179
client/organizations/get_org_webhook_info_responses.go
Normal file
179
client/organizations/get_org_webhook_info_responses.go
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package organizations
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
apiserver_params "github.com/cloudbase/garm/apiserver/params"
|
||||
garm_params "github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
// GetOrgWebhookInfoReader is a Reader for the GetOrgWebhookInfo structure.
|
||||
type GetOrgWebhookInfoReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *GetOrgWebhookInfoReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewGetOrgWebhookInfoOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
default:
|
||||
result := NewGetOrgWebhookInfoDefault(response.Code())
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code()/100 == 2 {
|
||||
return result, nil
|
||||
}
|
||||
return nil, result
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetOrgWebhookInfoOK creates a GetOrgWebhookInfoOK with default headers values
|
||||
func NewGetOrgWebhookInfoOK() *GetOrgWebhookInfoOK {
|
||||
return &GetOrgWebhookInfoOK{}
|
||||
}
|
||||
|
||||
/*
|
||||
GetOrgWebhookInfoOK describes a response with status code 200, with default header values.
|
||||
|
||||
HookInfo
|
||||
*/
|
||||
type GetOrgWebhookInfoOK struct {
|
||||
Payload garm_params.HookInfo
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this get org webhook info o k response has a 2xx status code
|
||||
func (o *GetOrgWebhookInfoOK) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this get org webhook info o k response has a 3xx status code
|
||||
func (o *GetOrgWebhookInfoOK) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this get org webhook info o k response has a 4xx status code
|
||||
func (o *GetOrgWebhookInfoOK) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this get org webhook info o k response has a 5xx status code
|
||||
func (o *GetOrgWebhookInfoOK) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this get org webhook info o k response a status code equal to that given
|
||||
func (o *GetOrgWebhookInfoOK) IsCode(code int) bool {
|
||||
return code == 200
|
||||
}
|
||||
|
||||
// Code gets the status code for the get org webhook info o k response
|
||||
func (o *GetOrgWebhookInfoOK) Code() int {
|
||||
return 200
|
||||
}
|
||||
|
||||
func (o *GetOrgWebhookInfoOK) Error() string {
|
||||
return fmt.Sprintf("[GET /organizations/{orgID}/webhook][%d] getOrgWebhookInfoOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetOrgWebhookInfoOK) String() string {
|
||||
return fmt.Sprintf("[GET /organizations/{orgID}/webhook][%d] getOrgWebhookInfoOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetOrgWebhookInfoOK) GetPayload() garm_params.HookInfo {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetOrgWebhookInfoOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewGetOrgWebhookInfoDefault creates a GetOrgWebhookInfoDefault with default headers values
|
||||
func NewGetOrgWebhookInfoDefault(code int) *GetOrgWebhookInfoDefault {
|
||||
return &GetOrgWebhookInfoDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
GetOrgWebhookInfoDefault describes a response with status code -1, with default header values.
|
||||
|
||||
APIErrorResponse
|
||||
*/
|
||||
type GetOrgWebhookInfoDefault struct {
|
||||
_statusCode int
|
||||
|
||||
Payload apiserver_params.APIErrorResponse
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this get org webhook info default response has a 2xx status code
|
||||
func (o *GetOrgWebhookInfoDefault) IsSuccess() bool {
|
||||
return o._statusCode/100 == 2
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this get org webhook info default response has a 3xx status code
|
||||
func (o *GetOrgWebhookInfoDefault) IsRedirect() bool {
|
||||
return o._statusCode/100 == 3
|
||||
}
|
||||
|
||||
// IsClientError returns true when this get org webhook info default response has a 4xx status code
|
||||
func (o *GetOrgWebhookInfoDefault) IsClientError() bool {
|
||||
return o._statusCode/100 == 4
|
||||
}
|
||||
|
||||
// IsServerError returns true when this get org webhook info default response has a 5xx status code
|
||||
func (o *GetOrgWebhookInfoDefault) IsServerError() bool {
|
||||
return o._statusCode/100 == 5
|
||||
}
|
||||
|
||||
// IsCode returns true when this get org webhook info default response a status code equal to that given
|
||||
func (o *GetOrgWebhookInfoDefault) IsCode(code int) bool {
|
||||
return o._statusCode == code
|
||||
}
|
||||
|
||||
// Code gets the status code for the get org webhook info default response
|
||||
func (o *GetOrgWebhookInfoDefault) Code() int {
|
||||
return o._statusCode
|
||||
}
|
||||
|
||||
func (o *GetOrgWebhookInfoDefault) Error() string {
|
||||
return fmt.Sprintf("[GET /organizations/{orgID}/webhook][%d] GetOrgWebhookInfo default %+v", o._statusCode, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetOrgWebhookInfoDefault) String() string {
|
||||
return fmt.Sprintf("[GET /organizations/{orgID}/webhook][%d] GetOrgWebhookInfo default %+v", o._statusCode, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetOrgWebhookInfoDefault) GetPayload() apiserver_params.APIErrorResponse {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetOrgWebhookInfoDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/go-openapi/strfmt"
|
||||
|
||||
apiserver_params "github.com/cloudbase/garm/apiserver/params"
|
||||
garm_params "github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
// InstallOrgWebhookReader is a Reader for the InstallOrgWebhook structure.
|
||||
|
|
@ -49,9 +50,10 @@ func NewInstallOrgWebhookOK() *InstallOrgWebhookOK {
|
|||
/*
|
||||
InstallOrgWebhookOK describes a response with status code 200, with default header values.
|
||||
|
||||
InstallOrgWebhookOK install org webhook o k
|
||||
HookInfo
|
||||
*/
|
||||
type InstallOrgWebhookOK struct {
|
||||
Payload garm_params.HookInfo
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this install org webhook o k response has a 2xx status code
|
||||
|
|
@ -85,15 +87,24 @@ func (o *InstallOrgWebhookOK) Code() int {
|
|||
}
|
||||
|
||||
func (o *InstallOrgWebhookOK) Error() string {
|
||||
return fmt.Sprintf("[POST /organizations/{orgID}/webhook][%d] installOrgWebhookOK ", 200)
|
||||
return fmt.Sprintf("[POST /organizations/{orgID}/webhook][%d] installOrgWebhookOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *InstallOrgWebhookOK) String() string {
|
||||
return fmt.Sprintf("[POST /organizations/{orgID}/webhook][%d] installOrgWebhookOK ", 200)
|
||||
return fmt.Sprintf("[POST /organizations/{orgID}/webhook][%d] installOrgWebhookOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *InstallOrgWebhookOK) GetPayload() garm_params.HookInfo {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *InstallOrgWebhookOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ type ClientService interface {
|
|||
|
||||
GetOrgPool(params *GetOrgPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOrgPoolOK, error)
|
||||
|
||||
GetOrgWebhookInfo(params *GetOrgWebhookInfoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOrgWebhookInfoOK, error)
|
||||
|
||||
InstallOrgWebhook(params *InstallOrgWebhookParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InstallOrgWebhookOK, error)
|
||||
|
||||
ListOrgInstances(params *ListOrgInstancesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListOrgInstancesOK, error)
|
||||
|
|
@ -273,6 +275,44 @@ func (a *Client) GetOrgPool(params *GetOrgPoolParams, authInfo runtime.ClientAut
|
|||
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
|
||||
}
|
||||
|
||||
/*
|
||||
GetOrgWebhookInfo gets information about the g a r m installed webhook on an organization
|
||||
*/
|
||||
func (a *Client) GetOrgWebhookInfo(params *GetOrgWebhookInfoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetOrgWebhookInfoOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewGetOrgWebhookInfoParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "GetOrgWebhookInfo",
|
||||
Method: "GET",
|
||||
PathPattern: "/organizations/{orgID}/webhook",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &GetOrgWebhookInfoReader{formats: a.formats},
|
||||
AuthInfo: authInfo,
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*GetOrgWebhookInfoOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
unexpectedSuccess := result.(*GetOrgWebhookInfoDefault)
|
||||
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
|
||||
}
|
||||
|
||||
/*
|
||||
InstallOrgWebhook Install the GARM webhook for an organization. The secret configured on the organization will
|
||||
|
||||
|
|
|
|||
151
client/repositories/get_repo_webhook_info_parameters.go
Normal file
151
client/repositories/get_repo_webhook_info_parameters.go
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package repositories
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
)
|
||||
|
||||
// NewGetRepoWebhookInfoParams creates a new GetRepoWebhookInfoParams object,
|
||||
// with the default timeout for this client.
|
||||
//
|
||||
// Default values are not hydrated, since defaults are normally applied by the API server side.
|
||||
//
|
||||
// To enforce default values in parameter, use SetDefaults or WithDefaults.
|
||||
func NewGetRepoWebhookInfoParams() *GetRepoWebhookInfoParams {
|
||||
return &GetRepoWebhookInfoParams{
|
||||
timeout: cr.DefaultTimeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetRepoWebhookInfoParamsWithTimeout creates a new GetRepoWebhookInfoParams object
|
||||
// with the ability to set a timeout on a request.
|
||||
func NewGetRepoWebhookInfoParamsWithTimeout(timeout time.Duration) *GetRepoWebhookInfoParams {
|
||||
return &GetRepoWebhookInfoParams{
|
||||
timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetRepoWebhookInfoParamsWithContext creates a new GetRepoWebhookInfoParams object
|
||||
// with the ability to set a context for a request.
|
||||
func NewGetRepoWebhookInfoParamsWithContext(ctx context.Context) *GetRepoWebhookInfoParams {
|
||||
return &GetRepoWebhookInfoParams{
|
||||
Context: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetRepoWebhookInfoParamsWithHTTPClient creates a new GetRepoWebhookInfoParams object
|
||||
// with the ability to set a custom HTTPClient for a request.
|
||||
func NewGetRepoWebhookInfoParamsWithHTTPClient(client *http.Client) *GetRepoWebhookInfoParams {
|
||||
return &GetRepoWebhookInfoParams{
|
||||
HTTPClient: client,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
GetRepoWebhookInfoParams contains all the parameters to send to the API endpoint
|
||||
|
||||
for the get repo webhook info operation.
|
||||
|
||||
Typically these are written to a http.Request.
|
||||
*/
|
||||
type GetRepoWebhookInfoParams struct {
|
||||
|
||||
/* RepoID.
|
||||
|
||||
Repository ID.
|
||||
*/
|
||||
RepoID string
|
||||
|
||||
timeout time.Duration
|
||||
Context context.Context
|
||||
HTTPClient *http.Client
|
||||
}
|
||||
|
||||
// WithDefaults hydrates default values in the get repo webhook info params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *GetRepoWebhookInfoParams) WithDefaults() *GetRepoWebhookInfoParams {
|
||||
o.SetDefaults()
|
||||
return o
|
||||
}
|
||||
|
||||
// SetDefaults hydrates default values in the get repo webhook info params (not the query body).
|
||||
//
|
||||
// All values with no default are reset to their zero value.
|
||||
func (o *GetRepoWebhookInfoParams) SetDefaults() {
|
||||
// no default values defined for this parameter
|
||||
}
|
||||
|
||||
// WithTimeout adds the timeout to the get repo webhook info params
|
||||
func (o *GetRepoWebhookInfoParams) WithTimeout(timeout time.Duration) *GetRepoWebhookInfoParams {
|
||||
o.SetTimeout(timeout)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetTimeout adds the timeout to the get repo webhook info params
|
||||
func (o *GetRepoWebhookInfoParams) SetTimeout(timeout time.Duration) {
|
||||
o.timeout = timeout
|
||||
}
|
||||
|
||||
// WithContext adds the context to the get repo webhook info params
|
||||
func (o *GetRepoWebhookInfoParams) WithContext(ctx context.Context) *GetRepoWebhookInfoParams {
|
||||
o.SetContext(ctx)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetContext adds the context to the get repo webhook info params
|
||||
func (o *GetRepoWebhookInfoParams) SetContext(ctx context.Context) {
|
||||
o.Context = ctx
|
||||
}
|
||||
|
||||
// WithHTTPClient adds the HTTPClient to the get repo webhook info params
|
||||
func (o *GetRepoWebhookInfoParams) WithHTTPClient(client *http.Client) *GetRepoWebhookInfoParams {
|
||||
o.SetHTTPClient(client)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetHTTPClient adds the HTTPClient to the get repo webhook info params
|
||||
func (o *GetRepoWebhookInfoParams) SetHTTPClient(client *http.Client) {
|
||||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithRepoID adds the repoID to the get repo webhook info params
|
||||
func (o *GetRepoWebhookInfoParams) WithRepoID(repoID string) *GetRepoWebhookInfoParams {
|
||||
o.SetRepoID(repoID)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetRepoID adds the repoId to the get repo webhook info params
|
||||
func (o *GetRepoWebhookInfoParams) SetRepoID(repoID string) {
|
||||
o.RepoID = repoID
|
||||
}
|
||||
|
||||
// WriteToRequest writes these params to a swagger request
|
||||
func (o *GetRepoWebhookInfoParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error {
|
||||
|
||||
if err := r.SetTimeout(o.timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
var res []error
|
||||
|
||||
// path param repoID
|
||||
if err := r.SetPathParam("repoID", o.RepoID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(res) > 0 {
|
||||
return errors.CompositeValidationError(res...)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
179
client/repositories/get_repo_webhook_info_responses.go
Normal file
179
client/repositories/get_repo_webhook_info_responses.go
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
// Code generated by go-swagger; DO NOT EDIT.
|
||||
|
||||
package repositories
|
||||
|
||||
// This file was generated by the swagger tool.
|
||||
// Editing this file might prove futile when you re-run the swagger generate command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/go-openapi/strfmt"
|
||||
|
||||
apiserver_params "github.com/cloudbase/garm/apiserver/params"
|
||||
garm_params "github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
// GetRepoWebhookInfoReader is a Reader for the GetRepoWebhookInfo structure.
|
||||
type GetRepoWebhookInfoReader struct {
|
||||
formats strfmt.Registry
|
||||
}
|
||||
|
||||
// ReadResponse reads a server response into the received o.
|
||||
func (o *GetRepoWebhookInfoReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) {
|
||||
switch response.Code() {
|
||||
case 200:
|
||||
result := NewGetRepoWebhookInfoOK()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
default:
|
||||
result := NewGetRepoWebhookInfoDefault(response.Code())
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if response.Code()/100 == 2 {
|
||||
return result, nil
|
||||
}
|
||||
return nil, result
|
||||
}
|
||||
}
|
||||
|
||||
// NewGetRepoWebhookInfoOK creates a GetRepoWebhookInfoOK with default headers values
|
||||
func NewGetRepoWebhookInfoOK() *GetRepoWebhookInfoOK {
|
||||
return &GetRepoWebhookInfoOK{}
|
||||
}
|
||||
|
||||
/*
|
||||
GetRepoWebhookInfoOK describes a response with status code 200, with default header values.
|
||||
|
||||
HookInfo
|
||||
*/
|
||||
type GetRepoWebhookInfoOK struct {
|
||||
Payload garm_params.HookInfo
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this get repo webhook info o k response has a 2xx status code
|
||||
func (o *GetRepoWebhookInfoOK) IsSuccess() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this get repo webhook info o k response has a 3xx status code
|
||||
func (o *GetRepoWebhookInfoOK) IsRedirect() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsClientError returns true when this get repo webhook info o k response has a 4xx status code
|
||||
func (o *GetRepoWebhookInfoOK) IsClientError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsServerError returns true when this get repo webhook info o k response has a 5xx status code
|
||||
func (o *GetRepoWebhookInfoOK) IsServerError() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// IsCode returns true when this get repo webhook info o k response a status code equal to that given
|
||||
func (o *GetRepoWebhookInfoOK) IsCode(code int) bool {
|
||||
return code == 200
|
||||
}
|
||||
|
||||
// Code gets the status code for the get repo webhook info o k response
|
||||
func (o *GetRepoWebhookInfoOK) Code() int {
|
||||
return 200
|
||||
}
|
||||
|
||||
func (o *GetRepoWebhookInfoOK) Error() string {
|
||||
return fmt.Sprintf("[GET /repositories/{repoID}/webhook][%d] getRepoWebhookInfoOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetRepoWebhookInfoOK) String() string {
|
||||
return fmt.Sprintf("[GET /repositories/{repoID}/webhook][%d] getRepoWebhookInfoOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetRepoWebhookInfoOK) GetPayload() garm_params.HookInfo {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetRepoWebhookInfoOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewGetRepoWebhookInfoDefault creates a GetRepoWebhookInfoDefault with default headers values
|
||||
func NewGetRepoWebhookInfoDefault(code int) *GetRepoWebhookInfoDefault {
|
||||
return &GetRepoWebhookInfoDefault{
|
||||
_statusCode: code,
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
GetRepoWebhookInfoDefault describes a response with status code -1, with default header values.
|
||||
|
||||
APIErrorResponse
|
||||
*/
|
||||
type GetRepoWebhookInfoDefault struct {
|
||||
_statusCode int
|
||||
|
||||
Payload apiserver_params.APIErrorResponse
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this get repo webhook info default response has a 2xx status code
|
||||
func (o *GetRepoWebhookInfoDefault) IsSuccess() bool {
|
||||
return o._statusCode/100 == 2
|
||||
}
|
||||
|
||||
// IsRedirect returns true when this get repo webhook info default response has a 3xx status code
|
||||
func (o *GetRepoWebhookInfoDefault) IsRedirect() bool {
|
||||
return o._statusCode/100 == 3
|
||||
}
|
||||
|
||||
// IsClientError returns true when this get repo webhook info default response has a 4xx status code
|
||||
func (o *GetRepoWebhookInfoDefault) IsClientError() bool {
|
||||
return o._statusCode/100 == 4
|
||||
}
|
||||
|
||||
// IsServerError returns true when this get repo webhook info default response has a 5xx status code
|
||||
func (o *GetRepoWebhookInfoDefault) IsServerError() bool {
|
||||
return o._statusCode/100 == 5
|
||||
}
|
||||
|
||||
// IsCode returns true when this get repo webhook info default response a status code equal to that given
|
||||
func (o *GetRepoWebhookInfoDefault) IsCode(code int) bool {
|
||||
return o._statusCode == code
|
||||
}
|
||||
|
||||
// Code gets the status code for the get repo webhook info default response
|
||||
func (o *GetRepoWebhookInfoDefault) Code() int {
|
||||
return o._statusCode
|
||||
}
|
||||
|
||||
func (o *GetRepoWebhookInfoDefault) Error() string {
|
||||
return fmt.Sprintf("[GET /repositories/{repoID}/webhook][%d] GetRepoWebhookInfo default %+v", o._statusCode, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetRepoWebhookInfoDefault) String() string {
|
||||
return fmt.Sprintf("[GET /repositories/{repoID}/webhook][%d] GetRepoWebhookInfo default %+v", o._statusCode, o.Payload)
|
||||
}
|
||||
|
||||
func (o *GetRepoWebhookInfoDefault) GetPayload() apiserver_params.APIErrorResponse {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *GetRepoWebhookInfoDefault) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/go-openapi/strfmt"
|
||||
|
||||
apiserver_params "github.com/cloudbase/garm/apiserver/params"
|
||||
garm_params "github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
// InstallRepoWebhookReader is a Reader for the InstallRepoWebhook structure.
|
||||
|
|
@ -49,9 +50,10 @@ func NewInstallRepoWebhookOK() *InstallRepoWebhookOK {
|
|||
/*
|
||||
InstallRepoWebhookOK describes a response with status code 200, with default header values.
|
||||
|
||||
InstallRepoWebhookOK install repo webhook o k
|
||||
HookInfo
|
||||
*/
|
||||
type InstallRepoWebhookOK struct {
|
||||
Payload garm_params.HookInfo
|
||||
}
|
||||
|
||||
// IsSuccess returns true when this install repo webhook o k response has a 2xx status code
|
||||
|
|
@ -85,15 +87,24 @@ func (o *InstallRepoWebhookOK) Code() int {
|
|||
}
|
||||
|
||||
func (o *InstallRepoWebhookOK) Error() string {
|
||||
return fmt.Sprintf("[POST /repositories/{repoID}/webhook][%d] installRepoWebhookOK ", 200)
|
||||
return fmt.Sprintf("[POST /repositories/{repoID}/webhook][%d] installRepoWebhookOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *InstallRepoWebhookOK) String() string {
|
||||
return fmt.Sprintf("[POST /repositories/{repoID}/webhook][%d] installRepoWebhookOK ", 200)
|
||||
return fmt.Sprintf("[POST /repositories/{repoID}/webhook][%d] installRepoWebhookOK %+v", 200, o.Payload)
|
||||
}
|
||||
|
||||
func (o *InstallRepoWebhookOK) GetPayload() garm_params.HookInfo {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *InstallRepoWebhookOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
// response payload
|
||||
if err := consumer.Consume(response.Body(), &o.Payload); err != nil && err != io.EOF {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ type ClientService interface {
|
|||
|
||||
GetRepoPool(params *GetRepoPoolParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetRepoPoolOK, error)
|
||||
|
||||
GetRepoWebhookInfo(params *GetRepoWebhookInfoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetRepoWebhookInfoOK, error)
|
||||
|
||||
InstallRepoWebhook(params *InstallRepoWebhookParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*InstallRepoWebhookOK, error)
|
||||
|
||||
ListRepoInstances(params *ListRepoInstancesParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*ListRepoInstancesOK, error)
|
||||
|
|
@ -273,6 +275,44 @@ func (a *Client) GetRepoPool(params *GetRepoPoolParams, authInfo runtime.ClientA
|
|||
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
|
||||
}
|
||||
|
||||
/*
|
||||
GetRepoWebhookInfo gets information about the g a r m installed webhook on a repository
|
||||
*/
|
||||
func (a *Client) GetRepoWebhookInfo(params *GetRepoWebhookInfoParams, authInfo runtime.ClientAuthInfoWriter, opts ...ClientOption) (*GetRepoWebhookInfoOK, error) {
|
||||
// TODO: Validate the params before sending
|
||||
if params == nil {
|
||||
params = NewGetRepoWebhookInfoParams()
|
||||
}
|
||||
op := &runtime.ClientOperation{
|
||||
ID: "GetRepoWebhookInfo",
|
||||
Method: "GET",
|
||||
PathPattern: "/repositories/{repoID}/webhook",
|
||||
ProducesMediaTypes: []string{"application/json"},
|
||||
ConsumesMediaTypes: []string{"application/json"},
|
||||
Schemes: []string{"http"},
|
||||
Params: params,
|
||||
Reader: &GetRepoWebhookInfoReader{formats: a.formats},
|
||||
AuthInfo: authInfo,
|
||||
Context: params.Context,
|
||||
Client: params.HTTPClient,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt(op)
|
||||
}
|
||||
|
||||
result, err := a.transport.Submit(op)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
success, ok := result.(*GetRepoWebhookInfoOK)
|
||||
if ok {
|
||||
return success, nil
|
||||
}
|
||||
// unexpected success response
|
||||
unexpectedSuccess := result.(*GetRepoWebhookInfoDefault)
|
||||
return nil, runtime.NewAPIError("unexpected success response: content available as default response in error", unexpectedSuccess, unexpectedSuccess.Code())
|
||||
}
|
||||
|
||||
/*
|
||||
InstallRepoWebhook Install the GARM webhook for an organization. The secret configured on the organization will
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue