From 62bc75edeb5b0317dbb599cdcfa85b55c7a64905 Mon Sep 17 00:00:00 2001 From: Curtis Myzie Date: Wed, 31 Jul 2019 08:33:30 -0400 Subject: [PATCH] First draft of the Fugue client --- .gitignore | 19 + Makefile | 30 ++ README.md | 91 ++++ .../create_environment_parameters.go | 139 +++++++ .../create_environment_responses.go | 211 ++++++++++ .../delete_environment_parameters.go | 136 ++++++ .../delete_environment_responses.go | 203 +++++++++ client/environments/environments_client.go | 185 +++++++++ .../get_environment_parameters.go | 136 ++++++ .../environments/get_environment_responses.go | 211 ++++++++++ .../list_environments_parameters.go | 280 +++++++++++++ .../list_environments_responses.go | 211 ++++++++++ .../update_environment_parameters.go | 160 +++++++ .../update_environment_responses.go | 247 +++++++++++ client/events/events_client.go | 61 +++ client/events/list_events_parameters.go | 385 +++++++++++++++++ client/events/list_events_responses.go | 211 ++++++++++ client/fugue_client.go | 145 +++++++ client/metadata/create_policy_parameters.go | 160 +++++++ client/metadata/create_policy_responses.go | 211 ++++++++++ .../metadata/get_resource_types_parameters.go | 168 ++++++++ .../metadata/get_resource_types_responses.go | 103 +++++ client/metadata/get_swagger_parameters.go | 113 +++++ client/metadata/get_swagger_responses.go | 101 +++++ client/metadata/get_swagger_ui_parameters.go | 113 +++++ client/metadata/get_swagger_ui_responses.go | 75 ++++ client/metadata/metadata_client.go | 151 +++++++ .../create_notification_parameters.go | 139 +++++++ .../create_notification_responses.go | 211 ++++++++++ .../delete_notification_parameters.go | 136 ++++++ .../delete_notification_responses.go | 203 +++++++++ .../list_notifications_parameters.go | 200 +++++++++ .../list_notifications_responses.go | 211 ++++++++++ client/notifications/notifications_client.go | 154 +++++++ .../update_notification_parameters.go | 160 +++++++ .../update_notification_responses.go | 211 ++++++++++ client/scans/create_scan_parameters.go | 140 +++++++ client/scans/create_scan_responses.go | 211 ++++++++++ ...compliance_by_resource_types_parameters.go | 269 ++++++++++++ ..._compliance_by_resource_types_responses.go | 211 ++++++++++ .../get_compliance_by_rules_parameters.go | 269 ++++++++++++ .../get_compliance_by_rules_responses.go | 211 ++++++++++ client/scans/get_scan_parameters.go | 136 ++++++ client/scans/get_scan_responses.go | 211 ++++++++++ client/scans/list_scans_parameters.go | 393 ++++++++++++++++++ client/scans/list_scans_responses.go | 211 ++++++++++ client/scans/scans_client.go | 185 +++++++++ cmd/client.go | 99 +++++ cmd/create.go | 14 + cmd/createEnvironment.go | 76 ++++ cmd/createPolicy.go | 51 +++ cmd/delete.go | 14 + cmd/deleteEnvironment.go | 32 ++ cmd/get.go | 14 + cmd/getEnvironment.go | 67 +++ cmd/getResourceTypes.go | 57 +++ cmd/getScan.go | 34 ++ cmd/getScanComplianceByResourceTypes.go | 82 ++++ cmd/getScanComplianceByRules.go | 82 ++++ cmd/list.go | 14 + cmd/listEnvironments.go | 86 ++++ cmd/listEvents.go | 103 +++++ cmd/listScans.go | 96 +++++ cmd/root.go | 89 ++++ cmd/triggerScan.go | 36 ++ cmd/update.go | 14 + cmd/updateEnvironment.go | 82 ++++ format/case.go | 15 + format/format.go | 167 ++++++++ format/format_test.go | 74 ++++ go.mod | 18 + go.sum | 118 ++++++ main.go | 7 + models/attribute.go | 61 +++ models/authentication_error.go | 106 +++++ models/authorization_error.go | 106 +++++ models/bad_request_error.go | 130 ++++++ models/compliance_by_resource_type.go | 89 ++++ models/compliance_by_resource_type_output.go | 89 ++++ models/compliance_by_rule.go | 272 ++++++++++++ ...nce_by_rule_failed_resource_types_items.go | 46 ++ ...mpliance_by_rule_failed_resources_items.go | 74 ++++ models/compliance_by_rules.go | 89 ++++ models/compliance_diff.go | 141 +++++++ models/compliance_diff_rules_items.go | 61 +++ models/create_environment_input.go | 164 ++++++++ models/create_notification_input.go | 55 +++ models/create_policy_input.go | 46 ++ models/environment.go | 230 ++++++++++ models/environment_with_summary.go | 124 ++++++ models/environment_with_summary_all_of1.go | 71 ++++ models/environments.go | 89 ++++ models/event.go | 162 ++++++++ models/events.go | 89 ++++ models/internal_server_error.go | 106 +++++ models/non_compliant_resource.go | 120 ++++++ ...n_compliant_resource_failed_rules_items.go | 49 +++ models/not_found_error.go | 103 +++++ models/notification.go | 73 ++++ models/notifications.go | 89 ++++ models/permissions.go | 71 ++++ models/permissions_aws.go | 46 ++ models/provider_options.go | 121 ++++++ models/provider_options_aws.go | 46 ++ models/provider_options_aws_update_input.go | 43 ++ models/provider_options_azure.go | 58 +++ models/provider_options_azure_update_input.go | 52 +++ models/provider_options_update_input.go | 121 ++++++ models/resource.go | 46 ++ models/resource_diff.go | 142 +++++++ models/resource_summary.go | 141 +++++++ models/resource_summary_families_items.go | 55 +++ models/resource_type_metadata.go | 43 ++ models/scan.go | 133 ++++++ models/scan_with_summary.go | 234 +++++++++++ models/scan_with_summary_all_of1.go | 105 +++++ ...mary_all_of1_resource_type_errors_items.go | 81 ++++ models/scans.go | 89 ++++ models/update_environment_input.go | 170 ++++++++ models/update_notification_input.go | 55 +++ 120 files changed, 14555 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README.md create mode 100644 client/environments/create_environment_parameters.go create mode 100644 client/environments/create_environment_responses.go create mode 100644 client/environments/delete_environment_parameters.go create mode 100644 client/environments/delete_environment_responses.go create mode 100644 client/environments/environments_client.go create mode 100644 client/environments/get_environment_parameters.go create mode 100644 client/environments/get_environment_responses.go create mode 100644 client/environments/list_environments_parameters.go create mode 100644 client/environments/list_environments_responses.go create mode 100644 client/environments/update_environment_parameters.go create mode 100644 client/environments/update_environment_responses.go create mode 100644 client/events/events_client.go create mode 100644 client/events/list_events_parameters.go create mode 100644 client/events/list_events_responses.go create mode 100644 client/fugue_client.go create mode 100644 client/metadata/create_policy_parameters.go create mode 100644 client/metadata/create_policy_responses.go create mode 100644 client/metadata/get_resource_types_parameters.go create mode 100644 client/metadata/get_resource_types_responses.go create mode 100644 client/metadata/get_swagger_parameters.go create mode 100644 client/metadata/get_swagger_responses.go create mode 100644 client/metadata/get_swagger_ui_parameters.go create mode 100644 client/metadata/get_swagger_ui_responses.go create mode 100644 client/metadata/metadata_client.go create mode 100644 client/notifications/create_notification_parameters.go create mode 100644 client/notifications/create_notification_responses.go create mode 100644 client/notifications/delete_notification_parameters.go create mode 100644 client/notifications/delete_notification_responses.go create mode 100644 client/notifications/list_notifications_parameters.go create mode 100644 client/notifications/list_notifications_responses.go create mode 100644 client/notifications/notifications_client.go create mode 100644 client/notifications/update_notification_parameters.go create mode 100644 client/notifications/update_notification_responses.go create mode 100644 client/scans/create_scan_parameters.go create mode 100644 client/scans/create_scan_responses.go create mode 100644 client/scans/get_compliance_by_resource_types_parameters.go create mode 100644 client/scans/get_compliance_by_resource_types_responses.go create mode 100644 client/scans/get_compliance_by_rules_parameters.go create mode 100644 client/scans/get_compliance_by_rules_responses.go create mode 100644 client/scans/get_scan_parameters.go create mode 100644 client/scans/get_scan_responses.go create mode 100644 client/scans/list_scans_parameters.go create mode 100644 client/scans/list_scans_responses.go create mode 100644 client/scans/scans_client.go create mode 100644 cmd/client.go create mode 100644 cmd/create.go create mode 100644 cmd/createEnvironment.go create mode 100644 cmd/createPolicy.go create mode 100644 cmd/delete.go create mode 100644 cmd/deleteEnvironment.go create mode 100644 cmd/get.go create mode 100644 cmd/getEnvironment.go create mode 100644 cmd/getResourceTypes.go create mode 100644 cmd/getScan.go create mode 100644 cmd/getScanComplianceByResourceTypes.go create mode 100644 cmd/getScanComplianceByRules.go create mode 100644 cmd/list.go create mode 100644 cmd/listEnvironments.go create mode 100644 cmd/listEvents.go create mode 100644 cmd/listScans.go create mode 100644 cmd/root.go create mode 100644 cmd/triggerScan.go create mode 100644 cmd/update.go create mode 100644 cmd/updateEnvironment.go create mode 100644 format/case.go create mode 100644 format/format.go create mode 100644 format/format_test.go create mode 100644 go.mod create mode 100644 go.sum create mode 100644 main.go create mode 100644 models/attribute.go create mode 100644 models/authentication_error.go create mode 100644 models/authorization_error.go create mode 100644 models/bad_request_error.go create mode 100644 models/compliance_by_resource_type.go create mode 100644 models/compliance_by_resource_type_output.go create mode 100644 models/compliance_by_rule.go create mode 100644 models/compliance_by_rule_failed_resource_types_items.go create mode 100644 models/compliance_by_rule_failed_resources_items.go create mode 100644 models/compliance_by_rules.go create mode 100644 models/compliance_diff.go create mode 100644 models/compliance_diff_rules_items.go create mode 100644 models/create_environment_input.go create mode 100644 models/create_notification_input.go create mode 100644 models/create_policy_input.go create mode 100644 models/environment.go create mode 100644 models/environment_with_summary.go create mode 100644 models/environment_with_summary_all_of1.go create mode 100644 models/environments.go create mode 100644 models/event.go create mode 100644 models/events.go create mode 100644 models/internal_server_error.go create mode 100644 models/non_compliant_resource.go create mode 100644 models/non_compliant_resource_failed_rules_items.go create mode 100644 models/not_found_error.go create mode 100644 models/notification.go create mode 100644 models/notifications.go create mode 100644 models/permissions.go create mode 100644 models/permissions_aws.go create mode 100644 models/provider_options.go create mode 100644 models/provider_options_aws.go create mode 100644 models/provider_options_aws_update_input.go create mode 100644 models/provider_options_azure.go create mode 100644 models/provider_options_azure_update_input.go create mode 100644 models/provider_options_update_input.go create mode 100644 models/resource.go create mode 100644 models/resource_diff.go create mode 100644 models/resource_summary.go create mode 100644 models/resource_summary_families_items.go create mode 100644 models/resource_type_metadata.go create mode 100644 models/scan.go create mode 100644 models/scan_with_summary.go create mode 100644 models/scan_with_summary_all_of1.go create mode 100644 models/scan_with_summary_all_of1_resource_type_errors_items.go create mode 100644 models/scans.go create mode 100644 models/update_environment_input.go create mode 100644 models/update_notification_input.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b50d32c --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +vendor/ + +.vscode +fugue +swagger.yaml diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..11b5d30 --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ + +GO=GO111MODULE=on go +BINARY=fugue +SWAGGER=swagger.yaml +SWAGGER_URL=https://api.riskmanager.fugue.co/v0/swagger +SOURCES=$(shell find . -name '*.go') +GOPATH?=$(shell echo "$$HOME")/go + +$(BINARY): $(SOURCES) + $(GO) build -v -o fugue + +.PHONY: install +install: $(BINARY) + cp $(BINARY) $(GOPATH)/bin/ + +$(SWAGGER): + wget -q -O $(SWAGGER) $(SWAGGER_URL) + +.PHONY: validate +validate: $(SWAGGER) + swagger validate $(SWAGGER) + +.PHONY: gen +gen: $(SWAGGER) + swagger generate client -f $(SWAGGER) + sed -i "" "s/,omitempty//g" $(shell find models -name "*.go") + +.PHONY: clean +clean: + rm -f $(BINARY) diff --git a/README.md b/README.md new file mode 100644 index 0000000..f8436de --- /dev/null +++ b/README.md @@ -0,0 +1,91 @@ +# Fugue API Client + +This is a command line client for the Fugue API. + +For information about enabling a client in your account, see +[the documenation](https://riskmanagerdocs.fugue.co/api.html). More details of the underlying Swagger API are available +[here](https://riskmanagerdocs.fugue.co/Resources/API/swagger.html). + +This project is under active development and is not yet stable. Commands will +change as we incorporate feedback. + +## Environment Variables + +The client uses the following *required* environment variables: + +* `FUGUE_API_ID` - your API client ID +* `FUGUE_API_SECRET` - your API client secret + +## Build + +Build the client executable: + +``` +make build +``` + +Install to $GOPATH/bin: + +``` +make install +``` + +## Usage + +Show usage: + +``` +fugue -h +``` + +Show usage for a subcommand: + +``` +fugue list -h +``` + +List environments: + +``` +fugue list environments +``` + +List environment scans: + +``` +fugue list scans [environment-id] +``` + +List environment events: + +``` +fugue list events [environment-id] +``` + +Trigger a scan: + +``` +fugue scan [environment-id] +``` + +Compliance by resource types: + +``` +fugue get compliance-by-resource-types [scan-id] +``` + +Compliance by rules: + +``` +fugue get compliance-by-rules [scan-id] +``` + +## Aliases + +You may use the shorthand `env` instead of `environment` when running commands. + +For example: + +``` +fugue list envs +``` diff --git a/client/environments/create_environment_parameters.go b/client/environments/create_environment_parameters.go new file mode 100644 index 0000000..24b3eb3 --- /dev/null +++ b/client/environments/create_environment_parameters.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package environments + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// NewCreateEnvironmentParams creates a new CreateEnvironmentParams object +// with the default values initialized. +func NewCreateEnvironmentParams() *CreateEnvironmentParams { + var () + return &CreateEnvironmentParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewCreateEnvironmentParamsWithTimeout creates a new CreateEnvironmentParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewCreateEnvironmentParamsWithTimeout(timeout time.Duration) *CreateEnvironmentParams { + var () + return &CreateEnvironmentParams{ + + timeout: timeout, + } +} + +// NewCreateEnvironmentParamsWithContext creates a new CreateEnvironmentParams object +// with the default values initialized, and the ability to set a context for a request +func NewCreateEnvironmentParamsWithContext(ctx context.Context) *CreateEnvironmentParams { + var () + return &CreateEnvironmentParams{ + + Context: ctx, + } +} + +// NewCreateEnvironmentParamsWithHTTPClient creates a new CreateEnvironmentParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewCreateEnvironmentParamsWithHTTPClient(client *http.Client) *CreateEnvironmentParams { + var () + return &CreateEnvironmentParams{ + HTTPClient: client, + } +} + +/*CreateEnvironmentParams contains all the parameters to send to the API endpoint +for the create environment operation typically these are written to a http.Request +*/ +type CreateEnvironmentParams struct { + + /*Environment + Configuration options for the new environment. + + */ + Environment *models.CreateEnvironmentInput + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the create environment params +func (o *CreateEnvironmentParams) WithTimeout(timeout time.Duration) *CreateEnvironmentParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the create environment params +func (o *CreateEnvironmentParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the create environment params +func (o *CreateEnvironmentParams) WithContext(ctx context.Context) *CreateEnvironmentParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the create environment params +func (o *CreateEnvironmentParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the create environment params +func (o *CreateEnvironmentParams) WithHTTPClient(client *http.Client) *CreateEnvironmentParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the create environment params +func (o *CreateEnvironmentParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithEnvironment adds the environment to the create environment params +func (o *CreateEnvironmentParams) WithEnvironment(environment *models.CreateEnvironmentInput) *CreateEnvironmentParams { + o.SetEnvironment(environment) + return o +} + +// SetEnvironment adds the environment to the create environment params +func (o *CreateEnvironmentParams) SetEnvironment(environment *models.CreateEnvironmentInput) { + o.Environment = environment +} + +// WriteToRequest writes these params to a swagger request +func (o *CreateEnvironmentParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Environment != nil { + if err := r.SetBodyParam(o.Environment); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/environments/create_environment_responses.go b/client/environments/create_environment_responses.go new file mode 100644 index 0000000..18d1f85 --- /dev/null +++ b/client/environments/create_environment_responses.go @@ -0,0 +1,211 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package environments + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// CreateEnvironmentReader is a Reader for the CreateEnvironment structure. +type CreateEnvironmentReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *CreateEnvironmentReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 201: + result := NewCreateEnvironmentCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 401: + result := NewCreateEnvironmentUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 403: + result := NewCreateEnvironmentForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 404: + result := NewCreateEnvironmentNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewCreateEnvironmentInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewCreateEnvironmentCreated creates a CreateEnvironmentCreated with default headers values +func NewCreateEnvironmentCreated() *CreateEnvironmentCreated { + return &CreateEnvironmentCreated{} +} + +/*CreateEnvironmentCreated handles this case with default header values. + +New environment details. +*/ +type CreateEnvironmentCreated struct { + Payload *models.Environment +} + +func (o *CreateEnvironmentCreated) Error() string { + return fmt.Sprintf("[POST /environments][%d] createEnvironmentCreated %+v", 201, o.Payload) +} + +func (o *CreateEnvironmentCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Environment) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateEnvironmentUnauthorized creates a CreateEnvironmentUnauthorized with default headers values +func NewCreateEnvironmentUnauthorized() *CreateEnvironmentUnauthorized { + return &CreateEnvironmentUnauthorized{} +} + +/*CreateEnvironmentUnauthorized handles this case with default header values. + +Authentication error. +*/ +type CreateEnvironmentUnauthorized struct { + Payload *models.AuthenticationError +} + +func (o *CreateEnvironmentUnauthorized) Error() string { + return fmt.Sprintf("[POST /environments][%d] createEnvironmentUnauthorized %+v", 401, o.Payload) +} + +func (o *CreateEnvironmentUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthenticationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateEnvironmentForbidden creates a CreateEnvironmentForbidden with default headers values +func NewCreateEnvironmentForbidden() *CreateEnvironmentForbidden { + return &CreateEnvironmentForbidden{} +} + +/*CreateEnvironmentForbidden handles this case with default header values. + +Authorization error. +*/ +type CreateEnvironmentForbidden struct { + Payload *models.AuthorizationError +} + +func (o *CreateEnvironmentForbidden) Error() string { + return fmt.Sprintf("[POST /environments][%d] createEnvironmentForbidden %+v", 403, o.Payload) +} + +func (o *CreateEnvironmentForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthorizationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateEnvironmentNotFound creates a CreateEnvironmentNotFound with default headers values +func NewCreateEnvironmentNotFound() *CreateEnvironmentNotFound { + return &CreateEnvironmentNotFound{} +} + +/*CreateEnvironmentNotFound handles this case with default header values. + +Not found error. +*/ +type CreateEnvironmentNotFound struct { + Payload *models.NotFoundError +} + +func (o *CreateEnvironmentNotFound) Error() string { + return fmt.Sprintf("[POST /environments][%d] createEnvironmentNotFound %+v", 404, o.Payload) +} + +func (o *CreateEnvironmentNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.NotFoundError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateEnvironmentInternalServerError creates a CreateEnvironmentInternalServerError with default headers values +func NewCreateEnvironmentInternalServerError() *CreateEnvironmentInternalServerError { + return &CreateEnvironmentInternalServerError{} +} + +/*CreateEnvironmentInternalServerError handles this case with default header values. + +Internal server error. +*/ +type CreateEnvironmentInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *CreateEnvironmentInternalServerError) Error() string { + return fmt.Sprintf("[POST /environments][%d] createEnvironmentInternalServerError %+v", 500, o.Payload) +} + +func (o *CreateEnvironmentInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/environments/delete_environment_parameters.go b/client/environments/delete_environment_parameters.go new file mode 100644 index 0000000..ebf8c11 --- /dev/null +++ b/client/environments/delete_environment_parameters.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package environments + +// 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" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewDeleteEnvironmentParams creates a new DeleteEnvironmentParams object +// with the default values initialized. +func NewDeleteEnvironmentParams() *DeleteEnvironmentParams { + var () + return &DeleteEnvironmentParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewDeleteEnvironmentParamsWithTimeout creates a new DeleteEnvironmentParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewDeleteEnvironmentParamsWithTimeout(timeout time.Duration) *DeleteEnvironmentParams { + var () + return &DeleteEnvironmentParams{ + + timeout: timeout, + } +} + +// NewDeleteEnvironmentParamsWithContext creates a new DeleteEnvironmentParams object +// with the default values initialized, and the ability to set a context for a request +func NewDeleteEnvironmentParamsWithContext(ctx context.Context) *DeleteEnvironmentParams { + var () + return &DeleteEnvironmentParams{ + + Context: ctx, + } +} + +// NewDeleteEnvironmentParamsWithHTTPClient creates a new DeleteEnvironmentParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewDeleteEnvironmentParamsWithHTTPClient(client *http.Client) *DeleteEnvironmentParams { + var () + return &DeleteEnvironmentParams{ + HTTPClient: client, + } +} + +/*DeleteEnvironmentParams contains all the parameters to send to the API endpoint +for the delete environment operation typically these are written to a http.Request +*/ +type DeleteEnvironmentParams struct { + + /*EnvironmentID + Environment ID. + + */ + EnvironmentID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the delete environment params +func (o *DeleteEnvironmentParams) WithTimeout(timeout time.Duration) *DeleteEnvironmentParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the delete environment params +func (o *DeleteEnvironmentParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the delete environment params +func (o *DeleteEnvironmentParams) WithContext(ctx context.Context) *DeleteEnvironmentParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the delete environment params +func (o *DeleteEnvironmentParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the delete environment params +func (o *DeleteEnvironmentParams) WithHTTPClient(client *http.Client) *DeleteEnvironmentParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the delete environment params +func (o *DeleteEnvironmentParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithEnvironmentID adds the environmentID to the delete environment params +func (o *DeleteEnvironmentParams) WithEnvironmentID(environmentID string) *DeleteEnvironmentParams { + o.SetEnvironmentID(environmentID) + return o +} + +// SetEnvironmentID adds the environmentId to the delete environment params +func (o *DeleteEnvironmentParams) SetEnvironmentID(environmentID string) { + o.EnvironmentID = environmentID +} + +// WriteToRequest writes these params to a swagger request +func (o *DeleteEnvironmentParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param environment_id + if err := r.SetPathParam("environment_id", o.EnvironmentID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/environments/delete_environment_responses.go b/client/environments/delete_environment_responses.go new file mode 100644 index 0000000..ae42327 --- /dev/null +++ b/client/environments/delete_environment_responses.go @@ -0,0 +1,203 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package environments + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// DeleteEnvironmentReader is a Reader for the DeleteEnvironment structure. +type DeleteEnvironmentReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *DeleteEnvironmentReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 204: + result := NewDeleteEnvironmentNoContent() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 401: + result := NewDeleteEnvironmentUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 403: + result := NewDeleteEnvironmentForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 404: + result := NewDeleteEnvironmentNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewDeleteEnvironmentInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewDeleteEnvironmentNoContent creates a DeleteEnvironmentNoContent with default headers values +func NewDeleteEnvironmentNoContent() *DeleteEnvironmentNoContent { + return &DeleteEnvironmentNoContent{} +} + +/*DeleteEnvironmentNoContent handles this case with default header values. + +Environment deleted. +*/ +type DeleteEnvironmentNoContent struct { +} + +func (o *DeleteEnvironmentNoContent) Error() string { + return fmt.Sprintf("[DELETE /environments/{environment_id}][%d] deleteEnvironmentNoContent ", 204) +} + +func (o *DeleteEnvironmentNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewDeleteEnvironmentUnauthorized creates a DeleteEnvironmentUnauthorized with default headers values +func NewDeleteEnvironmentUnauthorized() *DeleteEnvironmentUnauthorized { + return &DeleteEnvironmentUnauthorized{} +} + +/*DeleteEnvironmentUnauthorized handles this case with default header values. + +Authentication error. +*/ +type DeleteEnvironmentUnauthorized struct { + Payload *models.AuthenticationError +} + +func (o *DeleteEnvironmentUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /environments/{environment_id}][%d] deleteEnvironmentUnauthorized %+v", 401, o.Payload) +} + +func (o *DeleteEnvironmentUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthenticationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewDeleteEnvironmentForbidden creates a DeleteEnvironmentForbidden with default headers values +func NewDeleteEnvironmentForbidden() *DeleteEnvironmentForbidden { + return &DeleteEnvironmentForbidden{} +} + +/*DeleteEnvironmentForbidden handles this case with default header values. + +Authorization error. +*/ +type DeleteEnvironmentForbidden struct { + Payload *models.AuthorizationError +} + +func (o *DeleteEnvironmentForbidden) Error() string { + return fmt.Sprintf("[DELETE /environments/{environment_id}][%d] deleteEnvironmentForbidden %+v", 403, o.Payload) +} + +func (o *DeleteEnvironmentForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthorizationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewDeleteEnvironmentNotFound creates a DeleteEnvironmentNotFound with default headers values +func NewDeleteEnvironmentNotFound() *DeleteEnvironmentNotFound { + return &DeleteEnvironmentNotFound{} +} + +/*DeleteEnvironmentNotFound handles this case with default header values. + +Not found error. +*/ +type DeleteEnvironmentNotFound struct { + Payload *models.NotFoundError +} + +func (o *DeleteEnvironmentNotFound) Error() string { + return fmt.Sprintf("[DELETE /environments/{environment_id}][%d] deleteEnvironmentNotFound %+v", 404, o.Payload) +} + +func (o *DeleteEnvironmentNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.NotFoundError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewDeleteEnvironmentInternalServerError creates a DeleteEnvironmentInternalServerError with default headers values +func NewDeleteEnvironmentInternalServerError() *DeleteEnvironmentInternalServerError { + return &DeleteEnvironmentInternalServerError{} +} + +/*DeleteEnvironmentInternalServerError handles this case with default header values. + +Internal server error. +*/ +type DeleteEnvironmentInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *DeleteEnvironmentInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /environments/{environment_id}][%d] deleteEnvironmentInternalServerError %+v", 500, o.Payload) +} + +func (o *DeleteEnvironmentInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/environments/environments_client.go b/client/environments/environments_client.go new file mode 100644 index 0000000..f62ac9f --- /dev/null +++ b/client/environments/environments_client.go @@ -0,0 +1,185 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package environments + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + + strfmt "github.com/go-openapi/strfmt" +) + +// New creates a new environments API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { + return &Client{transport: transport, formats: formats} +} + +/* +Client for environments API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +/* +CreateEnvironment creates a new environment + +Creates a new environment. +*/ +func (a *Client) CreateEnvironment(params *CreateEnvironmentParams, authInfo runtime.ClientAuthInfoWriter) (*CreateEnvironmentCreated, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewCreateEnvironmentParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "createEnvironment", + Method: "POST", + PathPattern: "/environments", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &CreateEnvironmentReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*CreateEnvironmentCreated), nil + +} + +/* +DeleteEnvironment deletes an environment + +Deletes an environment. +*/ +func (a *Client) DeleteEnvironment(params *DeleteEnvironmentParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteEnvironmentNoContent, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewDeleteEnvironmentParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "deleteEnvironment", + Method: "DELETE", + PathPattern: "/environments/{environment_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &DeleteEnvironmentReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*DeleteEnvironmentNoContent), nil + +} + +/* +GetEnvironment retrieves details and resource summary for an environment + +Retrieves details and resource summary for an environment. +*/ +func (a *Client) GetEnvironment(params *GetEnvironmentParams, authInfo runtime.ClientAuthInfoWriter) (*GetEnvironmentOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetEnvironmentParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getEnvironment", + Method: "GET", + PathPattern: "/environments/{environment_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &GetEnvironmentReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*GetEnvironmentOK), nil + +} + +/* +ListEnvironments lists details for all environments + +Lists details for all environments. +*/ +func (a *Client) ListEnvironments(params *ListEnvironmentsParams, authInfo runtime.ClientAuthInfoWriter) (*ListEnvironmentsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListEnvironmentsParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "listEnvironments", + Method: "GET", + PathPattern: "/environments", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &ListEnvironmentsReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*ListEnvironmentsOK), nil + +} + +/* +UpdateEnvironment updates an environment + +Updates an environment. +*/ +func (a *Client) UpdateEnvironment(params *UpdateEnvironmentParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateEnvironmentOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewUpdateEnvironmentParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "updateEnvironment", + Method: "PATCH", + PathPattern: "/environments/{environment_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &UpdateEnvironmentReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*UpdateEnvironmentOK), nil + +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/client/environments/get_environment_parameters.go b/client/environments/get_environment_parameters.go new file mode 100644 index 0000000..479ddec --- /dev/null +++ b/client/environments/get_environment_parameters.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package environments + +// 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" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewGetEnvironmentParams creates a new GetEnvironmentParams object +// with the default values initialized. +func NewGetEnvironmentParams() *GetEnvironmentParams { + var () + return &GetEnvironmentParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewGetEnvironmentParamsWithTimeout creates a new GetEnvironmentParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetEnvironmentParamsWithTimeout(timeout time.Duration) *GetEnvironmentParams { + var () + return &GetEnvironmentParams{ + + timeout: timeout, + } +} + +// NewGetEnvironmentParamsWithContext creates a new GetEnvironmentParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetEnvironmentParamsWithContext(ctx context.Context) *GetEnvironmentParams { + var () + return &GetEnvironmentParams{ + + Context: ctx, + } +} + +// NewGetEnvironmentParamsWithHTTPClient creates a new GetEnvironmentParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetEnvironmentParamsWithHTTPClient(client *http.Client) *GetEnvironmentParams { + var () + return &GetEnvironmentParams{ + HTTPClient: client, + } +} + +/*GetEnvironmentParams contains all the parameters to send to the API endpoint +for the get environment operation typically these are written to a http.Request +*/ +type GetEnvironmentParams struct { + + /*EnvironmentID + Environment ID. + + */ + EnvironmentID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get environment params +func (o *GetEnvironmentParams) WithTimeout(timeout time.Duration) *GetEnvironmentParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get environment params +func (o *GetEnvironmentParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get environment params +func (o *GetEnvironmentParams) WithContext(ctx context.Context) *GetEnvironmentParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get environment params +func (o *GetEnvironmentParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get environment params +func (o *GetEnvironmentParams) WithHTTPClient(client *http.Client) *GetEnvironmentParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get environment params +func (o *GetEnvironmentParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithEnvironmentID adds the environmentID to the get environment params +func (o *GetEnvironmentParams) WithEnvironmentID(environmentID string) *GetEnvironmentParams { + o.SetEnvironmentID(environmentID) + return o +} + +// SetEnvironmentID adds the environmentId to the get environment params +func (o *GetEnvironmentParams) SetEnvironmentID(environmentID string) { + o.EnvironmentID = environmentID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetEnvironmentParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param environment_id + if err := r.SetPathParam("environment_id", o.EnvironmentID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/environments/get_environment_responses.go b/client/environments/get_environment_responses.go new file mode 100644 index 0000000..70f828a --- /dev/null +++ b/client/environments/get_environment_responses.go @@ -0,0 +1,211 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package environments + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// GetEnvironmentReader is a Reader for the GetEnvironment structure. +type GetEnvironmentReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetEnvironmentReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewGetEnvironmentOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 401: + result := NewGetEnvironmentUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 403: + result := NewGetEnvironmentForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 404: + result := NewGetEnvironmentNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewGetEnvironmentInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewGetEnvironmentOK creates a GetEnvironmentOK with default headers values +func NewGetEnvironmentOK() *GetEnvironmentOK { + return &GetEnvironmentOK{} +} + +/*GetEnvironmentOK handles this case with default header values. + +Environment details. +*/ +type GetEnvironmentOK struct { + Payload *models.EnvironmentWithSummary +} + +func (o *GetEnvironmentOK) Error() string { + return fmt.Sprintf("[GET /environments/{environment_id}][%d] getEnvironmentOK %+v", 200, o.Payload) +} + +func (o *GetEnvironmentOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.EnvironmentWithSummary) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetEnvironmentUnauthorized creates a GetEnvironmentUnauthorized with default headers values +func NewGetEnvironmentUnauthorized() *GetEnvironmentUnauthorized { + return &GetEnvironmentUnauthorized{} +} + +/*GetEnvironmentUnauthorized handles this case with default header values. + +Authentication error. +*/ +type GetEnvironmentUnauthorized struct { + Payload *models.AuthenticationError +} + +func (o *GetEnvironmentUnauthorized) Error() string { + return fmt.Sprintf("[GET /environments/{environment_id}][%d] getEnvironmentUnauthorized %+v", 401, o.Payload) +} + +func (o *GetEnvironmentUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthenticationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetEnvironmentForbidden creates a GetEnvironmentForbidden with default headers values +func NewGetEnvironmentForbidden() *GetEnvironmentForbidden { + return &GetEnvironmentForbidden{} +} + +/*GetEnvironmentForbidden handles this case with default header values. + +Authorization error. +*/ +type GetEnvironmentForbidden struct { + Payload *models.AuthorizationError +} + +func (o *GetEnvironmentForbidden) Error() string { + return fmt.Sprintf("[GET /environments/{environment_id}][%d] getEnvironmentForbidden %+v", 403, o.Payload) +} + +func (o *GetEnvironmentForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthorizationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetEnvironmentNotFound creates a GetEnvironmentNotFound with default headers values +func NewGetEnvironmentNotFound() *GetEnvironmentNotFound { + return &GetEnvironmentNotFound{} +} + +/*GetEnvironmentNotFound handles this case with default header values. + +Not found error. +*/ +type GetEnvironmentNotFound struct { + Payload *models.NotFoundError +} + +func (o *GetEnvironmentNotFound) Error() string { + return fmt.Sprintf("[GET /environments/{environment_id}][%d] getEnvironmentNotFound %+v", 404, o.Payload) +} + +func (o *GetEnvironmentNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.NotFoundError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetEnvironmentInternalServerError creates a GetEnvironmentInternalServerError with default headers values +func NewGetEnvironmentInternalServerError() *GetEnvironmentInternalServerError { + return &GetEnvironmentInternalServerError{} +} + +/*GetEnvironmentInternalServerError handles this case with default header values. + +Internal server error. +*/ +type GetEnvironmentInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *GetEnvironmentInternalServerError) Error() string { + return fmt.Sprintf("[GET /environments/{environment_id}][%d] getEnvironmentInternalServerError %+v", 500, o.Payload) +} + +func (o *GetEnvironmentInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/environments/list_environments_parameters.go b/client/environments/list_environments_parameters.go new file mode 100644 index 0000000..94cb857 --- /dev/null +++ b/client/environments/list_environments_parameters.go @@ -0,0 +1,280 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package environments + +// 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/swag" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewListEnvironmentsParams creates a new ListEnvironmentsParams object +// with the default values initialized. +func NewListEnvironmentsParams() *ListEnvironmentsParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + orderByDefault = string("created_at") + orderDirectionDefault = string("desc") + ) + return &ListEnvironmentsParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + OrderBy: &orderByDefault, + OrderDirection: &orderDirectionDefault, + + timeout: cr.DefaultTimeout, + } +} + +// NewListEnvironmentsParamsWithTimeout creates a new ListEnvironmentsParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewListEnvironmentsParamsWithTimeout(timeout time.Duration) *ListEnvironmentsParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + orderByDefault = string("created_at") + orderDirectionDefault = string("desc") + ) + return &ListEnvironmentsParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + OrderBy: &orderByDefault, + OrderDirection: &orderDirectionDefault, + + timeout: timeout, + } +} + +// NewListEnvironmentsParamsWithContext creates a new ListEnvironmentsParams object +// with the default values initialized, and the ability to set a context for a request +func NewListEnvironmentsParamsWithContext(ctx context.Context) *ListEnvironmentsParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + orderByDefault = string("created_at") + orderDirectionDefault = string("desc") + ) + return &ListEnvironmentsParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + OrderBy: &orderByDefault, + OrderDirection: &orderDirectionDefault, + + Context: ctx, + } +} + +// NewListEnvironmentsParamsWithHTTPClient creates a new ListEnvironmentsParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewListEnvironmentsParamsWithHTTPClient(client *http.Client) *ListEnvironmentsParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + orderByDefault = string("created_at") + orderDirectionDefault = string("desc") + ) + return &ListEnvironmentsParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + OrderBy: &orderByDefault, + OrderDirection: &orderDirectionDefault, + HTTPClient: client, + } +} + +/*ListEnvironmentsParams contains all the parameters to send to the API endpoint +for the list environments operation typically these are written to a http.Request +*/ +type ListEnvironmentsParams struct { + + /*MaxItems + Maximum number of items to return. + + */ + MaxItems *int64 + /*Offset + Number of items to skip before returning. This parameter is used when the number of items spans multiple pages. + + */ + Offset *int64 + /*OrderBy + Field to sort the items by. + + */ + OrderBy *string + /*OrderDirection + Direction to sort the items in. + + */ + OrderDirection *string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the list environments params +func (o *ListEnvironmentsParams) WithTimeout(timeout time.Duration) *ListEnvironmentsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list environments params +func (o *ListEnvironmentsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list environments params +func (o *ListEnvironmentsParams) WithContext(ctx context.Context) *ListEnvironmentsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list environments params +func (o *ListEnvironmentsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list environments params +func (o *ListEnvironmentsParams) WithHTTPClient(client *http.Client) *ListEnvironmentsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list environments params +func (o *ListEnvironmentsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithMaxItems adds the maxItems to the list environments params +func (o *ListEnvironmentsParams) WithMaxItems(maxItems *int64) *ListEnvironmentsParams { + o.SetMaxItems(maxItems) + return o +} + +// SetMaxItems adds the maxItems to the list environments params +func (o *ListEnvironmentsParams) SetMaxItems(maxItems *int64) { + o.MaxItems = maxItems +} + +// WithOffset adds the offset to the list environments params +func (o *ListEnvironmentsParams) WithOffset(offset *int64) *ListEnvironmentsParams { + o.SetOffset(offset) + return o +} + +// SetOffset adds the offset to the list environments params +func (o *ListEnvironmentsParams) SetOffset(offset *int64) { + o.Offset = offset +} + +// WithOrderBy adds the orderBy to the list environments params +func (o *ListEnvironmentsParams) WithOrderBy(orderBy *string) *ListEnvironmentsParams { + o.SetOrderBy(orderBy) + return o +} + +// SetOrderBy adds the orderBy to the list environments params +func (o *ListEnvironmentsParams) SetOrderBy(orderBy *string) { + o.OrderBy = orderBy +} + +// WithOrderDirection adds the orderDirection to the list environments params +func (o *ListEnvironmentsParams) WithOrderDirection(orderDirection *string) *ListEnvironmentsParams { + o.SetOrderDirection(orderDirection) + return o +} + +// SetOrderDirection adds the orderDirection to the list environments params +func (o *ListEnvironmentsParams) SetOrderDirection(orderDirection *string) { + o.OrderDirection = orderDirection +} + +// WriteToRequest writes these params to a swagger request +func (o *ListEnvironmentsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.MaxItems != nil { + + // query param max_items + var qrMaxItems int64 + if o.MaxItems != nil { + qrMaxItems = *o.MaxItems + } + qMaxItems := swag.FormatInt64(qrMaxItems) + if qMaxItems != "" { + if err := r.SetQueryParam("max_items", qMaxItems); err != nil { + return err + } + } + + } + + if o.Offset != nil { + + // query param offset + var qrOffset int64 + if o.Offset != nil { + qrOffset = *o.Offset + } + qOffset := swag.FormatInt64(qrOffset) + if qOffset != "" { + if err := r.SetQueryParam("offset", qOffset); err != nil { + return err + } + } + + } + + if o.OrderBy != nil { + + // query param order_by + var qrOrderBy string + if o.OrderBy != nil { + qrOrderBy = *o.OrderBy + } + qOrderBy := qrOrderBy + if qOrderBy != "" { + if err := r.SetQueryParam("order_by", qOrderBy); err != nil { + return err + } + } + + } + + if o.OrderDirection != nil { + + // query param order_direction + var qrOrderDirection string + if o.OrderDirection != nil { + qrOrderDirection = *o.OrderDirection + } + qOrderDirection := qrOrderDirection + if qOrderDirection != "" { + if err := r.SetQueryParam("order_direction", qOrderDirection); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/environments/list_environments_responses.go b/client/environments/list_environments_responses.go new file mode 100644 index 0000000..db9a074 --- /dev/null +++ b/client/environments/list_environments_responses.go @@ -0,0 +1,211 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package environments + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// ListEnvironmentsReader is a Reader for the ListEnvironments structure. +type ListEnvironmentsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListEnvironmentsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewListEnvironmentsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 400: + result := NewListEnvironmentsBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 401: + result := NewListEnvironmentsUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 403: + result := NewListEnvironmentsForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewListEnvironmentsInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewListEnvironmentsOK creates a ListEnvironmentsOK with default headers values +func NewListEnvironmentsOK() *ListEnvironmentsOK { + return &ListEnvironmentsOK{} +} + +/*ListEnvironmentsOK handles this case with default header values. + +List of environments and details. +*/ +type ListEnvironmentsOK struct { + Payload *models.Environments +} + +func (o *ListEnvironmentsOK) Error() string { + return fmt.Sprintf("[GET /environments][%d] listEnvironmentsOK %+v", 200, o.Payload) +} + +func (o *ListEnvironmentsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Environments) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListEnvironmentsBadRequest creates a ListEnvironmentsBadRequest with default headers values +func NewListEnvironmentsBadRequest() *ListEnvironmentsBadRequest { + return &ListEnvironmentsBadRequest{} +} + +/*ListEnvironmentsBadRequest handles this case with default header values. + +Bad request error. +*/ +type ListEnvironmentsBadRequest struct { + Payload *models.BadRequestError +} + +func (o *ListEnvironmentsBadRequest) Error() string { + return fmt.Sprintf("[GET /environments][%d] listEnvironmentsBadRequest %+v", 400, o.Payload) +} + +func (o *ListEnvironmentsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.BadRequestError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListEnvironmentsUnauthorized creates a ListEnvironmentsUnauthorized with default headers values +func NewListEnvironmentsUnauthorized() *ListEnvironmentsUnauthorized { + return &ListEnvironmentsUnauthorized{} +} + +/*ListEnvironmentsUnauthorized handles this case with default header values. + +Authentication error. +*/ +type ListEnvironmentsUnauthorized struct { + Payload *models.AuthenticationError +} + +func (o *ListEnvironmentsUnauthorized) Error() string { + return fmt.Sprintf("[GET /environments][%d] listEnvironmentsUnauthorized %+v", 401, o.Payload) +} + +func (o *ListEnvironmentsUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthenticationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListEnvironmentsForbidden creates a ListEnvironmentsForbidden with default headers values +func NewListEnvironmentsForbidden() *ListEnvironmentsForbidden { + return &ListEnvironmentsForbidden{} +} + +/*ListEnvironmentsForbidden handles this case with default header values. + +Authorization error. +*/ +type ListEnvironmentsForbidden struct { + Payload *models.AuthorizationError +} + +func (o *ListEnvironmentsForbidden) Error() string { + return fmt.Sprintf("[GET /environments][%d] listEnvironmentsForbidden %+v", 403, o.Payload) +} + +func (o *ListEnvironmentsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthorizationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListEnvironmentsInternalServerError creates a ListEnvironmentsInternalServerError with default headers values +func NewListEnvironmentsInternalServerError() *ListEnvironmentsInternalServerError { + return &ListEnvironmentsInternalServerError{} +} + +/*ListEnvironmentsInternalServerError handles this case with default header values. + +Internal server error. +*/ +type ListEnvironmentsInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *ListEnvironmentsInternalServerError) Error() string { + return fmt.Sprintf("[GET /environments][%d] listEnvironmentsInternalServerError %+v", 500, o.Payload) +} + +func (o *ListEnvironmentsInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/environments/update_environment_parameters.go b/client/environments/update_environment_parameters.go new file mode 100644 index 0000000..5a81a09 --- /dev/null +++ b/client/environments/update_environment_parameters.go @@ -0,0 +1,160 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package environments + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// NewUpdateEnvironmentParams creates a new UpdateEnvironmentParams object +// with the default values initialized. +func NewUpdateEnvironmentParams() *UpdateEnvironmentParams { + var () + return &UpdateEnvironmentParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewUpdateEnvironmentParamsWithTimeout creates a new UpdateEnvironmentParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewUpdateEnvironmentParamsWithTimeout(timeout time.Duration) *UpdateEnvironmentParams { + var () + return &UpdateEnvironmentParams{ + + timeout: timeout, + } +} + +// NewUpdateEnvironmentParamsWithContext creates a new UpdateEnvironmentParams object +// with the default values initialized, and the ability to set a context for a request +func NewUpdateEnvironmentParamsWithContext(ctx context.Context) *UpdateEnvironmentParams { + var () + return &UpdateEnvironmentParams{ + + Context: ctx, + } +} + +// NewUpdateEnvironmentParamsWithHTTPClient creates a new UpdateEnvironmentParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewUpdateEnvironmentParamsWithHTTPClient(client *http.Client) *UpdateEnvironmentParams { + var () + return &UpdateEnvironmentParams{ + HTTPClient: client, + } +} + +/*UpdateEnvironmentParams contains all the parameters to send to the API endpoint +for the update environment operation typically these are written to a http.Request +*/ +type UpdateEnvironmentParams struct { + + /*Environment + Environment details to update. + + */ + Environment *models.UpdateEnvironmentInput + /*EnvironmentID + Environment ID. + + */ + EnvironmentID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the update environment params +func (o *UpdateEnvironmentParams) WithTimeout(timeout time.Duration) *UpdateEnvironmentParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the update environment params +func (o *UpdateEnvironmentParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the update environment params +func (o *UpdateEnvironmentParams) WithContext(ctx context.Context) *UpdateEnvironmentParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the update environment params +func (o *UpdateEnvironmentParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the update environment params +func (o *UpdateEnvironmentParams) WithHTTPClient(client *http.Client) *UpdateEnvironmentParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the update environment params +func (o *UpdateEnvironmentParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithEnvironment adds the environment to the update environment params +func (o *UpdateEnvironmentParams) WithEnvironment(environment *models.UpdateEnvironmentInput) *UpdateEnvironmentParams { + o.SetEnvironment(environment) + return o +} + +// SetEnvironment adds the environment to the update environment params +func (o *UpdateEnvironmentParams) SetEnvironment(environment *models.UpdateEnvironmentInput) { + o.Environment = environment +} + +// WithEnvironmentID adds the environmentID to the update environment params +func (o *UpdateEnvironmentParams) WithEnvironmentID(environmentID string) *UpdateEnvironmentParams { + o.SetEnvironmentID(environmentID) + return o +} + +// SetEnvironmentID adds the environmentId to the update environment params +func (o *UpdateEnvironmentParams) SetEnvironmentID(environmentID string) { + o.EnvironmentID = environmentID +} + +// WriteToRequest writes these params to a swagger request +func (o *UpdateEnvironmentParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Environment != nil { + if err := r.SetBodyParam(o.Environment); err != nil { + return err + } + } + + // path param environment_id + if err := r.SetPathParam("environment_id", o.EnvironmentID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/environments/update_environment_responses.go b/client/environments/update_environment_responses.go new file mode 100644 index 0000000..3cdaf9b --- /dev/null +++ b/client/environments/update_environment_responses.go @@ -0,0 +1,247 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package environments + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// UpdateEnvironmentReader is a Reader for the UpdateEnvironment structure. +type UpdateEnvironmentReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *UpdateEnvironmentReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewUpdateEnvironmentOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 400: + result := NewUpdateEnvironmentBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 401: + result := NewUpdateEnvironmentUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 403: + result := NewUpdateEnvironmentForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 404: + result := NewUpdateEnvironmentNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewUpdateEnvironmentInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewUpdateEnvironmentOK creates a UpdateEnvironmentOK with default headers values +func NewUpdateEnvironmentOK() *UpdateEnvironmentOK { + return &UpdateEnvironmentOK{} +} + +/*UpdateEnvironmentOK handles this case with default header values. + +Updated environment details. +*/ +type UpdateEnvironmentOK struct { + Payload *models.Environment +} + +func (o *UpdateEnvironmentOK) Error() string { + return fmt.Sprintf("[PATCH /environments/{environment_id}][%d] updateEnvironmentOK %+v", 200, o.Payload) +} + +func (o *UpdateEnvironmentOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Environment) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUpdateEnvironmentBadRequest creates a UpdateEnvironmentBadRequest with default headers values +func NewUpdateEnvironmentBadRequest() *UpdateEnvironmentBadRequest { + return &UpdateEnvironmentBadRequest{} +} + +/*UpdateEnvironmentBadRequest handles this case with default header values. + +Bad request error. +*/ +type UpdateEnvironmentBadRequest struct { + Payload *models.BadRequestError +} + +func (o *UpdateEnvironmentBadRequest) Error() string { + return fmt.Sprintf("[PATCH /environments/{environment_id}][%d] updateEnvironmentBadRequest %+v", 400, o.Payload) +} + +func (o *UpdateEnvironmentBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.BadRequestError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUpdateEnvironmentUnauthorized creates a UpdateEnvironmentUnauthorized with default headers values +func NewUpdateEnvironmentUnauthorized() *UpdateEnvironmentUnauthorized { + return &UpdateEnvironmentUnauthorized{} +} + +/*UpdateEnvironmentUnauthorized handles this case with default header values. + +Authentication error. +*/ +type UpdateEnvironmentUnauthorized struct { + Payload *models.AuthenticationError +} + +func (o *UpdateEnvironmentUnauthorized) Error() string { + return fmt.Sprintf("[PATCH /environments/{environment_id}][%d] updateEnvironmentUnauthorized %+v", 401, o.Payload) +} + +func (o *UpdateEnvironmentUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthenticationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUpdateEnvironmentForbidden creates a UpdateEnvironmentForbidden with default headers values +func NewUpdateEnvironmentForbidden() *UpdateEnvironmentForbidden { + return &UpdateEnvironmentForbidden{} +} + +/*UpdateEnvironmentForbidden handles this case with default header values. + +Authorization error. +*/ +type UpdateEnvironmentForbidden struct { + Payload *models.AuthorizationError +} + +func (o *UpdateEnvironmentForbidden) Error() string { + return fmt.Sprintf("[PATCH /environments/{environment_id}][%d] updateEnvironmentForbidden %+v", 403, o.Payload) +} + +func (o *UpdateEnvironmentForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthorizationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUpdateEnvironmentNotFound creates a UpdateEnvironmentNotFound with default headers values +func NewUpdateEnvironmentNotFound() *UpdateEnvironmentNotFound { + return &UpdateEnvironmentNotFound{} +} + +/*UpdateEnvironmentNotFound handles this case with default header values. + +Not found error. +*/ +type UpdateEnvironmentNotFound struct { + Payload *models.NotFoundError +} + +func (o *UpdateEnvironmentNotFound) Error() string { + return fmt.Sprintf("[PATCH /environments/{environment_id}][%d] updateEnvironmentNotFound %+v", 404, o.Payload) +} + +func (o *UpdateEnvironmentNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.NotFoundError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUpdateEnvironmentInternalServerError creates a UpdateEnvironmentInternalServerError with default headers values +func NewUpdateEnvironmentInternalServerError() *UpdateEnvironmentInternalServerError { + return &UpdateEnvironmentInternalServerError{} +} + +/*UpdateEnvironmentInternalServerError handles this case with default header values. + +Internal server error. +*/ +type UpdateEnvironmentInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *UpdateEnvironmentInternalServerError) Error() string { + return fmt.Sprintf("[PATCH /environments/{environment_id}][%d] updateEnvironmentInternalServerError %+v", 500, o.Payload) +} + +func (o *UpdateEnvironmentInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/events/events_client.go b/client/events/events_client.go new file mode 100644 index 0000000..08e12f2 --- /dev/null +++ b/client/events/events_client.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package events + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + + strfmt "github.com/go-openapi/strfmt" +) + +// New creates a new events API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { + return &Client{transport: transport, formats: formats} +} + +/* +Client for events API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +/* +ListEvents lists drift remediation and compliance events for an environment + +Lists drift, remediation, and compliance events for an environment. +*/ +func (a *Client) ListEvents(params *ListEventsParams, authInfo runtime.ClientAuthInfoWriter) (*ListEventsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListEventsParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "listEvents", + Method: "GET", + PathPattern: "/events", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &ListEventsReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*ListEventsOK), nil + +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/client/events/list_events_parameters.go b/client/events/list_events_parameters.go new file mode 100644 index 0000000..cbeddab --- /dev/null +++ b/client/events/list_events_parameters.go @@ -0,0 +1,385 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package events + +// 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/swag" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewListEventsParams creates a new ListEventsParams object +// with the default values initialized. +func NewListEventsParams() *ListEventsParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + ) + return &ListEventsParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + + timeout: cr.DefaultTimeout, + } +} + +// NewListEventsParamsWithTimeout creates a new ListEventsParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewListEventsParamsWithTimeout(timeout time.Duration) *ListEventsParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + ) + return &ListEventsParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + + timeout: timeout, + } +} + +// NewListEventsParamsWithContext creates a new ListEventsParams object +// with the default values initialized, and the ability to set a context for a request +func NewListEventsParamsWithContext(ctx context.Context) *ListEventsParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + ) + return &ListEventsParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + + Context: ctx, + } +} + +// NewListEventsParamsWithHTTPClient creates a new ListEventsParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewListEventsParamsWithHTTPClient(client *http.Client) *ListEventsParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + ) + return &ListEventsParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + HTTPClient: client, + } +} + +/*ListEventsParams contains all the parameters to send to the API endpoint +for the list events operation typically these are written to a http.Request +*/ +type ListEventsParams struct { + + /*Change + Type of change made in the event to filter by. When not specified, all change types will be returned. + + */ + Change []string + /*EnvironmentID + Environment ID. + + */ + EnvironmentID string + /*EventType + Event type to filter by. When not specified, all event types will be returned. + + */ + EventType []string + /*MaxItems + Maximum number of items to return. + + */ + MaxItems *int64 + /*Offset + Number of items to skip before returning. This parameter is used when the number of items spans multiple pages. + + */ + Offset *int64 + /*RangeFrom + Earliest created_at time to return events from. + + */ + RangeFrom *int64 + /*RangeTo + Latest created_at time to return events from. + + */ + RangeTo *int64 + /*Remediated + Filter remediation results for an event by success or failure. When not specified, all remediation results will be returned. + + */ + Remediated []string + /*ResourceType + Resource types in the event to filter by. When not specified, all resource types will be returned. + + */ + ResourceType []string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the list events params +func (o *ListEventsParams) WithTimeout(timeout time.Duration) *ListEventsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list events params +func (o *ListEventsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list events params +func (o *ListEventsParams) WithContext(ctx context.Context) *ListEventsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list events params +func (o *ListEventsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list events params +func (o *ListEventsParams) WithHTTPClient(client *http.Client) *ListEventsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list events params +func (o *ListEventsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithChange adds the change to the list events params +func (o *ListEventsParams) WithChange(change []string) *ListEventsParams { + o.SetChange(change) + return o +} + +// SetChange adds the change to the list events params +func (o *ListEventsParams) SetChange(change []string) { + o.Change = change +} + +// WithEnvironmentID adds the environmentID to the list events params +func (o *ListEventsParams) WithEnvironmentID(environmentID string) *ListEventsParams { + o.SetEnvironmentID(environmentID) + return o +} + +// SetEnvironmentID adds the environmentId to the list events params +func (o *ListEventsParams) SetEnvironmentID(environmentID string) { + o.EnvironmentID = environmentID +} + +// WithEventType adds the eventType to the list events params +func (o *ListEventsParams) WithEventType(eventType []string) *ListEventsParams { + o.SetEventType(eventType) + return o +} + +// SetEventType adds the eventType to the list events params +func (o *ListEventsParams) SetEventType(eventType []string) { + o.EventType = eventType +} + +// WithMaxItems adds the maxItems to the list events params +func (o *ListEventsParams) WithMaxItems(maxItems *int64) *ListEventsParams { + o.SetMaxItems(maxItems) + return o +} + +// SetMaxItems adds the maxItems to the list events params +func (o *ListEventsParams) SetMaxItems(maxItems *int64) { + o.MaxItems = maxItems +} + +// WithOffset adds the offset to the list events params +func (o *ListEventsParams) WithOffset(offset *int64) *ListEventsParams { + o.SetOffset(offset) + return o +} + +// SetOffset adds the offset to the list events params +func (o *ListEventsParams) SetOffset(offset *int64) { + o.Offset = offset +} + +// WithRangeFrom adds the rangeFrom to the list events params +func (o *ListEventsParams) WithRangeFrom(rangeFrom *int64) *ListEventsParams { + o.SetRangeFrom(rangeFrom) + return o +} + +// SetRangeFrom adds the rangeFrom to the list events params +func (o *ListEventsParams) SetRangeFrom(rangeFrom *int64) { + o.RangeFrom = rangeFrom +} + +// WithRangeTo adds the rangeTo to the list events params +func (o *ListEventsParams) WithRangeTo(rangeTo *int64) *ListEventsParams { + o.SetRangeTo(rangeTo) + return o +} + +// SetRangeTo adds the rangeTo to the list events params +func (o *ListEventsParams) SetRangeTo(rangeTo *int64) { + o.RangeTo = rangeTo +} + +// WithRemediated adds the remediated to the list events params +func (o *ListEventsParams) WithRemediated(remediated []string) *ListEventsParams { + o.SetRemediated(remediated) + return o +} + +// SetRemediated adds the remediated to the list events params +func (o *ListEventsParams) SetRemediated(remediated []string) { + o.Remediated = remediated +} + +// WithResourceType adds the resourceType to the list events params +func (o *ListEventsParams) WithResourceType(resourceType []string) *ListEventsParams { + o.SetResourceType(resourceType) + return o +} + +// SetResourceType adds the resourceType to the list events params +func (o *ListEventsParams) SetResourceType(resourceType []string) { + o.ResourceType = resourceType +} + +// WriteToRequest writes these params to a swagger request +func (o *ListEventsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + valuesChange := o.Change + + joinedChange := swag.JoinByFormat(valuesChange, "multi") + // query array param change + if err := r.SetQueryParam("change", joinedChange...); err != nil { + return err + } + + // query param environment_id + qrEnvironmentID := o.EnvironmentID + qEnvironmentID := qrEnvironmentID + if qEnvironmentID != "" { + if err := r.SetQueryParam("environment_id", qEnvironmentID); err != nil { + return err + } + } + + valuesEventType := o.EventType + + joinedEventType := swag.JoinByFormat(valuesEventType, "multi") + // query array param event_type + if err := r.SetQueryParam("event_type", joinedEventType...); err != nil { + return err + } + + if o.MaxItems != nil { + + // query param max_items + var qrMaxItems int64 + if o.MaxItems != nil { + qrMaxItems = *o.MaxItems + } + qMaxItems := swag.FormatInt64(qrMaxItems) + if qMaxItems != "" { + if err := r.SetQueryParam("max_items", qMaxItems); err != nil { + return err + } + } + + } + + if o.Offset != nil { + + // query param offset + var qrOffset int64 + if o.Offset != nil { + qrOffset = *o.Offset + } + qOffset := swag.FormatInt64(qrOffset) + if qOffset != "" { + if err := r.SetQueryParam("offset", qOffset); err != nil { + return err + } + } + + } + + if o.RangeFrom != nil { + + // query param range_from + var qrRangeFrom int64 + if o.RangeFrom != nil { + qrRangeFrom = *o.RangeFrom + } + qRangeFrom := swag.FormatInt64(qrRangeFrom) + if qRangeFrom != "" { + if err := r.SetQueryParam("range_from", qRangeFrom); err != nil { + return err + } + } + + } + + if o.RangeTo != nil { + + // query param range_to + var qrRangeTo int64 + if o.RangeTo != nil { + qrRangeTo = *o.RangeTo + } + qRangeTo := swag.FormatInt64(qrRangeTo) + if qRangeTo != "" { + if err := r.SetQueryParam("range_to", qRangeTo); err != nil { + return err + } + } + + } + + valuesRemediated := o.Remediated + + joinedRemediated := swag.JoinByFormat(valuesRemediated, "multi") + // query array param remediated + if err := r.SetQueryParam("remediated", joinedRemediated...); err != nil { + return err + } + + valuesResourceType := o.ResourceType + + joinedResourceType := swag.JoinByFormat(valuesResourceType, "multi") + // query array param resource_type + if err := r.SetQueryParam("resource_type", joinedResourceType...); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/events/list_events_responses.go b/client/events/list_events_responses.go new file mode 100644 index 0000000..8256029 --- /dev/null +++ b/client/events/list_events_responses.go @@ -0,0 +1,211 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package events + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// ListEventsReader is a Reader for the ListEvents structure. +type ListEventsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListEventsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewListEventsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 401: + result := NewListEventsUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 403: + result := NewListEventsForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 404: + result := NewListEventsNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewListEventsInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewListEventsOK creates a ListEventsOK with default headers values +func NewListEventsOK() *ListEventsOK { + return &ListEventsOK{} +} + +/*ListEventsOK handles this case with default header values. + +List of drift and remediation events. +*/ +type ListEventsOK struct { + Payload *models.Events +} + +func (o *ListEventsOK) Error() string { + return fmt.Sprintf("[GET /events][%d] listEventsOK %+v", 200, o.Payload) +} + +func (o *ListEventsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Events) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListEventsUnauthorized creates a ListEventsUnauthorized with default headers values +func NewListEventsUnauthorized() *ListEventsUnauthorized { + return &ListEventsUnauthorized{} +} + +/*ListEventsUnauthorized handles this case with default header values. + +Authentication error. +*/ +type ListEventsUnauthorized struct { + Payload *models.AuthenticationError +} + +func (o *ListEventsUnauthorized) Error() string { + return fmt.Sprintf("[GET /events][%d] listEventsUnauthorized %+v", 401, o.Payload) +} + +func (o *ListEventsUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthenticationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListEventsForbidden creates a ListEventsForbidden with default headers values +func NewListEventsForbidden() *ListEventsForbidden { + return &ListEventsForbidden{} +} + +/*ListEventsForbidden handles this case with default header values. + +Authorization error. +*/ +type ListEventsForbidden struct { + Payload *models.AuthorizationError +} + +func (o *ListEventsForbidden) Error() string { + return fmt.Sprintf("[GET /events][%d] listEventsForbidden %+v", 403, o.Payload) +} + +func (o *ListEventsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthorizationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListEventsNotFound creates a ListEventsNotFound with default headers values +func NewListEventsNotFound() *ListEventsNotFound { + return &ListEventsNotFound{} +} + +/*ListEventsNotFound handles this case with default header values. + +Not found error. +*/ +type ListEventsNotFound struct { + Payload *models.NotFoundError +} + +func (o *ListEventsNotFound) Error() string { + return fmt.Sprintf("[GET /events][%d] listEventsNotFound %+v", 404, o.Payload) +} + +func (o *ListEventsNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.NotFoundError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListEventsInternalServerError creates a ListEventsInternalServerError with default headers values +func NewListEventsInternalServerError() *ListEventsInternalServerError { + return &ListEventsInternalServerError{} +} + +/*ListEventsInternalServerError handles this case with default header values. + +Internal server error. +*/ +type ListEventsInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *ListEventsInternalServerError) Error() string { + return fmt.Sprintf("[GET /events][%d] listEventsInternalServerError %+v", 500, o.Payload) +} + +func (o *ListEventsInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/fugue_client.go b/client/fugue_client.go new file mode 100644 index 0000000..54f8b03 --- /dev/null +++ b/client/fugue_client.go @@ -0,0 +1,145 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package client + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + httptransport "github.com/go-openapi/runtime/client" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/fugue/fugue-client/client/environments" + "github.com/fugue/fugue-client/client/events" + "github.com/fugue/fugue-client/client/metadata" + "github.com/fugue/fugue-client/client/notifications" + "github.com/fugue/fugue-client/client/scans" +) + +// Default fugue HTTP client. +var Default = NewHTTPClient(nil) + +const ( + // DefaultHost is the default Host + // found in Meta (info) section of spec file + DefaultHost string = "api.riskmanager.fugue.co" + // DefaultBasePath is the default BasePath + // found in Meta (info) section of spec file + DefaultBasePath string = "/v0" +) + +// DefaultSchemes are the default schemes found in Meta (info) section of spec file +var DefaultSchemes = []string{"https"} + +// NewHTTPClient creates a new fugue HTTP client. +func NewHTTPClient(formats strfmt.Registry) *Fugue { + return NewHTTPClientWithConfig(formats, nil) +} + +// NewHTTPClientWithConfig creates a new fugue HTTP client, +// using a customizable transport config. +func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *Fugue { + // ensure nullable parameters have default + if cfg == nil { + cfg = DefaultTransportConfig() + } + + // create transport and client + transport := httptransport.New(cfg.Host, cfg.BasePath, cfg.Schemes) + return New(transport, formats) +} + +// New creates a new fugue client +func New(transport runtime.ClientTransport, formats strfmt.Registry) *Fugue { + // ensure nullable parameters have default + if formats == nil { + formats = strfmt.Default + } + + cli := new(Fugue) + cli.Transport = transport + + cli.Environments = environments.New(transport, formats) + + cli.Events = events.New(transport, formats) + + cli.Metadata = metadata.New(transport, formats) + + cli.Notifications = notifications.New(transport, formats) + + cli.Scans = scans.New(transport, formats) + + return cli +} + +// DefaultTransportConfig creates a TransportConfig with the +// default settings taken from the meta section of the spec file. +func DefaultTransportConfig() *TransportConfig { + return &TransportConfig{ + Host: DefaultHost, + BasePath: DefaultBasePath, + Schemes: DefaultSchemes, + } +} + +// TransportConfig contains the transport related info, +// found in the meta section of the spec file. +type TransportConfig struct { + Host string + BasePath string + Schemes []string +} + +// WithHost overrides the default host, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithHost(host string) *TransportConfig { + cfg.Host = host + return cfg +} + +// WithBasePath overrides the default basePath, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithBasePath(basePath string) *TransportConfig { + cfg.BasePath = basePath + return cfg +} + +// WithSchemes overrides the default schemes, +// provided by the meta section of the spec file. +func (cfg *TransportConfig) WithSchemes(schemes []string) *TransportConfig { + cfg.Schemes = schemes + return cfg +} + +// Fugue is a client for fugue +type Fugue struct { + Environments *environments.Client + + Events *events.Client + + Metadata *metadata.Client + + Notifications *notifications.Client + + Scans *scans.Client + + Transport runtime.ClientTransport +} + +// SetTransport changes the transport on the client and all its subresources +func (c *Fugue) SetTransport(transport runtime.ClientTransport) { + c.Transport = transport + + c.Environments.SetTransport(transport) + + c.Events.SetTransport(transport) + + c.Metadata.SetTransport(transport) + + c.Notifications.SetTransport(transport) + + c.Scans.SetTransport(transport) + +} diff --git a/client/metadata/create_policy_parameters.go b/client/metadata/create_policy_parameters.go new file mode 100644 index 0000000..1b0cd26 --- /dev/null +++ b/client/metadata/create_policy_parameters.go @@ -0,0 +1,160 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metadata + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// NewCreatePolicyParams creates a new CreatePolicyParams object +// with the default values initialized. +func NewCreatePolicyParams() *CreatePolicyParams { + var () + return &CreatePolicyParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewCreatePolicyParamsWithTimeout creates a new CreatePolicyParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewCreatePolicyParamsWithTimeout(timeout time.Duration) *CreatePolicyParams { + var () + return &CreatePolicyParams{ + + timeout: timeout, + } +} + +// NewCreatePolicyParamsWithContext creates a new CreatePolicyParams object +// with the default values initialized, and the ability to set a context for a request +func NewCreatePolicyParamsWithContext(ctx context.Context) *CreatePolicyParams { + var () + return &CreatePolicyParams{ + + Context: ctx, + } +} + +// NewCreatePolicyParamsWithHTTPClient creates a new CreatePolicyParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewCreatePolicyParamsWithHTTPClient(client *http.Client) *CreatePolicyParams { + var () + return &CreatePolicyParams{ + HTTPClient: client, + } +} + +/*CreatePolicyParams contains all the parameters to send to the API endpoint +for the create policy operation typically these are written to a http.Request +*/ +type CreatePolicyParams struct { + + /*Input + List of resource types to be able to survey and remediate. + + */ + Input *models.CreatePolicyInput + /*Provider + Name of the cloud provider. + + */ + Provider string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the create policy params +func (o *CreatePolicyParams) WithTimeout(timeout time.Duration) *CreatePolicyParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the create policy params +func (o *CreatePolicyParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the create policy params +func (o *CreatePolicyParams) WithContext(ctx context.Context) *CreatePolicyParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the create policy params +func (o *CreatePolicyParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the create policy params +func (o *CreatePolicyParams) WithHTTPClient(client *http.Client) *CreatePolicyParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the create policy params +func (o *CreatePolicyParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithInput adds the input to the create policy params +func (o *CreatePolicyParams) WithInput(input *models.CreatePolicyInput) *CreatePolicyParams { + o.SetInput(input) + return o +} + +// SetInput adds the input to the create policy params +func (o *CreatePolicyParams) SetInput(input *models.CreatePolicyInput) { + o.Input = input +} + +// WithProvider adds the provider to the create policy params +func (o *CreatePolicyParams) WithProvider(provider string) *CreatePolicyParams { + o.SetProvider(provider) + return o +} + +// SetProvider adds the provider to the create policy params +func (o *CreatePolicyParams) SetProvider(provider string) { + o.Provider = provider +} + +// WriteToRequest writes these params to a swagger request +func (o *CreatePolicyParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Input != nil { + if err := r.SetBodyParam(o.Input); err != nil { + return err + } + } + + // path param provider + if err := r.SetPathParam("provider", o.Provider); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/metadata/create_policy_responses.go b/client/metadata/create_policy_responses.go new file mode 100644 index 0000000..0d3e5ae --- /dev/null +++ b/client/metadata/create_policy_responses.go @@ -0,0 +1,211 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metadata + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// CreatePolicyReader is a Reader for the CreatePolicy structure. +type CreatePolicyReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *CreatePolicyReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 201: + result := NewCreatePolicyCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 400: + result := NewCreatePolicyBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 401: + result := NewCreatePolicyUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 403: + result := NewCreatePolicyForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewCreatePolicyInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewCreatePolicyCreated creates a CreatePolicyCreated with default headers values +func NewCreatePolicyCreated() *CreatePolicyCreated { + return &CreatePolicyCreated{} +} + +/*CreatePolicyCreated handles this case with default header values. + +Permissions for surveying and remediating the specified resource types. +*/ +type CreatePolicyCreated struct { + Payload *models.Permissions +} + +func (o *CreatePolicyCreated) Error() string { + return fmt.Sprintf("[POST /metadata/{provider}/permissions][%d] createPolicyCreated %+v", 201, o.Payload) +} + +func (o *CreatePolicyCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Permissions) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreatePolicyBadRequest creates a CreatePolicyBadRequest with default headers values +func NewCreatePolicyBadRequest() *CreatePolicyBadRequest { + return &CreatePolicyBadRequest{} +} + +/*CreatePolicyBadRequest handles this case with default header values. + +Bad request error. +*/ +type CreatePolicyBadRequest struct { + Payload *models.BadRequestError +} + +func (o *CreatePolicyBadRequest) Error() string { + return fmt.Sprintf("[POST /metadata/{provider}/permissions][%d] createPolicyBadRequest %+v", 400, o.Payload) +} + +func (o *CreatePolicyBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.BadRequestError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreatePolicyUnauthorized creates a CreatePolicyUnauthorized with default headers values +func NewCreatePolicyUnauthorized() *CreatePolicyUnauthorized { + return &CreatePolicyUnauthorized{} +} + +/*CreatePolicyUnauthorized handles this case with default header values. + +Authentication error. +*/ +type CreatePolicyUnauthorized struct { + Payload *models.AuthenticationError +} + +func (o *CreatePolicyUnauthorized) Error() string { + return fmt.Sprintf("[POST /metadata/{provider}/permissions][%d] createPolicyUnauthorized %+v", 401, o.Payload) +} + +func (o *CreatePolicyUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthenticationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreatePolicyForbidden creates a CreatePolicyForbidden with default headers values +func NewCreatePolicyForbidden() *CreatePolicyForbidden { + return &CreatePolicyForbidden{} +} + +/*CreatePolicyForbidden handles this case with default header values. + +Authorization error. +*/ +type CreatePolicyForbidden struct { + Payload *models.AuthorizationError +} + +func (o *CreatePolicyForbidden) Error() string { + return fmt.Sprintf("[POST /metadata/{provider}/permissions][%d] createPolicyForbidden %+v", 403, o.Payload) +} + +func (o *CreatePolicyForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthorizationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreatePolicyInternalServerError creates a CreatePolicyInternalServerError with default headers values +func NewCreatePolicyInternalServerError() *CreatePolicyInternalServerError { + return &CreatePolicyInternalServerError{} +} + +/*CreatePolicyInternalServerError handles this case with default header values. + +Internal server error. +*/ +type CreatePolicyInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *CreatePolicyInternalServerError) Error() string { + return fmt.Sprintf("[POST /metadata/{provider}/permissions][%d] createPolicyInternalServerError %+v", 500, o.Payload) +} + +func (o *CreatePolicyInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/metadata/get_resource_types_parameters.go b/client/metadata/get_resource_types_parameters.go new file mode 100644 index 0000000..d9f6c40 --- /dev/null +++ b/client/metadata/get_resource_types_parameters.go @@ -0,0 +1,168 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metadata + +// 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" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewGetResourceTypesParams creates a new GetResourceTypesParams object +// with the default values initialized. +func NewGetResourceTypesParams() *GetResourceTypesParams { + var () + return &GetResourceTypesParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewGetResourceTypesParamsWithTimeout creates a new GetResourceTypesParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetResourceTypesParamsWithTimeout(timeout time.Duration) *GetResourceTypesParams { + var () + return &GetResourceTypesParams{ + + timeout: timeout, + } +} + +// NewGetResourceTypesParamsWithContext creates a new GetResourceTypesParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetResourceTypesParamsWithContext(ctx context.Context) *GetResourceTypesParams { + var () + return &GetResourceTypesParams{ + + Context: ctx, + } +} + +// NewGetResourceTypesParamsWithHTTPClient creates a new GetResourceTypesParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetResourceTypesParamsWithHTTPClient(client *http.Client) *GetResourceTypesParams { + var () + return &GetResourceTypesParams{ + HTTPClient: client, + } +} + +/*GetResourceTypesParams contains all the parameters to send to the API endpoint +for the get resource types operation typically these are written to a http.Request +*/ +type GetResourceTypesParams struct { + + /*Provider + Name of the cloud provider. + + */ + Provider string + /*Region + The AWS region for which to return resource types. Required if provider is aws or aws_govcloud. + + */ + Region *string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get resource types params +func (o *GetResourceTypesParams) WithTimeout(timeout time.Duration) *GetResourceTypesParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get resource types params +func (o *GetResourceTypesParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get resource types params +func (o *GetResourceTypesParams) WithContext(ctx context.Context) *GetResourceTypesParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get resource types params +func (o *GetResourceTypesParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get resource types params +func (o *GetResourceTypesParams) WithHTTPClient(client *http.Client) *GetResourceTypesParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get resource types params +func (o *GetResourceTypesParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithProvider adds the provider to the get resource types params +func (o *GetResourceTypesParams) WithProvider(provider string) *GetResourceTypesParams { + o.SetProvider(provider) + return o +} + +// SetProvider adds the provider to the get resource types params +func (o *GetResourceTypesParams) SetProvider(provider string) { + o.Provider = provider +} + +// WithRegion adds the region to the get resource types params +func (o *GetResourceTypesParams) WithRegion(region *string) *GetResourceTypesParams { + o.SetRegion(region) + return o +} + +// SetRegion adds the region to the get resource types params +func (o *GetResourceTypesParams) SetRegion(region *string) { + o.Region = region +} + +// WriteToRequest writes these params to a swagger request +func (o *GetResourceTypesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param provider + if err := r.SetPathParam("provider", o.Provider); err != nil { + return err + } + + if o.Region != nil { + + // query param region + var qrRegion string + if o.Region != nil { + qrRegion = *o.Region + } + qRegion := qrRegion + if qRegion != "" { + if err := r.SetQueryParam("region", qRegion); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/metadata/get_resource_types_responses.go b/client/metadata/get_resource_types_responses.go new file mode 100644 index 0000000..633422f --- /dev/null +++ b/client/metadata/get_resource_types_responses.go @@ -0,0 +1,103 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metadata + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// GetResourceTypesReader is a Reader for the GetResourceTypes structure. +type GetResourceTypesReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetResourceTypesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewGetResourceTypesOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 500: + result := NewGetResourceTypesInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewGetResourceTypesOK creates a GetResourceTypesOK with default headers values +func NewGetResourceTypesOK() *GetResourceTypesOK { + return &GetResourceTypesOK{} +} + +/*GetResourceTypesOK handles this case with default header values. + +List of supported resource types. +*/ +type GetResourceTypesOK struct { + Payload *models.ResourceTypeMetadata +} + +func (o *GetResourceTypesOK) Error() string { + return fmt.Sprintf("[GET /metadata/{provider}/resource_types][%d] getResourceTypesOK %+v", 200, o.Payload) +} + +func (o *GetResourceTypesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ResourceTypeMetadata) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetResourceTypesInternalServerError creates a GetResourceTypesInternalServerError with default headers values +func NewGetResourceTypesInternalServerError() *GetResourceTypesInternalServerError { + return &GetResourceTypesInternalServerError{} +} + +/*GetResourceTypesInternalServerError handles this case with default header values. + +Internal server error. +*/ +type GetResourceTypesInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *GetResourceTypesInternalServerError) Error() string { + return fmt.Sprintf("[GET /metadata/{provider}/resource_types][%d] getResourceTypesInternalServerError %+v", 500, o.Payload) +} + +func (o *GetResourceTypesInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/metadata/get_swagger_parameters.go b/client/metadata/get_swagger_parameters.go new file mode 100644 index 0000000..dae28e8 --- /dev/null +++ b/client/metadata/get_swagger_parameters.go @@ -0,0 +1,113 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metadata + +// 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" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewGetSwaggerParams creates a new GetSwaggerParams object +// with the default values initialized. +func NewGetSwaggerParams() *GetSwaggerParams { + + return &GetSwaggerParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewGetSwaggerParamsWithTimeout creates a new GetSwaggerParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetSwaggerParamsWithTimeout(timeout time.Duration) *GetSwaggerParams { + + return &GetSwaggerParams{ + + timeout: timeout, + } +} + +// NewGetSwaggerParamsWithContext creates a new GetSwaggerParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetSwaggerParamsWithContext(ctx context.Context) *GetSwaggerParams { + + return &GetSwaggerParams{ + + Context: ctx, + } +} + +// NewGetSwaggerParamsWithHTTPClient creates a new GetSwaggerParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetSwaggerParamsWithHTTPClient(client *http.Client) *GetSwaggerParams { + + return &GetSwaggerParams{ + HTTPClient: client, + } +} + +/*GetSwaggerParams contains all the parameters to send to the API endpoint +for the get swagger operation typically these are written to a http.Request +*/ +type GetSwaggerParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get swagger params +func (o *GetSwaggerParams) WithTimeout(timeout time.Duration) *GetSwaggerParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get swagger params +func (o *GetSwaggerParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get swagger params +func (o *GetSwaggerParams) WithContext(ctx context.Context) *GetSwaggerParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get swagger params +func (o *GetSwaggerParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get swagger params +func (o *GetSwaggerParams) WithHTTPClient(client *http.Client) *GetSwaggerParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get swagger params +func (o *GetSwaggerParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *GetSwaggerParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/metadata/get_swagger_responses.go b/client/metadata/get_swagger_responses.go new file mode 100644 index 0000000..eb7e316 --- /dev/null +++ b/client/metadata/get_swagger_responses.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metadata + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// GetSwaggerReader is a Reader for the GetSwagger structure. +type GetSwaggerReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetSwaggerReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewGetSwaggerOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 500: + result := NewGetSwaggerInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewGetSwaggerOK creates a GetSwaggerOK with default headers values +func NewGetSwaggerOK() *GetSwaggerOK { + return &GetSwaggerOK{} +} + +/*GetSwaggerOK handles this case with default header values. + +OpenAPI 2.0 specification. +*/ +type GetSwaggerOK struct { + Payload interface{} +} + +func (o *GetSwaggerOK) Error() string { + return fmt.Sprintf("[GET /swagger][%d] getSwaggerOK %+v", 200, o.Payload) +} + +func (o *GetSwaggerOK) 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 +} + +// NewGetSwaggerInternalServerError creates a GetSwaggerInternalServerError with default headers values +func NewGetSwaggerInternalServerError() *GetSwaggerInternalServerError { + return &GetSwaggerInternalServerError{} +} + +/*GetSwaggerInternalServerError handles this case with default header values. + +Internal server error. +*/ +type GetSwaggerInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *GetSwaggerInternalServerError) Error() string { + return fmt.Sprintf("[GET /swagger][%d] getSwaggerInternalServerError %+v", 500, o.Payload) +} + +func (o *GetSwaggerInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/metadata/get_swagger_ui_parameters.go b/client/metadata/get_swagger_ui_parameters.go new file mode 100644 index 0000000..64103eb --- /dev/null +++ b/client/metadata/get_swagger_ui_parameters.go @@ -0,0 +1,113 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metadata + +// 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" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewGetSwaggerUIParams creates a new GetSwaggerUIParams object +// with the default values initialized. +func NewGetSwaggerUIParams() *GetSwaggerUIParams { + + return &GetSwaggerUIParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewGetSwaggerUIParamsWithTimeout creates a new GetSwaggerUIParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetSwaggerUIParamsWithTimeout(timeout time.Duration) *GetSwaggerUIParams { + + return &GetSwaggerUIParams{ + + timeout: timeout, + } +} + +// NewGetSwaggerUIParamsWithContext creates a new GetSwaggerUIParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetSwaggerUIParamsWithContext(ctx context.Context) *GetSwaggerUIParams { + + return &GetSwaggerUIParams{ + + Context: ctx, + } +} + +// NewGetSwaggerUIParamsWithHTTPClient creates a new GetSwaggerUIParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetSwaggerUIParamsWithHTTPClient(client *http.Client) *GetSwaggerUIParams { + + return &GetSwaggerUIParams{ + HTTPClient: client, + } +} + +/*GetSwaggerUIParams contains all the parameters to send to the API endpoint +for the get swagger UI operation typically these are written to a http.Request +*/ +type GetSwaggerUIParams struct { + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get swagger UI params +func (o *GetSwaggerUIParams) WithTimeout(timeout time.Duration) *GetSwaggerUIParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get swagger UI params +func (o *GetSwaggerUIParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get swagger UI params +func (o *GetSwaggerUIParams) WithContext(ctx context.Context) *GetSwaggerUIParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get swagger UI params +func (o *GetSwaggerUIParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get swagger UI params +func (o *GetSwaggerUIParams) WithHTTPClient(client *http.Client) *GetSwaggerUIParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get swagger UI params +func (o *GetSwaggerUIParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WriteToRequest writes these params to a swagger request +func (o *GetSwaggerUIParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/metadata/get_swagger_ui_responses.go b/client/metadata/get_swagger_ui_responses.go new file mode 100644 index 0000000..9b914ad --- /dev/null +++ b/client/metadata/get_swagger_ui_responses.go @@ -0,0 +1,75 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "fmt" + + "github.com/go-openapi/runtime" + + strfmt "github.com/go-openapi/strfmt" +) + +// GetSwaggerUIReader is a Reader for the GetSwaggerUI structure. +type GetSwaggerUIReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetSwaggerUIReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewGetSwaggerUIOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewGetSwaggerUIOK creates a GetSwaggerUIOK with default headers values +func NewGetSwaggerUIOK() *GetSwaggerUIOK { + return &GetSwaggerUIOK{} +} + +/*GetSwaggerUIOK handles this case with default header values. + +The Swagger UI +*/ +type GetSwaggerUIOK struct { + AccessControlAllowHeaders string + + AccessControlAllowMethods string + + AccessControlAllowOrigin string + + ContentType string +} + +func (o *GetSwaggerUIOK) Error() string { + return fmt.Sprintf("[GET /swagger/ui][%d] getSwaggerUiOK ", 200) +} + +func (o *GetSwaggerUIOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + // response header Access-Control-Allow-Headers + o.AccessControlAllowHeaders = response.GetHeader("Access-Control-Allow-Headers") + + // response header Access-Control-Allow-Methods + o.AccessControlAllowMethods = response.GetHeader("Access-Control-Allow-Methods") + + // response header Access-Control-Allow-Origin + o.AccessControlAllowOrigin = response.GetHeader("Access-Control-Allow-Origin") + + // response header Content-Type + o.ContentType = response.GetHeader("Content-Type") + + return nil +} diff --git a/client/metadata/metadata_client.go b/client/metadata/metadata_client.go new file mode 100644 index 0000000..801ac4d --- /dev/null +++ b/client/metadata/metadata_client.go @@ -0,0 +1,151 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package metadata + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + + strfmt "github.com/go-openapi/strfmt" +) + +// New creates a new metadata API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { + return &Client{transport: transport, formats: formats} +} + +/* +Client for metadata API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +/* +CreatePolicy returns the permissions required to survey and remediate resources + +Returns the permissions required to survey and remediate resources. +*/ +func (a *Client) CreatePolicy(params *CreatePolicyParams, authInfo runtime.ClientAuthInfoWriter) (*CreatePolicyCreated, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewCreatePolicyParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "createPolicy", + Method: "POST", + PathPattern: "/metadata/{provider}/permissions", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &CreatePolicyReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*CreatePolicyCreated), nil + +} + +/* +GetResourceTypes lists the resource types supported by fugue + +Lists the resource types supported by Fugue. +*/ +func (a *Client) GetResourceTypes(params *GetResourceTypesParams) (*GetResourceTypesOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetResourceTypesParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getResourceTypes", + Method: "GET", + PathPattern: "/metadata/{provider}/resource_types", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &GetResourceTypesReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*GetResourceTypesOK), nil + +} + +/* +GetSwagger returns the open API 2 0 specification for this API + +Returns the OpenAPI 2.0 specification for this API. +*/ +func (a *Client) GetSwagger(params *GetSwaggerParams) (*GetSwaggerOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetSwaggerParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getSwagger", + Method: "GET", + PathPattern: "/swagger", + ProducesMediaTypes: []string{"application/json", "application/yaml"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &GetSwaggerReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*GetSwaggerOK), nil + +} + +/* +GetSwaggerUI returns a friendly user interface for the open API 2 0 specification for this API + +Returns a friendly user interface for the OpenAPI 2.0 specification for this API. +*/ +func (a *Client) GetSwaggerUI(params *GetSwaggerUIParams) (*GetSwaggerUIOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetSwaggerUIParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getSwaggerUI", + Method: "GET", + PathPattern: "/swagger/ui", + ProducesMediaTypes: []string{"text/html"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &GetSwaggerUIReader{formats: a.formats}, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*GetSwaggerUIOK), nil + +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/client/notifications/create_notification_parameters.go b/client/notifications/create_notification_parameters.go new file mode 100644 index 0000000..69622df --- /dev/null +++ b/client/notifications/create_notification_parameters.go @@ -0,0 +1,139 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package notifications + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// NewCreateNotificationParams creates a new CreateNotificationParams object +// with the default values initialized. +func NewCreateNotificationParams() *CreateNotificationParams { + var () + return &CreateNotificationParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewCreateNotificationParamsWithTimeout creates a new CreateNotificationParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewCreateNotificationParamsWithTimeout(timeout time.Duration) *CreateNotificationParams { + var () + return &CreateNotificationParams{ + + timeout: timeout, + } +} + +// NewCreateNotificationParamsWithContext creates a new CreateNotificationParams object +// with the default values initialized, and the ability to set a context for a request +func NewCreateNotificationParamsWithContext(ctx context.Context) *CreateNotificationParams { + var () + return &CreateNotificationParams{ + + Context: ctx, + } +} + +// NewCreateNotificationParamsWithHTTPClient creates a new CreateNotificationParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewCreateNotificationParamsWithHTTPClient(client *http.Client) *CreateNotificationParams { + var () + return &CreateNotificationParams{ + HTTPClient: client, + } +} + +/*CreateNotificationParams contains all the parameters to send to the API endpoint +for the create notification operation typically these are written to a http.Request +*/ +type CreateNotificationParams struct { + + /*Notification + Configuration options for the new notification. + + */ + Notification *models.CreateNotificationInput + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the create notification params +func (o *CreateNotificationParams) WithTimeout(timeout time.Duration) *CreateNotificationParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the create notification params +func (o *CreateNotificationParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the create notification params +func (o *CreateNotificationParams) WithContext(ctx context.Context) *CreateNotificationParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the create notification params +func (o *CreateNotificationParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the create notification params +func (o *CreateNotificationParams) WithHTTPClient(client *http.Client) *CreateNotificationParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the create notification params +func (o *CreateNotificationParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithNotification adds the notification to the create notification params +func (o *CreateNotificationParams) WithNotification(notification *models.CreateNotificationInput) *CreateNotificationParams { + o.SetNotification(notification) + return o +} + +// SetNotification adds the notification to the create notification params +func (o *CreateNotificationParams) SetNotification(notification *models.CreateNotificationInput) { + o.Notification = notification +} + +// WriteToRequest writes these params to a swagger request +func (o *CreateNotificationParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Notification != nil { + if err := r.SetBodyParam(o.Notification); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/notifications/create_notification_responses.go b/client/notifications/create_notification_responses.go new file mode 100644 index 0000000..95bca28 --- /dev/null +++ b/client/notifications/create_notification_responses.go @@ -0,0 +1,211 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package notifications + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// CreateNotificationReader is a Reader for the CreateNotification structure. +type CreateNotificationReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *CreateNotificationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 201: + result := NewCreateNotificationCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 401: + result := NewCreateNotificationUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 403: + result := NewCreateNotificationForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 404: + result := NewCreateNotificationNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewCreateNotificationInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewCreateNotificationCreated creates a CreateNotificationCreated with default headers values +func NewCreateNotificationCreated() *CreateNotificationCreated { + return &CreateNotificationCreated{} +} + +/*CreateNotificationCreated handles this case with default header values. + +New notification details. +*/ +type CreateNotificationCreated struct { + Payload *models.Notification +} + +func (o *CreateNotificationCreated) Error() string { + return fmt.Sprintf("[POST /notifications][%d] createNotificationCreated %+v", 201, o.Payload) +} + +func (o *CreateNotificationCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Notification) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateNotificationUnauthorized creates a CreateNotificationUnauthorized with default headers values +func NewCreateNotificationUnauthorized() *CreateNotificationUnauthorized { + return &CreateNotificationUnauthorized{} +} + +/*CreateNotificationUnauthorized handles this case with default header values. + +Authentication error. +*/ +type CreateNotificationUnauthorized struct { + Payload *models.AuthenticationError +} + +func (o *CreateNotificationUnauthorized) Error() string { + return fmt.Sprintf("[POST /notifications][%d] createNotificationUnauthorized %+v", 401, o.Payload) +} + +func (o *CreateNotificationUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthenticationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateNotificationForbidden creates a CreateNotificationForbidden with default headers values +func NewCreateNotificationForbidden() *CreateNotificationForbidden { + return &CreateNotificationForbidden{} +} + +/*CreateNotificationForbidden handles this case with default header values. + +Authorization error. +*/ +type CreateNotificationForbidden struct { + Payload *models.AuthorizationError +} + +func (o *CreateNotificationForbidden) Error() string { + return fmt.Sprintf("[POST /notifications][%d] createNotificationForbidden %+v", 403, o.Payload) +} + +func (o *CreateNotificationForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthorizationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateNotificationNotFound creates a CreateNotificationNotFound with default headers values +func NewCreateNotificationNotFound() *CreateNotificationNotFound { + return &CreateNotificationNotFound{} +} + +/*CreateNotificationNotFound handles this case with default header values. + +Not found error. +*/ +type CreateNotificationNotFound struct { + Payload *models.NotFoundError +} + +func (o *CreateNotificationNotFound) Error() string { + return fmt.Sprintf("[POST /notifications][%d] createNotificationNotFound %+v", 404, o.Payload) +} + +func (o *CreateNotificationNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.NotFoundError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateNotificationInternalServerError creates a CreateNotificationInternalServerError with default headers values +func NewCreateNotificationInternalServerError() *CreateNotificationInternalServerError { + return &CreateNotificationInternalServerError{} +} + +/*CreateNotificationInternalServerError handles this case with default header values. + +Internal server error. +*/ +type CreateNotificationInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *CreateNotificationInternalServerError) Error() string { + return fmt.Sprintf("[POST /notifications][%d] createNotificationInternalServerError %+v", 500, o.Payload) +} + +func (o *CreateNotificationInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/notifications/delete_notification_parameters.go b/client/notifications/delete_notification_parameters.go new file mode 100644 index 0000000..31a2526 --- /dev/null +++ b/client/notifications/delete_notification_parameters.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package notifications + +// 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" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewDeleteNotificationParams creates a new DeleteNotificationParams object +// with the default values initialized. +func NewDeleteNotificationParams() *DeleteNotificationParams { + var () + return &DeleteNotificationParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewDeleteNotificationParamsWithTimeout creates a new DeleteNotificationParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewDeleteNotificationParamsWithTimeout(timeout time.Duration) *DeleteNotificationParams { + var () + return &DeleteNotificationParams{ + + timeout: timeout, + } +} + +// NewDeleteNotificationParamsWithContext creates a new DeleteNotificationParams object +// with the default values initialized, and the ability to set a context for a request +func NewDeleteNotificationParamsWithContext(ctx context.Context) *DeleteNotificationParams { + var () + return &DeleteNotificationParams{ + + Context: ctx, + } +} + +// NewDeleteNotificationParamsWithHTTPClient creates a new DeleteNotificationParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewDeleteNotificationParamsWithHTTPClient(client *http.Client) *DeleteNotificationParams { + var () + return &DeleteNotificationParams{ + HTTPClient: client, + } +} + +/*DeleteNotificationParams contains all the parameters to send to the API endpoint +for the delete notification operation typically these are written to a http.Request +*/ +type DeleteNotificationParams struct { + + /*NotificationID + Notification ID. + + */ + NotificationID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the delete notification params +func (o *DeleteNotificationParams) WithTimeout(timeout time.Duration) *DeleteNotificationParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the delete notification params +func (o *DeleteNotificationParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the delete notification params +func (o *DeleteNotificationParams) WithContext(ctx context.Context) *DeleteNotificationParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the delete notification params +func (o *DeleteNotificationParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the delete notification params +func (o *DeleteNotificationParams) WithHTTPClient(client *http.Client) *DeleteNotificationParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the delete notification params +func (o *DeleteNotificationParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithNotificationID adds the notificationID to the delete notification params +func (o *DeleteNotificationParams) WithNotificationID(notificationID string) *DeleteNotificationParams { + o.SetNotificationID(notificationID) + return o +} + +// SetNotificationID adds the notificationId to the delete notification params +func (o *DeleteNotificationParams) SetNotificationID(notificationID string) { + o.NotificationID = notificationID +} + +// WriteToRequest writes these params to a swagger request +func (o *DeleteNotificationParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param notification_id + if err := r.SetPathParam("notification_id", o.NotificationID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/notifications/delete_notification_responses.go b/client/notifications/delete_notification_responses.go new file mode 100644 index 0000000..8684a17 --- /dev/null +++ b/client/notifications/delete_notification_responses.go @@ -0,0 +1,203 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package notifications + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// DeleteNotificationReader is a Reader for the DeleteNotification structure. +type DeleteNotificationReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *DeleteNotificationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 204: + result := NewDeleteNotificationNoContent() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 401: + result := NewDeleteNotificationUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 403: + result := NewDeleteNotificationForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 404: + result := NewDeleteNotificationNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewDeleteNotificationInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewDeleteNotificationNoContent creates a DeleteNotificationNoContent with default headers values +func NewDeleteNotificationNoContent() *DeleteNotificationNoContent { + return &DeleteNotificationNoContent{} +} + +/*DeleteNotificationNoContent handles this case with default header values. + +Notification deleted. +*/ +type DeleteNotificationNoContent struct { +} + +func (o *DeleteNotificationNoContent) Error() string { + return fmt.Sprintf("[DELETE /notifications/{notification_id}][%d] deleteNotificationNoContent ", 204) +} + +func (o *DeleteNotificationNoContent) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + return nil +} + +// NewDeleteNotificationUnauthorized creates a DeleteNotificationUnauthorized with default headers values +func NewDeleteNotificationUnauthorized() *DeleteNotificationUnauthorized { + return &DeleteNotificationUnauthorized{} +} + +/*DeleteNotificationUnauthorized handles this case with default header values. + +Authentication error. +*/ +type DeleteNotificationUnauthorized struct { + Payload *models.AuthenticationError +} + +func (o *DeleteNotificationUnauthorized) Error() string { + return fmt.Sprintf("[DELETE /notifications/{notification_id}][%d] deleteNotificationUnauthorized %+v", 401, o.Payload) +} + +func (o *DeleteNotificationUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthenticationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewDeleteNotificationForbidden creates a DeleteNotificationForbidden with default headers values +func NewDeleteNotificationForbidden() *DeleteNotificationForbidden { + return &DeleteNotificationForbidden{} +} + +/*DeleteNotificationForbidden handles this case with default header values. + +Authorization error. +*/ +type DeleteNotificationForbidden struct { + Payload *models.AuthorizationError +} + +func (o *DeleteNotificationForbidden) Error() string { + return fmt.Sprintf("[DELETE /notifications/{notification_id}][%d] deleteNotificationForbidden %+v", 403, o.Payload) +} + +func (o *DeleteNotificationForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthorizationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewDeleteNotificationNotFound creates a DeleteNotificationNotFound with default headers values +func NewDeleteNotificationNotFound() *DeleteNotificationNotFound { + return &DeleteNotificationNotFound{} +} + +/*DeleteNotificationNotFound handles this case with default header values. + +Not found error. +*/ +type DeleteNotificationNotFound struct { + Payload *models.NotFoundError +} + +func (o *DeleteNotificationNotFound) Error() string { + return fmt.Sprintf("[DELETE /notifications/{notification_id}][%d] deleteNotificationNotFound %+v", 404, o.Payload) +} + +func (o *DeleteNotificationNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.NotFoundError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewDeleteNotificationInternalServerError creates a DeleteNotificationInternalServerError with default headers values +func NewDeleteNotificationInternalServerError() *DeleteNotificationInternalServerError { + return &DeleteNotificationInternalServerError{} +} + +/*DeleteNotificationInternalServerError handles this case with default header values. + +Internal server error. +*/ +type DeleteNotificationInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *DeleteNotificationInternalServerError) Error() string { + return fmt.Sprintf("[DELETE /notifications/{notification_id}][%d] deleteNotificationInternalServerError %+v", 500, o.Payload) +} + +func (o *DeleteNotificationInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/notifications/list_notifications_parameters.go b/client/notifications/list_notifications_parameters.go new file mode 100644 index 0000000..2261fea --- /dev/null +++ b/client/notifications/list_notifications_parameters.go @@ -0,0 +1,200 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package notifications + +// 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/swag" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewListNotificationsParams creates a new ListNotificationsParams object +// with the default values initialized. +func NewListNotificationsParams() *ListNotificationsParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + ) + return &ListNotificationsParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + + timeout: cr.DefaultTimeout, + } +} + +// NewListNotificationsParamsWithTimeout creates a new ListNotificationsParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewListNotificationsParamsWithTimeout(timeout time.Duration) *ListNotificationsParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + ) + return &ListNotificationsParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + + timeout: timeout, + } +} + +// NewListNotificationsParamsWithContext creates a new ListNotificationsParams object +// with the default values initialized, and the ability to set a context for a request +func NewListNotificationsParamsWithContext(ctx context.Context) *ListNotificationsParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + ) + return &ListNotificationsParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + + Context: ctx, + } +} + +// NewListNotificationsParamsWithHTTPClient creates a new ListNotificationsParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewListNotificationsParamsWithHTTPClient(client *http.Client) *ListNotificationsParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + ) + return &ListNotificationsParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + HTTPClient: client, + } +} + +/*ListNotificationsParams contains all the parameters to send to the API endpoint +for the list notifications operation typically these are written to a http.Request +*/ +type ListNotificationsParams struct { + + /*MaxItems + Maximum number of items to return. + + */ + MaxItems *int64 + /*Offset + Number of items to skip before returning. This parameter is used when the number of items spans multiple pages. + + */ + Offset *int64 + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the list notifications params +func (o *ListNotificationsParams) WithTimeout(timeout time.Duration) *ListNotificationsParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list notifications params +func (o *ListNotificationsParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list notifications params +func (o *ListNotificationsParams) WithContext(ctx context.Context) *ListNotificationsParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list notifications params +func (o *ListNotificationsParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list notifications params +func (o *ListNotificationsParams) WithHTTPClient(client *http.Client) *ListNotificationsParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list notifications params +func (o *ListNotificationsParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithMaxItems adds the maxItems to the list notifications params +func (o *ListNotificationsParams) WithMaxItems(maxItems *int64) *ListNotificationsParams { + o.SetMaxItems(maxItems) + return o +} + +// SetMaxItems adds the maxItems to the list notifications params +func (o *ListNotificationsParams) SetMaxItems(maxItems *int64) { + o.MaxItems = maxItems +} + +// WithOffset adds the offset to the list notifications params +func (o *ListNotificationsParams) WithOffset(offset *int64) *ListNotificationsParams { + o.SetOffset(offset) + return o +} + +// SetOffset adds the offset to the list notifications params +func (o *ListNotificationsParams) SetOffset(offset *int64) { + o.Offset = offset +} + +// WriteToRequest writes these params to a swagger request +func (o *ListNotificationsParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.MaxItems != nil { + + // query param max_items + var qrMaxItems int64 + if o.MaxItems != nil { + qrMaxItems = *o.MaxItems + } + qMaxItems := swag.FormatInt64(qrMaxItems) + if qMaxItems != "" { + if err := r.SetQueryParam("max_items", qMaxItems); err != nil { + return err + } + } + + } + + if o.Offset != nil { + + // query param offset + var qrOffset int64 + if o.Offset != nil { + qrOffset = *o.Offset + } + qOffset := swag.FormatInt64(qrOffset) + if qOffset != "" { + if err := r.SetQueryParam("offset", qOffset); err != nil { + return err + } + } + + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/notifications/list_notifications_responses.go b/client/notifications/list_notifications_responses.go new file mode 100644 index 0000000..5bad9b9 --- /dev/null +++ b/client/notifications/list_notifications_responses.go @@ -0,0 +1,211 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package notifications + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// ListNotificationsReader is a Reader for the ListNotifications structure. +type ListNotificationsReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListNotificationsReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewListNotificationsOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 400: + result := NewListNotificationsBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 401: + result := NewListNotificationsUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 403: + result := NewListNotificationsForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewListNotificationsInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewListNotificationsOK creates a ListNotificationsOK with default headers values +func NewListNotificationsOK() *ListNotificationsOK { + return &ListNotificationsOK{} +} + +/*ListNotificationsOK handles this case with default header values. + +List of notification details. +*/ +type ListNotificationsOK struct { + Payload *models.Notifications +} + +func (o *ListNotificationsOK) Error() string { + return fmt.Sprintf("[GET /notifications][%d] listNotificationsOK %+v", 200, o.Payload) +} + +func (o *ListNotificationsOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Notifications) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListNotificationsBadRequest creates a ListNotificationsBadRequest with default headers values +func NewListNotificationsBadRequest() *ListNotificationsBadRequest { + return &ListNotificationsBadRequest{} +} + +/*ListNotificationsBadRequest handles this case with default header values. + +Bad request error. +*/ +type ListNotificationsBadRequest struct { + Payload *models.BadRequestError +} + +func (o *ListNotificationsBadRequest) Error() string { + return fmt.Sprintf("[GET /notifications][%d] listNotificationsBadRequest %+v", 400, o.Payload) +} + +func (o *ListNotificationsBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.BadRequestError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListNotificationsUnauthorized creates a ListNotificationsUnauthorized with default headers values +func NewListNotificationsUnauthorized() *ListNotificationsUnauthorized { + return &ListNotificationsUnauthorized{} +} + +/*ListNotificationsUnauthorized handles this case with default header values. + +Authentication error. +*/ +type ListNotificationsUnauthorized struct { + Payload *models.AuthenticationError +} + +func (o *ListNotificationsUnauthorized) Error() string { + return fmt.Sprintf("[GET /notifications][%d] listNotificationsUnauthorized %+v", 401, o.Payload) +} + +func (o *ListNotificationsUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthenticationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListNotificationsForbidden creates a ListNotificationsForbidden with default headers values +func NewListNotificationsForbidden() *ListNotificationsForbidden { + return &ListNotificationsForbidden{} +} + +/*ListNotificationsForbidden handles this case with default header values. + +Authorization error. +*/ +type ListNotificationsForbidden struct { + Payload *models.AuthorizationError +} + +func (o *ListNotificationsForbidden) Error() string { + return fmt.Sprintf("[GET /notifications][%d] listNotificationsForbidden %+v", 403, o.Payload) +} + +func (o *ListNotificationsForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthorizationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListNotificationsInternalServerError creates a ListNotificationsInternalServerError with default headers values +func NewListNotificationsInternalServerError() *ListNotificationsInternalServerError { + return &ListNotificationsInternalServerError{} +} + +/*ListNotificationsInternalServerError handles this case with default header values. + +Internal server error. +*/ +type ListNotificationsInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *ListNotificationsInternalServerError) Error() string { + return fmt.Sprintf("[GET /notifications][%d] listNotificationsInternalServerError %+v", 500, o.Payload) +} + +func (o *ListNotificationsInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/notifications/notifications_client.go b/client/notifications/notifications_client.go new file mode 100644 index 0000000..aa47614 --- /dev/null +++ b/client/notifications/notifications_client.go @@ -0,0 +1,154 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package notifications + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + + strfmt "github.com/go-openapi/strfmt" +) + +// New creates a new notifications API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { + return &Client{transport: transport, formats: formats} +} + +/* +Client for notifications API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +/* +CreateNotification creates a new notification + +Creates a new notification. +*/ +func (a *Client) CreateNotification(params *CreateNotificationParams, authInfo runtime.ClientAuthInfoWriter) (*CreateNotificationCreated, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewCreateNotificationParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "createNotification", + Method: "POST", + PathPattern: "/notifications", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &CreateNotificationReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*CreateNotificationCreated), nil + +} + +/* +DeleteNotification deletes a notification + +Deletes a notification. +*/ +func (a *Client) DeleteNotification(params *DeleteNotificationParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteNotificationNoContent, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewDeleteNotificationParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "deleteNotification", + Method: "DELETE", + PathPattern: "/notifications/{notification_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &DeleteNotificationReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*DeleteNotificationNoContent), nil + +} + +/* +ListNotifications lists details for all notifications + +Lists details for all notifications. +*/ +func (a *Client) ListNotifications(params *ListNotificationsParams, authInfo runtime.ClientAuthInfoWriter) (*ListNotificationsOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListNotificationsParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "listNotifications", + Method: "GET", + PathPattern: "/notifications", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &ListNotificationsReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*ListNotificationsOK), nil + +} + +/* +UpdateNotification updates an existing notification + +Updates an existing notification. +*/ +func (a *Client) UpdateNotification(params *UpdateNotificationParams, authInfo runtime.ClientAuthInfoWriter) (*UpdateNotificationOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewUpdateNotificationParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "updateNotification", + Method: "PUT", + PathPattern: "/notifications/{notification_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &UpdateNotificationReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*UpdateNotificationOK), nil + +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/client/notifications/update_notification_parameters.go b/client/notifications/update_notification_parameters.go new file mode 100644 index 0000000..d9a1dbe --- /dev/null +++ b/client/notifications/update_notification_parameters.go @@ -0,0 +1,160 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package notifications + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// NewUpdateNotificationParams creates a new UpdateNotificationParams object +// with the default values initialized. +func NewUpdateNotificationParams() *UpdateNotificationParams { + var () + return &UpdateNotificationParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewUpdateNotificationParamsWithTimeout creates a new UpdateNotificationParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewUpdateNotificationParamsWithTimeout(timeout time.Duration) *UpdateNotificationParams { + var () + return &UpdateNotificationParams{ + + timeout: timeout, + } +} + +// NewUpdateNotificationParamsWithContext creates a new UpdateNotificationParams object +// with the default values initialized, and the ability to set a context for a request +func NewUpdateNotificationParamsWithContext(ctx context.Context) *UpdateNotificationParams { + var () + return &UpdateNotificationParams{ + + Context: ctx, + } +} + +// NewUpdateNotificationParamsWithHTTPClient creates a new UpdateNotificationParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewUpdateNotificationParamsWithHTTPClient(client *http.Client) *UpdateNotificationParams { + var () + return &UpdateNotificationParams{ + HTTPClient: client, + } +} + +/*UpdateNotificationParams contains all the parameters to send to the API endpoint +for the update notification operation typically these are written to a http.Request +*/ +type UpdateNotificationParams struct { + + /*Notification + New configuration options for the notification. + + */ + Notification *models.UpdateNotificationInput + /*NotificationID + Notification ID. + + */ + NotificationID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the update notification params +func (o *UpdateNotificationParams) WithTimeout(timeout time.Duration) *UpdateNotificationParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the update notification params +func (o *UpdateNotificationParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the update notification params +func (o *UpdateNotificationParams) WithContext(ctx context.Context) *UpdateNotificationParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the update notification params +func (o *UpdateNotificationParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the update notification params +func (o *UpdateNotificationParams) WithHTTPClient(client *http.Client) *UpdateNotificationParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the update notification params +func (o *UpdateNotificationParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithNotification adds the notification to the update notification params +func (o *UpdateNotificationParams) WithNotification(notification *models.UpdateNotificationInput) *UpdateNotificationParams { + o.SetNotification(notification) + return o +} + +// SetNotification adds the notification to the update notification params +func (o *UpdateNotificationParams) SetNotification(notification *models.UpdateNotificationInput) { + o.Notification = notification +} + +// WithNotificationID adds the notificationID to the update notification params +func (o *UpdateNotificationParams) WithNotificationID(notificationID string) *UpdateNotificationParams { + o.SetNotificationID(notificationID) + return o +} + +// SetNotificationID adds the notificationId to the update notification params +func (o *UpdateNotificationParams) SetNotificationID(notificationID string) { + o.NotificationID = notificationID +} + +// WriteToRequest writes these params to a swagger request +func (o *UpdateNotificationParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + if o.Notification != nil { + if err := r.SetBodyParam(o.Notification); err != nil { + return err + } + } + + // path param notification_id + if err := r.SetPathParam("notification_id", o.NotificationID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/notifications/update_notification_responses.go b/client/notifications/update_notification_responses.go new file mode 100644 index 0000000..1a4130b --- /dev/null +++ b/client/notifications/update_notification_responses.go @@ -0,0 +1,211 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package notifications + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// UpdateNotificationReader is a Reader for the UpdateNotification structure. +type UpdateNotificationReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *UpdateNotificationReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewUpdateNotificationOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 401: + result := NewUpdateNotificationUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 403: + result := NewUpdateNotificationForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 404: + result := NewUpdateNotificationNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewUpdateNotificationInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewUpdateNotificationOK creates a UpdateNotificationOK with default headers values +func NewUpdateNotificationOK() *UpdateNotificationOK { + return &UpdateNotificationOK{} +} + +/*UpdateNotificationOK handles this case with default header values. + +New notification details. +*/ +type UpdateNotificationOK struct { + Payload *models.Notification +} + +func (o *UpdateNotificationOK) Error() string { + return fmt.Sprintf("[PUT /notifications/{notification_id}][%d] updateNotificationOK %+v", 200, o.Payload) +} + +func (o *UpdateNotificationOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Notification) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUpdateNotificationUnauthorized creates a UpdateNotificationUnauthorized with default headers values +func NewUpdateNotificationUnauthorized() *UpdateNotificationUnauthorized { + return &UpdateNotificationUnauthorized{} +} + +/*UpdateNotificationUnauthorized handles this case with default header values. + +Authentication error. +*/ +type UpdateNotificationUnauthorized struct { + Payload *models.AuthenticationError +} + +func (o *UpdateNotificationUnauthorized) Error() string { + return fmt.Sprintf("[PUT /notifications/{notification_id}][%d] updateNotificationUnauthorized %+v", 401, o.Payload) +} + +func (o *UpdateNotificationUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthenticationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUpdateNotificationForbidden creates a UpdateNotificationForbidden with default headers values +func NewUpdateNotificationForbidden() *UpdateNotificationForbidden { + return &UpdateNotificationForbidden{} +} + +/*UpdateNotificationForbidden handles this case with default header values. + +Authorization error. +*/ +type UpdateNotificationForbidden struct { + Payload *models.AuthorizationError +} + +func (o *UpdateNotificationForbidden) Error() string { + return fmt.Sprintf("[PUT /notifications/{notification_id}][%d] updateNotificationForbidden %+v", 403, o.Payload) +} + +func (o *UpdateNotificationForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthorizationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUpdateNotificationNotFound creates a UpdateNotificationNotFound with default headers values +func NewUpdateNotificationNotFound() *UpdateNotificationNotFound { + return &UpdateNotificationNotFound{} +} + +/*UpdateNotificationNotFound handles this case with default header values. + +Not found error. +*/ +type UpdateNotificationNotFound struct { + Payload *models.NotFoundError +} + +func (o *UpdateNotificationNotFound) Error() string { + return fmt.Sprintf("[PUT /notifications/{notification_id}][%d] updateNotificationNotFound %+v", 404, o.Payload) +} + +func (o *UpdateNotificationNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.NotFoundError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewUpdateNotificationInternalServerError creates a UpdateNotificationInternalServerError with default headers values +func NewUpdateNotificationInternalServerError() *UpdateNotificationInternalServerError { + return &UpdateNotificationInternalServerError{} +} + +/*UpdateNotificationInternalServerError handles this case with default header values. + +Internal server error. +*/ +type UpdateNotificationInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *UpdateNotificationInternalServerError) Error() string { + return fmt.Sprintf("[PUT /notifications/{notification_id}][%d] updateNotificationInternalServerError %+v", 500, o.Payload) +} + +func (o *UpdateNotificationInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/scans/create_scan_parameters.go b/client/scans/create_scan_parameters.go new file mode 100644 index 0000000..562790d --- /dev/null +++ b/client/scans/create_scan_parameters.go @@ -0,0 +1,140 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scans + +// 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" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewCreateScanParams creates a new CreateScanParams object +// with the default values initialized. +func NewCreateScanParams() *CreateScanParams { + var () + return &CreateScanParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewCreateScanParamsWithTimeout creates a new CreateScanParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewCreateScanParamsWithTimeout(timeout time.Duration) *CreateScanParams { + var () + return &CreateScanParams{ + + timeout: timeout, + } +} + +// NewCreateScanParamsWithContext creates a new CreateScanParams object +// with the default values initialized, and the ability to set a context for a request +func NewCreateScanParamsWithContext(ctx context.Context) *CreateScanParams { + var () + return &CreateScanParams{ + + Context: ctx, + } +} + +// NewCreateScanParamsWithHTTPClient creates a new CreateScanParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewCreateScanParamsWithHTTPClient(client *http.Client) *CreateScanParams { + var () + return &CreateScanParams{ + HTTPClient: client, + } +} + +/*CreateScanParams contains all the parameters to send to the API endpoint +for the create scan operation typically these are written to a http.Request +*/ +type CreateScanParams struct { + + /*EnvironmentID + ID of the environment to scan. + + */ + EnvironmentID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the create scan params +func (o *CreateScanParams) WithTimeout(timeout time.Duration) *CreateScanParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the create scan params +func (o *CreateScanParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the create scan params +func (o *CreateScanParams) WithContext(ctx context.Context) *CreateScanParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the create scan params +func (o *CreateScanParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the create scan params +func (o *CreateScanParams) WithHTTPClient(client *http.Client) *CreateScanParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the create scan params +func (o *CreateScanParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithEnvironmentID adds the environmentID to the create scan params +func (o *CreateScanParams) WithEnvironmentID(environmentID string) *CreateScanParams { + o.SetEnvironmentID(environmentID) + return o +} + +// SetEnvironmentID adds the environmentId to the create scan params +func (o *CreateScanParams) SetEnvironmentID(environmentID string) { + o.EnvironmentID = environmentID +} + +// WriteToRequest writes these params to a swagger request +func (o *CreateScanParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // query param environment_id + qrEnvironmentID := o.EnvironmentID + qEnvironmentID := qrEnvironmentID + if qEnvironmentID != "" { + if err := r.SetQueryParam("environment_id", qEnvironmentID); err != nil { + return err + } + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/scans/create_scan_responses.go b/client/scans/create_scan_responses.go new file mode 100644 index 0000000..0db93ba --- /dev/null +++ b/client/scans/create_scan_responses.go @@ -0,0 +1,211 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scans + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// CreateScanReader is a Reader for the CreateScan structure. +type CreateScanReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *CreateScanReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 201: + result := NewCreateScanCreated() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 400: + result := NewCreateScanBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 401: + result := NewCreateScanUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 403: + result := NewCreateScanForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewCreateScanInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewCreateScanCreated creates a CreateScanCreated with default headers values +func NewCreateScanCreated() *CreateScanCreated { + return &CreateScanCreated{} +} + +/*CreateScanCreated handles this case with default header values. + +Scan details. +*/ +type CreateScanCreated struct { + Payload *models.Scan +} + +func (o *CreateScanCreated) Error() string { + return fmt.Sprintf("[POST /scans][%d] createScanCreated %+v", 201, o.Payload) +} + +func (o *CreateScanCreated) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Scan) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateScanBadRequest creates a CreateScanBadRequest with default headers values +func NewCreateScanBadRequest() *CreateScanBadRequest { + return &CreateScanBadRequest{} +} + +/*CreateScanBadRequest handles this case with default header values. + +Bad request error. +*/ +type CreateScanBadRequest struct { + Payload *models.BadRequestError +} + +func (o *CreateScanBadRequest) Error() string { + return fmt.Sprintf("[POST /scans][%d] createScanBadRequest %+v", 400, o.Payload) +} + +func (o *CreateScanBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.BadRequestError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateScanUnauthorized creates a CreateScanUnauthorized with default headers values +func NewCreateScanUnauthorized() *CreateScanUnauthorized { + return &CreateScanUnauthorized{} +} + +/*CreateScanUnauthorized handles this case with default header values. + +Authentication error. +*/ +type CreateScanUnauthorized struct { + Payload *models.AuthenticationError +} + +func (o *CreateScanUnauthorized) Error() string { + return fmt.Sprintf("[POST /scans][%d] createScanUnauthorized %+v", 401, o.Payload) +} + +func (o *CreateScanUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthenticationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateScanForbidden creates a CreateScanForbidden with default headers values +func NewCreateScanForbidden() *CreateScanForbidden { + return &CreateScanForbidden{} +} + +/*CreateScanForbidden handles this case with default header values. + +Authorization error. +*/ +type CreateScanForbidden struct { + Payload *models.AuthorizationError +} + +func (o *CreateScanForbidden) Error() string { + return fmt.Sprintf("[POST /scans][%d] createScanForbidden %+v", 403, o.Payload) +} + +func (o *CreateScanForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthorizationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewCreateScanInternalServerError creates a CreateScanInternalServerError with default headers values +func NewCreateScanInternalServerError() *CreateScanInternalServerError { + return &CreateScanInternalServerError{} +} + +/*CreateScanInternalServerError handles this case with default header values. + +Internal server error. +*/ +type CreateScanInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *CreateScanInternalServerError) Error() string { + return fmt.Sprintf("[POST /scans][%d] createScanInternalServerError %+v", 500, o.Payload) +} + +func (o *CreateScanInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/scans/get_compliance_by_resource_types_parameters.go b/client/scans/get_compliance_by_resource_types_parameters.go new file mode 100644 index 0000000..006d283 --- /dev/null +++ b/client/scans/get_compliance_by_resource_types_parameters.go @@ -0,0 +1,269 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scans + +// 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/swag" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewGetComplianceByResourceTypesParams creates a new GetComplianceByResourceTypesParams object +// with the default values initialized. +func NewGetComplianceByResourceTypesParams() *GetComplianceByResourceTypesParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + ) + return &GetComplianceByResourceTypesParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + + timeout: cr.DefaultTimeout, + } +} + +// NewGetComplianceByResourceTypesParamsWithTimeout creates a new GetComplianceByResourceTypesParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetComplianceByResourceTypesParamsWithTimeout(timeout time.Duration) *GetComplianceByResourceTypesParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + ) + return &GetComplianceByResourceTypesParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + + timeout: timeout, + } +} + +// NewGetComplianceByResourceTypesParamsWithContext creates a new GetComplianceByResourceTypesParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetComplianceByResourceTypesParamsWithContext(ctx context.Context) *GetComplianceByResourceTypesParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + ) + return &GetComplianceByResourceTypesParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + + Context: ctx, + } +} + +// NewGetComplianceByResourceTypesParamsWithHTTPClient creates a new GetComplianceByResourceTypesParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetComplianceByResourceTypesParamsWithHTTPClient(client *http.Client) *GetComplianceByResourceTypesParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + ) + return &GetComplianceByResourceTypesParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + HTTPClient: client, + } +} + +/*GetComplianceByResourceTypesParams contains all the parameters to send to the API endpoint +for the get compliance by resource types operation typically these are written to a http.Request +*/ +type GetComplianceByResourceTypesParams struct { + + /*Family + Compliance family to filter by. When not specified, all compliance families will be returned. + + */ + Family []string + /*MaxItems + Maximum number of items to return. + + */ + MaxItems *int64 + /*Offset + Number of items to skip before returning. This parameter is used when the number of items spans multiple pages. + + */ + Offset *int64 + /*ResourceType + Resource types to filter by. When not specified, all resource types will be returned. + + */ + ResourceType []string + /*ScanID + Scan ID. + + */ + ScanID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get compliance by resource types params +func (o *GetComplianceByResourceTypesParams) WithTimeout(timeout time.Duration) *GetComplianceByResourceTypesParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get compliance by resource types params +func (o *GetComplianceByResourceTypesParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get compliance by resource types params +func (o *GetComplianceByResourceTypesParams) WithContext(ctx context.Context) *GetComplianceByResourceTypesParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get compliance by resource types params +func (o *GetComplianceByResourceTypesParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get compliance by resource types params +func (o *GetComplianceByResourceTypesParams) WithHTTPClient(client *http.Client) *GetComplianceByResourceTypesParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get compliance by resource types params +func (o *GetComplianceByResourceTypesParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithFamily adds the family to the get compliance by resource types params +func (o *GetComplianceByResourceTypesParams) WithFamily(family []string) *GetComplianceByResourceTypesParams { + o.SetFamily(family) + return o +} + +// SetFamily adds the family to the get compliance by resource types params +func (o *GetComplianceByResourceTypesParams) SetFamily(family []string) { + o.Family = family +} + +// WithMaxItems adds the maxItems to the get compliance by resource types params +func (o *GetComplianceByResourceTypesParams) WithMaxItems(maxItems *int64) *GetComplianceByResourceTypesParams { + o.SetMaxItems(maxItems) + return o +} + +// SetMaxItems adds the maxItems to the get compliance by resource types params +func (o *GetComplianceByResourceTypesParams) SetMaxItems(maxItems *int64) { + o.MaxItems = maxItems +} + +// WithOffset adds the offset to the get compliance by resource types params +func (o *GetComplianceByResourceTypesParams) WithOffset(offset *int64) *GetComplianceByResourceTypesParams { + o.SetOffset(offset) + return o +} + +// SetOffset adds the offset to the get compliance by resource types params +func (o *GetComplianceByResourceTypesParams) SetOffset(offset *int64) { + o.Offset = offset +} + +// WithResourceType adds the resourceType to the get compliance by resource types params +func (o *GetComplianceByResourceTypesParams) WithResourceType(resourceType []string) *GetComplianceByResourceTypesParams { + o.SetResourceType(resourceType) + return o +} + +// SetResourceType adds the resourceType to the get compliance by resource types params +func (o *GetComplianceByResourceTypesParams) SetResourceType(resourceType []string) { + o.ResourceType = resourceType +} + +// WithScanID adds the scanID to the get compliance by resource types params +func (o *GetComplianceByResourceTypesParams) WithScanID(scanID string) *GetComplianceByResourceTypesParams { + o.SetScanID(scanID) + return o +} + +// SetScanID adds the scanId to the get compliance by resource types params +func (o *GetComplianceByResourceTypesParams) SetScanID(scanID string) { + o.ScanID = scanID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetComplianceByResourceTypesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + valuesFamily := o.Family + + joinedFamily := swag.JoinByFormat(valuesFamily, "multi") + // query array param family + if err := r.SetQueryParam("family", joinedFamily...); err != nil { + return err + } + + if o.MaxItems != nil { + + // query param max_items + var qrMaxItems int64 + if o.MaxItems != nil { + qrMaxItems = *o.MaxItems + } + qMaxItems := swag.FormatInt64(qrMaxItems) + if qMaxItems != "" { + if err := r.SetQueryParam("max_items", qMaxItems); err != nil { + return err + } + } + + } + + if o.Offset != nil { + + // query param offset + var qrOffset int64 + if o.Offset != nil { + qrOffset = *o.Offset + } + qOffset := swag.FormatInt64(qrOffset) + if qOffset != "" { + if err := r.SetQueryParam("offset", qOffset); err != nil { + return err + } + } + + } + + valuesResourceType := o.ResourceType + + joinedResourceType := swag.JoinByFormat(valuesResourceType, "multi") + // query array param resource_type + if err := r.SetQueryParam("resource_type", joinedResourceType...); err != nil { + return err + } + + // path param scan_id + if err := r.SetPathParam("scan_id", o.ScanID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/scans/get_compliance_by_resource_types_responses.go b/client/scans/get_compliance_by_resource_types_responses.go new file mode 100644 index 0000000..4c2ec39 --- /dev/null +++ b/client/scans/get_compliance_by_resource_types_responses.go @@ -0,0 +1,211 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scans + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// GetComplianceByResourceTypesReader is a Reader for the GetComplianceByResourceTypes structure. +type GetComplianceByResourceTypesReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetComplianceByResourceTypesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewGetComplianceByResourceTypesOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 401: + result := NewGetComplianceByResourceTypesUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 403: + result := NewGetComplianceByResourceTypesForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 404: + result := NewGetComplianceByResourceTypesNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewGetComplianceByResourceTypesInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewGetComplianceByResourceTypesOK creates a GetComplianceByResourceTypesOK with default headers values +func NewGetComplianceByResourceTypesOK() *GetComplianceByResourceTypesOK { + return &GetComplianceByResourceTypesOK{} +} + +/*GetComplianceByResourceTypesOK handles this case with default header values. + +List of compliance results from a scan grouped by resource type. +*/ +type GetComplianceByResourceTypesOK struct { + Payload *models.ComplianceByResourceTypeOutput +} + +func (o *GetComplianceByResourceTypesOK) Error() string { + return fmt.Sprintf("[GET /scans/{scan_id}/compliance_by_resource_types][%d] getComplianceByResourceTypesOK %+v", 200, o.Payload) +} + +func (o *GetComplianceByResourceTypesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ComplianceByResourceTypeOutput) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetComplianceByResourceTypesUnauthorized creates a GetComplianceByResourceTypesUnauthorized with default headers values +func NewGetComplianceByResourceTypesUnauthorized() *GetComplianceByResourceTypesUnauthorized { + return &GetComplianceByResourceTypesUnauthorized{} +} + +/*GetComplianceByResourceTypesUnauthorized handles this case with default header values. + +Authentication error. +*/ +type GetComplianceByResourceTypesUnauthorized struct { + Payload *models.AuthenticationError +} + +func (o *GetComplianceByResourceTypesUnauthorized) Error() string { + return fmt.Sprintf("[GET /scans/{scan_id}/compliance_by_resource_types][%d] getComplianceByResourceTypesUnauthorized %+v", 401, o.Payload) +} + +func (o *GetComplianceByResourceTypesUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthenticationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetComplianceByResourceTypesForbidden creates a GetComplianceByResourceTypesForbidden with default headers values +func NewGetComplianceByResourceTypesForbidden() *GetComplianceByResourceTypesForbidden { + return &GetComplianceByResourceTypesForbidden{} +} + +/*GetComplianceByResourceTypesForbidden handles this case with default header values. + +Authorization error. +*/ +type GetComplianceByResourceTypesForbidden struct { + Payload *models.AuthorizationError +} + +func (o *GetComplianceByResourceTypesForbidden) Error() string { + return fmt.Sprintf("[GET /scans/{scan_id}/compliance_by_resource_types][%d] getComplianceByResourceTypesForbidden %+v", 403, o.Payload) +} + +func (o *GetComplianceByResourceTypesForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthorizationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetComplianceByResourceTypesNotFound creates a GetComplianceByResourceTypesNotFound with default headers values +func NewGetComplianceByResourceTypesNotFound() *GetComplianceByResourceTypesNotFound { + return &GetComplianceByResourceTypesNotFound{} +} + +/*GetComplianceByResourceTypesNotFound handles this case with default header values. + +Not found error. +*/ +type GetComplianceByResourceTypesNotFound struct { + Payload *models.NotFoundError +} + +func (o *GetComplianceByResourceTypesNotFound) Error() string { + return fmt.Sprintf("[GET /scans/{scan_id}/compliance_by_resource_types][%d] getComplianceByResourceTypesNotFound %+v", 404, o.Payload) +} + +func (o *GetComplianceByResourceTypesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.NotFoundError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetComplianceByResourceTypesInternalServerError creates a GetComplianceByResourceTypesInternalServerError with default headers values +func NewGetComplianceByResourceTypesInternalServerError() *GetComplianceByResourceTypesInternalServerError { + return &GetComplianceByResourceTypesInternalServerError{} +} + +/*GetComplianceByResourceTypesInternalServerError handles this case with default header values. + +Internal server error. +*/ +type GetComplianceByResourceTypesInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *GetComplianceByResourceTypesInternalServerError) Error() string { + return fmt.Sprintf("[GET /scans/{scan_id}/compliance_by_resource_types][%d] getComplianceByResourceTypesInternalServerError %+v", 500, o.Payload) +} + +func (o *GetComplianceByResourceTypesInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/scans/get_compliance_by_rules_parameters.go b/client/scans/get_compliance_by_rules_parameters.go new file mode 100644 index 0000000..58159b4 --- /dev/null +++ b/client/scans/get_compliance_by_rules_parameters.go @@ -0,0 +1,269 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scans + +// 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/swag" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewGetComplianceByRulesParams creates a new GetComplianceByRulesParams object +// with the default values initialized. +func NewGetComplianceByRulesParams() *GetComplianceByRulesParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + ) + return &GetComplianceByRulesParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + + timeout: cr.DefaultTimeout, + } +} + +// NewGetComplianceByRulesParamsWithTimeout creates a new GetComplianceByRulesParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetComplianceByRulesParamsWithTimeout(timeout time.Duration) *GetComplianceByRulesParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + ) + return &GetComplianceByRulesParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + + timeout: timeout, + } +} + +// NewGetComplianceByRulesParamsWithContext creates a new GetComplianceByRulesParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetComplianceByRulesParamsWithContext(ctx context.Context) *GetComplianceByRulesParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + ) + return &GetComplianceByRulesParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + + Context: ctx, + } +} + +// NewGetComplianceByRulesParamsWithHTTPClient creates a new GetComplianceByRulesParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetComplianceByRulesParamsWithHTTPClient(client *http.Client) *GetComplianceByRulesParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + ) + return &GetComplianceByRulesParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + HTTPClient: client, + } +} + +/*GetComplianceByRulesParams contains all the parameters to send to the API endpoint +for the get compliance by rules operation typically these are written to a http.Request +*/ +type GetComplianceByRulesParams struct { + + /*Family + Compliance family to filter by. When not specified, all compliance families will be returned. + + */ + Family []string + /*MaxItems + Maximum number of items to return. + + */ + MaxItems *int64 + /*Offset + Number of items to skip before returning. This parameter is used when the number of items spans multiple pages. + + */ + Offset *int64 + /*Result + Rule result to filter by. When not specified, all results will be returned. + + */ + Result []string + /*ScanID + Scan ID. + + */ + ScanID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get compliance by rules params +func (o *GetComplianceByRulesParams) WithTimeout(timeout time.Duration) *GetComplianceByRulesParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get compliance by rules params +func (o *GetComplianceByRulesParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get compliance by rules params +func (o *GetComplianceByRulesParams) WithContext(ctx context.Context) *GetComplianceByRulesParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get compliance by rules params +func (o *GetComplianceByRulesParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get compliance by rules params +func (o *GetComplianceByRulesParams) WithHTTPClient(client *http.Client) *GetComplianceByRulesParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get compliance by rules params +func (o *GetComplianceByRulesParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithFamily adds the family to the get compliance by rules params +func (o *GetComplianceByRulesParams) WithFamily(family []string) *GetComplianceByRulesParams { + o.SetFamily(family) + return o +} + +// SetFamily adds the family to the get compliance by rules params +func (o *GetComplianceByRulesParams) SetFamily(family []string) { + o.Family = family +} + +// WithMaxItems adds the maxItems to the get compliance by rules params +func (o *GetComplianceByRulesParams) WithMaxItems(maxItems *int64) *GetComplianceByRulesParams { + o.SetMaxItems(maxItems) + return o +} + +// SetMaxItems adds the maxItems to the get compliance by rules params +func (o *GetComplianceByRulesParams) SetMaxItems(maxItems *int64) { + o.MaxItems = maxItems +} + +// WithOffset adds the offset to the get compliance by rules params +func (o *GetComplianceByRulesParams) WithOffset(offset *int64) *GetComplianceByRulesParams { + o.SetOffset(offset) + return o +} + +// SetOffset adds the offset to the get compliance by rules params +func (o *GetComplianceByRulesParams) SetOffset(offset *int64) { + o.Offset = offset +} + +// WithResult adds the result to the get compliance by rules params +func (o *GetComplianceByRulesParams) WithResult(result []string) *GetComplianceByRulesParams { + o.SetResult(result) + return o +} + +// SetResult adds the result to the get compliance by rules params +func (o *GetComplianceByRulesParams) SetResult(result []string) { + o.Result = result +} + +// WithScanID adds the scanID to the get compliance by rules params +func (o *GetComplianceByRulesParams) WithScanID(scanID string) *GetComplianceByRulesParams { + o.SetScanID(scanID) + return o +} + +// SetScanID adds the scanId to the get compliance by rules params +func (o *GetComplianceByRulesParams) SetScanID(scanID string) { + o.ScanID = scanID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetComplianceByRulesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + valuesFamily := o.Family + + joinedFamily := swag.JoinByFormat(valuesFamily, "multi") + // query array param family + if err := r.SetQueryParam("family", joinedFamily...); err != nil { + return err + } + + if o.MaxItems != nil { + + // query param max_items + var qrMaxItems int64 + if o.MaxItems != nil { + qrMaxItems = *o.MaxItems + } + qMaxItems := swag.FormatInt64(qrMaxItems) + if qMaxItems != "" { + if err := r.SetQueryParam("max_items", qMaxItems); err != nil { + return err + } + } + + } + + if o.Offset != nil { + + // query param offset + var qrOffset int64 + if o.Offset != nil { + qrOffset = *o.Offset + } + qOffset := swag.FormatInt64(qrOffset) + if qOffset != "" { + if err := r.SetQueryParam("offset", qOffset); err != nil { + return err + } + } + + } + + valuesResult := o.Result + + joinedResult := swag.JoinByFormat(valuesResult, "multi") + // query array param result + if err := r.SetQueryParam("result", joinedResult...); err != nil { + return err + } + + // path param scan_id + if err := r.SetPathParam("scan_id", o.ScanID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/scans/get_compliance_by_rules_responses.go b/client/scans/get_compliance_by_rules_responses.go new file mode 100644 index 0000000..6e8b692 --- /dev/null +++ b/client/scans/get_compliance_by_rules_responses.go @@ -0,0 +1,211 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scans + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// GetComplianceByRulesReader is a Reader for the GetComplianceByRules structure. +type GetComplianceByRulesReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetComplianceByRulesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewGetComplianceByRulesOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 401: + result := NewGetComplianceByRulesUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 403: + result := NewGetComplianceByRulesForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 404: + result := NewGetComplianceByRulesNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewGetComplianceByRulesInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewGetComplianceByRulesOK creates a GetComplianceByRulesOK with default headers values +func NewGetComplianceByRulesOK() *GetComplianceByRulesOK { + return &GetComplianceByRulesOK{} +} + +/*GetComplianceByRulesOK handles this case with default header values. + +List of compliance results from a scan grouped by rule. +*/ +type GetComplianceByRulesOK struct { + Payload *models.ComplianceByRules +} + +func (o *GetComplianceByRulesOK) Error() string { + return fmt.Sprintf("[GET /scans/{scan_id}/compliance_by_rules][%d] getComplianceByRulesOK %+v", 200, o.Payload) +} + +func (o *GetComplianceByRulesOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ComplianceByRules) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetComplianceByRulesUnauthorized creates a GetComplianceByRulesUnauthorized with default headers values +func NewGetComplianceByRulesUnauthorized() *GetComplianceByRulesUnauthorized { + return &GetComplianceByRulesUnauthorized{} +} + +/*GetComplianceByRulesUnauthorized handles this case with default header values. + +Authentication error. +*/ +type GetComplianceByRulesUnauthorized struct { + Payload *models.AuthenticationError +} + +func (o *GetComplianceByRulesUnauthorized) Error() string { + return fmt.Sprintf("[GET /scans/{scan_id}/compliance_by_rules][%d] getComplianceByRulesUnauthorized %+v", 401, o.Payload) +} + +func (o *GetComplianceByRulesUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthenticationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetComplianceByRulesForbidden creates a GetComplianceByRulesForbidden with default headers values +func NewGetComplianceByRulesForbidden() *GetComplianceByRulesForbidden { + return &GetComplianceByRulesForbidden{} +} + +/*GetComplianceByRulesForbidden handles this case with default header values. + +Authorization error. +*/ +type GetComplianceByRulesForbidden struct { + Payload *models.AuthorizationError +} + +func (o *GetComplianceByRulesForbidden) Error() string { + return fmt.Sprintf("[GET /scans/{scan_id}/compliance_by_rules][%d] getComplianceByRulesForbidden %+v", 403, o.Payload) +} + +func (o *GetComplianceByRulesForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthorizationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetComplianceByRulesNotFound creates a GetComplianceByRulesNotFound with default headers values +func NewGetComplianceByRulesNotFound() *GetComplianceByRulesNotFound { + return &GetComplianceByRulesNotFound{} +} + +/*GetComplianceByRulesNotFound handles this case with default header values. + +Not found error. +*/ +type GetComplianceByRulesNotFound struct { + Payload *models.NotFoundError +} + +func (o *GetComplianceByRulesNotFound) Error() string { + return fmt.Sprintf("[GET /scans/{scan_id}/compliance_by_rules][%d] getComplianceByRulesNotFound %+v", 404, o.Payload) +} + +func (o *GetComplianceByRulesNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.NotFoundError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetComplianceByRulesInternalServerError creates a GetComplianceByRulesInternalServerError with default headers values +func NewGetComplianceByRulesInternalServerError() *GetComplianceByRulesInternalServerError { + return &GetComplianceByRulesInternalServerError{} +} + +/*GetComplianceByRulesInternalServerError handles this case with default header values. + +Internal server error. +*/ +type GetComplianceByRulesInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *GetComplianceByRulesInternalServerError) Error() string { + return fmt.Sprintf("[GET /scans/{scan_id}/compliance_by_rules][%d] getComplianceByRulesInternalServerError %+v", 500, o.Payload) +} + +func (o *GetComplianceByRulesInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/scans/get_scan_parameters.go b/client/scans/get_scan_parameters.go new file mode 100644 index 0000000..9d53889 --- /dev/null +++ b/client/scans/get_scan_parameters.go @@ -0,0 +1,136 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scans + +// 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" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewGetScanParams creates a new GetScanParams object +// with the default values initialized. +func NewGetScanParams() *GetScanParams { + var () + return &GetScanParams{ + + timeout: cr.DefaultTimeout, + } +} + +// NewGetScanParamsWithTimeout creates a new GetScanParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewGetScanParamsWithTimeout(timeout time.Duration) *GetScanParams { + var () + return &GetScanParams{ + + timeout: timeout, + } +} + +// NewGetScanParamsWithContext creates a new GetScanParams object +// with the default values initialized, and the ability to set a context for a request +func NewGetScanParamsWithContext(ctx context.Context) *GetScanParams { + var () + return &GetScanParams{ + + Context: ctx, + } +} + +// NewGetScanParamsWithHTTPClient creates a new GetScanParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewGetScanParamsWithHTTPClient(client *http.Client) *GetScanParams { + var () + return &GetScanParams{ + HTTPClient: client, + } +} + +/*GetScanParams contains all the parameters to send to the API endpoint +for the get scan operation typically these are written to a http.Request +*/ +type GetScanParams struct { + + /*ScanID + Scan ID. + + */ + ScanID string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the get scan params +func (o *GetScanParams) WithTimeout(timeout time.Duration) *GetScanParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the get scan params +func (o *GetScanParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the get scan params +func (o *GetScanParams) WithContext(ctx context.Context) *GetScanParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the get scan params +func (o *GetScanParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the get scan params +func (o *GetScanParams) WithHTTPClient(client *http.Client) *GetScanParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the get scan params +func (o *GetScanParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithScanID adds the scanID to the get scan params +func (o *GetScanParams) WithScanID(scanID string) *GetScanParams { + o.SetScanID(scanID) + return o +} + +// SetScanID adds the scanId to the get scan params +func (o *GetScanParams) SetScanID(scanID string) { + o.ScanID = scanID +} + +// WriteToRequest writes these params to a swagger request +func (o *GetScanParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // path param scan_id + if err := r.SetPathParam("scan_id", o.ScanID); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/scans/get_scan_responses.go b/client/scans/get_scan_responses.go new file mode 100644 index 0000000..f6130d7 --- /dev/null +++ b/client/scans/get_scan_responses.go @@ -0,0 +1,211 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scans + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// GetScanReader is a Reader for the GetScan structure. +type GetScanReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *GetScanReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewGetScanOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 401: + result := NewGetScanUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 403: + result := NewGetScanForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 404: + result := NewGetScanNotFound() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewGetScanInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewGetScanOK creates a GetScanOK with default headers values +func NewGetScanOK() *GetScanOK { + return &GetScanOK{} +} + +/*GetScanOK handles this case with default header values. + +Scan details. +*/ +type GetScanOK struct { + Payload *models.ScanWithSummary +} + +func (o *GetScanOK) Error() string { + return fmt.Sprintf("[GET /scans/{scan_id}][%d] getScanOK %+v", 200, o.Payload) +} + +func (o *GetScanOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.ScanWithSummary) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetScanUnauthorized creates a GetScanUnauthorized with default headers values +func NewGetScanUnauthorized() *GetScanUnauthorized { + return &GetScanUnauthorized{} +} + +/*GetScanUnauthorized handles this case with default header values. + +Authentication error. +*/ +type GetScanUnauthorized struct { + Payload *models.AuthenticationError +} + +func (o *GetScanUnauthorized) Error() string { + return fmt.Sprintf("[GET /scans/{scan_id}][%d] getScanUnauthorized %+v", 401, o.Payload) +} + +func (o *GetScanUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthenticationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetScanForbidden creates a GetScanForbidden with default headers values +func NewGetScanForbidden() *GetScanForbidden { + return &GetScanForbidden{} +} + +/*GetScanForbidden handles this case with default header values. + +Authorization error. +*/ +type GetScanForbidden struct { + Payload *models.AuthorizationError +} + +func (o *GetScanForbidden) Error() string { + return fmt.Sprintf("[GET /scans/{scan_id}][%d] getScanForbidden %+v", 403, o.Payload) +} + +func (o *GetScanForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthorizationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetScanNotFound creates a GetScanNotFound with default headers values +func NewGetScanNotFound() *GetScanNotFound { + return &GetScanNotFound{} +} + +/*GetScanNotFound handles this case with default header values. + +Not found error. +*/ +type GetScanNotFound struct { + Payload *models.NotFoundError +} + +func (o *GetScanNotFound) Error() string { + return fmt.Sprintf("[GET /scans/{scan_id}][%d] getScanNotFound %+v", 404, o.Payload) +} + +func (o *GetScanNotFound) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.NotFoundError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewGetScanInternalServerError creates a GetScanInternalServerError with default headers values +func NewGetScanInternalServerError() *GetScanInternalServerError { + return &GetScanInternalServerError{} +} + +/*GetScanInternalServerError handles this case with default header values. + +Internal server error. +*/ +type GetScanInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *GetScanInternalServerError) Error() string { + return fmt.Sprintf("[GET /scans/{scan_id}][%d] getScanInternalServerError %+v", 500, o.Payload) +} + +func (o *GetScanInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/scans/list_scans_parameters.go b/client/scans/list_scans_parameters.go new file mode 100644 index 0000000..e395760 --- /dev/null +++ b/client/scans/list_scans_parameters.go @@ -0,0 +1,393 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scans + +// 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/swag" + + strfmt "github.com/go-openapi/strfmt" +) + +// NewListScansParams creates a new ListScansParams object +// with the default values initialized. +func NewListScansParams() *ListScansParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + orderByDefault = string("created_at") + orderDirectionDefault = string("desc") + ) + return &ListScansParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + OrderBy: &orderByDefault, + OrderDirection: &orderDirectionDefault, + + timeout: cr.DefaultTimeout, + } +} + +// NewListScansParamsWithTimeout creates a new ListScansParams object +// with the default values initialized, and the ability to set a timeout on a request +func NewListScansParamsWithTimeout(timeout time.Duration) *ListScansParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + orderByDefault = string("created_at") + orderDirectionDefault = string("desc") + ) + return &ListScansParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + OrderBy: &orderByDefault, + OrderDirection: &orderDirectionDefault, + + timeout: timeout, + } +} + +// NewListScansParamsWithContext creates a new ListScansParams object +// with the default values initialized, and the ability to set a context for a request +func NewListScansParamsWithContext(ctx context.Context) *ListScansParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + orderByDefault = string("created_at") + orderDirectionDefault = string("desc") + ) + return &ListScansParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + OrderBy: &orderByDefault, + OrderDirection: &orderDirectionDefault, + + Context: ctx, + } +} + +// NewListScansParamsWithHTTPClient creates a new ListScansParams object +// with the default values initialized, and the ability to set a custom HTTPClient for a request +func NewListScansParamsWithHTTPClient(client *http.Client) *ListScansParams { + var ( + maxItemsDefault = int64(100) + offsetDefault = int64(0) + orderByDefault = string("created_at") + orderDirectionDefault = string("desc") + ) + return &ListScansParams{ + MaxItems: &maxItemsDefault, + Offset: &offsetDefault, + OrderBy: &orderByDefault, + OrderDirection: &orderDirectionDefault, + HTTPClient: client, + } +} + +/*ListScansParams contains all the parameters to send to the API endpoint +for the list scans operation typically these are written to a http.Request +*/ +type ListScansParams struct { + + /*EnvironmentID + ID of the environment to retrieve scans for. + + */ + EnvironmentID string + /*MaxItems + Maximum number of items to return. + + */ + MaxItems *int64 + /*Offset + Number of items to skip before returning. This parameter is used when the number of items spans multiple pages. + + */ + Offset *int64 + /*OrderBy + Field to sort the items by. + + */ + OrderBy *string + /*OrderDirection + Direction to sort the items in. + + */ + OrderDirection *string + /*RangeFrom + Earliest created_at time to return scans from. + + */ + RangeFrom *int64 + /*RangeTo + Latest created_at time to return scans from. + + */ + RangeTo *int64 + /*Status + Status to filter by. When not specified, all statuses will be returned. + + */ + Status []string + + timeout time.Duration + Context context.Context + HTTPClient *http.Client +} + +// WithTimeout adds the timeout to the list scans params +func (o *ListScansParams) WithTimeout(timeout time.Duration) *ListScansParams { + o.SetTimeout(timeout) + return o +} + +// SetTimeout adds the timeout to the list scans params +func (o *ListScansParams) SetTimeout(timeout time.Duration) { + o.timeout = timeout +} + +// WithContext adds the context to the list scans params +func (o *ListScansParams) WithContext(ctx context.Context) *ListScansParams { + o.SetContext(ctx) + return o +} + +// SetContext adds the context to the list scans params +func (o *ListScansParams) SetContext(ctx context.Context) { + o.Context = ctx +} + +// WithHTTPClient adds the HTTPClient to the list scans params +func (o *ListScansParams) WithHTTPClient(client *http.Client) *ListScansParams { + o.SetHTTPClient(client) + return o +} + +// SetHTTPClient adds the HTTPClient to the list scans params +func (o *ListScansParams) SetHTTPClient(client *http.Client) { + o.HTTPClient = client +} + +// WithEnvironmentID adds the environmentID to the list scans params +func (o *ListScansParams) WithEnvironmentID(environmentID string) *ListScansParams { + o.SetEnvironmentID(environmentID) + return o +} + +// SetEnvironmentID adds the environmentId to the list scans params +func (o *ListScansParams) SetEnvironmentID(environmentID string) { + o.EnvironmentID = environmentID +} + +// WithMaxItems adds the maxItems to the list scans params +func (o *ListScansParams) WithMaxItems(maxItems *int64) *ListScansParams { + o.SetMaxItems(maxItems) + return o +} + +// SetMaxItems adds the maxItems to the list scans params +func (o *ListScansParams) SetMaxItems(maxItems *int64) { + o.MaxItems = maxItems +} + +// WithOffset adds the offset to the list scans params +func (o *ListScansParams) WithOffset(offset *int64) *ListScansParams { + o.SetOffset(offset) + return o +} + +// SetOffset adds the offset to the list scans params +func (o *ListScansParams) SetOffset(offset *int64) { + o.Offset = offset +} + +// WithOrderBy adds the orderBy to the list scans params +func (o *ListScansParams) WithOrderBy(orderBy *string) *ListScansParams { + o.SetOrderBy(orderBy) + return o +} + +// SetOrderBy adds the orderBy to the list scans params +func (o *ListScansParams) SetOrderBy(orderBy *string) { + o.OrderBy = orderBy +} + +// WithOrderDirection adds the orderDirection to the list scans params +func (o *ListScansParams) WithOrderDirection(orderDirection *string) *ListScansParams { + o.SetOrderDirection(orderDirection) + return o +} + +// SetOrderDirection adds the orderDirection to the list scans params +func (o *ListScansParams) SetOrderDirection(orderDirection *string) { + o.OrderDirection = orderDirection +} + +// WithRangeFrom adds the rangeFrom to the list scans params +func (o *ListScansParams) WithRangeFrom(rangeFrom *int64) *ListScansParams { + o.SetRangeFrom(rangeFrom) + return o +} + +// SetRangeFrom adds the rangeFrom to the list scans params +func (o *ListScansParams) SetRangeFrom(rangeFrom *int64) { + o.RangeFrom = rangeFrom +} + +// WithRangeTo adds the rangeTo to the list scans params +func (o *ListScansParams) WithRangeTo(rangeTo *int64) *ListScansParams { + o.SetRangeTo(rangeTo) + return o +} + +// SetRangeTo adds the rangeTo to the list scans params +func (o *ListScansParams) SetRangeTo(rangeTo *int64) { + o.RangeTo = rangeTo +} + +// WithStatus adds the status to the list scans params +func (o *ListScansParams) WithStatus(status []string) *ListScansParams { + o.SetStatus(status) + return o +} + +// SetStatus adds the status to the list scans params +func (o *ListScansParams) SetStatus(status []string) { + o.Status = status +} + +// WriteToRequest writes these params to a swagger request +func (o *ListScansParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { + + if err := r.SetTimeout(o.timeout); err != nil { + return err + } + var res []error + + // query param environment_id + qrEnvironmentID := o.EnvironmentID + qEnvironmentID := qrEnvironmentID + if qEnvironmentID != "" { + if err := r.SetQueryParam("environment_id", qEnvironmentID); err != nil { + return err + } + } + + if o.MaxItems != nil { + + // query param max_items + var qrMaxItems int64 + if o.MaxItems != nil { + qrMaxItems = *o.MaxItems + } + qMaxItems := swag.FormatInt64(qrMaxItems) + if qMaxItems != "" { + if err := r.SetQueryParam("max_items", qMaxItems); err != nil { + return err + } + } + + } + + if o.Offset != nil { + + // query param offset + var qrOffset int64 + if o.Offset != nil { + qrOffset = *o.Offset + } + qOffset := swag.FormatInt64(qrOffset) + if qOffset != "" { + if err := r.SetQueryParam("offset", qOffset); err != nil { + return err + } + } + + } + + if o.OrderBy != nil { + + // query param order_by + var qrOrderBy string + if o.OrderBy != nil { + qrOrderBy = *o.OrderBy + } + qOrderBy := qrOrderBy + if qOrderBy != "" { + if err := r.SetQueryParam("order_by", qOrderBy); err != nil { + return err + } + } + + } + + if o.OrderDirection != nil { + + // query param order_direction + var qrOrderDirection string + if o.OrderDirection != nil { + qrOrderDirection = *o.OrderDirection + } + qOrderDirection := qrOrderDirection + if qOrderDirection != "" { + if err := r.SetQueryParam("order_direction", qOrderDirection); err != nil { + return err + } + } + + } + + if o.RangeFrom != nil { + + // query param range_from + var qrRangeFrom int64 + if o.RangeFrom != nil { + qrRangeFrom = *o.RangeFrom + } + qRangeFrom := swag.FormatInt64(qrRangeFrom) + if qRangeFrom != "" { + if err := r.SetQueryParam("range_from", qRangeFrom); err != nil { + return err + } + } + + } + + if o.RangeTo != nil { + + // query param range_to + var qrRangeTo int64 + if o.RangeTo != nil { + qrRangeTo = *o.RangeTo + } + qRangeTo := swag.FormatInt64(qrRangeTo) + if qRangeTo != "" { + if err := r.SetQueryParam("range_to", qRangeTo); err != nil { + return err + } + } + + } + + valuesStatus := o.Status + + joinedStatus := swag.JoinByFormat(valuesStatus, "multi") + // query array param status + if err := r.SetQueryParam("status", joinedStatus...); err != nil { + return err + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} diff --git a/client/scans/list_scans_responses.go b/client/scans/list_scans_responses.go new file mode 100644 index 0000000..542024b --- /dev/null +++ b/client/scans/list_scans_responses.go @@ -0,0 +1,211 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scans + +// 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" + + strfmt "github.com/go-openapi/strfmt" + + models "github.com/fugue/fugue-client/models" +) + +// ListScansReader is a Reader for the ListScans structure. +type ListScansReader struct { + formats strfmt.Registry +} + +// ReadResponse reads a server response into the received o. +func (o *ListScansReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { + switch response.Code() { + + case 200: + result := NewListScansOK() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return result, nil + + case 400: + result := NewListScansBadRequest() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 401: + result := NewListScansUnauthorized() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 403: + result := NewListScansForbidden() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + case 500: + result := NewListScansInternalServerError() + if err := result.readResponse(response, consumer, o.formats); err != nil { + return nil, err + } + return nil, result + + default: + return nil, runtime.NewAPIError("unknown error", response, response.Code()) + } +} + +// NewListScansOK creates a ListScansOK with default headers values +func NewListScansOK() *ListScansOK { + return &ListScansOK{} +} + +/*ListScansOK handles this case with default header values. + +List of scans. +*/ +type ListScansOK struct { + Payload *models.Scans +} + +func (o *ListScansOK) Error() string { + return fmt.Sprintf("[GET /scans][%d] listScansOK %+v", 200, o.Payload) +} + +func (o *ListScansOK) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.Scans) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListScansBadRequest creates a ListScansBadRequest with default headers values +func NewListScansBadRequest() *ListScansBadRequest { + return &ListScansBadRequest{} +} + +/*ListScansBadRequest handles this case with default header values. + +Bad request error. +*/ +type ListScansBadRequest struct { + Payload *models.BadRequestError +} + +func (o *ListScansBadRequest) Error() string { + return fmt.Sprintf("[GET /scans][%d] listScansBadRequest %+v", 400, o.Payload) +} + +func (o *ListScansBadRequest) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.BadRequestError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListScansUnauthorized creates a ListScansUnauthorized with default headers values +func NewListScansUnauthorized() *ListScansUnauthorized { + return &ListScansUnauthorized{} +} + +/*ListScansUnauthorized handles this case with default header values. + +Authentication error. +*/ +type ListScansUnauthorized struct { + Payload *models.AuthenticationError +} + +func (o *ListScansUnauthorized) Error() string { + return fmt.Sprintf("[GET /scans][%d] listScansUnauthorized %+v", 401, o.Payload) +} + +func (o *ListScansUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthenticationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListScansForbidden creates a ListScansForbidden with default headers values +func NewListScansForbidden() *ListScansForbidden { + return &ListScansForbidden{} +} + +/*ListScansForbidden handles this case with default header values. + +Authorization error. +*/ +type ListScansForbidden struct { + Payload *models.AuthorizationError +} + +func (o *ListScansForbidden) Error() string { + return fmt.Sprintf("[GET /scans][%d] listScansForbidden %+v", 403, o.Payload) +} + +func (o *ListScansForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.AuthorizationError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} + +// NewListScansInternalServerError creates a ListScansInternalServerError with default headers values +func NewListScansInternalServerError() *ListScansInternalServerError { + return &ListScansInternalServerError{} +} + +/*ListScansInternalServerError handles this case with default header values. + +Internal server error. +*/ +type ListScansInternalServerError struct { + Payload *models.InternalServerError +} + +func (o *ListScansInternalServerError) Error() string { + return fmt.Sprintf("[GET /scans][%d] listScansInternalServerError %+v", 500, o.Payload) +} + +func (o *ListScansInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { + + o.Payload = new(models.InternalServerError) + + // response payload + if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { + return err + } + + return nil +} diff --git a/client/scans/scans_client.go b/client/scans/scans_client.go new file mode 100644 index 0000000..e772fbd --- /dev/null +++ b/client/scans/scans_client.go @@ -0,0 +1,185 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package scans + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "github.com/go-openapi/runtime" + + strfmt "github.com/go-openapi/strfmt" +) + +// New creates a new scans API client. +func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client { + return &Client{transport: transport, formats: formats} +} + +/* +Client for scans API +*/ +type Client struct { + transport runtime.ClientTransport + formats strfmt.Registry +} + +/* +CreateScan creates and triggers a new environment scan + +Creates and triggers a new environment scan. +*/ +func (a *Client) CreateScan(params *CreateScanParams, authInfo runtime.ClientAuthInfoWriter) (*CreateScanCreated, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewCreateScanParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "createScan", + Method: "POST", + PathPattern: "/scans", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &CreateScanReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*CreateScanCreated), nil + +} + +/* +GetComplianceByResourceTypes lists compliance results by resource type for a scan + +Lists compliance results by resource type for a scan. +*/ +func (a *Client) GetComplianceByResourceTypes(params *GetComplianceByResourceTypesParams, authInfo runtime.ClientAuthInfoWriter) (*GetComplianceByResourceTypesOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetComplianceByResourceTypesParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getComplianceByResourceTypes", + Method: "GET", + PathPattern: "/scans/{scan_id}/compliance_by_resource_types", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &GetComplianceByResourceTypesReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*GetComplianceByResourceTypesOK), nil + +} + +/* +GetComplianceByRules lists compliance results by rule for a scan + +Lists compliance results by rule for a scan. +*/ +func (a *Client) GetComplianceByRules(params *GetComplianceByRulesParams, authInfo runtime.ClientAuthInfoWriter) (*GetComplianceByRulesOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetComplianceByRulesParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getComplianceByRules", + Method: "GET", + PathPattern: "/scans/{scan_id}/compliance_by_rules", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &GetComplianceByRulesReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*GetComplianceByRulesOK), nil + +} + +/* +GetScan retrieves details for a scan + +Retrieves details for a scan. +*/ +func (a *Client) GetScan(params *GetScanParams, authInfo runtime.ClientAuthInfoWriter) (*GetScanOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewGetScanParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "getScan", + Method: "GET", + PathPattern: "/scans/{scan_id}", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &GetScanReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*GetScanOK), nil + +} + +/* +ListScans lists scans for an environment + +Lists scans for an environment. +*/ +func (a *Client) ListScans(params *ListScansParams, authInfo runtime.ClientAuthInfoWriter) (*ListScansOK, error) { + // TODO: Validate the params before sending + if params == nil { + params = NewListScansParams() + } + + result, err := a.transport.Submit(&runtime.ClientOperation{ + ID: "listScans", + Method: "GET", + PathPattern: "/scans", + ProducesMediaTypes: []string{"application/json"}, + ConsumesMediaTypes: []string{"application/json"}, + Schemes: []string{"https"}, + Params: params, + Reader: &ListScansReader{formats: a.formats}, + AuthInfo: authInfo, + Context: params.Context, + Client: params.HTTPClient, + }) + if err != nil { + return nil, err + } + return result.(*ListScansOK), nil + +} + +// SetTransport changes the transport on the client +func (a *Client) SetTransport(transport runtime.ClientTransport) { + a.transport = transport +} diff --git a/cmd/client.go b/cmd/client.go new file mode 100644 index 0000000..b931238 --- /dev/null +++ b/cmd/client.go @@ -0,0 +1,99 @@ +package cmd + +import ( + "encoding/json" + "fmt" + "log" + "os" + + "github.com/fugue/fugue-client/client" + apiclient "github.com/fugue/fugue-client/client" + "github.com/go-openapi/runtime" + httptransport "github.com/go-openapi/runtime/client" + "github.com/go-openapi/strfmt" + "github.com/spf13/cobra" +) + +const ( + // DefaultHost is the default hostname of the Fugue API + DefaultHost = "api.riskmanager.fugue.co" + + // DefaultBase is the base path of the Fugue API + DefaultBase = "v0" +) + +func mustGetEnv(name string) string { + value := os.Getenv(name) + if value == "" { + fmt.Fprintf(os.Stderr, "Missing environment variable: %s\n", name) + os.Exit(1) + } + return value +} + +func getEnvWithDefault(name, defaultValue string) string { + value := os.Getenv(name) + if value == "" { + return defaultValue + } + return value +} + +func getClient() (*client.Fugue, runtime.ClientAuthInfoWriter) { + + clientID := mustGetEnv("FUGUE_API_ID") + clientSecret := mustGetEnv("FUGUE_API_SECRET") + + host := getEnvWithDefault("FUGUE_API_HOST", DefaultHost) + base := getEnvWithDefault("FUGUE_API_BASE", DefaultBase) + + transport := httptransport.New(host, base, []string{"https"}) + client := apiclient.New(transport, strfmt.Default) + + auth := httptransport.BasicAuth(clientID, clientSecret) + + return client, auth +} + +func showResponse(obj interface{}) { + js, err := json.Marshal(obj) + if err != nil { + log.Fatal(err) + } + fmt.Printf("%s\n", string(js)) +} + +func flagStringValue(cmd *cobra.Command, name string) string { + value, err := cmd.PersistentFlags().GetString(name) + if err != nil { + log.Fatal(err) + } + return value +} + +func flagBoolValue(cmd *cobra.Command, name string) bool { + value, err := cmd.PersistentFlags().GetBool(name) + if err != nil { + log.Fatal(err) + } + return value +} + +func flagInt64Value(cmd *cobra.Command, name string) int64 { + value, err := cmd.PersistentFlags().GetInt64(name) + if err != nil { + log.Fatal(err) + } + return value +} + +func flagStringSliceValue(cmd *cobra.Command, name string) []string { + if cmd.PersistentFlags().Lookup(name).Changed { + value, err := cmd.PersistentFlags().GetStringSlice(name) + if err != nil { + log.Fatal(err) + } + return value + } + return nil +} diff --git a/cmd/create.go b/cmd/create.go new file mode 100644 index 0000000..e189e8b --- /dev/null +++ b/cmd/create.go @@ -0,0 +1,14 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +var createCmd = &cobra.Command{ + Use: "create", + Short: "Create a resource", +} + +func init() { + rootCmd.AddCommand(createCmd) +} diff --git a/cmd/createEnvironment.go b/cmd/createEnvironment.go new file mode 100644 index 0000000..b93f92a --- /dev/null +++ b/cmd/createEnvironment.go @@ -0,0 +1,76 @@ +package cmd + +import ( + "log" + + "github.com/fugue/fugue-client/client/environments" + "github.com/fugue/fugue-client/models" + "github.com/spf13/cobra" +) + +type createEnvironmentOptions struct { + Name string + Region string + Provider string + Role string + ScanInterval int64 + ComplianceFamilies []string + RemediationResourceTypes []string + SurveyResourceTypes []string + ScanScheduleEnabled bool +} + +// NewCreateEnvironmentCommand returns a command that creates an environment +func NewCreateEnvironmentCommand() *cobra.Command { + + var opts createEnvironmentOptions + + cmd := &cobra.Command{ + Use: "environment", + Short: "Create an environment", + Aliases: []string{"env"}, + Run: func(cmd *cobra.Command, args []string) { + + client, auth := getClient() + + params := environments.NewCreateEnvironmentParams() + params.Environment = &models.CreateEnvironmentInput{ + ComplianceFamilies: opts.ComplianceFamilies, + Name: opts.Name, + Provider: opts.Provider, + ProviderOptions: &models.ProviderOptions{ + Aws: &models.ProviderOptionsAws{ + Region: opts.Region, + RoleArn: opts.Role, + }, + }, + ScanInterval: opts.ScanInterval, + SurveyResourceTypes: opts.SurveyResourceTypes, + RemediateResourceTypes: opts.RemediationResourceTypes, + ScanScheduleEnabled: opts.ScanScheduleEnabled, + } + + resp, err := client.Environments.CreateEnvironment(params, auth) + if err != nil { + log.Fatal(err) + } + showResponse(resp.Payload) + }, + } + + cmd.Flags().StringVar(&opts.Name, "name", "", "Environment name") + cmd.Flags().StringVar(&opts.Region, "region", "", "AWS region") + cmd.Flags().StringVar(&opts.Provider, "provider", "", "Provider: aws | aws_govcloud") + cmd.Flags().StringVar(&opts.Role, "role", "", "AWS IAM role arn") + cmd.Flags().Int64Var(&opts.ScanInterval, "scan-interval", 0, "Scan interval (seconds)") + cmd.Flags().StringSliceVar(&opts.ComplianceFamilies, "compliance-families", nil, "Compliance families") + cmd.Flags().StringSliceVar(&opts.RemediationResourceTypes, "remediation-resource-types", nil, "Remediation resource types") + cmd.Flags().StringSliceVar(&opts.SurveyResourceTypes, "survey-resource-types", nil, "Survey resource types") + cmd.Flags().BoolVar(&opts.ScanScheduleEnabled, "scan-schedule-enabled", false, "Scan schedule enabled") + + return cmd +} + +func init() { + createCmd.AddCommand(NewCreateEnvironmentCommand()) +} diff --git a/cmd/createPolicy.go b/cmd/createPolicy.go new file mode 100644 index 0000000..f0e126b --- /dev/null +++ b/cmd/createPolicy.go @@ -0,0 +1,51 @@ +package cmd + +import ( + "github.com/fugue/fugue-client/client/metadata" + "github.com/fugue/fugue-client/models" + "github.com/spf13/cobra" +) + +type createPolicyOptions struct { + Provider string + RemediationResourceTypes []string + SurveyResourceTypes []string +} + +// NewCreatePolicyCommand returns a command that creates an IAM policy +// that can be used to allow Fugue to scan an environment +func NewCreatePolicyCommand() *cobra.Command { + + var opts createPolicyOptions + + cmd := &cobra.Command{ + Use: "policy", + Short: "Get an AWS IAM policy for survey and remediation", + Run: func(cmd *cobra.Command, args []string) { + + client, auth := getClient() + + params := metadata.NewCreatePolicyParams() + params.Provider = opts.Provider + params.Input = &models.CreatePolicyInput{ + SurveyResourceTypes: opts.SurveyResourceTypes, + RemediateResourceTypes: opts.RemediationResourceTypes, + } + + resp, err := client.Metadata.CreatePolicy(params, auth) + CheckErr(err) + + showResponse(resp.Payload) + }, + } + + cmd.Flags().StringVar(&opts.Provider, "provider", "aws", "Cloud provider [aws | aws_govcloud]") + cmd.Flags().StringSliceVar(&opts.RemediationResourceTypes, "remediation-types", nil, "Remediation resource types") + cmd.Flags().StringSliceVar(&opts.SurveyResourceTypes, "survey-types", nil, "Survey resource types") + + return cmd +} + +func init() { + getCmd.AddCommand(NewCreatePolicyCommand()) +} diff --git a/cmd/delete.go b/cmd/delete.go new file mode 100644 index 0000000..c5c3bda --- /dev/null +++ b/cmd/delete.go @@ -0,0 +1,14 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +var deleteCmd = &cobra.Command{ + Use: "delete", + Short: "Delete a resource", +} + +func init() { + rootCmd.AddCommand(deleteCmd) +} diff --git a/cmd/deleteEnvironment.go b/cmd/deleteEnvironment.go new file mode 100644 index 0000000..f6fa474 --- /dev/null +++ b/cmd/deleteEnvironment.go @@ -0,0 +1,32 @@ +package cmd + +import ( + "github.com/fugue/fugue-client/client/environments" + "github.com/spf13/cobra" +) + +// NewDeleteEnvironmentCommand returns a command that deletes an environment +func NewDeleteEnvironmentCommand() *cobra.Command { + + cmd := &cobra.Command{ + Use: "environment [environment_id]", + Aliases: []string{"env"}, + Short: "Deletes an environment", + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, args []string) { + + client, auth := getClient() + + params := environments.NewDeleteEnvironmentParams() + params.EnvironmentID = args[0] + + _, err := client.Environments.DeleteEnvironment(params, auth) + CheckErr(err) + }, + } + return cmd +} + +func init() { + deleteCmd.AddCommand(NewDeleteEnvironmentCommand()) +} diff --git a/cmd/get.go b/cmd/get.go new file mode 100644 index 0000000..984ba58 --- /dev/null +++ b/cmd/get.go @@ -0,0 +1,14 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +var getCmd = &cobra.Command{ + Use: "get", + Short: "Retrieve a resource", +} + +func init() { + rootCmd.AddCommand(getCmd) +} diff --git a/cmd/getEnvironment.go b/cmd/getEnvironment.go new file mode 100644 index 0000000..6fa16d4 --- /dev/null +++ b/cmd/getEnvironment.go @@ -0,0 +1,67 @@ +package cmd + +import ( + "fmt" + + "github.com/fugue/fugue-client/client/environments" + "github.com/fugue/fugue-client/format" + "github.com/spf13/cobra" +) + +type Item struct { + Key string + Value interface{} +} + +// NewGetEnvironmentCommand returns a command that retrieves environment details +func NewGetEnvironmentCommand() *cobra.Command { + + cmd := &cobra.Command{ + Use: "environment [environment_id]", + Aliases: []string{"env"}, + Short: "Retrieve details for an environment", + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, args []string) { + + client, auth := getClient() + + params := environments.NewGetEnvironmentParams() + params.EnvironmentID = args[0] + + resp, err := client.Environments.GetEnvironment(params, auth) + CheckErr(err) + + env := resp.Payload + + items := []interface{}{ + Item{"ID", env.ID}, + Item{"Name", env.Name}, + Item{"Provider", env.Provider}, + Item{"ScanInterval", env.ScanInterval}, + Item{"LastScanAt", env.LastScanAt}, + Item{"NextScanAt", env.NextScanAt}, + Item{"ScanStatus", env.ScanStatus}, + Item{"Compliance Families", env.ComplianceFamilies}, + Item{"Drift", env.Drift}, + Item{"Remediation", env.Remediation}, + } + + table, err := format.Table(format.TableOpts{ + Rows: items, + Columns: []string{"Key", "Value"}, + ShowHeader: false, + }) + CheckErr(err) + + for _, tableRow := range table { + fmt.Println(tableRow) + } + }, + } + + return cmd +} + +func init() { + getCmd.AddCommand(NewGetEnvironmentCommand()) +} diff --git a/cmd/getResourceTypes.go b/cmd/getResourceTypes.go new file mode 100644 index 0000000..8109050 --- /dev/null +++ b/cmd/getResourceTypes.go @@ -0,0 +1,57 @@ +package cmd + +import ( + "fmt" + + "github.com/fugue/fugue-client/client/metadata" + "github.com/spf13/cobra" +) + +type getResourceTypesOptions struct { + Provider string + Region string +} + +// NewGetResourceTypesCommand returns a command that retrives available +// resource types for the given provider and region +func NewGetResourceTypesCommand() *cobra.Command { + + var opts getResourceTypesOptions + + cmd := &cobra.Command{ + Use: "types", + Short: "List supported resource types", + Aliases: []string{"resource-types"}, + Run: func(cmd *cobra.Command, args []string) { + + client, _ := getClient() + + params := metadata.NewGetResourceTypesParams() + params.Provider = opts.Provider + + if opts.Provider == "aws" || opts.Provider == "aws_govcloud" { + if opts.Region == "" { + Fatal("Must specify a region", 1) + } + params.Region = &opts.Region + } + + resp, err := client.Metadata.GetResourceTypes(params) + CheckErr(err) + + for _, rtype := range resp.Payload.ResourceTypes { + fmt.Println(rtype) + } + }, + } + + cmd.Flags().StringVar(&opts.Provider, "provider", "aws", "Cloud provider [aws | aws_govcloud | azure]") + cmd.Flags().StringVar(&opts.Region, "region", "", "Region") + cmd.MarkFlagRequired("provider") + + return cmd +} + +func init() { + getCmd.AddCommand(NewGetResourceTypesCommand()) +} diff --git a/cmd/getScan.go b/cmd/getScan.go new file mode 100644 index 0000000..0c5b0e9 --- /dev/null +++ b/cmd/getScan.go @@ -0,0 +1,34 @@ +package cmd + +import ( + "github.com/fugue/fugue-client/client/scans" + "github.com/spf13/cobra" +) + +// NewGetScanCommand returns a command that retrives details of a single scan +func NewGetScanCommand() *cobra.Command { + + cmd := &cobra.Command{ + Use: "scan [scan_id]", + Short: "Get scan details", + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, args []string) { + + client, auth := getClient() + + params := scans.NewGetScanParams() + params.ScanID = args[0] + + resp, err := client.Scans.GetScan(params, auth) + CheckErr(err) + + showResponse(resp.Payload) + }, + } + + return cmd +} + +func init() { + getCmd.AddCommand(NewGetScanCommand()) +} diff --git a/cmd/getScanComplianceByResourceTypes.go b/cmd/getScanComplianceByResourceTypes.go new file mode 100644 index 0000000..6a5d6b7 --- /dev/null +++ b/cmd/getScanComplianceByResourceTypes.go @@ -0,0 +1,82 @@ +package cmd + +import ( + "fmt" + + "github.com/fugue/fugue-client/client/scans" + "github.com/fugue/fugue-client/format" + "github.com/spf13/cobra" +) + +type getScanComplianceByResourceTypesOptions struct { + Offset int64 + MaxItems int64 + ResourceTypes []string + Families []string + Columns []string +} + +// NewGetScanComplianceByResourceTypesCommand returns a command that retrives +// compliance by resource types +func NewGetScanComplianceByResourceTypesCommand() *cobra.Command { + + var opts getScanComplianceByResourceTypesOptions + + cmd := &cobra.Command{ + Use: "compliance-by-resource-types [scan_id]", + Short: "Show compliance results by resource type", + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, args []string) { + + client, auth := getClient() + + params := scans.NewGetComplianceByResourceTypesParams() + params.ScanID = args[0] + + if opts.Offset > 0 { + params.Offset = &opts.Offset + } + if opts.MaxItems > 0 { + params.MaxItems = &opts.MaxItems + } + if len(opts.ResourceTypes) > 0 { + params.ResourceType = opts.ResourceTypes + } + if len(opts.Families) > 0 { + params.Family = opts.Families + } + + resp, err := client.Scans.GetComplianceByResourceTypes(params, auth) + CheckErr(err) + + rtypes := resp.Payload.Items + rows := make([]interface{}, len(rtypes)) + for i, rtype := range rtypes { + rows[i] = rtype + } + + table, err := format.Table(format.TableOpts{ + Rows: rows, + Columns: opts.Columns, + ShowHeader: true, + }) + CheckErr(err) + + for _, tableRow := range table { + fmt.Println(tableRow) + } + }, + } + + cmd.Flags().Int64Var(&opts.Offset, "offset", 0, "Offset") + cmd.Flags().Int64Var(&opts.MaxItems, "max-items", 0, "Max items") + cmd.Flags().StringSliceVar(&opts.ResourceTypes, "resource-type", nil, "Resource type filter") + cmd.Flags().StringSliceVar(&opts.Families, "family", nil, "Compliance family filter") + cmd.Flags().StringSliceVar(&opts.Columns, "columns", []string{"ResourceType", "Compliant", "Total"}, "columns to show") + + return cmd +} + +func init() { + getCmd.AddCommand(NewGetScanComplianceByResourceTypesCommand()) +} diff --git a/cmd/getScanComplianceByRules.go b/cmd/getScanComplianceByRules.go new file mode 100644 index 0000000..3c5cd95 --- /dev/null +++ b/cmd/getScanComplianceByRules.go @@ -0,0 +1,82 @@ +package cmd + +import ( + "fmt" + + "github.com/fugue/fugue-client/client/scans" + "github.com/fugue/fugue-client/format" + "github.com/spf13/cobra" +) + +type getScanComplianceByRulesOptions struct { + Offset int64 + MaxItems int64 + Results []string + Families []string + Columns []string +} + +// NewGetScanComplianceByRulesCommand returns a command that retrives +// compliance by rule +func NewGetScanComplianceByRulesCommand() *cobra.Command { + + var opts getScanComplianceByRulesOptions + + cmd := &cobra.Command{ + Use: "compliance-by-rules [scan_id]", + Short: "Show compliance results by rule", + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, args []string) { + + client, auth := getClient() + + params := scans.NewGetComplianceByRulesParams() + params.ScanID = args[0] + + if opts.Offset > 0 { + params.Offset = &opts.Offset + } + if opts.MaxItems > 0 { + params.MaxItems = &opts.MaxItems + } + if len(opts.Results) > 0 { + params.Result = opts.Results + } + if len(opts.Families) > 0 { + params.Family = opts.Families + } + + resp, err := client.Scans.GetComplianceByRules(params, auth) + CheckErr(err) + + rules := resp.Payload.Items + rows := make([]interface{}, len(rules)) + for i, rule := range rules { + rows[i] = rule + } + + table, err := format.Table(format.TableOpts{ + Rows: rows, + Columns: opts.Columns, + ShowHeader: true, + }) + CheckErr(err) + + for _, tableRow := range table { + fmt.Println(tableRow) + } + }, + } + + cmd.Flags().Int64Var(&opts.Offset, "offset", 0, "Offset") + cmd.Flags().Int64Var(&opts.MaxItems, "max-items", 0, "Max items") + cmd.Flags().StringSliceVar(&opts.Results, "result", nil, "Rule result filter") + cmd.Flags().StringSliceVar(&opts.Families, "family", nil, "Compliance family filter") + cmd.Flags().StringSliceVar(&opts.Columns, "columns", []string{"Family", "Rule", "Result"}, "columns to show") + + return cmd +} + +func init() { + getCmd.AddCommand(NewGetScanComplianceByRulesCommand()) +} diff --git a/cmd/list.go b/cmd/list.go new file mode 100644 index 0000000..e4c8c26 --- /dev/null +++ b/cmd/list.go @@ -0,0 +1,14 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +var listCmd = &cobra.Command{ + Use: "list", + Short: "List a collection of resources", +} + +func init() { + rootCmd.AddCommand(listCmd) +} diff --git a/cmd/listEnvironments.go b/cmd/listEnvironments.go new file mode 100644 index 0000000..c0b11ed --- /dev/null +++ b/cmd/listEnvironments.go @@ -0,0 +1,86 @@ +package cmd + +import ( + "fmt" + "sort" + + "github.com/fugue/fugue-client/client/environments" + "github.com/fugue/fugue-client/format" + "github.com/spf13/cobra" +) + +type listEnvironmentsOptions struct { + Offset int64 + MaxItems int64 + OrderBy string + OrderDirection string + Columns []string +} + +// NewListEnvironmentsCommand returns a command that lists environments in Fugue +func NewListEnvironmentsCommand() *cobra.Command { + + var opts listEnvironmentsOptions + + cmd := &cobra.Command{ + Use: "environments", + Short: "Lists details for multiple environments", + Long: `Lists details for multiple environments`, + Aliases: []string{"envs", "env"}, + Run: func(cmd *cobra.Command, args []string) { + + client, auth := getClient() + + params := environments.NewListEnvironmentsParams() + if opts.Offset > 0 { + params.Offset = &opts.Offset + } + if opts.MaxItems > 0 { + params.MaxItems = &opts.MaxItems + } + if opts.OrderBy != "" { + params.OrderBy = &opts.OrderBy + } + if opts.OrderDirection != "" { + params.OrderDirection = &opts.OrderDirection + } + + resp, err := client.Environments.ListEnvironments(params, auth) + CheckErr(err) + + environments := resp.Payload.Items + + sort.Slice(environments, func(i, j int) bool { + return environments[i].Name < environments[j].Name + }) + + rows := make([]interface{}, len(environments)) + for i, env := range environments { + rows[i] = env + } + + table, err := format.Table(format.TableOpts{ + Rows: rows, + Columns: opts.Columns, + ShowHeader: true, + }) + CheckErr(err) + + for _, tableRow := range table { + fmt.Println(tableRow) + } + }, + } + + cmd.Flags().Int64Var(&opts.Offset, "offset", 0, "offset into results") + cmd.Flags().Int64Var(&opts.MaxItems, "max-items", 0, "max items to return") + cmd.Flags().StringVar(&opts.OrderBy, "order-by", "", "order by attribute") + cmd.Flags().StringVar(&opts.OrderDirection, "order-direction", "", "order by direction [asc | desc]") + cmd.Flags().StringSliceVar(&opts.Columns, "columns", []string{"ID", "Name", "Provider", "ScanStatus"}, "columns to show") + + return cmd +} + +func init() { + listCmd.AddCommand(NewListEnvironmentsCommand()) +} diff --git a/cmd/listEvents.go b/cmd/listEvents.go new file mode 100644 index 0000000..a1a4a98 --- /dev/null +++ b/cmd/listEvents.go @@ -0,0 +1,103 @@ +package cmd + +import ( + "fmt" + + "github.com/fugue/fugue-client/client/events" + "github.com/fugue/fugue-client/format" + "github.com/spf13/cobra" +) + +type listEventsOptions struct { + Offset int64 + MaxItems int64 + RangeFrom int64 + RangeTo int64 + EventType []string + Change []string + Remediated []string + ResourceType []string + Columns []string +} + +// NewListEventsCommand returns a command that lists events in an environment +func NewListEventsCommand() *cobra.Command { + + var opts listEventsOptions + + cmd := &cobra.Command{ + Use: "events [environment_id]", + Short: "List environment events", + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, args []string) { + + client, auth := getClient() + + params := events.NewListEventsParams() + params.EnvironmentID = args[0] + + if opts.Offset > 0 { + params.Offset = &opts.Offset + } + if opts.MaxItems > 0 { + params.MaxItems = &opts.MaxItems + } + if opts.RangeFrom > 0 { + params.RangeFrom = &opts.RangeFrom + } + if opts.RangeTo > 0 { + params.RangeTo = &opts.RangeTo + } + if len(opts.EventType) > 0 { + params.EventType = opts.EventType + } + if len(opts.Change) > 0 { + params.Change = opts.Change + } + if len(opts.Remediated) > 0 { + params.Remediated = opts.Remediated + } + if len(opts.ResourceType) > 0 { + params.ResourceType = opts.ResourceType + } + + resp, err := client.Events.ListEvents(params, auth) + CheckErr(err) + + events := resp.Payload.Items + + rows := make([]interface{}, len(events)) + for i, event := range events { + rows[i] = event + } + + table, err := format.Table(format.TableOpts{ + Rows: rows, + Columns: opts.Columns, + ShowHeader: true, + }) + CheckErr(err) + + for _, tableRow := range table { + fmt.Println(tableRow) + } + }, + } + + cmd.Flags().String("environment-id", "", "Environment ID (required)") + cmd.Flags().Int64("offset", 0, "Offset") + cmd.Flags().Int64("max-items", 0, "Max items") + cmd.Flags().Int64("range-from", 0, "Range from") + cmd.Flags().Int64("range-to", 0, "Range to") + cmd.Flags().StringSlice("event-type", nil, "Event types") + cmd.Flags().StringSlice("change", nil, "Change") + cmd.Flags().StringSlice("remediated", nil, "Remediated") + cmd.Flags().StringSlice("resource-type", nil, "Resource types") + cmd.Flags().StringSliceVar(&opts.Columns, "columns", []string{"ID", "EventType", "CreatedAt"}, "columns to show") + + return cmd +} + +func init() { + listCmd.AddCommand(NewListEventsCommand()) +} diff --git a/cmd/listScans.go b/cmd/listScans.go new file mode 100644 index 0000000..72e61df --- /dev/null +++ b/cmd/listScans.go @@ -0,0 +1,96 @@ +package cmd + +import ( + "fmt" + + "github.com/fugue/fugue-client/client/scans" + "github.com/fugue/fugue-client/format" + "github.com/spf13/cobra" +) + +type listScansOptions struct { + Offset int64 + MaxItems int64 + OrderBy string + OrderDirection string + Status []string + RangeFrom int64 + RangeTo int64 +} + +// NewListScansCommand returns a command that lists scans in Fugue +func NewListScansCommand() *cobra.Command { + + var opts listScansOptions + + cmd := &cobra.Command{ + Use: "scans [environment_id]", + Short: "List scans belonging to an environment", + Aliases: []string{"scan"}, + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, args []string) { + + client, auth := getClient() + + params := scans.NewListScansParams() + params.EnvironmentID = args[0] + + if opts.Offset > 0 { + params.Offset = &opts.Offset + } + if opts.MaxItems > 0 { + params.MaxItems = &opts.MaxItems + } + if opts.RangeFrom > 0 { + params.RangeFrom = &opts.RangeFrom + } + if opts.RangeTo > 0 { + params.RangeTo = &opts.RangeTo + } + if opts.OrderBy != "" { + params.OrderBy = &opts.OrderBy + } + if opts.OrderDirection != "" { + params.OrderDirection = &opts.OrderDirection + } + if len(opts.Status) > 0 { + params.Status = opts.Status + } + + resp, err := client.Scans.ListScans(params, auth) + CheckErr(err) + + scans := resp.Payload.Items + + rows := make([]interface{}, len(scans)) + for i, scan := range scans { + rows[i] = scan + } + + table, err := format.Table(format.TableOpts{ + Rows: rows, + Columns: []string{"ID", "FinishedAt", "Status", "Message"}, + ShowHeader: true, + }) + CheckErr(err) + + for _, tableRow := range table { + fmt.Println(tableRow) + } + }, + } + + cmd.Flags().Int64Var(&opts.Offset, "offset", 0, "offset into results") + cmd.Flags().Int64Var(&opts.MaxItems, "max-items", 20, "max items to return") + cmd.Flags().StringVar(&opts.OrderBy, "order-by", "", "order by attribute") + cmd.Flags().StringVar(&opts.OrderDirection, "order-direction", "", "order by direction [asc | desc]") + cmd.Flags().StringSliceVar(&opts.Status, "status", nil, "Scan status filter [IN-PROGRESS | SUCCESS | ERROR]") + cmd.Flags().Int64Var(&opts.RangeFrom, "range-from", 0, "Range from time filter") + cmd.Flags().Int64Var(&opts.RangeTo, "range-to", 0, "Range to time filter") + + return cmd +} + +func init() { + listCmd.AddCommand(NewListScansCommand()) +} diff --git a/cmd/root.go b/cmd/root.go new file mode 100644 index 0000000..7887b5f --- /dev/null +++ b/cmd/root.go @@ -0,0 +1,89 @@ +package cmd + +import ( + "fmt" + "os" + "strings" + + homedir "github.com/mitchellh/go-homedir" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +const ( + // DefaultErrorExitCode is the exit code value when an error occurs + DefaultErrorExitCode = 1 +) + +var cfgFile string + +// rootCmd represents the base command when called without any subcommands +var rootCmd = &cobra.Command{ + Use: "fugue-client", + Short: "Fugue API Client", + Long: ``, + // Uncomment the following line if your bare application + // has an action associated with it: + // Run: func(cmd *cobra.Command, args []string) { }, +} + +// Execute adds all child commands to the root command and sets flags appropriately. +// This is called by main.main(). It only needs to happen once to the rootCmd. +func Execute() { + CheckErr(rootCmd.Execute()) +} + +func init() { + cobra.OnInitialize(initConfig) + + // Application global flags + // rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.fugue.yaml)") +} + +// initConfig reads in config file and ENV variables if set. +func initConfig() { + if cfgFile != "" { + // Use config file from the flag. + viper.SetConfigFile(cfgFile) + } else { + // Find home directory. + home, err := homedir.Dir() + CheckErr(err) + + // Search config in home directory with name ".fugue" (without extension). + viper.AddConfigPath(home) + viper.SetConfigName(".fugue") + } + + viper.AutomaticEnv() // read in environment variables that match + + // If a config file is found, read it in. + if err := viper.ReadInConfig(); err == nil { + fmt.Println("Using config file:", viper.ConfigFileUsed()) + } +} + +// Fatal prints the message (if provided) and then exits. +func Fatal(msg string, code int) { + if len(msg) > 0 { + // add newline if needed + if !strings.HasSuffix(msg, "\n") { + msg += "\n" + } + fmt.Fprint(os.Stderr, msg) + } + os.Exit(code) +} + +// CheckErr prints a user friendly error to STDERR and exits with a non-zero +// exit code. Unrecognized errors will be printed with an "error: " prefix. +func CheckErr(err error) { + if err == nil { + return + } + msg := err.Error() + if !strings.HasPrefix(msg, "error: ") { + msg = fmt.Sprintf("error: %s", msg) + } + Fatal(msg, DefaultErrorExitCode) +} diff --git a/cmd/triggerScan.go b/cmd/triggerScan.go new file mode 100644 index 0000000..2898763 --- /dev/null +++ b/cmd/triggerScan.go @@ -0,0 +1,36 @@ +package cmd + +import ( + "fmt" + + "github.com/fugue/fugue-client/client/scans" + "github.com/spf13/cobra" +) + +// NewTriggerScanCommand returns a command that scans a specified environment +func NewTriggerScanCommand() *cobra.Command { + + cmd := &cobra.Command{ + Use: "scan [environment_id]", + Short: "Trigger a scan", + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, args []string) { + + client, auth := getClient() + + params := scans.NewCreateScanParams() + params.EnvironmentID = args[0] + + resp, err := client.Scans.CreateScan(params, auth) + CheckErr(err) + + fmt.Println(resp.Payload.ID) + }, + } + + return cmd +} + +func init() { + rootCmd.AddCommand(NewTriggerScanCommand()) +} diff --git a/cmd/update.go b/cmd/update.go new file mode 100644 index 0000000..f39e322 --- /dev/null +++ b/cmd/update.go @@ -0,0 +1,14 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +var updateCmd = &cobra.Command{ + Use: "update", + Short: "Update a resource", +} + +func init() { + rootCmd.AddCommand(updateCmd) +} diff --git a/cmd/updateEnvironment.go b/cmd/updateEnvironment.go new file mode 100644 index 0000000..69d82b4 --- /dev/null +++ b/cmd/updateEnvironment.go @@ -0,0 +1,82 @@ +package cmd + +import ( + "github.com/fugue/fugue-client/client/environments" + "github.com/fugue/fugue-client/models" + "github.com/spf13/cobra" + "github.com/spf13/pflag" +) + +type updateEnvironmentOptions struct { + Name string + BaselineID string + ScanInterval int64 + ComplianceFamilies []string + RemediateResourceTypes []string + SurveyResourceTypes []string + Remediation bool + ScanScheduleEnabled bool +} + +// NewUpdateEnvironmentCommand returns a command that updates an environment +func NewUpdateEnvironmentCommand() *cobra.Command { + + var opts updateEnvironmentOptions + + cmd := &cobra.Command{ + Use: "environment", + Short: "Update environment settings", + Aliases: []string{"env"}, + Args: cobra.ExactArgs(1), + Run: func(cmd *cobra.Command, args []string) { + + client, auth := getClient() + + params := environments.NewUpdateEnvironmentParams() + params.EnvironmentID = args[0] + params.Environment = &models.UpdateEnvironmentInput{} + + // Using Visit here allows us to process only flags that were set + cmd.Flags().Visit(func(f *pflag.Flag) { + switch f.Name { + case "name": + params.Environment.Name = opts.Name + case "baseline-id": + params.Environment.BaselineID = opts.BaselineID + case "scan-interval": + params.Environment.ScanInterval = opts.ScanInterval + case "compliance-families": + params.Environment.ComplianceFamilies = opts.ComplianceFamilies + case "survey-resource-types": + params.Environment.SurveyResourceTypes = opts.SurveyResourceTypes + case "remediate-resource-types": + params.Environment.RemediateResourceTypes = opts.RemediateResourceTypes + case "remediation": + params.Environment.Remediation = opts.Remediation + case "scan-schedule-enabled": + params.Environment.ScanScheduleEnabled = opts.ScanScheduleEnabled + } + }) + + resp, err := client.Environments.UpdateEnvironment(params, auth) + CheckErr(err) + + showResponse(resp.Payload) + }, + } + + cmd.Flags().StringVar(&opts.Name, "name", "", "Environment name") + cmd.Flags().StringVar(&opts.BaselineID, "baseline-id", "", "Baseline scan ID") + cmd.Flags().Int64Var(&opts.ScanInterval, "scan-interval", 0, "Scan interval (seconds)") + cmd.Flags().StringSliceVar(&opts.ComplianceFamilies, "compliance-families", nil, "Compliance families") + cmd.Flags().StringSliceVar(&opts.RemediateResourceTypes, "remediate-resource-types", nil, "Remediation resource types") + cmd.Flags().StringSliceVar(&opts.SurveyResourceTypes, "survey-resource-types", nil, "Survey resource types") + cmd.Flags().BoolVar(&opts.Remediation, "remediation", false, "Remediation enabled") + cmd.Flags().BoolVar(&opts.ScanScheduleEnabled, "scan-schedule-enabled", false, "Scan schedule enabled") + + return cmd +} + +func init() { + updateCmd.AddCommand(NewUpdateEnvironmentCommand()) +} diff --git a/format/case.go b/format/case.go new file mode 100644 index 0000000..b141b63 --- /dev/null +++ b/format/case.go @@ -0,0 +1,15 @@ +package format + +import ( + "regexp" + "strings" +) + +var matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)") +var matchAllCap = regexp.MustCompile("([a-z0-9])([A-Z])") + +func toSnakeCase(str string) string { + snake := matchFirstCap.ReplaceAllString(str, "${1}_${2}") + snake = matchAllCap.ReplaceAllString(snake, "${1}_${2}") + return strings.ToLower(snake) +} diff --git a/format/format.go b/format/format.go new file mode 100644 index 0000000..a93466a --- /dev/null +++ b/format/format.go @@ -0,0 +1,167 @@ +package format + +import ( + "encoding/json" + "errors" + "fmt" + "strings" + + "github.com/fatih/structs" +) + +func getRowMaps(rows []interface{}) []map[string]interface{} { + result := []map[string]interface{}{} + for _, row := range rows { + result = append(result, structs.Map(row)) + } + return result +} + +func extractAttrs(item map[string]interface{}, attrs []string) ([]string, error) { + result := make([]string, len(attrs)) + for i, attr := range attrs { + value, ok := item[attr] + if !ok { + return nil, fmt.Errorf("Item has no attribute: %s", attr) + } + switch value.(type) { + case map[string]interface{}: + txt, err := json.Marshal(value) + if err != nil { + return nil, err + } + result[i] = fmt.Sprintf("%+v", string(txt)) + default: + result[i] = fmt.Sprintf("%v", value) + } + } + return result, nil +} + +func extractSliceAttrs(items []map[string]interface{}, attrs []string) ([][]string, error) { + result := make([][]string, len(items)) + for i, item := range items { + values, err := extractAttrs(item, attrs) + if err != nil { + return nil, err + } + result[i] = values + } + return result, nil +} + +func extractColumn(rows [][]string, column int) []string { + values := make([]string, len(rows)) + for i, row := range rows { + values[i] = row[column] + } + return values +} + +func columnWidths(rows [][]string, colNames []string, includeCols bool) []int { + + if len(rows) == 0 { + return nil + } + columnCount := len(colNames) + + widths := make([]int, columnCount) + + if includeCols { + for i, name := range colNames { + widths[i] = len(name) + } + } + + for _, row := range rows { + for colIndex, colValue := range row { + valLen := len(colValue) + if valLen > widths[colIndex] { + widths[colIndex] = valLen + } + } + } + return widths +} + +func columnFormats(widths []int) []string { + formats := make([]string, len(widths)) + for i, width := range widths { + formats[i] = fmt.Sprintf("%%-%ds", width) + } + return formats +} + +func sum(items []int) int { + result := 0 + for _, item := range items { + result += item + } + return result +} + +// TableOpts are options used when rendering a table +type TableOpts struct { + Rows []interface{} + Columns []string + Separator string + ShowHeader bool +} + +// Table builds a text table from the given data items and chosen columns. +// It returns a list of rows that can be printed. +func Table(opts TableOpts) ([]string, error) { + + if len(opts.Rows) == 0 { + return nil, errors.New("No rows to display") + } + if len(opts.Columns) == 0 { + return nil, errors.New("No columns to display") + } + + rowMaps := getRowMaps(opts.Rows) + + tableData, err := extractSliceAttrs(rowMaps, opts.Columns) + if err != nil { + return nil, err + } + + separator := " | " + if opts.Separator != "" { + separator = opts.Separator + } + + separatorLen := len(separator) + columnWidths := columnWidths(tableData, opts.Columns, opts.ShowHeader) + columnFormats := columnFormats(columnWidths) + tableWidth := sum(columnWidths) + separatorLen*(len(opts.Columns)-1) + + rowCount := len(tableData) + rowOffset := 0 + if opts.ShowHeader { + rowCount += 3 + rowOffset = 3 + } + rows := make([]string, rowCount) + + if opts.ShowHeader { + headers := make([]string, len(opts.Columns)) + for i, col := range opts.Columns { + colName := strings.ToUpper(toSnakeCase(col)) + headers[i] = fmt.Sprintf(columnFormats[i], colName) + } + rows[0] = strings.Repeat("=", tableWidth) + rows[1] = strings.Join(headers, separator) + rows[2] = strings.Repeat("=", tableWidth) + } + + for i, row := range tableData { + rowItems := make([]string, len(row)) + for h, item := range row { + rowItems[h] = fmt.Sprintf(columnFormats[h], item) + } + rows[i+rowOffset] = strings.Join(rowItems, separator) + } + + return rows, nil +} diff --git a/format/format_test.go b/format/format_test.go new file mode 100644 index 0000000..6c7a26a --- /dev/null +++ b/format/format_test.go @@ -0,0 +1,74 @@ +package format + +import ( + "testing" +) + +type item struct { + Name string + Age int + Married bool +} + +func TestFormatTable(t *testing.T) { + + items := []interface{}{ + item{"hank", 32, true}, + item{"peggy", 31, true}, + item{"bobby", 1, false}, + } + + rows, err := Table(TableOpts{ + Rows: items, + Columns: []string{"Name", "Age"}, + ShowHeader: true, + }) + if err != nil { + t.Fatal(err) + } + + expected := []string{ + "===========", + "NAME | AGE", + "===========", + "hank | 32 ", + "peggy | 31 ", + "bobby | 1 ", + } + + for i, row := range rows { + if row != expected[i] { + t.Errorf("Got: '%s' Expected: '%s'", row, expected[i]) + } + } +} + +func TestFormatTableNoHeader(t *testing.T) { + + items := []interface{}{ + item{"a", 0, true}, + item{"abcd", 31, true}, + item{"abcdef", 1, false}, + } + + rows, err := Table(TableOpts{ + Rows: items, + Columns: []string{"Name", "Married"}, + Separator: " . ", + }) + if err != nil { + t.Fatal(err) + } + + expected := []string{ + "a . true ", + "abcd . true ", + "abcdef . false", + } + + for i, row := range rows { + if row != expected[i] { + t.Errorf("Got: '%s' Expected: '%s'", row, expected[i]) + } + } +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..84ab381 --- /dev/null +++ b/go.mod @@ -0,0 +1,18 @@ +module github.com/fugue/fugue-client + +go 1.12 + +require ( + github.com/BurntSushi/toml v0.3.1 // indirect + github.com/fatih/structs v1.1.0 + github.com/go-openapi/errors v0.18.0 + github.com/go-openapi/runtime v0.19.0 + github.com/go-openapi/strfmt v0.19.0 + github.com/go-openapi/swag v0.18.0 + github.com/go-openapi/validate v0.18.0 + github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/mitchellh/go-homedir v1.1.0 + github.com/spf13/cobra v0.0.3 + github.com/spf13/pflag v1.0.3 + github.com/spf13/viper v1.3.2 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..0927a7a --- /dev/null +++ b/go.sum @@ -0,0 +1,118 @@ +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= +github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf h1:eg0MeVzsP1G42dRafH3vf+al2vQIJU0YHX+1Tw87oco= +github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= +github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= +github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= +github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is= +github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= +github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= +github.com/go-openapi/analysis v0.18.0 h1:hRMEymXOgwo7KLPqqFmw6t3jLO2/zxUe/TXjAHPq9Gc= +github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= +github.com/go-openapi/errors v0.17.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= +github.com/go-openapi/errors v0.18.0 h1:+RnmJ5MQccF7jwWAoMzwOpzJEspZ18ZIWfg9Z2eiXq8= +github.com/go-openapi/errors v0.18.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= +github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= +github.com/go-openapi/jsonpointer v0.18.0 h1:KVRzjXpMzgdM4GEMDmDTnGcY5yBwGWreJwmmk4k35yU= +github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= +github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/jsonreference v0.18.0 h1:oP2OUNdG1l2r5kYhrfVMXO54gWmzcfAwP/GFuHpNTkE= +github.com/go-openapi/jsonreference v0.18.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= +github.com/go-openapi/loads v0.17.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= +github.com/go-openapi/loads v0.18.0 h1:2A3goxrC4KuN8ZrMKHCqAAugtq6A6WfXVfOIKUbZ4n0= +github.com/go-openapi/loads v0.18.0/go.mod h1:72tmFy5wsWx89uEVddd0RjRWPZm92WRLhf7AC+0+OOU= +github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6LTXWQCdL8k1AO3cvqx5OtZY/Y9wKTgaoP6YRfA= +github.com/go-openapi/runtime v0.19.0 h1:sU6pp4dSV2sGlNKKyHxZzi1m1kG4WnYtWcJ+HYbygjE= +github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64= +github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/spec v0.18.0 h1:aIjeyG5mo5/FrvDkpKKEGZPmF9MPHahS72mzfVqeQXQ= +github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= +github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= +github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= +github.com/go-openapi/strfmt v0.19.0 h1:0Dn9qy1G9+UJfRU7TR8bmdGxb4uifB7HNrJjOnV0yPk= +github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+ZPMF/cC8nDY= +github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= +github.com/go-openapi/swag v0.18.0 h1:1DU8Km1MRGv9Pj7BNLmkA+umwTStwDHttXvx3NhJA70= +github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= +github.com/go-openapi/validate v0.18.0 h1:PVXYcP1GkTl+XIAJnyJxOmK6CSG5Q1UcvoCvNO++5Kg= +github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= +github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= +github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe h1:W/GaMY0y69G4cFlmsC6B9sbuo2fP8OFP1ABjt4kPz+w= +github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= +github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= +github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= +github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8= +github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M= +github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190320223903-b7391e95e576/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53 h1:kcXqo9vE6fsZY5X5Rd7R1l7fTgnWaDCVmln65REefiE= +golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54 h1:xe1/2UUJRmA9iDglQSlkx8c5n3twv58+K0mPpC2zmhA= +golang.org/x/sys v0.0.0-20190321052220-f7bb7a8bee54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/main.go b/main.go new file mode 100644 index 0000000..b641b76 --- /dev/null +++ b/main.go @@ -0,0 +1,7 @@ +package main + +import "github.com/fugue/fugue-client/cmd" + +func main() { + cmd.Execute() +} diff --git a/models/attribute.go b/models/attribute.go new file mode 100644 index 0000000..14fa8f6 --- /dev/null +++ b/models/attribute.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// Attribute Description of a change to a resource attribute. +// swagger:model Attribute +type Attribute struct { + + // Indicates whether the attribute type is input or output. + AttrType string `json:"attr_type"` + + // Name of the attribute. + Name string `json:"name"` + + // Value of the attribute as a result of the event. + New string `json:"new"` + + // Value of the attribute before the event. + Old string `json:"old"` + + // Indicates whether the attribute was removed. + Removed bool `json:"removed"` + + // Indicates whether the attribute needed to be deleted and recreated. + RequiresNew bool `json:"requires_new"` + + // Indicates whether the attribute contains sensitive data. + Sensitive bool `json:"sensitive"` +} + +// Validate validates this attribute +func (m *Attribute) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Attribute) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Attribute) UnmarshalBinary(b []byte) error { + var res Attribute + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/authentication_error.go b/models/authentication_error.go new file mode 100644 index 0000000..a19e048 --- /dev/null +++ b/models/authentication_error.go @@ -0,0 +1,106 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// AuthenticationError Error returned when the API is unable to authenticate the request. +// swagger:model AuthenticationError +type AuthenticationError struct { + + // HTTP status code for the error. + Code int64 `json:"code"` + + // Detailed human-readable message about the authentication error. + Message string `json:"message"` + + // Type of authentication error. + // Enum: [AuthenticationError InvalidOrMissingToken] + Type string `json:"type"` +} + +// Validate validates this authentication error +func (m *AuthenticationError) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var authenticationErrorTypeTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["AuthenticationError","InvalidOrMissingToken"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + authenticationErrorTypeTypePropEnum = append(authenticationErrorTypeTypePropEnum, v) + } +} + +const ( + + // AuthenticationErrorTypeAuthenticationError captures enum value "AuthenticationError" + AuthenticationErrorTypeAuthenticationError string = "AuthenticationError" + + // AuthenticationErrorTypeInvalidOrMissingToken captures enum value "InvalidOrMissingToken" + AuthenticationErrorTypeInvalidOrMissingToken string = "InvalidOrMissingToken" +) + +// prop value enum +func (m *AuthenticationError) validateTypeEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, authenticationErrorTypeTypePropEnum); err != nil { + return err + } + return nil +} + +func (m *AuthenticationError) validateType(formats strfmt.Registry) error { + + if swag.IsZero(m.Type) { // not required + return nil + } + + // value enum + if err := m.validateTypeEnum("type", "body", m.Type); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *AuthenticationError) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AuthenticationError) UnmarshalBinary(b []byte) error { + var res AuthenticationError + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/authorization_error.go b/models/authorization_error.go new file mode 100644 index 0000000..de1104b --- /dev/null +++ b/models/authorization_error.go @@ -0,0 +1,106 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// AuthorizationError Error returned when the API is unable to authorize the request. +// swagger:model AuthorizationError +type AuthorizationError struct { + + // HTTP status code for the error. + Code int64 `json:"code"` + + // Detailed human-readable message about the authorization error. + Message string `json:"message"` + + // Type of authorization error. + // Enum: [AuthorizationError EnvironmentAccessDenied] + Type string `json:"type"` +} + +// Validate validates this authorization error +func (m *AuthorizationError) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var authorizationErrorTypeTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["AuthorizationError","EnvironmentAccessDenied"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + authorizationErrorTypeTypePropEnum = append(authorizationErrorTypeTypePropEnum, v) + } +} + +const ( + + // AuthorizationErrorTypeAuthorizationError captures enum value "AuthorizationError" + AuthorizationErrorTypeAuthorizationError string = "AuthorizationError" + + // AuthorizationErrorTypeEnvironmentAccessDenied captures enum value "EnvironmentAccessDenied" + AuthorizationErrorTypeEnvironmentAccessDenied string = "EnvironmentAccessDenied" +) + +// prop value enum +func (m *AuthorizationError) validateTypeEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, authorizationErrorTypeTypePropEnum); err != nil { + return err + } + return nil +} + +func (m *AuthorizationError) validateType(formats strfmt.Registry) error { + + if swag.IsZero(m.Type) { // not required + return nil + } + + // value enum + if err := m.validateTypeEnum("type", "body", m.Type); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *AuthorizationError) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AuthorizationError) UnmarshalBinary(b []byte) error { + var res AuthorizationError + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/bad_request_error.go b/models/bad_request_error.go new file mode 100644 index 0000000..ef15ccf --- /dev/null +++ b/models/bad_request_error.go @@ -0,0 +1,130 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// BadRequestError Error returned when the API is presented with a bad request. +// swagger:model BadRequestError +type BadRequestError struct { + + // HTTP status code for the error. + Code int64 `json:"code"` + + // Detailed human-readable message about the bad request. + Message string `json:"message"` + + // Type of bad request. + // Enum: [BadRequest AlreadyAttachedToDifferentTenantError AlreadyAttachedToTenantError AlreadyInvitedError InvalidCredential InvalidJSON InvalidParameterValue MissingParameter RoleNotAssumable WorkAlreadyStartedException] + Type string `json:"type"` +} + +// Validate validates this bad request error +func (m *BadRequestError) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var badRequestErrorTypeTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["BadRequest","AlreadyAttachedToDifferentTenantError","AlreadyAttachedToTenantError","AlreadyInvitedError","InvalidCredential","InvalidJSON","InvalidParameterValue","MissingParameter","RoleNotAssumable","WorkAlreadyStartedException"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + badRequestErrorTypeTypePropEnum = append(badRequestErrorTypeTypePropEnum, v) + } +} + +const ( + + // BadRequestErrorTypeBadRequest captures enum value "BadRequest" + BadRequestErrorTypeBadRequest string = "BadRequest" + + // BadRequestErrorTypeAlreadyAttachedToDifferentTenantError captures enum value "AlreadyAttachedToDifferentTenantError" + BadRequestErrorTypeAlreadyAttachedToDifferentTenantError string = "AlreadyAttachedToDifferentTenantError" + + // BadRequestErrorTypeAlreadyAttachedToTenantError captures enum value "AlreadyAttachedToTenantError" + BadRequestErrorTypeAlreadyAttachedToTenantError string = "AlreadyAttachedToTenantError" + + // BadRequestErrorTypeAlreadyInvitedError captures enum value "AlreadyInvitedError" + BadRequestErrorTypeAlreadyInvitedError string = "AlreadyInvitedError" + + // BadRequestErrorTypeInvalidCredential captures enum value "InvalidCredential" + BadRequestErrorTypeInvalidCredential string = "InvalidCredential" + + // BadRequestErrorTypeInvalidJSON captures enum value "InvalidJSON" + BadRequestErrorTypeInvalidJSON string = "InvalidJSON" + + // BadRequestErrorTypeInvalidParameterValue captures enum value "InvalidParameterValue" + BadRequestErrorTypeInvalidParameterValue string = "InvalidParameterValue" + + // BadRequestErrorTypeMissingParameter captures enum value "MissingParameter" + BadRequestErrorTypeMissingParameter string = "MissingParameter" + + // BadRequestErrorTypeRoleNotAssumable captures enum value "RoleNotAssumable" + BadRequestErrorTypeRoleNotAssumable string = "RoleNotAssumable" + + // BadRequestErrorTypeWorkAlreadyStartedException captures enum value "WorkAlreadyStartedException" + BadRequestErrorTypeWorkAlreadyStartedException string = "WorkAlreadyStartedException" +) + +// prop value enum +func (m *BadRequestError) validateTypeEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, badRequestErrorTypeTypePropEnum); err != nil { + return err + } + return nil +} + +func (m *BadRequestError) validateType(formats strfmt.Registry) error { + + if swag.IsZero(m.Type) { // not required + return nil + } + + // value enum + if err := m.validateTypeEnum("type", "body", m.Type); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *BadRequestError) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *BadRequestError) UnmarshalBinary(b []byte) error { + var res BadRequestError + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/compliance_by_resource_type.go b/models/compliance_by_resource_type.go new file mode 100644 index 0000000..73a38e6 --- /dev/null +++ b/models/compliance_by_resource_type.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// ComplianceByResourceType Compliance results for a resource type. +// swagger:model ComplianceByResourceType +type ComplianceByResourceType struct { + + // Count of resources found to be fully compliant with all rules it has been evaulated against. + Compliant int64 `json:"compliant"` + + // List of non-compliant resources and the rules they have violated. + Noncompliant []*NonCompliantResource `json:"noncompliant"` + + // Name of the resource type. + ResourceType string `json:"resource_type"` + + // Count of all resources evaluated for this resource type. + Total int64 `json:"total"` +} + +// Validate validates this compliance by resource type +func (m *ComplianceByResourceType) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateNoncompliant(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ComplianceByResourceType) validateNoncompliant(formats strfmt.Registry) error { + + if swag.IsZero(m.Noncompliant) { // not required + return nil + } + + for i := 0; i < len(m.Noncompliant); i++ { + if swag.IsZero(m.Noncompliant[i]) { // not required + continue + } + + if m.Noncompliant[i] != nil { + if err := m.Noncompliant[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("noncompliant" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ComplianceByResourceType) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ComplianceByResourceType) UnmarshalBinary(b []byte) error { + var res ComplianceByResourceType + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/compliance_by_resource_type_output.go b/models/compliance_by_resource_type_output.go new file mode 100644 index 0000000..493d0fe --- /dev/null +++ b/models/compliance_by_resource_type_output.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// ComplianceByResourceTypeOutput Paginated list of compliance results grouped by resource type. +// swagger:model ComplianceByResourceTypeOutput +type ComplianceByResourceTypeOutput struct { + + // Total number of items. + Count int64 `json:"count"` + + // Indicates whether there are more items at the next offset. + IsTruncated bool `json:"is_truncated"` + + // Paginated list of compliance results grouped by resource type. + Items []*ComplianceByResourceType `json:"items"` + + // Next offset to use to get the next page of items. + NextOffset int64 `json:"next_offset"` +} + +// Validate validates this compliance by resource type output +func (m *ComplianceByResourceTypeOutput) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateItems(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ComplianceByResourceTypeOutput) validateItems(formats strfmt.Registry) error { + + if swag.IsZero(m.Items) { // not required + return nil + } + + for i := 0; i < len(m.Items); i++ { + if swag.IsZero(m.Items[i]) { // not required + continue + } + + if m.Items[i] != nil { + if err := m.Items[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("items" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ComplianceByResourceTypeOutput) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ComplianceByResourceTypeOutput) UnmarshalBinary(b []byte) error { + var res ComplianceByResourceTypeOutput + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/compliance_by_rule.go b/models/compliance_by_rule.go new file mode 100644 index 0000000..e043bd7 --- /dev/null +++ b/models/compliance_by_rule.go @@ -0,0 +1,272 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ComplianceByRule Compliance rule and result. +// swagger:model ComplianceByRule +type ComplianceByRule struct { + + // List of resource types that failed to satisfy the rule due to a required resource being omitted and associated error messages. + FailedResourceTypes []*ComplianceByRuleFailedResourceTypesItems0 `json:"failed_resource_types"` + + // List of resources that failed to satisfy the rule due to a misconfiguration in the resource and associated error messages. + FailedResources []*ComplianceByRuleFailedResourcesItems0 `json:"failed_resources"` + + // Name of the compliance family. + Family string `json:"family"` + + // Result of the rule. + // Enum: [PASS FAIL UNKNOWN] + Result string `json:"result"` + + // Name of the compliance rule. + Rule string `json:"rule"` + + // List of resource types that were not surveyed and caused the result to be unknown. + UnsurveyedResourceTypes []string `json:"unsurveyed_resource_types"` +} + +// Validate validates this compliance by rule +func (m *ComplianceByRule) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateFailedResourceTypes(formats); err != nil { + res = append(res, err) + } + + if err := m.validateFailedResources(formats); err != nil { + res = append(res, err) + } + + if err := m.validateResult(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ComplianceByRule) validateFailedResourceTypes(formats strfmt.Registry) error { + + if swag.IsZero(m.FailedResourceTypes) { // not required + return nil + } + + for i := 0; i < len(m.FailedResourceTypes); i++ { + if swag.IsZero(m.FailedResourceTypes[i]) { // not required + continue + } + + if m.FailedResourceTypes[i] != nil { + if err := m.FailedResourceTypes[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("failed_resource_types" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *ComplianceByRule) validateFailedResources(formats strfmt.Registry) error { + + if swag.IsZero(m.FailedResources) { // not required + return nil + } + + for i := 0; i < len(m.FailedResources); i++ { + if swag.IsZero(m.FailedResources[i]) { // not required + continue + } + + if m.FailedResources[i] != nil { + if err := m.FailedResources[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("failed_resources" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +var complianceByRuleTypeResultPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["PASS","FAIL","UNKNOWN"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + complianceByRuleTypeResultPropEnum = append(complianceByRuleTypeResultPropEnum, v) + } +} + +const ( + + // ComplianceByRuleResultPASS captures enum value "PASS" + ComplianceByRuleResultPASS string = "PASS" + + // ComplianceByRuleResultFAIL captures enum value "FAIL" + ComplianceByRuleResultFAIL string = "FAIL" + + // ComplianceByRuleResultUNKNOWN captures enum value "UNKNOWN" + ComplianceByRuleResultUNKNOWN string = "UNKNOWN" +) + +// prop value enum +func (m *ComplianceByRule) validateResultEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, complianceByRuleTypeResultPropEnum); err != nil { + return err + } + return nil +} + +func (m *ComplianceByRule) validateResult(formats strfmt.Registry) error { + + if swag.IsZero(m.Result) { // not required + return nil + } + + // value enum + if err := m.validateResultEnum("result", "body", m.Result); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ComplianceByRule) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ComplianceByRule) UnmarshalBinary(b []byte) error { + var res ComplianceByRule + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// ComplianceByRuleFailedResourceTypesItems0 Resource type that failed to satisfy the rule due to a required resource being omitted and associated error messages. +// swagger:model ComplianceByRuleFailedResourceTypesItems0 +type ComplianceByRuleFailedResourceTypesItems0 struct { + + // Messages why the rule failed. + Messages []string `json:"messages"` + + // Resource type that failed to satisfy the rule. + ResourceType string `json:"resource_type"` +} + +// Validate validates this compliance by rule failed resource types items0 +func (m *ComplianceByRuleFailedResourceTypesItems0) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ComplianceByRuleFailedResourceTypesItems0) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ComplianceByRuleFailedResourceTypesItems0) UnmarshalBinary(b []byte) error { + var res ComplianceByRuleFailedResourceTypesItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// ComplianceByRuleFailedResourcesItems0 Resource that failed to satisfy the rule due to a misconfiguration in the resource and associated error messages. +// swagger:model ComplianceByRuleFailedResourcesItems0 +type ComplianceByRuleFailedResourcesItems0 struct { + + // Messages why the rule failed. + Messages []string `json:"messages"` + + // resource + Resource *Resource `json:"resource"` +} + +// Validate validates this compliance by rule failed resources items0 +func (m *ComplianceByRuleFailedResourcesItems0) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateResource(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ComplianceByRuleFailedResourcesItems0) validateResource(formats strfmt.Registry) error { + + if swag.IsZero(m.Resource) { // not required + return nil + } + + if m.Resource != nil { + if err := m.Resource.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resource") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ComplianceByRuleFailedResourcesItems0) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ComplianceByRuleFailedResourcesItems0) UnmarshalBinary(b []byte) error { + var res ComplianceByRuleFailedResourcesItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/compliance_by_rule_failed_resource_types_items.go b/models/compliance_by_rule_failed_resource_types_items.go new file mode 100644 index 0000000..7887647 --- /dev/null +++ b/models/compliance_by_rule_failed_resource_types_items.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// ComplianceByRuleFailedResourceTypesItems Resource type that failed to satisfy the rule due to a required resource being omitted and associated error messages. +// swagger:model complianceByRuleFailedResourceTypesItems +type ComplianceByRuleFailedResourceTypesItems struct { + + // Messages why the rule failed. + Messages []string `json:"messages"` + + // Resource type that failed to satisfy the rule. + ResourceType string `json:"resource_type"` +} + +// Validate validates this compliance by rule failed resource types items +func (m *ComplianceByRuleFailedResourceTypesItems) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ComplianceByRuleFailedResourceTypesItems) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ComplianceByRuleFailedResourceTypesItems) UnmarshalBinary(b []byte) error { + var res ComplianceByRuleFailedResourceTypesItems + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/compliance_by_rule_failed_resources_items.go b/models/compliance_by_rule_failed_resources_items.go new file mode 100644 index 0000000..a828133 --- /dev/null +++ b/models/compliance_by_rule_failed_resources_items.go @@ -0,0 +1,74 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// ComplianceByRuleFailedResourcesItems Resource that failed to satisfy the rule due to a misconfiguration in the resource and associated error messages. +// swagger:model complianceByRuleFailedResourcesItems +type ComplianceByRuleFailedResourcesItems struct { + + // Messages why the rule failed. + Messages []string `json:"messages"` + + // resource + Resource *Resource `json:"resource"` +} + +// Validate validates this compliance by rule failed resources items +func (m *ComplianceByRuleFailedResourcesItems) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateResource(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ComplianceByRuleFailedResourcesItems) validateResource(formats strfmt.Registry) error { + + if swag.IsZero(m.Resource) { // not required + return nil + } + + if m.Resource != nil { + if err := m.Resource.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resource") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ComplianceByRuleFailedResourcesItems) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ComplianceByRuleFailedResourcesItems) UnmarshalBinary(b []byte) error { + var res ComplianceByRuleFailedResourcesItems + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/compliance_by_rules.go b/models/compliance_by_rules.go new file mode 100644 index 0000000..4a1857c --- /dev/null +++ b/models/compliance_by_rules.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// ComplianceByRules Paginated list of compliance rules and results for a scan. +// swagger:model ComplianceByRules +type ComplianceByRules struct { + + // Total number of items. + Count int64 `json:"count"` + + // Indicates whether there are more items at the next offset. + IsTruncated bool `json:"is_truncated"` + + // Paginated list of compliance rules and results for a scan. + Items []*ComplianceByRule `json:"items"` + + // Next offset to use to get the next page of items. + NextOffset int64 `json:"next_offset"` +} + +// Validate validates this compliance by rules +func (m *ComplianceByRules) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateItems(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ComplianceByRules) validateItems(formats strfmt.Registry) error { + + if swag.IsZero(m.Items) { // not required + return nil + } + + for i := 0; i < len(m.Items); i++ { + if swag.IsZero(m.Items[i]) { // not required + continue + } + + if m.Items[i] != nil { + if err := m.Items[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("items" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ComplianceByRules) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ComplianceByRules) UnmarshalBinary(b []byte) error { + var res ComplianceByRules + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/compliance_diff.go b/models/compliance_diff.go new file mode 100644 index 0000000..c885df4 --- /dev/null +++ b/models/compliance_diff.go @@ -0,0 +1,141 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// ComplianceDiff Difference between the old and new compliance state of a resource after an event. +// swagger:model ComplianceDiff +type ComplianceDiff struct { + + // The resource's compliance state after an event. + NewState string `json:"new_state"` + + // The resource's compliance state before an event. + OldState string `json:"old_state"` + + // ID of the resource given by the provider. + ResourceID string `json:"resource_id"` + + // Resource type. + ResourceType string `json:"resource_type"` + + // List of rule evaluations that changed state after an event. + Rules []*ComplianceDiffRulesItems0 `json:"rules"` +} + +// Validate validates this compliance diff +func (m *ComplianceDiff) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateRules(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ComplianceDiff) validateRules(formats strfmt.Registry) error { + + if swag.IsZero(m.Rules) { // not required + return nil + } + + for i := 0; i < len(m.Rules); i++ { + if swag.IsZero(m.Rules[i]) { // not required + continue + } + + if m.Rules[i] != nil { + if err := m.Rules[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("rules" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ComplianceDiff) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ComplianceDiff) UnmarshalBinary(b []byte) error { + var res ComplianceDiff + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// ComplianceDiffRulesItems0 compliance diff rules items0 +// swagger:model ComplianceDiffRulesItems0 +type ComplianceDiffRulesItems0 struct { + + // The compliance families that a rule is evaluated for. + ComplianceFamilies []string `json:"compliance_families"` + + // The compliance controls that a rule is evaluated for. + Controls []string `json:"controls"` + + // The rule's error message after an event. + NewMessage string `json:"new_message"` + + // The rule's evaluation state after an event. + NewState string `json:"new_state"` + + // The rule's error message before an event. + OldMessage string `json:"old_message"` + + // The rule's evaluation state before an event. + OldState string `json:"old_state"` + + // Summary of the rule a resource was evaluated against. + Summary string `json:"summary"` +} + +// Validate validates this compliance diff rules items0 +func (m *ComplianceDiffRulesItems0) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ComplianceDiffRulesItems0) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ComplianceDiffRulesItems0) UnmarshalBinary(b []byte) error { + var res ComplianceDiffRulesItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/compliance_diff_rules_items.go b/models/compliance_diff_rules_items.go new file mode 100644 index 0000000..4b41536 --- /dev/null +++ b/models/compliance_diff_rules_items.go @@ -0,0 +1,61 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// ComplianceDiffRulesItems compliance diff rules items +// swagger:model complianceDiffRulesItems +type ComplianceDiffRulesItems struct { + + // The compliance families that a rule is evaluated for. + ComplianceFamilies []string `json:"compliance_families"` + + // The compliance controls that a rule is evaluated for. + Controls []string `json:"controls"` + + // The rule's error message after an event. + NewMessage string `json:"new_message"` + + // The rule's evaluation state after an event. + NewState string `json:"new_state"` + + // The rule's error message before an event. + OldMessage string `json:"old_message"` + + // The rule's evaluation state before an event. + OldState string `json:"old_state"` + + // Summary of the rule a resource was evaluated against. + Summary string `json:"summary"` +} + +// Validate validates this compliance diff rules items +func (m *ComplianceDiffRulesItems) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ComplianceDiffRulesItems) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ComplianceDiffRulesItems) UnmarshalBinary(b []byte) error { + var res ComplianceDiffRulesItems + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/create_environment_input.go b/models/create_environment_input.go new file mode 100644 index 0000000..6920b5e --- /dev/null +++ b/models/create_environment_input.go @@ -0,0 +1,164 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// CreateEnvironmentInput Structure of the body for creating a new environment. +// swagger:model CreateEnvironmentInput +type CreateEnvironmentInput struct { + + // List of compliance families validated against the environment. + ComplianceFamilies []string `json:"compliance_families"` + + // Name of the environment. + Name string `json:"name"` + + // Name of the cloud service provider for the environment. + // Enum: [aws aws_govcloud azure] + Provider string `json:"provider"` + + // A dictionary of options for the provider. + ProviderOptions *ProviderOptions `json:"provider_options"` + + // List of resource types to be remediated if remediation is enabled. + RemediateResourceTypes []string `json:"remediate_resource_types"` + + // Time in seconds between the end of one scan to the start of the next. Must also set scan_schedule_enabled to true. + // Minimum: 300 + ScanInterval int64 `json:"scan_interval"` + + // Indicates if the new environment should have scans run on a schedule upon creation. + ScanScheduleEnabled bool `json:"scan_schedule_enabled"` + + // List of resource types to be surveyed. + SurveyResourceTypes []string `json:"survey_resource_types"` +} + +// Validate validates this create environment input +func (m *CreateEnvironmentInput) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateProvider(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProviderOptions(formats); err != nil { + res = append(res, err) + } + + if err := m.validateScanInterval(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var createEnvironmentInputTypeProviderPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["aws","aws_govcloud","azure"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + createEnvironmentInputTypeProviderPropEnum = append(createEnvironmentInputTypeProviderPropEnum, v) + } +} + +const ( + + // CreateEnvironmentInputProviderAws captures enum value "aws" + CreateEnvironmentInputProviderAws string = "aws" + + // CreateEnvironmentInputProviderAwsGovcloud captures enum value "aws_govcloud" + CreateEnvironmentInputProviderAwsGovcloud string = "aws_govcloud" + + // CreateEnvironmentInputProviderAzure captures enum value "azure" + CreateEnvironmentInputProviderAzure string = "azure" +) + +// prop value enum +func (m *CreateEnvironmentInput) validateProviderEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, createEnvironmentInputTypeProviderPropEnum); err != nil { + return err + } + return nil +} + +func (m *CreateEnvironmentInput) validateProvider(formats strfmt.Registry) error { + + if swag.IsZero(m.Provider) { // not required + return nil + } + + // value enum + if err := m.validateProviderEnum("provider", "body", m.Provider); err != nil { + return err + } + + return nil +} + +func (m *CreateEnvironmentInput) validateProviderOptions(formats strfmt.Registry) error { + + if swag.IsZero(m.ProviderOptions) { // not required + return nil + } + + if m.ProviderOptions != nil { + if err := m.ProviderOptions.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("provider_options") + } + return err + } + } + + return nil +} + +func (m *CreateEnvironmentInput) validateScanInterval(formats strfmt.Registry) error { + + if swag.IsZero(m.ScanInterval) { // not required + return nil + } + + if err := validate.MinimumInt("scan_interval", "body", int64(m.ScanInterval), 300, false); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *CreateEnvironmentInput) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CreateEnvironmentInput) UnmarshalBinary(b []byte) error { + var res CreateEnvironmentInput + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/create_notification_input.go b/models/create_notification_input.go new file mode 100644 index 0000000..c707ef0 --- /dev/null +++ b/models/create_notification_input.go @@ -0,0 +1,55 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// CreateNotificationInput Request for creating a new notification. +// swagger:model CreateNotificationInput +type CreateNotificationInput struct { + + // List of email address the notification is delivered to. + Emails []string `json:"emails"` + + // List of environment ids the notification is attached to. + Environments []string `json:"environments"` + + // List of events the notification is triggered on. + Events []string `json:"events"` + + // Human readable name of the notification. + Name string `json:"name"` + + // AWS SNS topic arn the notification is delivered to. + TopicArn string `json:"topic_arn"` +} + +// Validate validates this create notification input +func (m *CreateNotificationInput) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *CreateNotificationInput) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CreateNotificationInput) UnmarshalBinary(b []byte) error { + var res CreateNotificationInput + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/create_policy_input.go b/models/create_policy_input.go new file mode 100644 index 0000000..4a5c886 --- /dev/null +++ b/models/create_policy_input.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// CreatePolicyInput List of resource types to be able to survey and remediate. +// swagger:model CreatePolicyInput +type CreatePolicyInput struct { + + // List of resource types to be able to remediate. + RemediateResourceTypes []string `json:"remediate_resource_types"` + + // List of resource types to be able to survey. + SurveyResourceTypes []string `json:"survey_resource_types"` +} + +// Validate validates this create policy input +func (m *CreatePolicyInput) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *CreatePolicyInput) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *CreatePolicyInput) UnmarshalBinary(b []byte) error { + var res CreatePolicyInput + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/environment.go b/models/environment.go new file mode 100644 index 0000000..780d2f1 --- /dev/null +++ b/models/environment.go @@ -0,0 +1,230 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Environment A managed environment. +// swagger:model Environment +type Environment struct { + + // Scan ID of the baseline if baseline is enabled. + BaselineID string `json:"baseline_id"` + + // List of compliance families validated against the environment. + ComplianceFamilies []string `json:"compliance_families"` + + // Indicates whether drift detection is enabled for the environment. + Drift bool `json:"drift"` + + // ID of the environment. + ID string `json:"id"` + + // Time the current or most recently completed scan for the environment started. + LastScanAt int64 `json:"last_scan_at"` + + // Name of the environment. + Name string `json:"name"` + + // Time the next scan will start. + NextScanAt int64 `json:"next_scan_at"` + + // Name of the cloud service provider for the environment. + // Enum: [aws aws_govcloud azure] + Provider string `json:"provider"` + + // provider options + ProviderOptions *ProviderOptions `json:"provider_options"` + + // List of resource types remediated for the environment if remediation is enabled. + RemediateResourceTypes []string `json:"remediate_resource_types"` + + // Indicates whether remediation is enabled for the environment. + Remediation bool `json:"remediation"` + + // Time in seconds between the end of one scan to the start of the next. + ScanInterval int64 `json:"scan_interval"` + + // Indicates whether the environment should have scans run on a schedule. + ScanScheduleEnabled bool `json:"scan_schedule_enabled"` + + // Status of the current or most recently completed scan for the environment. + // Enum: [CREATED QUEUED IN_PROGRESS ERROR SUCCESS CANCELED] + ScanStatus string `json:"scan_status"` + + // List of resource types surveyed for the environment. + SurveyResourceTypes []string `json:"survey_resource_types"` + + // ID of the tenant that owns the environment. + TenantID string `json:"tenant_id"` +} + +// Validate validates this environment +func (m *Environment) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateProvider(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProviderOptions(formats); err != nil { + res = append(res, err) + } + + if err := m.validateScanStatus(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var environmentTypeProviderPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["aws","aws_govcloud","azure"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + environmentTypeProviderPropEnum = append(environmentTypeProviderPropEnum, v) + } +} + +const ( + + // EnvironmentProviderAws captures enum value "aws" + EnvironmentProviderAws string = "aws" + + // EnvironmentProviderAwsGovcloud captures enum value "aws_govcloud" + EnvironmentProviderAwsGovcloud string = "aws_govcloud" + + // EnvironmentProviderAzure captures enum value "azure" + EnvironmentProviderAzure string = "azure" +) + +// prop value enum +func (m *Environment) validateProviderEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, environmentTypeProviderPropEnum); err != nil { + return err + } + return nil +} + +func (m *Environment) validateProvider(formats strfmt.Registry) error { + + if swag.IsZero(m.Provider) { // not required + return nil + } + + // value enum + if err := m.validateProviderEnum("provider", "body", m.Provider); err != nil { + return err + } + + return nil +} + +func (m *Environment) validateProviderOptions(formats strfmt.Registry) error { + + if swag.IsZero(m.ProviderOptions) { // not required + return nil + } + + if m.ProviderOptions != nil { + if err := m.ProviderOptions.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("provider_options") + } + return err + } + } + + return nil +} + +var environmentTypeScanStatusPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["CREATED","QUEUED","IN_PROGRESS","ERROR","SUCCESS","CANCELED"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + environmentTypeScanStatusPropEnum = append(environmentTypeScanStatusPropEnum, v) + } +} + +const ( + + // EnvironmentScanStatusCREATED captures enum value "CREATED" + EnvironmentScanStatusCREATED string = "CREATED" + + // EnvironmentScanStatusQUEUED captures enum value "QUEUED" + EnvironmentScanStatusQUEUED string = "QUEUED" + + // EnvironmentScanStatusINPROGRESS captures enum value "IN_PROGRESS" + EnvironmentScanStatusINPROGRESS string = "IN_PROGRESS" + + // EnvironmentScanStatusERROR captures enum value "ERROR" + EnvironmentScanStatusERROR string = "ERROR" + + // EnvironmentScanStatusSUCCESS captures enum value "SUCCESS" + EnvironmentScanStatusSUCCESS string = "SUCCESS" + + // EnvironmentScanStatusCANCELED captures enum value "CANCELED" + EnvironmentScanStatusCANCELED string = "CANCELED" +) + +// prop value enum +func (m *Environment) validateScanStatusEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, environmentTypeScanStatusPropEnum); err != nil { + return err + } + return nil +} + +func (m *Environment) validateScanStatus(formats strfmt.Registry) error { + + if swag.IsZero(m.ScanStatus) { // not required + return nil + } + + // value enum + if err := m.validateScanStatusEnum("scan_status", "body", m.ScanStatus); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Environment) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Environment) UnmarshalBinary(b []byte) error { + var res Environment + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/environment_with_summary.go b/models/environment_with_summary.go new file mode 100644 index 0000000..891a485 --- /dev/null +++ b/models/environment_with_summary.go @@ -0,0 +1,124 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// EnvironmentWithSummary A managed environment with its latest scan summary. +// swagger:model EnvironmentWithSummary +type EnvironmentWithSummary struct { + Environment + + // resource summary + ResourceSummary *ResourceSummary `json:"resource_summary"` +} + +// UnmarshalJSON unmarshals this object from a JSON structure +func (m *EnvironmentWithSummary) UnmarshalJSON(raw []byte) error { + // AO0 + var aO0 Environment + if err := swag.ReadJSON(raw, &aO0); err != nil { + return err + } + m.Environment = aO0 + + // AO1 + var dataAO1 struct { + ResourceSummary *ResourceSummary `json:"resource_summary"` + } + if err := swag.ReadJSON(raw, &dataAO1); err != nil { + return err + } + + m.ResourceSummary = dataAO1.ResourceSummary + + return nil +} + +// MarshalJSON marshals this object to a JSON structure +func (m EnvironmentWithSummary) MarshalJSON() ([]byte, error) { + _parts := make([][]byte, 0, 2) + + aO0, err := swag.WriteJSON(m.Environment) + if err != nil { + return nil, err + } + _parts = append(_parts, aO0) + + var dataAO1 struct { + ResourceSummary *ResourceSummary `json:"resource_summary"` + } + + dataAO1.ResourceSummary = m.ResourceSummary + + jsonDataAO1, errAO1 := swag.WriteJSON(dataAO1) + if errAO1 != nil { + return nil, errAO1 + } + _parts = append(_parts, jsonDataAO1) + + return swag.ConcatJSON(_parts...), nil +} + +// Validate validates this environment with summary +func (m *EnvironmentWithSummary) Validate(formats strfmt.Registry) error { + var res []error + + // validation for a type composition with Environment + if err := m.Environment.Validate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateResourceSummary(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *EnvironmentWithSummary) validateResourceSummary(formats strfmt.Registry) error { + + if swag.IsZero(m.ResourceSummary) { // not required + return nil + } + + if m.ResourceSummary != nil { + if err := m.ResourceSummary.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resource_summary") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *EnvironmentWithSummary) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *EnvironmentWithSummary) UnmarshalBinary(b []byte) error { + var res EnvironmentWithSummary + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/environment_with_summary_all_of1.go b/models/environment_with_summary_all_of1.go new file mode 100644 index 0000000..0fbec09 --- /dev/null +++ b/models/environment_with_summary_all_of1.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// EnvironmentWithSummaryAllOf1 environment with summary all of1 +// swagger:model environmentWithSummaryAllOf1 +type EnvironmentWithSummaryAllOf1 struct { + + // resource summary + ResourceSummary *ResourceSummary `json:"resource_summary"` +} + +// Validate validates this environment with summary all of1 +func (m *EnvironmentWithSummaryAllOf1) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateResourceSummary(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *EnvironmentWithSummaryAllOf1) validateResourceSummary(formats strfmt.Registry) error { + + if swag.IsZero(m.ResourceSummary) { // not required + return nil + } + + if m.ResourceSummary != nil { + if err := m.ResourceSummary.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resource_summary") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *EnvironmentWithSummaryAllOf1) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *EnvironmentWithSummaryAllOf1) UnmarshalBinary(b []byte) error { + var res EnvironmentWithSummaryAllOf1 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/environments.go b/models/environments.go new file mode 100644 index 0000000..590c516 --- /dev/null +++ b/models/environments.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// Environments Paginated list of environments. +// swagger:model Environments +type Environments struct { + + // Total number of items. + Count int64 `json:"count"` + + // Indicates whether there are more items at the next offset. + IsTruncated bool `json:"is_truncated"` + + // Paginated list of environments. + Items []*Environment `json:"items"` + + // Next offset to use to get the next page of items. + NextOffset int64 `json:"next_offset"` +} + +// Validate validates this environments +func (m *Environments) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateItems(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Environments) validateItems(formats strfmt.Registry) error { + + if swag.IsZero(m.Items) { // not required + return nil + } + + for i := 0; i < len(m.Items); i++ { + if swag.IsZero(m.Items[i]) { // not required + continue + } + + if m.Items[i] != nil { + if err := m.Items[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("items" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Environments) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Environments) UnmarshalBinary(b []byte) error { + var res Environments + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/event.go b/models/event.go new file mode 100644 index 0000000..7bb225d --- /dev/null +++ b/models/event.go @@ -0,0 +1,162 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Event A drift or remediation event. +// swagger:model Event +type Event struct { + + // Difference between the old and new compliance state of the resource. + ComplianceDiff *ComplianceDiff `json:"compliance_diff"` + + // Time the event occurred. + CreatedAt int64 `json:"created_at"` + + // Error message. + Error string `json:"error"` + + // Type of event - drift, remediation, or compliance. + // Enum: [DRIFT REMEDIATION COMPLIANCE] + EventType string `json:"event_type"` + + // ID of event + ID string `json:"id"` + + // Difference between the old and new state of the resource. + ResourceDiff *ResourceDiff `json:"resource_diff"` +} + +// Validate validates this event +func (m *Event) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateComplianceDiff(formats); err != nil { + res = append(res, err) + } + + if err := m.validateEventType(formats); err != nil { + res = append(res, err) + } + + if err := m.validateResourceDiff(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Event) validateComplianceDiff(formats strfmt.Registry) error { + + if swag.IsZero(m.ComplianceDiff) { // not required + return nil + } + + if m.ComplianceDiff != nil { + if err := m.ComplianceDiff.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("compliance_diff") + } + return err + } + } + + return nil +} + +var eventTypeEventTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["DRIFT","REMEDIATION","COMPLIANCE"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + eventTypeEventTypePropEnum = append(eventTypeEventTypePropEnum, v) + } +} + +const ( + + // EventEventTypeDRIFT captures enum value "DRIFT" + EventEventTypeDRIFT string = "DRIFT" + + // EventEventTypeREMEDIATION captures enum value "REMEDIATION" + EventEventTypeREMEDIATION string = "REMEDIATION" + + // EventEventTypeCOMPLIANCE captures enum value "COMPLIANCE" + EventEventTypeCOMPLIANCE string = "COMPLIANCE" +) + +// prop value enum +func (m *Event) validateEventTypeEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, eventTypeEventTypePropEnum); err != nil { + return err + } + return nil +} + +func (m *Event) validateEventType(formats strfmt.Registry) error { + + if swag.IsZero(m.EventType) { // not required + return nil + } + + // value enum + if err := m.validateEventTypeEnum("event_type", "body", m.EventType); err != nil { + return err + } + + return nil +} + +func (m *Event) validateResourceDiff(formats strfmt.Registry) error { + + if swag.IsZero(m.ResourceDiff) { // not required + return nil + } + + if m.ResourceDiff != nil { + if err := m.ResourceDiff.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resource_diff") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Event) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Event) UnmarshalBinary(b []byte) error { + var res Event + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/events.go b/models/events.go new file mode 100644 index 0000000..3a44dff --- /dev/null +++ b/models/events.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// Events Paginated list of drift, remediation, and compliance events. +// swagger:model Events +type Events struct { + + // Total number of items. DEPRECATED: This property no longer returns accurate counts when filters are applied and will be removed in future API versions + Count int64 `json:"count"` + + // Indicates whether there are more items at the next offset. + IsTruncated bool `json:"is_truncated"` + + // Paginated list of events. + Items []*Event `json:"items"` + + // Next offset to use to get the next page of items. + NextOffset int64 `json:"next_offset"` +} + +// Validate validates this events +func (m *Events) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateItems(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Events) validateItems(formats strfmt.Registry) error { + + if swag.IsZero(m.Items) { // not required + return nil + } + + for i := 0; i < len(m.Items); i++ { + if swag.IsZero(m.Items[i]) { // not required + continue + } + + if m.Items[i] != nil { + if err := m.Items[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("items" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Events) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Events) UnmarshalBinary(b []byte) error { + var res Events + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/internal_server_error.go b/models/internal_server_error.go new file mode 100644 index 0000000..cdf5542 --- /dev/null +++ b/models/internal_server_error.go @@ -0,0 +1,106 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// InternalServerError Error returned when the API request results in an internal server error. +// swagger:model InternalServerError +type InternalServerError struct { + + // HTTP status code for the error. + Code int64 `json:"code"` + + // Detailed human-readable message about the internal server error. + Message string `json:"message"` + + // Type of internal server error. + // Enum: [InternalServerError DatabaseError] + Type string `json:"type"` +} + +// Validate validates this internal server error +func (m *InternalServerError) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var internalServerErrorTypeTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["InternalServerError","DatabaseError"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + internalServerErrorTypeTypePropEnum = append(internalServerErrorTypeTypePropEnum, v) + } +} + +const ( + + // InternalServerErrorTypeInternalServerError captures enum value "InternalServerError" + InternalServerErrorTypeInternalServerError string = "InternalServerError" + + // InternalServerErrorTypeDatabaseError captures enum value "DatabaseError" + InternalServerErrorTypeDatabaseError string = "DatabaseError" +) + +// prop value enum +func (m *InternalServerError) validateTypeEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, internalServerErrorTypeTypePropEnum); err != nil { + return err + } + return nil +} + +func (m *InternalServerError) validateType(formats strfmt.Registry) error { + + if swag.IsZero(m.Type) { // not required + return nil + } + + // value enum + if err := m.validateTypeEnum("type", "body", m.Type); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *InternalServerError) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *InternalServerError) UnmarshalBinary(b []byte) error { + var res InternalServerError + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/non_compliant_resource.go b/models/non_compliant_resource.go new file mode 100644 index 0000000..a0849dc --- /dev/null +++ b/models/non_compliant_resource.go @@ -0,0 +1,120 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// NonCompliantResource Describes the rules violated by a resource. +// swagger:model NonCompliantResource +type NonCompliantResource struct { + + // List of rules and messages the resource violates. + FailedRules []*NonCompliantResourceFailedRulesItems0 `json:"failed_rules"` + + // ID of the failing resource. + ResourceID string `json:"resource_id"` +} + +// Validate validates this non compliant resource +func (m *NonCompliantResource) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateFailedRules(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *NonCompliantResource) validateFailedRules(formats strfmt.Registry) error { + + if swag.IsZero(m.FailedRules) { // not required + return nil + } + + for i := 0; i < len(m.FailedRules); i++ { + if swag.IsZero(m.FailedRules[i]) { // not required + continue + } + + if m.FailedRules[i] != nil { + if err := m.FailedRules[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("failed_rules" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *NonCompliantResource) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NonCompliantResource) UnmarshalBinary(b []byte) error { + var res NonCompliantResource + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// NonCompliantResourceFailedRulesItems0 non compliant resource failed rules items0 +// swagger:model NonCompliantResourceFailedRulesItems0 +type NonCompliantResourceFailedRulesItems0 struct { + + // Compliance family the violated rule belongs to. + Family string `json:"family"` + + // Reasons the resource was found in violation of a rule. + Messages []string `json:"messages"` + + // ID of the violated rule. + Rule string `json:"rule"` +} + +// Validate validates this non compliant resource failed rules items0 +func (m *NonCompliantResourceFailedRulesItems0) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *NonCompliantResourceFailedRulesItems0) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NonCompliantResourceFailedRulesItems0) UnmarshalBinary(b []byte) error { + var res NonCompliantResourceFailedRulesItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/non_compliant_resource_failed_rules_items.go b/models/non_compliant_resource_failed_rules_items.go new file mode 100644 index 0000000..f977e96 --- /dev/null +++ b/models/non_compliant_resource_failed_rules_items.go @@ -0,0 +1,49 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// NonCompliantResourceFailedRulesItems non compliant resource failed rules items +// swagger:model nonCompliantResourceFailedRulesItems +type NonCompliantResourceFailedRulesItems struct { + + // Compliance family the violated rule belongs to. + Family string `json:"family"` + + // Reasons the resource was found in violation of a rule. + Messages []string `json:"messages"` + + // ID of the violated rule. + Rule string `json:"rule"` +} + +// Validate validates this non compliant resource failed rules items +func (m *NonCompliantResourceFailedRulesItems) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *NonCompliantResourceFailedRulesItems) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NonCompliantResourceFailedRulesItems) UnmarshalBinary(b []byte) error { + var res NonCompliantResourceFailedRulesItems + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/not_found_error.go b/models/not_found_error.go new file mode 100644 index 0000000..03ba807 --- /dev/null +++ b/models/not_found_error.go @@ -0,0 +1,103 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// NotFoundError Error returned when the API request references a non-existent resource. +// swagger:model NotFoundError +type NotFoundError struct { + + // HTTP status code for the error. + Code int64 `json:"code"` + + // Detailed human-readable message about the not found error. + Message string `json:"message"` + + // Type of not found error. + // Enum: [NotFound] + Type string `json:"type"` +} + +// Validate validates this not found error +func (m *NotFoundError) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var notFoundErrorTypeTypePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["NotFound"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + notFoundErrorTypeTypePropEnum = append(notFoundErrorTypeTypePropEnum, v) + } +} + +const ( + + // NotFoundErrorTypeNotFound captures enum value "NotFound" + NotFoundErrorTypeNotFound string = "NotFound" +) + +// prop value enum +func (m *NotFoundError) validateTypeEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, notFoundErrorTypeTypePropEnum); err != nil { + return err + } + return nil +} + +func (m *NotFoundError) validateType(formats strfmt.Registry) error { + + if swag.IsZero(m.Type) { // not required + return nil + } + + // value enum + if err := m.validateTypeEnum("type", "body", m.Type); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *NotFoundError) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *NotFoundError) UnmarshalBinary(b []byte) error { + var res NotFoundError + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/notification.go b/models/notification.go new file mode 100644 index 0000000..c8053e9 --- /dev/null +++ b/models/notification.go @@ -0,0 +1,73 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// Notification Describes configuration of a notification. +// swagger:model Notification +type Notification struct { + + // The date and time the notification was created. + CreatedAt int64 `json:"created_at"` + + // Principal the created the notification. + CreatedBy string `json:"created_by"` + + // List of email address the notification is delivered to. + Emails []string `json:"emails"` + + // List of maps from environment id to name the notification is attached to. + Environments []map[string]string `json:"environments"` + + // List of events the notification is triggered on. + Events []string `json:"events"` + + // Last error recorded while processing notification. If the last notification processed had no error this field will be empty. + LastError string `json:"last_error"` + + // Human readable name of the notification. + Name string `json:"name"` + + // ID of the notification. + NotificationID string `json:"notification_id"` + + // AWS SNS topic arn the notification is delivered to. + TopicArn string `json:"topic_arn"` + + // AWS The date and time the notification was last updated. + UpdatedAt int64 `json:"updated_at"` + + // Principal that last updated the notification. + UpdatedBy string `json:"updated_by"` +} + +// Validate validates this notification +func (m *Notification) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Notification) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Notification) UnmarshalBinary(b []byte) error { + var res Notification + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/notifications.go b/models/notifications.go new file mode 100644 index 0000000..a1bf1e2 --- /dev/null +++ b/models/notifications.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// Notifications Paginiated result of notification lists. +// swagger:model Notifications +type Notifications struct { + + // Count of all found notifications. + Count int64 `json:"count"` + + // Indicates whether there are more items at the next offset. + IsTruncated bool `json:"is_truncated"` + + // List of notification configurations. + Items []*Notification `json:"items"` + + // Next offset to use to get the next page of items. + NextOffset int64 `json:"next_offset"` +} + +// Validate validates this notifications +func (m *Notifications) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateItems(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Notifications) validateItems(formats strfmt.Registry) error { + + if swag.IsZero(m.Items) { // not required + return nil + } + + for i := 0; i < len(m.Items); i++ { + if swag.IsZero(m.Items[i]) { // not required + continue + } + + if m.Items[i] != nil { + if err := m.Items[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("items" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Notifications) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Notifications) UnmarshalBinary(b []byte) error { + var res Notifications + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/permissions.go b/models/permissions.go new file mode 100644 index 0000000..35772c0 --- /dev/null +++ b/models/permissions.go @@ -0,0 +1,71 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// Permissions Permissions for surveying and remediating the specified resource types. +// swagger:model Permissions +type Permissions struct { + + // aws + Aws *PermissionsAws `json:"aws"` +} + +// Validate validates this permissions +func (m *Permissions) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAws(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Permissions) validateAws(formats strfmt.Registry) error { + + if swag.IsZero(m.Aws) { // not required + return nil + } + + if m.Aws != nil { + if err := m.Aws.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("aws") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Permissions) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Permissions) UnmarshalBinary(b []byte) error { + var res Permissions + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/permissions_aws.go b/models/permissions_aws.go new file mode 100644 index 0000000..c8ae9f2 --- /dev/null +++ b/models/permissions_aws.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// PermissionsAws IAM policy required for surveying and remediating the desired resource types. +// swagger:model PermissionsAws +type PermissionsAws struct { + + // JSON policy for surveying and remediating the desired resource types. + Policy interface{} `json:"policy"` + + // JSON trust relationship for IAM role + TrustRelationship interface{} `json:"trust_relationship"` +} + +// Validate validates this permissions aws +func (m *PermissionsAws) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *PermissionsAws) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *PermissionsAws) UnmarshalBinary(b []byte) error { + var res PermissionsAws + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/provider_options.go b/models/provider_options.go new file mode 100644 index 0000000..b15dc54 --- /dev/null +++ b/models/provider_options.go @@ -0,0 +1,121 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// ProviderOptions Provider options. +// swagger:model ProviderOptions +type ProviderOptions struct { + + // aws + Aws *ProviderOptionsAws `json:"aws"` + + // aws govcloud + AwsGovcloud *ProviderOptionsAws `json:"aws_govcloud"` + + // azure + Azure *ProviderOptionsAzure `json:"azure"` +} + +// Validate validates this provider options +func (m *ProviderOptions) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAws(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAwsGovcloud(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAzure(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProviderOptions) validateAws(formats strfmt.Registry) error { + + if swag.IsZero(m.Aws) { // not required + return nil + } + + if m.Aws != nil { + if err := m.Aws.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("aws") + } + return err + } + } + + return nil +} + +func (m *ProviderOptions) validateAwsGovcloud(formats strfmt.Registry) error { + + if swag.IsZero(m.AwsGovcloud) { // not required + return nil + } + + if m.AwsGovcloud != nil { + if err := m.AwsGovcloud.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("aws_govcloud") + } + return err + } + } + + return nil +} + +func (m *ProviderOptions) validateAzure(formats strfmt.Registry) error { + + if swag.IsZero(m.Azure) { // not required + return nil + } + + if m.Azure != nil { + if err := m.Azure.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("azure") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ProviderOptions) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProviderOptions) UnmarshalBinary(b []byte) error { + var res ProviderOptions + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/provider_options_aws.go b/models/provider_options_aws.go new file mode 100644 index 0000000..2d9dc74 --- /dev/null +++ b/models/provider_options_aws.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// ProviderOptionsAws Provider options for AWS. +// swagger:model ProviderOptionsAws +type ProviderOptionsAws struct { + + // The AWS region to scan and remediate infrastructure in. + Region string `json:"region"` + + // AWS IAM Role ARN that will be assumed to scan and remediate infrastructure. + RoleArn string `json:"role_arn"` +} + +// Validate validates this provider options aws +func (m *ProviderOptionsAws) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ProviderOptionsAws) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProviderOptionsAws) UnmarshalBinary(b []byte) error { + var res ProviderOptionsAws + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/provider_options_aws_update_input.go b/models/provider_options_aws_update_input.go new file mode 100644 index 0000000..e028f2d --- /dev/null +++ b/models/provider_options_aws_update_input.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// ProviderOptionsAwsUpdateInput Mutable provider options for AWS. +// swagger:model ProviderOptionsAwsUpdateInput +type ProviderOptionsAwsUpdateInput struct { + + // AWS IAM Role ARN that will be assumed to scan and remediate infrastructure. + RoleArn string `json:"role_arn"` +} + +// Validate validates this provider options aws update input +func (m *ProviderOptionsAwsUpdateInput) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ProviderOptionsAwsUpdateInput) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProviderOptionsAwsUpdateInput) UnmarshalBinary(b []byte) error { + var res ProviderOptionsAwsUpdateInput + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/provider_options_azure.go b/models/provider_options_azure.go new file mode 100644 index 0000000..6e2dfd9 --- /dev/null +++ b/models/provider_options_azure.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// ProviderOptionsAzure Provider options for Azire. +// swagger:model ProviderOptionsAzure +type ProviderOptionsAzure struct { + + // The application ID/client ID of the service principal to be used + ApplicationID string `json:"application_id"` + + // The client secret of the service principal to be used + ClientSecret string `json:"client_secret"` + + // The resource groups to be remediated + RemediateResourceGroups []string `json:"remediate_resource_groups"` + + // The subscription ID of the Azure subscription to be used + SubscriptionID string `json:"subscription_id"` + + // The resource groups to be surveyed + SurveyResourceGroups []string `json:"survey_resource_groups"` + + // The tenant ID of the Azure subscription to be used + TenantID string `json:"tenant_id"` +} + +// Validate validates this provider options azure +func (m *ProviderOptionsAzure) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ProviderOptionsAzure) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProviderOptionsAzure) UnmarshalBinary(b []byte) error { + var res ProviderOptionsAzure + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/provider_options_azure_update_input.go b/models/provider_options_azure_update_input.go new file mode 100644 index 0000000..d9972ea --- /dev/null +++ b/models/provider_options_azure_update_input.go @@ -0,0 +1,52 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// ProviderOptionsAzureUpdateInput Mutable provider options for Azure. +// swagger:model ProviderOptionsAzureUpdateInput +type ProviderOptionsAzureUpdateInput struct { + + // The application ID/client ID of the service principal to be used + ApplicationID string `json:"application_id"` + + // The client secret of the service principal to be used + ClientSecret string `json:"client_secret"` + + // The resource groups to be remediated + RemediateResourceGroups []string `json:"remediate_resource_groups"` + + // The resource groups to be surveyed + SurveyResourceGroups []string `json:"survey_resource_groups"` +} + +// Validate validates this provider options azure update input +func (m *ProviderOptionsAzureUpdateInput) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ProviderOptionsAzureUpdateInput) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProviderOptionsAzureUpdateInput) UnmarshalBinary(b []byte) error { + var res ProviderOptionsAzureUpdateInput + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/provider_options_update_input.go b/models/provider_options_update_input.go new file mode 100644 index 0000000..2e9a467 --- /dev/null +++ b/models/provider_options_update_input.go @@ -0,0 +1,121 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// ProviderOptionsUpdateInput Mutable provider options. +// swagger:model ProviderOptionsUpdateInput +type ProviderOptionsUpdateInput struct { + + // aws + Aws *ProviderOptionsAwsUpdateInput `json:"aws"` + + // aws govcloud + AwsGovcloud *ProviderOptionsAwsUpdateInput `json:"aws_govcloud"` + + // azure + Azure *ProviderOptionsAzureUpdateInput `json:"azure"` +} + +// Validate validates this provider options update input +func (m *ProviderOptionsUpdateInput) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAws(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAwsGovcloud(formats); err != nil { + res = append(res, err) + } + + if err := m.validateAzure(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ProviderOptionsUpdateInput) validateAws(formats strfmt.Registry) error { + + if swag.IsZero(m.Aws) { // not required + return nil + } + + if m.Aws != nil { + if err := m.Aws.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("aws") + } + return err + } + } + + return nil +} + +func (m *ProviderOptionsUpdateInput) validateAwsGovcloud(formats strfmt.Registry) error { + + if swag.IsZero(m.AwsGovcloud) { // not required + return nil + } + + if m.AwsGovcloud != nil { + if err := m.AwsGovcloud.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("aws_govcloud") + } + return err + } + } + + return nil +} + +func (m *ProviderOptionsUpdateInput) validateAzure(formats strfmt.Registry) error { + + if swag.IsZero(m.Azure) { // not required + return nil + } + + if m.Azure != nil { + if err := m.Azure.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("azure") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ProviderOptionsUpdateInput) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ProviderOptionsUpdateInput) UnmarshalBinary(b []byte) error { + var res ProviderOptionsUpdateInput + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/resource.go b/models/resource.go new file mode 100644 index 0000000..4a237e0 --- /dev/null +++ b/models/resource.go @@ -0,0 +1,46 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// Resource A resource. +// swagger:model Resource +type Resource struct { + + // Resource ID. + ResourceID string `json:"resource_id"` + + // Resource type. + ResourceType string `json:"resource_type"` +} + +// Validate validates this resource +func (m *Resource) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *Resource) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Resource) UnmarshalBinary(b []byte) error { + var res Resource + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/resource_diff.go b/models/resource_diff.go new file mode 100644 index 0000000..53db669 --- /dev/null +++ b/models/resource_diff.go @@ -0,0 +1,142 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ResourceDiff Difference between the old and new state of a resource after an event. +// swagger:model ResourceDiff +type ResourceDiff struct { + + // Description of the changes to the resource's attributes. + Attributes []*Attribute `json:"attributes"` + + // Type of change which occurred. + // Enum: [ADDED MODIFIED REMOVED] + Change string `json:"change"` + + // ID of the resource given by the provider. + ResourceID string `json:"resource_id"` + + // Resource type. + ResourceType string `json:"resource_type"` +} + +// Validate validates this resource diff +func (m *ResourceDiff) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAttributes(formats); err != nil { + res = append(res, err) + } + + if err := m.validateChange(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ResourceDiff) validateAttributes(formats strfmt.Registry) error { + + if swag.IsZero(m.Attributes) { // not required + return nil + } + + for i := 0; i < len(m.Attributes); i++ { + if swag.IsZero(m.Attributes[i]) { // not required + continue + } + + if m.Attributes[i] != nil { + if err := m.Attributes[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("attributes" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +var resourceDiffTypeChangePropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["ADDED","MODIFIED","REMOVED"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + resourceDiffTypeChangePropEnum = append(resourceDiffTypeChangePropEnum, v) + } +} + +const ( + + // ResourceDiffChangeADDED captures enum value "ADDED" + ResourceDiffChangeADDED string = "ADDED" + + // ResourceDiffChangeMODIFIED captures enum value "MODIFIED" + ResourceDiffChangeMODIFIED string = "MODIFIED" + + // ResourceDiffChangeREMOVED captures enum value "REMOVED" + ResourceDiffChangeREMOVED string = "REMOVED" +) + +// prop value enum +func (m *ResourceDiff) validateChangeEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, resourceDiffTypeChangePropEnum); err != nil { + return err + } + return nil +} + +func (m *ResourceDiff) validateChange(formats strfmt.Registry) error { + + if swag.IsZero(m.Change) { // not required + return nil + } + + // value enum + if err := m.validateChangeEnum("change", "body", m.Change); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ResourceDiff) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ResourceDiff) UnmarshalBinary(b []byte) error { + var res ResourceDiff + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/resource_summary.go b/models/resource_summary.go new file mode 100644 index 0000000..ca9a00e --- /dev/null +++ b/models/resource_summary.go @@ -0,0 +1,141 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// ResourceSummary Summary of resources for a scan. +// swagger:model ResourceSummary +type ResourceSummary struct { + + // Number of compliant resources. + Compliant int64 `json:"compliant"` + + // Compliance summary for the compliance families run against resources for the scan. + Families []*ResourceSummaryFamiliesItems0 `json:"families"` + + // Number of noncompliant resources. + Noncompliant int64 `json:"noncompliant"` + + // Number of resource types in the scan. + ResourceTypes int64 `json:"resource_types"` + + // Number of compliance rules failed. + RulesFailed int64 `json:"rules_failed"` + + // Number of compliance rules passed. + RulesPassed int64 `json:"rules_passed"` + + // Total number of resources in the scan. + Total int64 `json:"total"` +} + +// Validate validates this resource summary +func (m *ResourceSummary) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateFamilies(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ResourceSummary) validateFamilies(formats strfmt.Registry) error { + + if swag.IsZero(m.Families) { // not required + return nil + } + + for i := 0; i < len(m.Families); i++ { + if swag.IsZero(m.Families[i]) { // not required + continue + } + + if m.Families[i] != nil { + if err := m.Families[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("families" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ResourceSummary) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ResourceSummary) UnmarshalBinary(b []byte) error { + var res ResourceSummary + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// ResourceSummaryFamiliesItems0 Compliance summary for the compliance family run against resources for the scan. +// swagger:model ResourceSummaryFamiliesItems0 +type ResourceSummaryFamiliesItems0 struct { + + // Number of compliant resources in this family. + Compliant int64 `json:"compliant"` + + // Name of the compliance family. + Family string `json:"family"` + + // Number of noncompliant resources in this family. + Noncompliant int64 `json:"noncompliant"` + + // Number of compliance rules failed in this family. + RulesFailed int64 `json:"rules_failed"` + + // Number of compliance rules passed in this family. + RulesPassed int64 `json:"rules_passed"` +} + +// Validate validates this resource summary families items0 +func (m *ResourceSummaryFamiliesItems0) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ResourceSummaryFamiliesItems0) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ResourceSummaryFamiliesItems0) UnmarshalBinary(b []byte) error { + var res ResourceSummaryFamiliesItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/resource_summary_families_items.go b/models/resource_summary_families_items.go new file mode 100644 index 0000000..fe7c734 --- /dev/null +++ b/models/resource_summary_families_items.go @@ -0,0 +1,55 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// ResourceSummaryFamiliesItems Compliance summary for the compliance family run against resources for the scan. +// swagger:model resourceSummaryFamiliesItems +type ResourceSummaryFamiliesItems struct { + + // Number of compliant resources in this family. + Compliant int64 `json:"compliant"` + + // Name of the compliance family. + Family string `json:"family"` + + // Number of noncompliant resources in this family. + Noncompliant int64 `json:"noncompliant"` + + // Number of compliance rules failed in this family. + RulesFailed int64 `json:"rules_failed"` + + // Number of compliance rules passed in this family. + RulesPassed int64 `json:"rules_passed"` +} + +// Validate validates this resource summary families items +func (m *ResourceSummaryFamiliesItems) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ResourceSummaryFamiliesItems) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ResourceSummaryFamiliesItems) UnmarshalBinary(b []byte) error { + var res ResourceSummaryFamiliesItems + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/resource_type_metadata.go b/models/resource_type_metadata.go new file mode 100644 index 0000000..682c8fb --- /dev/null +++ b/models/resource_type_metadata.go @@ -0,0 +1,43 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// ResourceTypeMetadata List of resource types supported by Fugue. +// swagger:model ResourceTypeMetadata +type ResourceTypeMetadata struct { + + // List of resource types supported by Fugue. + ResourceTypes []string `json:"resource_types"` +} + +// Validate validates this resource type metadata +func (m *ResourceTypeMetadata) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *ResourceTypeMetadata) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ResourceTypeMetadata) UnmarshalBinary(b []byte) error { + var res ResourceTypeMetadata + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/scan.go b/models/scan.go new file mode 100644 index 0000000..8dde57e --- /dev/null +++ b/models/scan.go @@ -0,0 +1,133 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// Scan A scan belonging to an environment. +// swagger:model Scan +type Scan struct { + + // Time the scan was created. + CreatedAt int64 `json:"created_at"` + + // ID of the environment the scan belongs to. + EnvironmentID string `json:"environment_id"` + + // Time the scan was finished. + FinishedAt int64 `json:"finished_at"` + + // ID of the scan. + ID string `json:"id"` + + // Message related to the scan. + Message string `json:"message"` + + // Indicates whether there were any remediation errors on the scan. + RemediationError bool `json:"remediation_error"` + + // Status of the scan. + // Enum: [CREATED QUEUED IN_PROGRESS ERROR SUCCESS CANCELED] + Status string `json:"status"` + + // Time the scan was last updated. + UpdatedAt int64 `json:"updated_at"` +} + +// Validate validates this scan +func (m *Scan) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateStatus(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var scanTypeStatusPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["CREATED","QUEUED","IN_PROGRESS","ERROR","SUCCESS","CANCELED"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + scanTypeStatusPropEnum = append(scanTypeStatusPropEnum, v) + } +} + +const ( + + // ScanStatusCREATED captures enum value "CREATED" + ScanStatusCREATED string = "CREATED" + + // ScanStatusQUEUED captures enum value "QUEUED" + ScanStatusQUEUED string = "QUEUED" + + // ScanStatusINPROGRESS captures enum value "IN_PROGRESS" + ScanStatusINPROGRESS string = "IN_PROGRESS" + + // ScanStatusERROR captures enum value "ERROR" + ScanStatusERROR string = "ERROR" + + // ScanStatusSUCCESS captures enum value "SUCCESS" + ScanStatusSUCCESS string = "SUCCESS" + + // ScanStatusCANCELED captures enum value "CANCELED" + ScanStatusCANCELED string = "CANCELED" +) + +// prop value enum +func (m *Scan) validateStatusEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, scanTypeStatusPropEnum); err != nil { + return err + } + return nil +} + +func (m *Scan) validateStatus(formats strfmt.Registry) error { + + if swag.IsZero(m.Status) { // not required + return nil + } + + // value enum + if err := m.validateStatusEnum("status", "body", m.Status); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Scan) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Scan) UnmarshalBinary(b []byte) error { + var res Scan + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/scan_with_summary.go b/models/scan_with_summary.go new file mode 100644 index 0000000..559938d --- /dev/null +++ b/models/scan_with_summary.go @@ -0,0 +1,234 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ScanWithSummary A scan belonging to an environment. +// swagger:model ScanWithSummary +type ScanWithSummary struct { + Scan + + // resource summary + ResourceSummary *ResourceSummary `json:"resource_summary"` + + // resource type errors + ResourceTypeErrors []*ScanWithSummaryResourceTypeErrorsItems0 `json:"resource_type_errors"` +} + +// UnmarshalJSON unmarshals this object from a JSON structure +func (m *ScanWithSummary) UnmarshalJSON(raw []byte) error { + // AO0 + var aO0 Scan + if err := swag.ReadJSON(raw, &aO0); err != nil { + return err + } + m.Scan = aO0 + + // AO1 + var dataAO1 struct { + ResourceSummary *ResourceSummary `json:"resource_summary"` + + ResourceTypeErrors []*ScanWithSummaryResourceTypeErrorsItems0 `json:"resource_type_errors"` + } + if err := swag.ReadJSON(raw, &dataAO1); err != nil { + return err + } + + m.ResourceSummary = dataAO1.ResourceSummary + + m.ResourceTypeErrors = dataAO1.ResourceTypeErrors + + return nil +} + +// MarshalJSON marshals this object to a JSON structure +func (m ScanWithSummary) MarshalJSON() ([]byte, error) { + _parts := make([][]byte, 0, 2) + + aO0, err := swag.WriteJSON(m.Scan) + if err != nil { + return nil, err + } + _parts = append(_parts, aO0) + + var dataAO1 struct { + ResourceSummary *ResourceSummary `json:"resource_summary"` + + ResourceTypeErrors []*ScanWithSummaryResourceTypeErrorsItems0 `json:"resource_type_errors"` + } + + dataAO1.ResourceSummary = m.ResourceSummary + + dataAO1.ResourceTypeErrors = m.ResourceTypeErrors + + jsonDataAO1, errAO1 := swag.WriteJSON(dataAO1) + if errAO1 != nil { + return nil, errAO1 + } + _parts = append(_parts, jsonDataAO1) + + return swag.ConcatJSON(_parts...), nil +} + +// Validate validates this scan with summary +func (m *ScanWithSummary) Validate(formats strfmt.Registry) error { + var res []error + + // validation for a type composition with Scan + if err := m.Scan.Validate(formats); err != nil { + res = append(res, err) + } + + if err := m.validateResourceSummary(formats); err != nil { + res = append(res, err) + } + + if err := m.validateResourceTypeErrors(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ScanWithSummary) validateResourceSummary(formats strfmt.Registry) error { + + if swag.IsZero(m.ResourceSummary) { // not required + return nil + } + + if m.ResourceSummary != nil { + if err := m.ResourceSummary.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resource_summary") + } + return err + } + } + + return nil +} + +func (m *ScanWithSummary) validateResourceTypeErrors(formats strfmt.Registry) error { + + if swag.IsZero(m.ResourceTypeErrors) { // not required + return nil + } + + for i := 0; i < len(m.ResourceTypeErrors); i++ { + if swag.IsZero(m.ResourceTypeErrors[i]) { // not required + continue + } + + if m.ResourceTypeErrors[i] != nil { + if err := m.ResourceTypeErrors[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resource_type_errors" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ScanWithSummary) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScanWithSummary) UnmarshalBinary(b []byte) error { + var res ScanWithSummary + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} + +// ScanWithSummaryResourceTypeErrorsItems0 scan with summary resource type errors items0 +// swagger:model ScanWithSummaryResourceTypeErrorsItems0 +type ScanWithSummaryResourceTypeErrorsItems0 struct { + + // error message + // Required: true + ErrorMessage *string `json:"error_message"` + + // resource type + // Required: true + ResourceType *string `json:"resource_type"` +} + +// Validate validates this scan with summary resource type errors items0 +func (m *ScanWithSummaryResourceTypeErrorsItems0) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateErrorMessage(formats); err != nil { + res = append(res, err) + } + + if err := m.validateResourceType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ScanWithSummaryResourceTypeErrorsItems0) validateErrorMessage(formats strfmt.Registry) error { + + if err := validate.Required("error_message", "body", m.ErrorMessage); err != nil { + return err + } + + return nil +} + +func (m *ScanWithSummaryResourceTypeErrorsItems0) validateResourceType(formats strfmt.Registry) error { + + if err := validate.Required("resource_type", "body", m.ResourceType); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ScanWithSummaryResourceTypeErrorsItems0) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScanWithSummaryResourceTypeErrorsItems0) UnmarshalBinary(b []byte) error { + var res ScanWithSummaryResourceTypeErrorsItems0 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/scan_with_summary_all_of1.go b/models/scan_with_summary_all_of1.go new file mode 100644 index 0000000..9c38481 --- /dev/null +++ b/models/scan_with_summary_all_of1.go @@ -0,0 +1,105 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// ScanWithSummaryAllOf1 scan with summary all of1 +// swagger:model scanWithSummaryAllOf1 +type ScanWithSummaryAllOf1 struct { + + // resource summary + ResourceSummary *ResourceSummary `json:"resource_summary"` + + // resource type errors + ResourceTypeErrors []*ScanWithSummaryAllOf1ResourceTypeErrorsItems `json:"resource_type_errors"` +} + +// Validate validates this scan with summary all of1 +func (m *ScanWithSummaryAllOf1) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateResourceSummary(formats); err != nil { + res = append(res, err) + } + + if err := m.validateResourceTypeErrors(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ScanWithSummaryAllOf1) validateResourceSummary(formats strfmt.Registry) error { + + if swag.IsZero(m.ResourceSummary) { // not required + return nil + } + + if m.ResourceSummary != nil { + if err := m.ResourceSummary.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resource_summary") + } + return err + } + } + + return nil +} + +func (m *ScanWithSummaryAllOf1) validateResourceTypeErrors(formats strfmt.Registry) error { + + if swag.IsZero(m.ResourceTypeErrors) { // not required + return nil + } + + for i := 0; i < len(m.ResourceTypeErrors); i++ { + if swag.IsZero(m.ResourceTypeErrors[i]) { // not required + continue + } + + if m.ResourceTypeErrors[i] != nil { + if err := m.ResourceTypeErrors[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("resource_type_errors" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ScanWithSummaryAllOf1) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScanWithSummaryAllOf1) UnmarshalBinary(b []byte) error { + var res ScanWithSummaryAllOf1 + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/scan_with_summary_all_of1_resource_type_errors_items.go b/models/scan_with_summary_all_of1_resource_type_errors_items.go new file mode 100644 index 0000000..5c613fb --- /dev/null +++ b/models/scan_with_summary_all_of1_resource_type_errors_items.go @@ -0,0 +1,81 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// ScanWithSummaryAllOf1ResourceTypeErrorsItems scan with summary all of1 resource type errors items +// swagger:model scanWithSummaryAllOf1ResourceTypeErrorsItems +type ScanWithSummaryAllOf1ResourceTypeErrorsItems struct { + + // error message + // Required: true + ErrorMessage *string `json:"error_message"` + + // resource type + // Required: true + ResourceType *string `json:"resource_type"` +} + +// Validate validates this scan with summary all of1 resource type errors items +func (m *ScanWithSummaryAllOf1ResourceTypeErrorsItems) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateErrorMessage(formats); err != nil { + res = append(res, err) + } + + if err := m.validateResourceType(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *ScanWithSummaryAllOf1ResourceTypeErrorsItems) validateErrorMessage(formats strfmt.Registry) error { + + if err := validate.Required("error_message", "body", m.ErrorMessage); err != nil { + return err + } + + return nil +} + +func (m *ScanWithSummaryAllOf1ResourceTypeErrorsItems) validateResourceType(formats strfmt.Registry) error { + + if err := validate.Required("resource_type", "body", m.ResourceType); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *ScanWithSummaryAllOf1ResourceTypeErrorsItems) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *ScanWithSummaryAllOf1ResourceTypeErrorsItems) UnmarshalBinary(b []byte) error { + var res ScanWithSummaryAllOf1ResourceTypeErrorsItems + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/scans.go b/models/scans.go new file mode 100644 index 0000000..8c8e094 --- /dev/null +++ b/models/scans.go @@ -0,0 +1,89 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "strconv" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" +) + +// Scans Paginated list of scans. +// swagger:model Scans +type Scans struct { + + // Total number of items. + Count int64 `json:"count"` + + // Indicates whether there are more items at the next offset. + IsTruncated bool `json:"is_truncated"` + + // Paginated list of scans. + Items []*Scan `json:"items"` + + // Next offset to use to get the next page of items. + NextOffset int64 `json:"next_offset"` +} + +// Validate validates this scans +func (m *Scans) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateItems(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *Scans) validateItems(formats strfmt.Registry) error { + + if swag.IsZero(m.Items) { // not required + return nil + } + + for i := 0; i < len(m.Items); i++ { + if swag.IsZero(m.Items[i]) { // not required + continue + } + + if m.Items[i] != nil { + if err := m.Items[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("items" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *Scans) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *Scans) UnmarshalBinary(b []byte) error { + var res Scans + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/update_environment_input.go b/models/update_environment_input.go new file mode 100644 index 0000000..8818e2b --- /dev/null +++ b/models/update_environment_input.go @@ -0,0 +1,170 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "encoding/json" + + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/errors" + "github.com/go-openapi/swag" + "github.com/go-openapi/validate" +) + +// UpdateEnvironmentInput A managed environment. +// swagger:model UpdateEnvironmentInput +type UpdateEnvironmentInput struct { + + // Scan ID of the baseline if baseline is enabled. + BaselineID string `json:"baseline_id"` + + // List of compliance families validated against the environment. + ComplianceFamilies []string `json:"compliance_families"` + + // Name of the environment. + Name string `json:"name"` + + // Name of the cloud service provider for the environment. + // Enum: [aws aws_govcloud azure] + Provider string `json:"provider"` + + // provider options + ProviderOptions *ProviderOptionsUpdateInput `json:"provider_options"` + + // List of resource types remediated for the environment if remediation is enabled. + RemediateResourceTypes []string `json:"remediate_resource_types"` + + // Indicates whether remediation is enabled for the environment. + Remediation bool `json:"remediation"` + + // Time in seconds between the end of one scan to the start of the next. Must also set scan_schedule_enabled to true. + // Minimum: 300 + ScanInterval int64 `json:"scan_interval"` + + // Indicates whether an environment is scanned on a schedule. + ScanScheduleEnabled bool `json:"scan_schedule_enabled"` + + // List of resource types surveyed for the environment. + SurveyResourceTypes []string `json:"survey_resource_types"` +} + +// Validate validates this update environment input +func (m *UpdateEnvironmentInput) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateProvider(formats); err != nil { + res = append(res, err) + } + + if err := m.validateProviderOptions(formats); err != nil { + res = append(res, err) + } + + if err := m.validateScanInterval(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +var updateEnvironmentInputTypeProviderPropEnum []interface{} + +func init() { + var res []string + if err := json.Unmarshal([]byte(`["aws","aws_govcloud","azure"]`), &res); err != nil { + panic(err) + } + for _, v := range res { + updateEnvironmentInputTypeProviderPropEnum = append(updateEnvironmentInputTypeProviderPropEnum, v) + } +} + +const ( + + // UpdateEnvironmentInputProviderAws captures enum value "aws" + UpdateEnvironmentInputProviderAws string = "aws" + + // UpdateEnvironmentInputProviderAwsGovcloud captures enum value "aws_govcloud" + UpdateEnvironmentInputProviderAwsGovcloud string = "aws_govcloud" + + // UpdateEnvironmentInputProviderAzure captures enum value "azure" + UpdateEnvironmentInputProviderAzure string = "azure" +) + +// prop value enum +func (m *UpdateEnvironmentInput) validateProviderEnum(path, location string, value string) error { + if err := validate.Enum(path, location, value, updateEnvironmentInputTypeProviderPropEnum); err != nil { + return err + } + return nil +} + +func (m *UpdateEnvironmentInput) validateProvider(formats strfmt.Registry) error { + + if swag.IsZero(m.Provider) { // not required + return nil + } + + // value enum + if err := m.validateProviderEnum("provider", "body", m.Provider); err != nil { + return err + } + + return nil +} + +func (m *UpdateEnvironmentInput) validateProviderOptions(formats strfmt.Registry) error { + + if swag.IsZero(m.ProviderOptions) { // not required + return nil + } + + if m.ProviderOptions != nil { + if err := m.ProviderOptions.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("provider_options") + } + return err + } + } + + return nil +} + +func (m *UpdateEnvironmentInput) validateScanInterval(formats strfmt.Registry) error { + + if swag.IsZero(m.ScanInterval) { // not required + return nil + } + + if err := validate.MinimumInt("scan_interval", "body", int64(m.ScanInterval), 300, false); err != nil { + return err + } + + return nil +} + +// MarshalBinary interface implementation +func (m *UpdateEnvironmentInput) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UpdateEnvironmentInput) UnmarshalBinary(b []byte) error { + var res UpdateEnvironmentInput + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/models/update_notification_input.go b/models/update_notification_input.go new file mode 100644 index 0000000..0067582 --- /dev/null +++ b/models/update_notification_input.go @@ -0,0 +1,55 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + strfmt "github.com/go-openapi/strfmt" + + "github.com/go-openapi/swag" +) + +// UpdateNotificationInput Request for updating an existing notification. +// swagger:model UpdateNotificationInput +type UpdateNotificationInput struct { + + // List of email address the notification is delivered to. + Emails []string `json:"emails"` + + // List of environment ids the notification is attached to. + Environments []string `json:"environments"` + + // List of events the notification is triggered on. + Events []string `json:"events"` + + // Human readable name of the notification. + Name string `json:"name"` + + // AWS SNS topic arn the notification is delivered to. + TopicArn string `json:"topic_arn"` +} + +// Validate validates this update notification input +func (m *UpdateNotificationInput) Validate(formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *UpdateNotificationInput) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *UpdateNotificationInput) UnmarshalBinary(b []byte) error { + var res UpdateNotificationInput + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +}