diff --git a/.envrc b/.envrc index 425b88b73d1..7707113586c 100644 --- a/.envrc +++ b/.envrc @@ -310,7 +310,6 @@ export SERVE_API_INTERNAL=true export SERVE_API_GHC=true export SERVE_API_PRIME=true export SERVE_API_SUPPORT=true -export SERVE_API_PPTAS=true # enable prime simulator locally export SERVE_PRIME_SIMULATOR=true diff --git a/.gitignore b/.gitignore index febfd4d0dcc..5150b1676c9 100644 --- a/.gitignore +++ b/.gitignore @@ -64,7 +64,6 @@ public/swagger-ui/* !public/swagger-ui/prime_v3.html !public/swagger-ui/ghc.html !public/swagger-ui/support.html -!public/swagger-ui/pptas.html # Playwright integration tests playwright/.cache diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 575ab13889e..55781afb6f1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -180,7 +180,7 @@ repos: name: Spectral yaml linter entry: scripts/lint-yaml-with-spectral language: script - files: swagger/(admin|prime|prime_v2|prime_v3|support|pptas).yaml + files: swagger/(admin|prime|prime_v2|prime_v3|support).yaml types: [yaml] - repo: local diff --git a/.redocly.yaml b/.redocly.yaml index 58887a3bd29..e92e7f52ebf 100644 --- a/.redocly.yaml +++ b/.redocly.yaml @@ -8,7 +8,6 @@ apiDefinitions: prime_v2: swagger-def/prime_v2.yaml prime_v3: swagger-def/prime_v3.yaml support: swagger-def/support.yaml - pptas: swagger-def/pptas.yaml lint: extends: - recommended diff --git a/Makefile b/Makefile index b739a1b9189..b7c7633b4b0 100644 --- a/Makefile +++ b/Makefile @@ -213,8 +213,6 @@ admin_client_run: .client_deps.stamp ## Run MilMove Admin client HOST=adminlocal \ yarn start - - # # ----- END CLIENT TARGETS ----- # diff --git a/cmd/milmove/serve.go b/cmd/milmove/serve.go index cfddd0bfca4..db14c874853 100644 --- a/cmd/milmove/serve.go +++ b/cmd/milmove/serve.go @@ -409,10 +409,6 @@ func initializeRouteOptions(v *viper.Viper, routingConfig *routing.Config) { if routingConfig.ServeGHC { routingConfig.GHCSwaggerPath = v.GetString(cli.GHCSwaggerFlag) } - routingConfig.ServePPTAS = v.GetBool(cli.ServePPTASFlag) - if routingConfig.ServePPTAS { - routingConfig.PPTASSwaggerPath = v.GetString(cli.PPTASSwaggerFlag) - } routingConfig.ServeDevlocalAuth = v.GetBool(cli.DevlocalAuthFlag) routingConfig.GitBranch = gitBranch @@ -437,7 +433,6 @@ func buildRoutingConfig(appCtx appcontext.AppContext, v *viper.Viper, redisPool AdminServername: v.GetString(cli.HTTPAdminServerNameFlag), OrdersServername: v.GetString(cli.HTTPOrdersServerNameFlag), PrimeServername: v.GetString(cli.HTTPPrimeServerNameFlag), - PPTASServerName: v.GetString(cli.HTTPPPTASServerNameFlag), } clientAuthSecretKey := v.GetString(cli.ClientAuthSecretKeyFlag) diff --git a/pkg/auth/cookie.go b/pkg/auth/cookie.go index 1d099340cd4..b0ea67f3f36 100644 --- a/pkg/auth/cookie.go +++ b/pkg/auth/cookie.go @@ -20,7 +20,6 @@ type ApplicationServername struct { AdminServername string OrdersServername string PrimeServername string - PPTASServerName string } type errInvalidHostname struct { diff --git a/pkg/cli/hosts.go b/pkg/cli/hosts.go index a2ae02db622..91d7f700c76 100644 --- a/pkg/cli/hosts.go +++ b/pkg/cli/hosts.go @@ -20,8 +20,6 @@ const ( HTTPOrdersServerNameFlag string = "http-orders-server-name" // HTTPPrimeServerNameFlag is the HTTP GHC Prime Server Name Flag HTTPPrimeServerNameFlag string = "http-prime-server-name" - // HTTPPPTASServerNameFlag is the HTTP PPTAS Prime Server Name Flag - HTTPPPTASServerNameFlag string = "http-pptas-server-name" // HTTPMyServerNameLocal is the HTTP My Server Name for Local HTTPMyServerNameLocal string = "milmovelocal" // HTTPOfficeServerNameLocal is the HTTP Office Server Name for Local diff --git a/pkg/cli/services.go b/pkg/cli/services.go index 0efdcff646c..407ec81aaa7 100644 --- a/pkg/cli/services.go +++ b/pkg/cli/services.go @@ -22,8 +22,6 @@ const ( ServeSupportFlag string = "serve-api-support" // ServePrimeSimulatorFlag is the prime simulator api flag ServePrimeSimulatorFlag string = "serve-prime-simulator" - // ServePPTASFlag is the PPTAS api service flag - ServePPTASFlag string = "serve-api-pptas" // ServeClientCollectorFlag enables the endpoints to collect client // telemetry and logs ServeClientCollectorFlag string = "serve-client-collector" diff --git a/pkg/cli/swagger.go b/pkg/cli/swagger.go index fb52e3c22fc..547d3da2fe7 100644 --- a/pkg/cli/swagger.go +++ b/pkg/cli/swagger.go @@ -23,12 +23,10 @@ const ( PrimeV2SwaggerFlag string = "prime-v2-swagger" // PrimeV3SwaggerFlag is the Prime V3 Swagger Flag PrimeV3SwaggerFlag string = "prime-v3-swagger" - // SupportSwaggerFlag is the Support Swagger Flag - SupportSwaggerFlag string = "support-swagger" - // PPTASSwaggerFlag is the PPTAS Swagger Flag - PPTASSwaggerFlag string = "pptas-swagger" // ServeSwaggerUIFlag is the Serve Swagger UI Flag ServeSwaggerUIFlag string = "serve-swagger-ui" + // SupportSwaggerFlag is the Support Swagger Flag + SupportSwaggerFlag string = "support-swagger" ) // InitSwaggerFlags initializes the Swagger command line flags @@ -42,8 +40,7 @@ func InitSwaggerFlags(flag *pflag.FlagSet) { flag.String(PrimeV2SwaggerFlag, "swagger/prime_v2.yaml", "The location of the Prime V2 API swagger definition") flag.String(PrimeV3SwaggerFlag, "swagger/prime_v3.yaml", "The location of the Prime V3 API swagger definition") flag.String(SupportSwaggerFlag, "swagger/support.yaml", "The location of the Support API swagger definition") - flag.String(PPTASSwaggerFlag, "swagger/pptas.yaml", "The location of the PPTAS Export API swagger definition") - flag.Bool(ServeSwaggerUIFlag, true, "Whether to serve swagger UI for the APIs") + flag.Bool(ServeSwaggerUIFlag, false, "Whether to serve swagger UI for the APIs") } // CheckSwagger validates Swagger command line flags @@ -58,7 +55,6 @@ func CheckSwagger(v *viper.Viper) error { PrimeV2SwaggerFlag, PrimeV3SwaggerFlag, SupportSwaggerFlag, - PPTASSwaggerFlag, } for _, c := range swaggerVars { diff --git a/pkg/gen/pptasapi/configure_mymove.go b/pkg/gen/pptasapi/configure_mymove.go deleted file mode 100644 index a9d77e45b46..00000000000 --- a/pkg/gen/pptasapi/configure_mymove.go +++ /dev/null @@ -1,76 +0,0 @@ -// This file is safe to edit. Once it exists it will not be overwritten - -package pptasapi - -import ( - "crypto/tls" - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - - "github.com/transcom/mymove/pkg/gen/pptasapi/pptasoperations" - "github.com/transcom/mymove/pkg/gen/pptasapi/pptasoperations/moves" -) - -//go:generate swagger generate server --target ../../gen --name Mymove --spec ../../../swagger/pptas.yaml --api-package pptasoperations --model-package pptasmessages --server-package pptasapi --principal interface{} --exclude-main - -func configureFlags(api *pptasoperations.MymoveAPI) { - // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } -} - -func configureAPI(api *pptasoperations.MymoveAPI) http.Handler { - // configure the api here - api.ServeError = errors.ServeError - - // Set your custom logger if needed. Default one is log.Printf - // Expected interface func(string, ...interface{}) - // - // Example: - // api.Logger = log.Printf - - api.UseSwaggerUI() - // To continue using redoc as your UI, uncomment the following line - // api.UseRedoc() - - api.JSONConsumer = runtime.JSONConsumer() - - api.JSONProducer = runtime.JSONProducer() - - if api.MovesListMovesHandler == nil { - api.MovesListMovesHandler = moves.ListMovesHandlerFunc(func(params moves.ListMovesParams) middleware.Responder { - return middleware.NotImplemented("operation moves.ListMoves has not yet been implemented") - }) - } - - api.PreServerShutdown = func() {} - - api.ServerShutdown = func() {} - - return setupGlobalMiddleware(api.Serve(setupMiddlewares)) -} - -// The TLS configuration before HTTPS server starts. -func configureTLS(tlsConfig *tls.Config) { - // Make all necessary changes to the TLS configuration here. -} - -// As soon as server is initialized but not run yet, this function will be called. -// If you need to modify a config, store server instance to stop it individually later, this is the place. -// This function can be called multiple times, depending on the number of serving schemes. -// scheme value will be set accordingly: "http", "https" or "unix". -func configureServer(s *http.Server, scheme, addr string) { -} - -// The middleware configuration is for the handler executors. These do not apply to the swagger.json document. -// The middleware executes after routing but before authentication, binding and validation. -func setupMiddlewares(handler http.Handler) http.Handler { - return handler -} - -// The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document. -// So this is a good place to plug in a panic handling middleware, logging and metrics. -func setupGlobalMiddleware(handler http.Handler) http.Handler { - return handler -} diff --git a/pkg/gen/pptasapi/doc.go b/pkg/gen/pptasapi/doc.go deleted file mode 100644 index f91069f2715..00000000000 --- a/pkg/gen/pptasapi/doc.go +++ /dev/null @@ -1,25 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -// Package pptasapi MilMove PPTAS API -// -// The PPTAS API is a RESTful API that enables the Navy's PPTAS system to request -// information relating to current moves in progress. -// -// All endpoints are located at `/prime/pptas/`. -// -// Schemes: -// http -// Host: primelocal -// BasePath: /prime/pptas -// Version: 0.0.1 -// License: MIT https://opensource.org/licenses/MIT -// Contact: -// -// Consumes: -// - application/json -// -// Produces: -// - application/json -// -// swagger:meta -package pptasapi diff --git a/pkg/gen/pptasapi/embedded_spec.go b/pkg/gen/pptasapi/embedded_spec.go deleted file mode 100644 index 60509506328..00000000000 --- a/pkg/gen/pptasapi/embedded_spec.go +++ /dev/null @@ -1,361 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package pptasapi - -// 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" -) - -var ( - // SwaggerJSON embedded version of the swagger document used at generation time - SwaggerJSON json.RawMessage - // FlatSwaggerJSON embedded flattened version of the swagger document used at generation time - FlatSwaggerJSON json.RawMessage -) - -func init() { - SwaggerJSON = json.RawMessage([]byte(`{ - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "schemes": [ - "http" - ], - "swagger": "2.0", - "info": { - "description": "The PPTAS API is a RESTful API that enables the Navy's PPTAS system to request\ninformation relating to current moves in progress.\n\nAll endpoints are located at ` + "`" + `/prime/pptas/` + "`" + `.\n", - "title": "MilMove PPTAS API", - "contact": { - "email": "milmove-developers@caci.com" - }, - "license": { - "name": "MIT", - "url": "https://opensource.org/licenses/MIT" - }, - "version": "0.0.1" - }, - "host": "primelocal", - "basePath": "/prime/pptas", - "paths": { - "/moves": { - "get": { - "description": "Gets all moves that have been reviewed and approved by the TOO. The ` + "`" + `since` + "`" + ` parameter can be used to filter this\nlist down to only the moves that have been updated since the provided timestamp. A move will be considered\nupdated if the ` + "`" + `updatedAt` + "`" + ` timestamp on the move or on its orders, shipments, service items, or payment\nrequests, is later than the provided date and time.\n\n**WIP**: Include what causes moves to leave this list. Currently, once the ` + "`" + `availableToPrimeAt` + "`" + ` timestamp has\nbeen set, that move will always appear in this list.\n", - "produces": [ - "application/json" - ], - "tags": [ - "moves" - ], - "summary": "listMoves", - "operationId": "listMoves", - "parameters": [ - { - "type": "string", - "format": "date-time", - "description": "Only return moves updated since this time. Formatted like \"2021-07-23T18:30:47.116Z\"", - "name": "since", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successfully retrieved moves. A successful fetch might still return zero moves.", - "schema": { - "$ref": "#/definitions/ListMoves" - } - }, - "401": { - "$ref": "#/responses/PermissionDenied" - }, - "403": { - "$ref": "#/responses/PermissionDenied" - }, - "500": { - "$ref": "#/responses/ServerError" - } - } - } - } - }, - "definitions": { - "ClientError": { - "type": "object", - "required": [ - "title", - "detail", - "instance" - ], - "properties": { - "detail": { - "type": "string" - }, - "instance": { - "type": "string", - "format": "uuid" - }, - "title": { - "type": "string" - } - } - }, - "ListMove": { - "description": "An abbreviated definition for a move, without all the nested information (shipments, service items, etc). Used to fetch a list of moves more efficiently.\n", - "type": "object", - "properties": { - "availableToPrimeAt": { - "type": "string", - "format": "date-time", - "x-nullable": true, - "readOnly": true - }, - "createdAt": { - "type": "string", - "format": "date-time", - "readOnly": true - }, - "eTag": { - "type": "string", - "readOnly": true - }, - "id": { - "type": "string", - "format": "uuid", - "example": "1f2270c7-7166-40ae-981e-b200ebdf3054" - }, - "moveCode": { - "type": "string", - "readOnly": true, - "example": "HYXFJF" - }, - "orderID": { - "type": "string", - "format": "uuid", - "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" - }, - "ppmType": { - "type": "string", - "enum": [ - "FULL", - "PARTIAL" - ] - }, - "referenceId": { - "type": "string", - "example": "1001-3456" - }, - "updatedAt": { - "type": "string", - "format": "date-time", - "readOnly": true - } - } - }, - "ListMoves": { - "type": "array", - "items": { - "$ref": "#/definitions/ListMove" - } - } - }, - "responses": { - "PermissionDenied": { - "description": "The request was denied.", - "schema": { - "$ref": "#/definitions/ClientError" - } - }, - "ServerError": { - "description": "An unexpected error has occurred in the server.", - "schema": { - "$ref": "#/definitions/ClientError" - } - } - }, - "tags": [ - { - "name": "moves" - } - ] -}`)) - FlatSwaggerJSON = json.RawMessage([]byte(`{ - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "schemes": [ - "http" - ], - "swagger": "2.0", - "info": { - "description": "The PPTAS API is a RESTful API that enables the Navy's PPTAS system to request\ninformation relating to current moves in progress.\n\nAll endpoints are located at ` + "`" + `/prime/pptas/` + "`" + `.\n", - "title": "MilMove PPTAS API", - "contact": { - "email": "milmove-developers@caci.com" - }, - "license": { - "name": "MIT", - "url": "https://opensource.org/licenses/MIT" - }, - "version": "0.0.1" - }, - "host": "primelocal", - "basePath": "/prime/pptas", - "paths": { - "/moves": { - "get": { - "description": "Gets all moves that have been reviewed and approved by the TOO. The ` + "`" + `since` + "`" + ` parameter can be used to filter this\nlist down to only the moves that have been updated since the provided timestamp. A move will be considered\nupdated if the ` + "`" + `updatedAt` + "`" + ` timestamp on the move or on its orders, shipments, service items, or payment\nrequests, is later than the provided date and time.\n\n**WIP**: Include what causes moves to leave this list. Currently, once the ` + "`" + `availableToPrimeAt` + "`" + ` timestamp has\nbeen set, that move will always appear in this list.\n", - "produces": [ - "application/json" - ], - "tags": [ - "moves" - ], - "summary": "listMoves", - "operationId": "listMoves", - "parameters": [ - { - "type": "string", - "format": "date-time", - "description": "Only return moves updated since this time. Formatted like \"2021-07-23T18:30:47.116Z\"", - "name": "since", - "in": "query" - } - ], - "responses": { - "200": { - "description": "Successfully retrieved moves. A successful fetch might still return zero moves.", - "schema": { - "$ref": "#/definitions/ListMoves" - } - }, - "401": { - "description": "The request was denied.", - "schema": { - "$ref": "#/definitions/ClientError" - } - }, - "403": { - "description": "The request was denied.", - "schema": { - "$ref": "#/definitions/ClientError" - } - }, - "500": { - "description": "An unexpected error has occurred in the server.", - "schema": { - "$ref": "#/definitions/ClientError" - } - } - } - } - } - }, - "definitions": { - "ClientError": { - "type": "object", - "required": [ - "title", - "detail", - "instance" - ], - "properties": { - "detail": { - "type": "string" - }, - "instance": { - "type": "string", - "format": "uuid" - }, - "title": { - "type": "string" - } - } - }, - "ListMove": { - "description": "An abbreviated definition for a move, without all the nested information (shipments, service items, etc). Used to fetch a list of moves more efficiently.\n", - "type": "object", - "properties": { - "availableToPrimeAt": { - "type": "string", - "format": "date-time", - "x-nullable": true, - "readOnly": true - }, - "createdAt": { - "type": "string", - "format": "date-time", - "readOnly": true - }, - "eTag": { - "type": "string", - "readOnly": true - }, - "id": { - "type": "string", - "format": "uuid", - "example": "1f2270c7-7166-40ae-981e-b200ebdf3054" - }, - "moveCode": { - "type": "string", - "readOnly": true, - "example": "HYXFJF" - }, - "orderID": { - "type": "string", - "format": "uuid", - "example": "c56a4180-65aa-42ec-a945-5fd21dec0538" - }, - "ppmType": { - "type": "string", - "enum": [ - "FULL", - "PARTIAL" - ] - }, - "referenceId": { - "type": "string", - "example": "1001-3456" - }, - "updatedAt": { - "type": "string", - "format": "date-time", - "readOnly": true - } - } - }, - "ListMoves": { - "type": "array", - "items": { - "$ref": "#/definitions/ListMove" - } - } - }, - "responses": { - "PermissionDenied": { - "description": "The request was denied.", - "schema": { - "$ref": "#/definitions/ClientError" - } - }, - "ServerError": { - "description": "An unexpected error has occurred in the server.", - "schema": { - "$ref": "#/definitions/ClientError" - } - } - }, - "tags": [ - { - "name": "moves" - } - ] -}`)) -} diff --git a/pkg/gen/pptasapi/pptasoperations/moves/list_moves.go b/pkg/gen/pptasapi/pptasoperations/moves/list_moves.go deleted file mode 100644 index 6062de374fa..00000000000 --- a/pkg/gen/pptasapi/pptasoperations/moves/list_moves.go +++ /dev/null @@ -1,64 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package moves - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime/middleware" -) - -// ListMovesHandlerFunc turns a function with the right signature into a list moves handler -type ListMovesHandlerFunc func(ListMovesParams) middleware.Responder - -// Handle executing the request and returning a response -func (fn ListMovesHandlerFunc) Handle(params ListMovesParams) middleware.Responder { - return fn(params) -} - -// ListMovesHandler interface for that can handle valid list moves params -type ListMovesHandler interface { - Handle(ListMovesParams) middleware.Responder -} - -// NewListMoves creates a new http.Handler for the list moves operation -func NewListMoves(ctx *middleware.Context, handler ListMovesHandler) *ListMoves { - return &ListMoves{Context: ctx, Handler: handler} -} - -/* - ListMoves swagger:route GET /moves moves listMoves - -listMoves - -Gets all moves that have been reviewed and approved by the TOO. The `since` parameter can be used to filter this -list down to only the moves that have been updated since the provided timestamp. A move will be considered -updated if the `updatedAt` timestamp on the move or on its orders, shipments, service items, or payment -requests, is later than the provided date and time. - -**WIP**: Include what causes moves to leave this list. Currently, once the `availableToPrimeAt` timestamp has -been set, that move will always appear in this list. -*/ -type ListMoves struct { - Context *middleware.Context - Handler ListMovesHandler -} - -func (o *ListMoves) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - *r = *rCtx - } - var Params = NewListMovesParams() - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/pkg/gen/pptasapi/pptasoperations/moves/list_moves_parameters.go b/pkg/gen/pptasapi/pptasoperations/moves/list_moves_parameters.go deleted file mode 100644 index 7d92acc4d9a..00000000000 --- a/pkg/gen/pptasapi/pptasoperations/moves/list_moves_parameters.go +++ /dev/null @@ -1,97 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package moves - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/validate" -) - -// NewListMovesParams creates a new ListMovesParams object -// -// There are no default values defined in the spec. -func NewListMovesParams() ListMovesParams { - - return ListMovesParams{} -} - -// ListMovesParams contains all the bound params for the list moves operation -// typically these are obtained from a http.Request -// -// swagger:parameters listMoves -type ListMovesParams struct { - - // HTTP Request Object - HTTPRequest *http.Request `json:"-"` - - /*Only return moves updated since this time. Formatted like "2021-07-23T18:30:47.116Z" - In: query - */ - Since *strfmt.DateTime -} - -// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface -// for simple values it will use straight method calls. -// -// To ensure default values, the struct must have been initialized with NewListMovesParams() beforehand. -func (o *ListMovesParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { - var res []error - - o.HTTPRequest = r - - qs := runtime.Values(r.URL.Query()) - - qSince, qhkSince, _ := qs.GetOK("since") - if err := o.bindSince(qSince, qhkSince, route.Formats); err != nil { - res = append(res, err) - } - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// bindSince binds and validates parameter Since from query. -func (o *ListMovesParams) bindSince(rawData []string, hasKey bool, formats strfmt.Registry) error { - var raw string - if len(rawData) > 0 { - raw = rawData[len(rawData)-1] - } - - // Required: false - // AllowEmptyValue: false - - if raw == "" { // empty values pass all other validations - return nil - } - - // Format: date-time - value, err := formats.Parse("date-time", raw) - if err != nil { - return errors.InvalidType("since", "query", "strfmt.DateTime", raw) - } - o.Since = (value.(*strfmt.DateTime)) - - if err := o.validateSince(formats); err != nil { - return err - } - - return nil -} - -// validateSince carries on validations for parameter Since -func (o *ListMovesParams) validateSince(formats strfmt.Registry) error { - - if err := validate.FormatOf("since", "query", "date-time", o.Since.String(), formats); err != nil { - return err - } - return nil -} diff --git a/pkg/gen/pptasapi/pptasoperations/moves/list_moves_responses.go b/pkg/gen/pptasapi/pptasoperations/moves/list_moves_responses.go deleted file mode 100644 index 80649ff2982..00000000000 --- a/pkg/gen/pptasapi/pptasoperations/moves/list_moves_responses.go +++ /dev/null @@ -1,197 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package moves - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - - "github.com/transcom/mymove/pkg/gen/pptasmessages" -) - -// ListMovesOKCode is the HTTP code returned for type ListMovesOK -const ListMovesOKCode int = 200 - -/* -ListMovesOK Successfully retrieved moves. A successful fetch might still return zero moves. - -swagger:response listMovesOK -*/ -type ListMovesOK struct { - - /* - In: Body - */ - Payload pptasmessages.ListMoves `json:"body,omitempty"` -} - -// NewListMovesOK creates ListMovesOK with default headers values -func NewListMovesOK() *ListMovesOK { - - return &ListMovesOK{} -} - -// WithPayload adds the payload to the list moves o k response -func (o *ListMovesOK) WithPayload(payload pptasmessages.ListMoves) *ListMovesOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the list moves o k response -func (o *ListMovesOK) SetPayload(payload pptasmessages.ListMoves) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ListMovesOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(200) - payload := o.Payload - if payload == nil { - // return empty array - payload = pptasmessages.ListMoves{} - } - - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } -} - -// ListMovesUnauthorizedCode is the HTTP code returned for type ListMovesUnauthorized -const ListMovesUnauthorizedCode int = 401 - -/* -ListMovesUnauthorized The request was denied. - -swagger:response listMovesUnauthorized -*/ -type ListMovesUnauthorized struct { - - /* - In: Body - */ - Payload *pptasmessages.ClientError `json:"body,omitempty"` -} - -// NewListMovesUnauthorized creates ListMovesUnauthorized with default headers values -func NewListMovesUnauthorized() *ListMovesUnauthorized { - - return &ListMovesUnauthorized{} -} - -// WithPayload adds the payload to the list moves unauthorized response -func (o *ListMovesUnauthorized) WithPayload(payload *pptasmessages.ClientError) *ListMovesUnauthorized { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the list moves unauthorized response -func (o *ListMovesUnauthorized) SetPayload(payload *pptasmessages.ClientError) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ListMovesUnauthorized) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(401) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ListMovesForbiddenCode is the HTTP code returned for type ListMovesForbidden -const ListMovesForbiddenCode int = 403 - -/* -ListMovesForbidden The request was denied. - -swagger:response listMovesForbidden -*/ -type ListMovesForbidden struct { - - /* - In: Body - */ - Payload *pptasmessages.ClientError `json:"body,omitempty"` -} - -// NewListMovesForbidden creates ListMovesForbidden with default headers values -func NewListMovesForbidden() *ListMovesForbidden { - - return &ListMovesForbidden{} -} - -// WithPayload adds the payload to the list moves forbidden response -func (o *ListMovesForbidden) WithPayload(payload *pptasmessages.ClientError) *ListMovesForbidden { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the list moves forbidden response -func (o *ListMovesForbidden) SetPayload(payload *pptasmessages.ClientError) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ListMovesForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(403) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// ListMovesInternalServerErrorCode is the HTTP code returned for type ListMovesInternalServerError -const ListMovesInternalServerErrorCode int = 500 - -/* -ListMovesInternalServerError An unexpected error has occurred in the server. - -swagger:response listMovesInternalServerError -*/ -type ListMovesInternalServerError struct { - - /* - In: Body - */ - Payload *pptasmessages.ClientError `json:"body,omitempty"` -} - -// NewListMovesInternalServerError creates ListMovesInternalServerError with default headers values -func NewListMovesInternalServerError() *ListMovesInternalServerError { - - return &ListMovesInternalServerError{} -} - -// WithPayload adds the payload to the list moves internal server error response -func (o *ListMovesInternalServerError) WithPayload(payload *pptasmessages.ClientError) *ListMovesInternalServerError { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the list moves internal server error response -func (o *ListMovesInternalServerError) SetPayload(payload *pptasmessages.ClientError) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *ListMovesInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(500) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/pkg/gen/pptasapi/pptasoperations/moves/list_moves_urlbuilder.go b/pkg/gen/pptasapi/pptasoperations/moves/list_moves_urlbuilder.go deleted file mode 100644 index 2371770adb2..00000000000 --- a/pkg/gen/pptasapi/pptasoperations/moves/list_moves_urlbuilder.go +++ /dev/null @@ -1,105 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package moves - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "errors" - "net/url" - golangswaggerpaths "path" - - "github.com/go-openapi/strfmt" -) - -// ListMovesURL generates an URL for the list moves operation -type ListMovesURL struct { - Since *strfmt.DateTime - - _basePath string - // avoid unkeyed usage - _ struct{} -} - -// WithBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ListMovesURL) WithBasePath(bp string) *ListMovesURL { - o.SetBasePath(bp) - return o -} - -// SetBasePath sets the base path for this url builder, only required when it's different from the -// base path specified in the swagger spec. -// When the value of the base path is an empty string -func (o *ListMovesURL) SetBasePath(bp string) { - o._basePath = bp -} - -// Build a url path and query string -func (o *ListMovesURL) Build() (*url.URL, error) { - var _result url.URL - - var _path = "/moves" - - _basePath := o._basePath - if _basePath == "" { - _basePath = "/prime/pptas" - } - _result.Path = golangswaggerpaths.Join(_basePath, _path) - - qs := make(url.Values) - - var sinceQ string - if o.Since != nil { - sinceQ = o.Since.String() - } - if sinceQ != "" { - qs.Set("since", sinceQ) - } - - _result.RawQuery = qs.Encode() - - return &_result, nil -} - -// Must is a helper function to panic when the url builder returns an error -func (o *ListMovesURL) Must(u *url.URL, err error) *url.URL { - if err != nil { - panic(err) - } - if u == nil { - panic("url can't be nil") - } - return u -} - -// String returns the string representation of the path with query string -func (o *ListMovesURL) String() string { - return o.Must(o.Build()).String() -} - -// BuildFull builds a full url with scheme, host, path and query string -func (o *ListMovesURL) BuildFull(scheme, host string) (*url.URL, error) { - if scheme == "" { - return nil, errors.New("scheme is required for a full url on ListMovesURL") - } - if host == "" { - return nil, errors.New("host is required for a full url on ListMovesURL") - } - - base, err := o.Build() - if err != nil { - return nil, err - } - - base.Scheme = scheme - base.Host = host - return base, nil -} - -// StringFull returns the string representation of a complete url -func (o *ListMovesURL) StringFull(scheme, host string) string { - return o.Must(o.BuildFull(scheme, host)).String() -} diff --git a/pkg/gen/pptasapi/pptasoperations/mymove_api.go b/pkg/gen/pptasapi/pptasoperations/mymove_api.go deleted file mode 100644 index 46b9e47ce95..00000000000 --- a/pkg/gen/pptasapi/pptasoperations/mymove_api.go +++ /dev/null @@ -1,308 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package pptasoperations - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "net/http" - "strings" - - "github.com/go-openapi/errors" - "github.com/go-openapi/loads" - "github.com/go-openapi/runtime" - "github.com/go-openapi/runtime/middleware" - "github.com/go-openapi/runtime/security" - "github.com/go-openapi/spec" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - - "github.com/transcom/mymove/pkg/gen/pptasapi/pptasoperations/moves" -) - -// NewMymoveAPI creates a new Mymove instance -func NewMymoveAPI(spec *loads.Document) *MymoveAPI { - return &MymoveAPI{ - handlers: make(map[string]map[string]http.Handler), - formats: strfmt.Default, - defaultConsumes: "application/json", - defaultProduces: "application/json", - customConsumers: make(map[string]runtime.Consumer), - customProducers: make(map[string]runtime.Producer), - PreServerShutdown: func() {}, - ServerShutdown: func() {}, - spec: spec, - useSwaggerUI: false, - ServeError: errors.ServeError, - BasicAuthenticator: security.BasicAuth, - APIKeyAuthenticator: security.APIKeyAuth, - BearerAuthenticator: security.BearerAuth, - - JSONConsumer: runtime.JSONConsumer(), - - JSONProducer: runtime.JSONProducer(), - - MovesListMovesHandler: moves.ListMovesHandlerFunc(func(params moves.ListMovesParams) middleware.Responder { - return middleware.NotImplemented("operation moves.ListMoves has not yet been implemented") - }), - } -} - -/* -MymoveAPI The PPTAS API is a RESTful API that enables the Navy's PPTAS system to request -information relating to current moves in progress. - -All endpoints are located at `/prime/pptas/`. -*/ -type MymoveAPI struct { - spec *loads.Document - context *middleware.Context - handlers map[string]map[string]http.Handler - formats strfmt.Registry - customConsumers map[string]runtime.Consumer - customProducers map[string]runtime.Producer - defaultConsumes string - defaultProduces string - Middleware func(middleware.Builder) http.Handler - useSwaggerUI bool - - // BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function. - // It has a default implementation in the security package, however you can replace it for your particular usage. - BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator - - // APIKeyAuthenticator generates a runtime.Authenticator from the supplied token auth function. - // It has a default implementation in the security package, however you can replace it for your particular usage. - APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator - - // BearerAuthenticator generates a runtime.Authenticator from the supplied bearer token auth function. - // It has a default implementation in the security package, however you can replace it for your particular usage. - BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator - - // JSONConsumer registers a consumer for the following mime types: - // - application/json - JSONConsumer runtime.Consumer - - // JSONProducer registers a producer for the following mime types: - // - application/json - JSONProducer runtime.Producer - - // MovesListMovesHandler sets the operation handler for the list moves operation - MovesListMovesHandler moves.ListMovesHandler - - // ServeError is called when an error is received, there is a default handler - // but you can set your own with this - ServeError func(http.ResponseWriter, *http.Request, error) - - // PreServerShutdown is called before the HTTP(S) server is shutdown - // This allows for custom functions to get executed before the HTTP(S) server stops accepting traffic - PreServerShutdown func() - - // ServerShutdown is called when the HTTP(S) server is shut down and done - // handling all active connections and does not accept connections any more - ServerShutdown func() - - // Custom command line argument groups with their descriptions - CommandLineOptionsGroups []swag.CommandLineOptionsGroup - - // User defined logger function. - Logger func(string, ...interface{}) -} - -// UseRedoc for documentation at /docs -func (o *MymoveAPI) UseRedoc() { - o.useSwaggerUI = false -} - -// UseSwaggerUI for documentation at /docs -func (o *MymoveAPI) UseSwaggerUI() { - o.useSwaggerUI = true -} - -// SetDefaultProduces sets the default produces media type -func (o *MymoveAPI) SetDefaultProduces(mediaType string) { - o.defaultProduces = mediaType -} - -// SetDefaultConsumes returns the default consumes media type -func (o *MymoveAPI) SetDefaultConsumes(mediaType string) { - o.defaultConsumes = mediaType -} - -// SetSpec sets a spec that will be served for the clients. -func (o *MymoveAPI) SetSpec(spec *loads.Document) { - o.spec = spec -} - -// DefaultProduces returns the default produces media type -func (o *MymoveAPI) DefaultProduces() string { - return o.defaultProduces -} - -// DefaultConsumes returns the default consumes media type -func (o *MymoveAPI) DefaultConsumes() string { - return o.defaultConsumes -} - -// Formats returns the registered string formats -func (o *MymoveAPI) Formats() strfmt.Registry { - return o.formats -} - -// RegisterFormat registers a custom format validator -func (o *MymoveAPI) RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator) { - o.formats.Add(name, format, validator) -} - -// Validate validates the registrations in the MymoveAPI -func (o *MymoveAPI) Validate() error { - var unregistered []string - - if o.JSONConsumer == nil { - unregistered = append(unregistered, "JSONConsumer") - } - - if o.JSONProducer == nil { - unregistered = append(unregistered, "JSONProducer") - } - - if o.MovesListMovesHandler == nil { - unregistered = append(unregistered, "moves.ListMovesHandler") - } - - if len(unregistered) > 0 { - return fmt.Errorf("missing registration: %s", strings.Join(unregistered, ", ")) - } - - return nil -} - -// ServeErrorFor gets a error handler for a given operation id -func (o *MymoveAPI) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error) { - return o.ServeError -} - -// AuthenticatorsFor gets the authenticators for the specified security schemes -func (o *MymoveAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator { - return nil -} - -// Authorizer returns the registered authorizer -func (o *MymoveAPI) Authorizer() runtime.Authorizer { - return nil -} - -// ConsumersFor gets the consumers for the specified media types. -// MIME type parameters are ignored here. -func (o *MymoveAPI) ConsumersFor(mediaTypes []string) map[string]runtime.Consumer { - result := make(map[string]runtime.Consumer, len(mediaTypes)) - for _, mt := range mediaTypes { - switch mt { - case "application/json": - result["application/json"] = o.JSONConsumer - } - - if c, ok := o.customConsumers[mt]; ok { - result[mt] = c - } - } - return result -} - -// ProducersFor gets the producers for the specified media types. -// MIME type parameters are ignored here. -func (o *MymoveAPI) ProducersFor(mediaTypes []string) map[string]runtime.Producer { - result := make(map[string]runtime.Producer, len(mediaTypes)) - for _, mt := range mediaTypes { - switch mt { - case "application/json": - result["application/json"] = o.JSONProducer - } - - if p, ok := o.customProducers[mt]; ok { - result[mt] = p - } - } - return result -} - -// HandlerFor gets a http.Handler for the provided operation method and path -func (o *MymoveAPI) HandlerFor(method, path string) (http.Handler, bool) { - if o.handlers == nil { - return nil, false - } - um := strings.ToUpper(method) - if _, ok := o.handlers[um]; !ok { - return nil, false - } - if path == "/" { - path = "" - } - h, ok := o.handlers[um][path] - return h, ok -} - -// Context returns the middleware context for the mymove API -func (o *MymoveAPI) Context() *middleware.Context { - if o.context == nil { - o.context = middleware.NewRoutableContext(o.spec, o, nil) - } - - return o.context -} - -func (o *MymoveAPI) initHandlerCache() { - o.Context() // don't care about the result, just that the initialization happened - if o.handlers == nil { - o.handlers = make(map[string]map[string]http.Handler) - } - - if o.handlers["GET"] == nil { - o.handlers["GET"] = make(map[string]http.Handler) - } - o.handlers["GET"]["/moves"] = moves.NewListMoves(o.context, o.MovesListMovesHandler) -} - -// Serve creates a http handler to serve the API over HTTP -// can be used directly in http.ListenAndServe(":8000", api.Serve(nil)) -func (o *MymoveAPI) Serve(builder middleware.Builder) http.Handler { - o.Init() - - if o.Middleware != nil { - return o.Middleware(builder) - } - if o.useSwaggerUI { - return o.context.APIHandlerSwaggerUI(builder) - } - return o.context.APIHandler(builder) -} - -// Init allows you to just initialize the handler cache, you can then recompose the middleware as you see fit -func (o *MymoveAPI) Init() { - if len(o.handlers) == 0 { - o.initHandlerCache() - } -} - -// RegisterConsumer allows you to add (or override) a consumer for a media type. -func (o *MymoveAPI) RegisterConsumer(mediaType string, consumer runtime.Consumer) { - o.customConsumers[mediaType] = consumer -} - -// RegisterProducer allows you to add (or override) a producer for a media type. -func (o *MymoveAPI) RegisterProducer(mediaType string, producer runtime.Producer) { - o.customProducers[mediaType] = producer -} - -// AddMiddlewareFor adds a http middleware to existing handler -func (o *MymoveAPI) AddMiddlewareFor(method, path string, builder middleware.Builder) { - um := strings.ToUpper(method) - if path == "/" { - path = "" - } - o.Init() - if h, ok := o.handlers[um][path]; ok { - o.handlers[um][path] = builder(h) - } -} diff --git a/pkg/gen/pptasapi/server.go b/pkg/gen/pptasapi/server.go deleted file mode 100644 index 6f17692ba72..00000000000 --- a/pkg/gen/pptasapi/server.go +++ /dev/null @@ -1,507 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package pptasapi - -import ( - "context" - "crypto/tls" - "crypto/x509" - "errors" - "fmt" - "log" - "net" - "net/http" - "os" - "os/signal" - "strconv" - "sync" - "sync/atomic" - "syscall" - "time" - - "github.com/go-openapi/runtime/flagext" - "github.com/go-openapi/swag" - flags "github.com/jessevdk/go-flags" - "golang.org/x/net/netutil" - - "github.com/transcom/mymove/pkg/gen/pptasapi/pptasoperations" -) - -const ( - schemeHTTP = "http" - schemeHTTPS = "https" - schemeUnix = "unix" -) - -var defaultSchemes []string - -func init() { - defaultSchemes = []string{ - schemeHTTP, - } -} - -// NewServer creates a new api mymove server but does not configure it -func NewServer(api *pptasoperations.MymoveAPI) *Server { - s := new(Server) - - s.shutdown = make(chan struct{}) - s.api = api - s.interrupt = make(chan os.Signal, 1) - return s -} - -// ConfigureAPI configures the API and handlers. -func (s *Server) ConfigureAPI() { - if s.api != nil { - s.handler = configureAPI(s.api) - } -} - -// ConfigureFlags configures the additional flags defined by the handlers. Needs to be called before the parser.Parse -func (s *Server) ConfigureFlags() { - if s.api != nil { - configureFlags(s.api) - } -} - -// Server for the mymove API -type Server struct { - EnabledListeners []string `long:"scheme" description:"the listeners to enable, this can be repeated and defaults to the schemes in the swagger spec"` - CleanupTimeout time.Duration `long:"cleanup-timeout" description:"grace period for which to wait before killing idle connections" default:"10s"` - GracefulTimeout time.Duration `long:"graceful-timeout" description:"grace period for which to wait before shutting down the server" default:"15s"` - MaxHeaderSize flagext.ByteSize `long:"max-header-size" description:"controls the maximum number of bytes the server will read parsing the request header's keys and values, including the request line. It does not limit the size of the request body." default:"1MiB"` - - SocketPath flags.Filename `long:"socket-path" description:"the unix socket to listen on" default:"/var/run/mymove.sock"` - domainSocketL net.Listener - - Host string `long:"host" description:"the IP to listen on" default:"localhost" env:"HOST"` - Port int `long:"port" description:"the port to listen on for insecure connections, defaults to a random value" env:"PORT"` - ListenLimit int `long:"listen-limit" description:"limit the number of outstanding requests"` - KeepAlive time.Duration `long:"keep-alive" description:"sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)" default:"3m"` - ReadTimeout time.Duration `long:"read-timeout" description:"maximum duration before timing out read of the request" default:"30s"` - WriteTimeout time.Duration `long:"write-timeout" description:"maximum duration before timing out write of the response" default:"60s"` - httpServerL net.Listener - - TLSHost string `long:"tls-host" description:"the IP to listen on for tls, when not specified it's the same as --host" env:"TLS_HOST"` - TLSPort int `long:"tls-port" description:"the port to listen on for secure connections, defaults to a random value" env:"TLS_PORT"` - TLSCertificate flags.Filename `long:"tls-certificate" description:"the certificate to use for secure connections" env:"TLS_CERTIFICATE"` - TLSCertificateKey flags.Filename `long:"tls-key" description:"the private key to use for secure connections" env:"TLS_PRIVATE_KEY"` - TLSCACertificate flags.Filename `long:"tls-ca" description:"the certificate authority file to be used with mutual tls auth" env:"TLS_CA_CERTIFICATE"` - TLSListenLimit int `long:"tls-listen-limit" description:"limit the number of outstanding requests"` - TLSKeepAlive time.Duration `long:"tls-keep-alive" description:"sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)"` - TLSReadTimeout time.Duration `long:"tls-read-timeout" description:"maximum duration before timing out read of the request"` - TLSWriteTimeout time.Duration `long:"tls-write-timeout" description:"maximum duration before timing out write of the response"` - httpsServerL net.Listener - - api *pptasoperations.MymoveAPI - handler http.Handler - hasListeners bool - shutdown chan struct{} - shuttingDown int32 - interrupted bool - interrupt chan os.Signal -} - -// Logf logs message either via defined user logger or via system one if no user logger is defined. -func (s *Server) Logf(f string, args ...interface{}) { - if s.api != nil && s.api.Logger != nil { - s.api.Logger(f, args...) - } else { - log.Printf(f, args...) - } -} - -// Fatalf logs message either via defined user logger or via system one if no user logger is defined. -// Exits with non-zero status after printing -func (s *Server) Fatalf(f string, args ...interface{}) { - if s.api != nil && s.api.Logger != nil { - s.api.Logger(f, args...) - os.Exit(1) - } else { - log.Fatalf(f, args...) - } -} - -// SetAPI configures the server with the specified API. Needs to be called before Serve -func (s *Server) SetAPI(api *pptasoperations.MymoveAPI) { - if api == nil { - s.api = nil - s.handler = nil - return - } - - s.api = api - s.handler = configureAPI(api) -} - -func (s *Server) hasScheme(scheme string) bool { - schemes := s.EnabledListeners - if len(schemes) == 0 { - schemes = defaultSchemes - } - - for _, v := range schemes { - if v == scheme { - return true - } - } - return false -} - -// Serve the api -func (s *Server) Serve() (err error) { - if !s.hasListeners { - if err = s.Listen(); err != nil { - return err - } - } - - // set default handler, if none is set - if s.handler == nil { - if s.api == nil { - return errors.New("can't create the default handler, as no api is set") - } - - s.SetHandler(s.api.Serve(nil)) - } - - wg := new(sync.WaitGroup) - once := new(sync.Once) - signalNotify(s.interrupt) - go handleInterrupt(once, s) - - servers := []*http.Server{} - - if s.hasScheme(schemeUnix) { - domainSocket := new(http.Server) - domainSocket.MaxHeaderBytes = int(s.MaxHeaderSize) - domainSocket.Handler = s.handler - if int64(s.CleanupTimeout) > 0 { - domainSocket.IdleTimeout = s.CleanupTimeout - } - - configureServer(domainSocket, "unix", string(s.SocketPath)) - - servers = append(servers, domainSocket) - wg.Add(1) - s.Logf("Serving mymove at unix://%s", s.SocketPath) - go func(l net.Listener) { - defer wg.Done() - if err := domainSocket.Serve(l); err != nil && err != http.ErrServerClosed { - s.Fatalf("%v", err) - } - s.Logf("Stopped serving mymove at unix://%s", s.SocketPath) - }(s.domainSocketL) - } - - if s.hasScheme(schemeHTTP) { - httpServer := new(http.Server) - httpServer.MaxHeaderBytes = int(s.MaxHeaderSize) - httpServer.ReadTimeout = s.ReadTimeout - httpServer.WriteTimeout = s.WriteTimeout - httpServer.SetKeepAlivesEnabled(int64(s.KeepAlive) > 0) - if s.ListenLimit > 0 { - s.httpServerL = netutil.LimitListener(s.httpServerL, s.ListenLimit) - } - - if int64(s.CleanupTimeout) > 0 { - httpServer.IdleTimeout = s.CleanupTimeout - } - - httpServer.Handler = s.handler - - configureServer(httpServer, "http", s.httpServerL.Addr().String()) - - servers = append(servers, httpServer) - wg.Add(1) - s.Logf("Serving mymove at http://%s", s.httpServerL.Addr()) - go func(l net.Listener) { - defer wg.Done() - if err := httpServer.Serve(l); err != nil && err != http.ErrServerClosed { - s.Fatalf("%v", err) - } - s.Logf("Stopped serving mymove at http://%s", l.Addr()) - }(s.httpServerL) - } - - if s.hasScheme(schemeHTTPS) { - httpsServer := new(http.Server) - httpsServer.MaxHeaderBytes = int(s.MaxHeaderSize) - httpsServer.ReadTimeout = s.TLSReadTimeout - httpsServer.WriteTimeout = s.TLSWriteTimeout - httpsServer.SetKeepAlivesEnabled(int64(s.TLSKeepAlive) > 0) - if s.TLSListenLimit > 0 { - s.httpsServerL = netutil.LimitListener(s.httpsServerL, s.TLSListenLimit) - } - if int64(s.CleanupTimeout) > 0 { - httpsServer.IdleTimeout = s.CleanupTimeout - } - httpsServer.Handler = s.handler - - // Inspired by https://blog.bracebin.com/achieving-perfect-ssl-labs-score-with-go - httpsServer.TLSConfig = &tls.Config{ - // Causes servers to use Go's default ciphersuite preferences, - // which are tuned to avoid attacks. Does nothing on clients. - PreferServerCipherSuites: true, - // Only use curves which have assembly implementations - // https://github.com/golang/go/tree/master/src/crypto/elliptic - CurvePreferences: []tls.CurveID{tls.CurveP256}, - // Use modern tls mode https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility - NextProtos: []string{"h2", "http/1.1"}, - // https://www.owasp.org/index.php/Transport_Layer_Protection_Cheat_Sheet#Rule_-_Only_Support_Strong_Protocols - MinVersion: tls.VersionTLS12, - // These ciphersuites support Forward Secrecy: https://en.wikipedia.org/wiki/Forward_secrecy - CipherSuites: []uint16{ - tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, - tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, - tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, - tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, - tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, - tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, - }, - } - - // build standard config from server options - if s.TLSCertificate != "" && s.TLSCertificateKey != "" { - httpsServer.TLSConfig.Certificates = make([]tls.Certificate, 1) - httpsServer.TLSConfig.Certificates[0], err = tls.LoadX509KeyPair(string(s.TLSCertificate), string(s.TLSCertificateKey)) - if err != nil { - return err - } - } - - if s.TLSCACertificate != "" { - // include specified CA certificate - caCert, caCertErr := os.ReadFile(string(s.TLSCACertificate)) - if caCertErr != nil { - return caCertErr - } - caCertPool := x509.NewCertPool() - ok := caCertPool.AppendCertsFromPEM(caCert) - if !ok { - return fmt.Errorf("cannot parse CA certificate") - } - httpsServer.TLSConfig.ClientCAs = caCertPool - httpsServer.TLSConfig.ClientAuth = tls.RequireAndVerifyClientCert - } - - // call custom TLS configurator - configureTLS(httpsServer.TLSConfig) - - if len(httpsServer.TLSConfig.Certificates) == 0 && httpsServer.TLSConfig.GetCertificate == nil { - // after standard and custom config are passed, this ends up with no certificate - if s.TLSCertificate == "" { - if s.TLSCertificateKey == "" { - s.Fatalf("the required flags `--tls-certificate` and `--tls-key` were not specified") - } - s.Fatalf("the required flag `--tls-certificate` was not specified") - } - if s.TLSCertificateKey == "" { - s.Fatalf("the required flag `--tls-key` was not specified") - } - // this happens with a wrong custom TLS configurator - s.Fatalf("no certificate was configured for TLS") - } - - configureServer(httpsServer, "https", s.httpsServerL.Addr().String()) - - servers = append(servers, httpsServer) - wg.Add(1) - s.Logf("Serving mymove at https://%s", s.httpsServerL.Addr()) - go func(l net.Listener) { - defer wg.Done() - if err := httpsServer.Serve(l); err != nil && err != http.ErrServerClosed { - s.Fatalf("%v", err) - } - s.Logf("Stopped serving mymove at https://%s", l.Addr()) - }(tls.NewListener(s.httpsServerL, httpsServer.TLSConfig)) - } - - wg.Add(1) - go s.handleShutdown(wg, &servers) - - wg.Wait() - return nil -} - -// Listen creates the listeners for the server -func (s *Server) Listen() error { - if s.hasListeners { // already done this - return nil - } - - if s.hasScheme(schemeHTTPS) { - // Use http host if https host wasn't defined - if s.TLSHost == "" { - s.TLSHost = s.Host - } - // Use http listen limit if https listen limit wasn't defined - if s.TLSListenLimit == 0 { - s.TLSListenLimit = s.ListenLimit - } - // Use http tcp keep alive if https tcp keep alive wasn't defined - if int64(s.TLSKeepAlive) == 0 { - s.TLSKeepAlive = s.KeepAlive - } - // Use http read timeout if https read timeout wasn't defined - if int64(s.TLSReadTimeout) == 0 { - s.TLSReadTimeout = s.ReadTimeout - } - // Use http write timeout if https write timeout wasn't defined - if int64(s.TLSWriteTimeout) == 0 { - s.TLSWriteTimeout = s.WriteTimeout - } - } - - if s.hasScheme(schemeUnix) { - domSockListener, err := net.Listen("unix", string(s.SocketPath)) - if err != nil { - return err - } - s.domainSocketL = domSockListener - } - - if s.hasScheme(schemeHTTP) { - listener, err := net.Listen("tcp", net.JoinHostPort(s.Host, strconv.Itoa(s.Port))) - if err != nil { - return err - } - - h, p, err := swag.SplitHostPort(listener.Addr().String()) - if err != nil { - return err - } - s.Host = h - s.Port = p - s.httpServerL = listener - } - - if s.hasScheme(schemeHTTPS) { - tlsListener, err := net.Listen("tcp", net.JoinHostPort(s.TLSHost, strconv.Itoa(s.TLSPort))) - if err != nil { - return err - } - - sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String()) - if err != nil { - return err - } - s.TLSHost = sh - s.TLSPort = sp - s.httpsServerL = tlsListener - } - - s.hasListeners = true - return nil -} - -// Shutdown server and clean up resources -func (s *Server) Shutdown() error { - if atomic.CompareAndSwapInt32(&s.shuttingDown, 0, 1) { - close(s.shutdown) - } - return nil -} - -func (s *Server) handleShutdown(wg *sync.WaitGroup, serversPtr *[]*http.Server) { - // wg.Done must occur last, after s.api.ServerShutdown() - // (to preserve old behaviour) - defer wg.Done() - - <-s.shutdown - - servers := *serversPtr - - ctx, cancel := context.WithTimeout(context.TODO(), s.GracefulTimeout) - defer cancel() - - // first execute the pre-shutdown hook - s.api.PreServerShutdown() - - shutdownChan := make(chan bool) - for i := range servers { - server := servers[i] - go func() { - var success bool - defer func() { - shutdownChan <- success - }() - if err := server.Shutdown(ctx); err != nil { - // Error from closing listeners, or context timeout: - s.Logf("HTTP server Shutdown: %v", err) - } else { - success = true - } - }() - } - - // Wait until all listeners have successfully shut down before calling ServerShutdown - success := true - for range servers { - success = success && <-shutdownChan - } - if success { - s.api.ServerShutdown() - } -} - -// GetHandler returns a handler useful for testing -func (s *Server) GetHandler() http.Handler { - return s.handler -} - -// SetHandler allows for setting a http handler on this server -func (s *Server) SetHandler(handler http.Handler) { - s.handler = handler -} - -// UnixListener returns the domain socket listener -func (s *Server) UnixListener() (net.Listener, error) { - if !s.hasListeners { - if err := s.Listen(); err != nil { - return nil, err - } - } - return s.domainSocketL, nil -} - -// HTTPListener returns the http listener -func (s *Server) HTTPListener() (net.Listener, error) { - if !s.hasListeners { - if err := s.Listen(); err != nil { - return nil, err - } - } - return s.httpServerL, nil -} - -// TLSListener returns the https listener -func (s *Server) TLSListener() (net.Listener, error) { - if !s.hasListeners { - if err := s.Listen(); err != nil { - return nil, err - } - } - return s.httpsServerL, nil -} - -func handleInterrupt(once *sync.Once, s *Server) { - once.Do(func() { - for range s.interrupt { - if s.interrupted { - s.Logf("Server already shutting down") - continue - } - s.interrupted = true - s.Logf("Shutting down... ") - if err := s.Shutdown(); err != nil { - s.Logf("HTTP server Shutdown: %v", err) - } - } - }) -} - -func signalNotify(interrupt chan<- os.Signal) { - signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM) -} diff --git a/pkg/gen/pptasclient/moves/list_moves_parameters.go b/pkg/gen/pptasclient/moves/list_moves_parameters.go deleted file mode 100644 index a0abf41682e..00000000000 --- a/pkg/gen/pptasclient/moves/list_moves_parameters.go +++ /dev/null @@ -1,165 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package moves - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "net/http" - "time" - - "github.com/go-openapi/errors" - "github.com/go-openapi/runtime" - cr "github.com/go-openapi/runtime/client" - "github.com/go-openapi/strfmt" -) - -// NewListMovesParams creates a new ListMovesParams object, -// with the default timeout for this client. -// -// Default values are not hydrated, since defaults are normally applied by the API server side. -// -// To enforce default values in parameter, use SetDefaults or WithDefaults. -func NewListMovesParams() *ListMovesParams { - return &ListMovesParams{ - timeout: cr.DefaultTimeout, - } -} - -// NewListMovesParamsWithTimeout creates a new ListMovesParams object -// with the ability to set a timeout on a request. -func NewListMovesParamsWithTimeout(timeout time.Duration) *ListMovesParams { - return &ListMovesParams{ - timeout: timeout, - } -} - -// NewListMovesParamsWithContext creates a new ListMovesParams object -// with the ability to set a context for a request. -func NewListMovesParamsWithContext(ctx context.Context) *ListMovesParams { - return &ListMovesParams{ - Context: ctx, - } -} - -// NewListMovesParamsWithHTTPClient creates a new ListMovesParams object -// with the ability to set a custom HTTPClient for a request. -func NewListMovesParamsWithHTTPClient(client *http.Client) *ListMovesParams { - return &ListMovesParams{ - HTTPClient: client, - } -} - -/* -ListMovesParams contains all the parameters to send to the API endpoint - - for the list moves operation. - - Typically these are written to a http.Request. -*/ -type ListMovesParams struct { - - /* Since. - - Only return moves updated since this time. Formatted like "2021-07-23T18:30:47.116Z" - - Format: date-time - */ - Since *strfmt.DateTime - - timeout time.Duration - Context context.Context - HTTPClient *http.Client -} - -// WithDefaults hydrates default values in the list moves params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ListMovesParams) WithDefaults() *ListMovesParams { - o.SetDefaults() - return o -} - -// SetDefaults hydrates default values in the list moves params (not the query body). -// -// All values with no default are reset to their zero value. -func (o *ListMovesParams) SetDefaults() { - // no default values defined for this parameter -} - -// WithTimeout adds the timeout to the list moves params -func (o *ListMovesParams) WithTimeout(timeout time.Duration) *ListMovesParams { - o.SetTimeout(timeout) - return o -} - -// SetTimeout adds the timeout to the list moves params -func (o *ListMovesParams) SetTimeout(timeout time.Duration) { - o.timeout = timeout -} - -// WithContext adds the context to the list moves params -func (o *ListMovesParams) WithContext(ctx context.Context) *ListMovesParams { - o.SetContext(ctx) - return o -} - -// SetContext adds the context to the list moves params -func (o *ListMovesParams) SetContext(ctx context.Context) { - o.Context = ctx -} - -// WithHTTPClient adds the HTTPClient to the list moves params -func (o *ListMovesParams) WithHTTPClient(client *http.Client) *ListMovesParams { - o.SetHTTPClient(client) - return o -} - -// SetHTTPClient adds the HTTPClient to the list moves params -func (o *ListMovesParams) SetHTTPClient(client *http.Client) { - o.HTTPClient = client -} - -// WithSince adds the since to the list moves params -func (o *ListMovesParams) WithSince(since *strfmt.DateTime) *ListMovesParams { - o.SetSince(since) - return o -} - -// SetSince adds the since to the list moves params -func (o *ListMovesParams) SetSince(since *strfmt.DateTime) { - o.Since = since -} - -// WriteToRequest writes these params to a swagger request -func (o *ListMovesParams) WriteToRequest(r runtime.ClientRequest, reg strfmt.Registry) error { - - if err := r.SetTimeout(o.timeout); err != nil { - return err - } - var res []error - - if o.Since != nil { - - // query param since - var qrSince strfmt.DateTime - - if o.Since != nil { - qrSince = *o.Since - } - qSince := qrSince.String() - if qSince != "" { - - if err := r.SetQueryParam("since", qSince); err != nil { - return err - } - } - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/gen/pptasclient/moves/list_moves_responses.go b/pkg/gen/pptasclient/moves/list_moves_responses.go deleted file mode 100644 index 0d10991f8a9..00000000000 --- a/pkg/gen/pptasclient/moves/list_moves_responses.go +++ /dev/null @@ -1,323 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package moves - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "fmt" - "io" - - "github.com/go-openapi/runtime" - "github.com/go-openapi/strfmt" - - "github.com/transcom/mymove/pkg/gen/pptasmessages" -) - -// ListMovesReader is a Reader for the ListMoves structure. -type ListMovesReader struct { - formats strfmt.Registry -} - -// ReadResponse reads a server response into the received o. -func (o *ListMovesReader) ReadResponse(response runtime.ClientResponse, consumer runtime.Consumer) (interface{}, error) { - switch response.Code() { - case 200: - result := NewListMovesOK() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return result, nil - case 401: - result := NewListMovesUnauthorized() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 403: - result := NewListMovesForbidden() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - case 500: - result := NewListMovesInternalServerError() - if err := result.readResponse(response, consumer, o.formats); err != nil { - return nil, err - } - return nil, result - default: - return nil, runtime.NewAPIError("[GET /moves] listMoves", response, response.Code()) - } -} - -// NewListMovesOK creates a ListMovesOK with default headers values -func NewListMovesOK() *ListMovesOK { - return &ListMovesOK{} -} - -/* -ListMovesOK describes a response with status code 200, with default header values. - -Successfully retrieved moves. A successful fetch might still return zero moves. -*/ -type ListMovesOK struct { - Payload pptasmessages.ListMoves -} - -// IsSuccess returns true when this list moves o k response has a 2xx status code -func (o *ListMovesOK) IsSuccess() bool { - return true -} - -// IsRedirect returns true when this list moves o k response has a 3xx status code -func (o *ListMovesOK) IsRedirect() bool { - return false -} - -// IsClientError returns true when this list moves o k response has a 4xx status code -func (o *ListMovesOK) IsClientError() bool { - return false -} - -// IsServerError returns true when this list moves o k response has a 5xx status code -func (o *ListMovesOK) IsServerError() bool { - return false -} - -// IsCode returns true when this list moves o k response a status code equal to that given -func (o *ListMovesOK) IsCode(code int) bool { - return code == 200 -} - -// Code gets the status code for the list moves o k response -func (o *ListMovesOK) Code() int { - return 200 -} - -func (o *ListMovesOK) Error() string { - return fmt.Sprintf("[GET /moves][%d] listMovesOK %+v", 200, o.Payload) -} - -func (o *ListMovesOK) String() string { - return fmt.Sprintf("[GET /moves][%d] listMovesOK %+v", 200, o.Payload) -} - -func (o *ListMovesOK) GetPayload() pptasmessages.ListMoves { - return o.Payload -} - -func (o *ListMovesOK) 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 -} - -// NewListMovesUnauthorized creates a ListMovesUnauthorized with default headers values -func NewListMovesUnauthorized() *ListMovesUnauthorized { - return &ListMovesUnauthorized{} -} - -/* -ListMovesUnauthorized describes a response with status code 401, with default header values. - -The request was denied. -*/ -type ListMovesUnauthorized struct { - Payload *pptasmessages.ClientError -} - -// IsSuccess returns true when this list moves unauthorized response has a 2xx status code -func (o *ListMovesUnauthorized) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this list moves unauthorized response has a 3xx status code -func (o *ListMovesUnauthorized) IsRedirect() bool { - return false -} - -// IsClientError returns true when this list moves unauthorized response has a 4xx status code -func (o *ListMovesUnauthorized) IsClientError() bool { - return true -} - -// IsServerError returns true when this list moves unauthorized response has a 5xx status code -func (o *ListMovesUnauthorized) IsServerError() bool { - return false -} - -// IsCode returns true when this list moves unauthorized response a status code equal to that given -func (o *ListMovesUnauthorized) IsCode(code int) bool { - return code == 401 -} - -// Code gets the status code for the list moves unauthorized response -func (o *ListMovesUnauthorized) Code() int { - return 401 -} - -func (o *ListMovesUnauthorized) Error() string { - return fmt.Sprintf("[GET /moves][%d] listMovesUnauthorized %+v", 401, o.Payload) -} - -func (o *ListMovesUnauthorized) String() string { - return fmt.Sprintf("[GET /moves][%d] listMovesUnauthorized %+v", 401, o.Payload) -} - -func (o *ListMovesUnauthorized) GetPayload() *pptasmessages.ClientError { - return o.Payload -} - -func (o *ListMovesUnauthorized) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(pptasmessages.ClientError) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewListMovesForbidden creates a ListMovesForbidden with default headers values -func NewListMovesForbidden() *ListMovesForbidden { - return &ListMovesForbidden{} -} - -/* -ListMovesForbidden describes a response with status code 403, with default header values. - -The request was denied. -*/ -type ListMovesForbidden struct { - Payload *pptasmessages.ClientError -} - -// IsSuccess returns true when this list moves forbidden response has a 2xx status code -func (o *ListMovesForbidden) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this list moves forbidden response has a 3xx status code -func (o *ListMovesForbidden) IsRedirect() bool { - return false -} - -// IsClientError returns true when this list moves forbidden response has a 4xx status code -func (o *ListMovesForbidden) IsClientError() bool { - return true -} - -// IsServerError returns true when this list moves forbidden response has a 5xx status code -func (o *ListMovesForbidden) IsServerError() bool { - return false -} - -// IsCode returns true when this list moves forbidden response a status code equal to that given -func (o *ListMovesForbidden) IsCode(code int) bool { - return code == 403 -} - -// Code gets the status code for the list moves forbidden response -func (o *ListMovesForbidden) Code() int { - return 403 -} - -func (o *ListMovesForbidden) Error() string { - return fmt.Sprintf("[GET /moves][%d] listMovesForbidden %+v", 403, o.Payload) -} - -func (o *ListMovesForbidden) String() string { - return fmt.Sprintf("[GET /moves][%d] listMovesForbidden %+v", 403, o.Payload) -} - -func (o *ListMovesForbidden) GetPayload() *pptasmessages.ClientError { - return o.Payload -} - -func (o *ListMovesForbidden) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(pptasmessages.ClientError) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} - -// NewListMovesInternalServerError creates a ListMovesInternalServerError with default headers values -func NewListMovesInternalServerError() *ListMovesInternalServerError { - return &ListMovesInternalServerError{} -} - -/* -ListMovesInternalServerError describes a response with status code 500, with default header values. - -An unexpected error has occurred in the server. -*/ -type ListMovesInternalServerError struct { - Payload *pptasmessages.ClientError -} - -// IsSuccess returns true when this list moves internal server error response has a 2xx status code -func (o *ListMovesInternalServerError) IsSuccess() bool { - return false -} - -// IsRedirect returns true when this list moves internal server error response has a 3xx status code -func (o *ListMovesInternalServerError) IsRedirect() bool { - return false -} - -// IsClientError returns true when this list moves internal server error response has a 4xx status code -func (o *ListMovesInternalServerError) IsClientError() bool { - return false -} - -// IsServerError returns true when this list moves internal server error response has a 5xx status code -func (o *ListMovesInternalServerError) IsServerError() bool { - return true -} - -// IsCode returns true when this list moves internal server error response a status code equal to that given -func (o *ListMovesInternalServerError) IsCode(code int) bool { - return code == 500 -} - -// Code gets the status code for the list moves internal server error response -func (o *ListMovesInternalServerError) Code() int { - return 500 -} - -func (o *ListMovesInternalServerError) Error() string { - return fmt.Sprintf("[GET /moves][%d] listMovesInternalServerError %+v", 500, o.Payload) -} - -func (o *ListMovesInternalServerError) String() string { - return fmt.Sprintf("[GET /moves][%d] listMovesInternalServerError %+v", 500, o.Payload) -} - -func (o *ListMovesInternalServerError) GetPayload() *pptasmessages.ClientError { - return o.Payload -} - -func (o *ListMovesInternalServerError) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error { - - o.Payload = new(pptasmessages.ClientError) - - // response payload - if err := consumer.Consume(response.Body(), o.Payload); err != nil && err != io.EOF { - return err - } - - return nil -} diff --git a/pkg/gen/pptasclient/moves/moves_client.go b/pkg/gen/pptasclient/moves/moves_client.go deleted file mode 100644 index 767300b1052..00000000000 --- a/pkg/gen/pptasclient/moves/moves_client.go +++ /dev/null @@ -1,88 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package moves - -// 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" - "github.com/go-openapi/strfmt" -) - -// New creates a new moves API client. -func New(transport runtime.ClientTransport, formats strfmt.Registry) ClientService { - return &Client{transport: transport, formats: formats} -} - -/* -Client for moves API -*/ -type Client struct { - transport runtime.ClientTransport - formats strfmt.Registry -} - -// ClientOption is the option for Client methods -type ClientOption func(*runtime.ClientOperation) - -// ClientService is the interface for Client methods -type ClientService interface { - ListMoves(params *ListMovesParams, opts ...ClientOption) (*ListMovesOK, error) - - SetTransport(transport runtime.ClientTransport) -} - -/* - ListMoves lists moves - - Gets all moves that have been reviewed and approved by the TOO. The `since` parameter can be used to filter this - -list down to only the moves that have been updated since the provided timestamp. A move will be considered -updated if the `updatedAt` timestamp on the move or on its orders, shipments, service items, or payment -requests, is later than the provided date and time. - -**WIP**: Include what causes moves to leave this list. Currently, once the `availableToPrimeAt` timestamp has -been set, that move will always appear in this list. -*/ -func (a *Client) ListMoves(params *ListMovesParams, opts ...ClientOption) (*ListMovesOK, error) { - // TODO: Validate the params before sending - if params == nil { - params = NewListMovesParams() - } - op := &runtime.ClientOperation{ - ID: "listMoves", - Method: "GET", - PathPattern: "/moves", - ProducesMediaTypes: []string{"application/json"}, - ConsumesMediaTypes: []string{"application/json"}, - Schemes: []string{"http"}, - Params: params, - Reader: &ListMovesReader{formats: a.formats}, - Context: params.Context, - Client: params.HTTPClient, - } - for _, opt := range opts { - opt(op) - } - - result, err := a.transport.Submit(op) - if err != nil { - return nil, err - } - success, ok := result.(*ListMovesOK) - if ok { - return success, nil - } - // unexpected success response - // safeguard: normally, absent a default response, unknown success responses return an error above: so this is a codegen issue - msg := fmt.Sprintf("unexpected success response for listMoves: API contract not enforced by server. Client expected to get an error, but got: %T", result) - panic(msg) -} - -// SetTransport changes the transport on the client -func (a *Client) SetTransport(transport runtime.ClientTransport) { - a.transport = transport -} diff --git a/pkg/gen/pptasclient/mymove_client.go b/pkg/gen/pptasclient/mymove_client.go deleted file mode 100644 index b8f9241d2f0..00000000000 --- a/pkg/gen/pptasclient/mymove_client.go +++ /dev/null @@ -1,112 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package pptasclient - -// 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" - "github.com/go-openapi/strfmt" - - "github.com/transcom/mymove/pkg/gen/pptasclient/moves" -) - -// Default mymove HTTP client. -var Default = NewHTTPClient(nil) - -const ( - // DefaultHost is the default Host - // found in Meta (info) section of spec file - DefaultHost string = "primelocal" - // DefaultBasePath is the default BasePath - // found in Meta (info) section of spec file - DefaultBasePath string = "/prime/pptas" -) - -// DefaultSchemes are the default schemes found in Meta (info) section of spec file -var DefaultSchemes = []string{"http"} - -// NewHTTPClient creates a new mymove HTTP client. -func NewHTTPClient(formats strfmt.Registry) *Mymove { - return NewHTTPClientWithConfig(formats, nil) -} - -// NewHTTPClientWithConfig creates a new mymove HTTP client, -// using a customizable transport config. -func NewHTTPClientWithConfig(formats strfmt.Registry, cfg *TransportConfig) *Mymove { - // 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 mymove client -func New(transport runtime.ClientTransport, formats strfmt.Registry) *Mymove { - // ensure nullable parameters have default - if formats == nil { - formats = strfmt.Default - } - - cli := new(Mymove) - cli.Transport = transport - cli.Moves = moves.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 -} - -// Mymove is a client for mymove -type Mymove struct { - Moves moves.ClientService - - Transport runtime.ClientTransport -} - -// SetTransport changes the transport on the client and all its subresources -func (c *Mymove) SetTransport(transport runtime.ClientTransport) { - c.Transport = transport - c.Moves.SetTransport(transport) -} diff --git a/pkg/gen/pptasmessages/client_error.go b/pkg/gen/pptasmessages/client_error.go deleted file mode 100644 index dd858a7f274..00000000000 --- a/pkg/gen/pptasmessages/client_error.go +++ /dev/null @@ -1,110 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package pptasmessages - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// ClientError client error -// -// swagger:model ClientError -type ClientError struct { - - // detail - // Required: true - Detail *string `json:"detail"` - - // instance - // Required: true - // Format: uuid - Instance *strfmt.UUID `json:"instance"` - - // title - // Required: true - Title *string `json:"title"` -} - -// Validate validates this client error -func (m *ClientError) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateDetail(formats); err != nil { - res = append(res, err) - } - - if err := m.validateInstance(formats); err != nil { - res = append(res, err) - } - - if err := m.validateTitle(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ClientError) validateDetail(formats strfmt.Registry) error { - - if err := validate.Required("detail", "body", m.Detail); err != nil { - return err - } - - return nil -} - -func (m *ClientError) validateInstance(formats strfmt.Registry) error { - - if err := validate.Required("instance", "body", m.Instance); err != nil { - return err - } - - if err := validate.FormatOf("instance", "body", "uuid", m.Instance.String(), formats); err != nil { - return err - } - - return nil -} - -func (m *ClientError) validateTitle(formats strfmt.Registry) error { - - if err := validate.Required("title", "body", m.Title); err != nil { - return err - } - - return nil -} - -// ContextValidate validates this client error based on context it is used -func (m *ClientError) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - return nil -} - -// MarshalBinary interface implementation -func (m *ClientError) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ClientError) UnmarshalBinary(b []byte) error { - var res ClientError - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/gen/pptasmessages/list_move.go b/pkg/gen/pptasmessages/list_move.go deleted file mode 100644 index ff5abe85c25..00000000000 --- a/pkg/gen/pptasmessages/list_move.go +++ /dev/null @@ -1,293 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package pptasmessages - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "encoding/json" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" - "github.com/go-openapi/validate" -) - -// ListMove An abbreviated definition for a move, without all the nested information (shipments, service items, etc). Used to fetch a list of moves more efficiently. -// -// swagger:model ListMove -type ListMove struct { - - // available to prime at - // Read Only: true - // Format: date-time - AvailableToPrimeAt *strfmt.DateTime `json:"availableToPrimeAt,omitempty"` - - // created at - // Read Only: true - // Format: date-time - CreatedAt strfmt.DateTime `json:"createdAt,omitempty"` - - // e tag - // Read Only: true - ETag string `json:"eTag,omitempty"` - - // id - // Example: 1f2270c7-7166-40ae-981e-b200ebdf3054 - // Format: uuid - ID strfmt.UUID `json:"id,omitempty"` - - // move code - // Example: HYXFJF - // Read Only: true - MoveCode string `json:"moveCode,omitempty"` - - // order ID - // Example: c56a4180-65aa-42ec-a945-5fd21dec0538 - // Format: uuid - OrderID strfmt.UUID `json:"orderID,omitempty"` - - // ppm type - // Enum: [FULL PARTIAL] - PpmType string `json:"ppmType,omitempty"` - - // reference Id - // Example: 1001-3456 - ReferenceID string `json:"referenceId,omitempty"` - - // updated at - // Read Only: true - // Format: date-time - UpdatedAt strfmt.DateTime `json:"updatedAt,omitempty"` -} - -// Validate validates this list move -func (m *ListMove) Validate(formats strfmt.Registry) error { - var res []error - - if err := m.validateAvailableToPrimeAt(formats); err != nil { - res = append(res, err) - } - - if err := m.validateCreatedAt(formats); err != nil { - res = append(res, err) - } - - if err := m.validateID(formats); err != nil { - res = append(res, err) - } - - if err := m.validateOrderID(formats); err != nil { - res = append(res, err) - } - - if err := m.validatePpmType(formats); err != nil { - res = append(res, err) - } - - if err := m.validateUpdatedAt(formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ListMove) validateAvailableToPrimeAt(formats strfmt.Registry) error { - if swag.IsZero(m.AvailableToPrimeAt) { // not required - return nil - } - - if err := validate.FormatOf("availableToPrimeAt", "body", "date-time", m.AvailableToPrimeAt.String(), formats); err != nil { - return err - } - - return nil -} - -func (m *ListMove) validateCreatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.CreatedAt) { // not required - return nil - } - - if err := validate.FormatOf("createdAt", "body", "date-time", m.CreatedAt.String(), formats); err != nil { - return err - } - - return nil -} - -func (m *ListMove) validateID(formats strfmt.Registry) error { - if swag.IsZero(m.ID) { // not required - return nil - } - - if err := validate.FormatOf("id", "body", "uuid", m.ID.String(), formats); err != nil { - return err - } - - return nil -} - -func (m *ListMove) validateOrderID(formats strfmt.Registry) error { - if swag.IsZero(m.OrderID) { // not required - return nil - } - - if err := validate.FormatOf("orderID", "body", "uuid", m.OrderID.String(), formats); err != nil { - return err - } - - return nil -} - -var listMoveTypePpmTypePropEnum []interface{} - -func init() { - var res []string - if err := json.Unmarshal([]byte(`["FULL","PARTIAL"]`), &res); err != nil { - panic(err) - } - for _, v := range res { - listMoveTypePpmTypePropEnum = append(listMoveTypePpmTypePropEnum, v) - } -} - -const ( - - // ListMovePpmTypeFULL captures enum value "FULL" - ListMovePpmTypeFULL string = "FULL" - - // ListMovePpmTypePARTIAL captures enum value "PARTIAL" - ListMovePpmTypePARTIAL string = "PARTIAL" -) - -// prop value enum -func (m *ListMove) validatePpmTypeEnum(path, location string, value string) error { - if err := validate.EnumCase(path, location, value, listMoveTypePpmTypePropEnum, true); err != nil { - return err - } - return nil -} - -func (m *ListMove) validatePpmType(formats strfmt.Registry) error { - if swag.IsZero(m.PpmType) { // not required - return nil - } - - // value enum - if err := m.validatePpmTypeEnum("ppmType", "body", m.PpmType); err != nil { - return err - } - - return nil -} - -func (m *ListMove) validateUpdatedAt(formats strfmt.Registry) error { - if swag.IsZero(m.UpdatedAt) { // not required - return nil - } - - if err := validate.FormatOf("updatedAt", "body", "date-time", m.UpdatedAt.String(), formats); err != nil { - return err - } - - return nil -} - -// ContextValidate validate this list move based on the context it is used -func (m *ListMove) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - if err := m.contextValidateAvailableToPrimeAt(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateCreatedAt(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateETag(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateMoveCode(ctx, formats); err != nil { - res = append(res, err) - } - - if err := m.contextValidateUpdatedAt(ctx, formats); err != nil { - res = append(res, err) - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -func (m *ListMove) contextValidateAvailableToPrimeAt(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "availableToPrimeAt", "body", m.AvailableToPrimeAt); err != nil { - return err - } - - return nil -} - -func (m *ListMove) contextValidateCreatedAt(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "createdAt", "body", strfmt.DateTime(m.CreatedAt)); err != nil { - return err - } - - return nil -} - -func (m *ListMove) contextValidateETag(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "eTag", "body", string(m.ETag)); err != nil { - return err - } - - return nil -} - -func (m *ListMove) contextValidateMoveCode(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "moveCode", "body", string(m.MoveCode)); err != nil { - return err - } - - return nil -} - -func (m *ListMove) contextValidateUpdatedAt(ctx context.Context, formats strfmt.Registry) error { - - if err := validate.ReadOnly(ctx, "updatedAt", "body", strfmt.DateTime(m.UpdatedAt)); err != nil { - return err - } - - return nil -} - -// MarshalBinary interface implementation -func (m *ListMove) MarshalBinary() ([]byte, error) { - if m == nil { - return nil, nil - } - return swag.WriteJSON(m) -} - -// UnmarshalBinary interface implementation -func (m *ListMove) UnmarshalBinary(b []byte) error { - var res ListMove - if err := swag.ReadJSON(b, &res); err != nil { - return err - } - *m = res - return nil -} diff --git a/pkg/gen/pptasmessages/list_moves.go b/pkg/gen/pptasmessages/list_moves.go deleted file mode 100644 index 5ac76fbe8c7..00000000000 --- a/pkg/gen/pptasmessages/list_moves.go +++ /dev/null @@ -1,78 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package pptasmessages - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "context" - "strconv" - - "github.com/go-openapi/errors" - "github.com/go-openapi/strfmt" - "github.com/go-openapi/swag" -) - -// ListMoves list moves -// -// swagger:model ListMoves -type ListMoves []*ListMove - -// Validate validates this list moves -func (m ListMoves) Validate(formats strfmt.Registry) error { - var res []error - - for i := 0; i < len(m); i++ { - if swag.IsZero(m[i]) { // not required - continue - } - - if m[i] != nil { - if err := m[i].Validate(formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName(strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName(strconv.Itoa(i)) - } - return err - } - } - - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} - -// ContextValidate validate this list moves based on the context it is used -func (m ListMoves) ContextValidate(ctx context.Context, formats strfmt.Registry) error { - var res []error - - for i := 0; i < len(m); i++ { - - if m[i] != nil { - - if swag.IsZero(m[i]) { // not required - return nil - } - - if err := m[i].ContextValidate(ctx, formats); err != nil { - if ve, ok := err.(*errors.Validation); ok { - return ve.ValidateName(strconv.Itoa(i)) - } else if ce, ok := err.(*errors.CompositeError); ok { - return ce.ValidateName(strconv.Itoa(i)) - } - return err - } - } - - } - - if len(res) > 0 { - return errors.CompositeValidationError(res...) - } - return nil -} diff --git a/pkg/handlers/apitests.go b/pkg/handlers/apitests.go index bdea66989d8..0bd1ae31bac 100644 --- a/pkg/handlers/apitests.go +++ b/pkg/handlers/apitests.go @@ -39,8 +39,6 @@ const ( AdminTestHost string = "admin.example.com" // PrimeTestHost PrimeTestHost string = "prime.example.com" - // PrimeTestHost - PPTASTestHost string = "pptas.example.com" ) // ApplicationTestServername is a collection of the test servernames @@ -51,7 +49,6 @@ func ApplicationTestServername() auth.ApplicationServername { OrdersServername: OrdersTestHost, AdminServername: AdminTestHost, PrimeServername: PrimeTestHost, - PPTASServerName: PPTASTestHost, } } diff --git a/pkg/handlers/pptasapi/api.go b/pkg/handlers/pptasapi/api.go deleted file mode 100644 index 72e7ac67343..00000000000 --- a/pkg/handlers/pptasapi/api.go +++ /dev/null @@ -1,30 +0,0 @@ -package pptasapi - -import ( - "log" - "net/http" - - "github.com/go-openapi/loads" - - "github.com/transcom/mymove/pkg/gen/pptasapi" - pptasops "github.com/transcom/mymove/pkg/gen/pptasapi/pptasoperations" - "github.com/transcom/mymove/pkg/handlers" - movetaskorder "github.com/transcom/mymove/pkg/services/move_task_order" -) - -func NewPPTASApiHandler(handlerConfig handlers.HandlerConfig) http.Handler { - - pptasSpec, err := loads.Analyzed(pptasapi.SwaggerJSON, "") - if err != nil { - log.Fatalln(err) - } - pptasAPI := pptasops.NewMymoveAPI(pptasSpec) - pptasAPI.ServeError = handlers.ServeCustomError - - pptasAPI.MovesListMovesHandler = ListMovesHandler{ - HandlerConfig: handlerConfig, - MoveTaskOrderFetcher: movetaskorder.NewMoveTaskOrderFetcher(), - } - - return pptasAPI.Serve(nil) -} diff --git a/pkg/handlers/pptasapi/internal/payloads/model_to_payload.go b/pkg/handlers/pptasapi/internal/payloads/model_to_payload.go deleted file mode 100644 index 5fc0e934a60..00000000000 --- a/pkg/handlers/pptasapi/internal/payloads/model_to_payload.go +++ /dev/null @@ -1,60 +0,0 @@ -package payloads - -import ( - "github.com/go-openapi/strfmt" - "github.com/gofrs/uuid" - - "github.com/transcom/mymove/pkg/etag" - "github.com/transcom/mymove/pkg/gen/pptasmessages" - "github.com/transcom/mymove/pkg/handlers" - "github.com/transcom/mymove/pkg/models" -) - -// InternalServerError describes errors in a standard structure to be returned in the payload. -// If detail is nil, string defaults to "An internal server error has occurred." -func InternalServerError(detail *string, traceID uuid.UUID) *pptasmessages.ClientError { - instanceToUse := strfmt.UUID(traceID.String()) - payload := pptasmessages.ClientError{ - Title: handlers.FmtString(handlers.InternalServerErrMessage), - Detail: handlers.FmtString(handlers.InternalServerErrDetail), - Instance: &instanceToUse, - } - if detail != nil { - payload.Detail = detail - } - return &payload -} - -// ListMove payload -func ListMove(move *models.Move) *pptasmessages.ListMove { - if move == nil { - return nil - } - payload := &pptasmessages.ListMove{ - ID: strfmt.UUID(move.ID.String()), - MoveCode: move.Locator, - CreatedAt: strfmt.DateTime(move.CreatedAt), - AvailableToPrimeAt: handlers.FmtDateTimePtr(move.AvailableToPrimeAt), - OrderID: strfmt.UUID(move.OrdersID.String()), - ReferenceID: *move.ReferenceID, - UpdatedAt: strfmt.DateTime(move.UpdatedAt), - ETag: etag.GenerateEtag(move.UpdatedAt), - } - - if move.PPMType != nil { - payload.PpmType = *move.PPMType - } - - return payload -} - -// ListMoves payload -func ListMoves(moves *models.Moves) []*pptasmessages.ListMove { - payload := make(pptasmessages.ListMoves, len(*moves)) - - for i, m := range *moves { - copyOfM := m // Make copy to avoid implicit memory aliasing of items from a range statement. - payload[i] = ListMove(©OfM) - } - return payload -} diff --git a/pkg/handlers/pptasapi/moves.go b/pkg/handlers/pptasapi/moves.go deleted file mode 100644 index 62f6fc20fa5..00000000000 --- a/pkg/handlers/pptasapi/moves.go +++ /dev/null @@ -1,42 +0,0 @@ -package pptasapi - -import ( - "github.com/go-openapi/runtime/middleware" - "go.uber.org/zap" - - "github.com/transcom/mymove/pkg/appcontext" - pptasop "github.com/transcom/mymove/pkg/gen/pptasapi/pptasoperations/moves" - "github.com/transcom/mymove/pkg/handlers" - "github.com/transcom/mymove/pkg/handlers/pptasapi/internal/payloads" - "github.com/transcom/mymove/pkg/services" -) - -// ListMovesHandler lists moves with the option to filter since a particular date. Optimized ver. -type ListMovesHandler struct { - handlers.HandlerConfig - services.MoveTaskOrderFetcher -} - -// Handle fetches all moves with the option to filter since a particular date. Optimized version. -func (h ListMovesHandler) Handle(params pptasop.ListMovesParams) middleware.Responder { - return h.AuditableAppContextFromRequestWithErrors(params.HTTPRequest, - func(appCtx appcontext.AppContext) (middleware.Responder, error) { - - var searchParams services.MoveTaskOrderFetcherParams - if params.Since != nil { - since := handlers.FmtDateTimePtrToPop(params.Since) - searchParams.Since = &since - } - - mtos, err := h.MoveTaskOrderFetcher.ListPrimeMoveTaskOrders(appCtx, &searchParams) - - if err != nil { - appCtx.Logger().Error("Unexpected error while fetching moves:", zap.Error(err)) - return pptasop.NewListMovesInternalServerError().WithPayload(payloads.InternalServerError(nil, h.GetTraceIDFromRequest(params.HTTPRequest))), err - } - - payload := payloads.ListMoves(&mtos) - - return pptasop.NewListMovesOK().WithPayload(payload), nil - }) -} diff --git a/pkg/handlers/routing/base_routing_suite.go b/pkg/handlers/routing/base_routing_suite.go index 32e4ed985fe..0aed780d4bc 100644 --- a/pkg/handlers/routing/base_routing_suite.go +++ b/pkg/handlers/routing/base_routing_suite.go @@ -274,18 +274,6 @@ func (suite *BaseRoutingSuite) NewAuthenticatedPrimeRequest(method string, relat return req } -func (suite *BaseRoutingSuite) NewPPTASRequest(method string, relativePath string, body io.Reader) *http.Request { - return suite.NewRequest(method, - suite.HandlerConfig().AppNames().PPTASServerName, - relativePath, - body) -} -func (suite *BaseRoutingSuite) NewAuthenticatedPPTASRequest(method string, relativePath string, body io.Reader, clientCert models.ClientCert) *http.Request { - req := suite.NewOfficeRequest(method, relativePath, body) - req.Header.Add("X-Devlocal-Cert-Hash", clientCert.Sha256Digest) - return req -} - // The ClientCertMiddleware looks at the TLS certificate on the // request to make sure it matches something in the database. Fake the TLS // info on the request diff --git a/pkg/handlers/routing/routing_init.go b/pkg/handlers/routing/routing_init.go index 7329bbeec67..981cd00ce17 100644 --- a/pkg/handlers/routing/routing_init.go +++ b/pkg/handlers/routing/routing_init.go @@ -22,7 +22,6 @@ import ( "github.com/transcom/mymove/pkg/handlers/authentication" "github.com/transcom/mymove/pkg/handlers/ghcapi" "github.com/transcom/mymove/pkg/handlers/internalapi" - "github.com/transcom/mymove/pkg/handlers/pptasapi" "github.com/transcom/mymove/pkg/handlers/primeapi" "github.com/transcom/mymove/pkg/handlers/primeapiv2" "github.com/transcom/mymove/pkg/handlers/primeapiv3" @@ -103,11 +102,6 @@ type Config struct { // The path to the ghc api swagger definition GHCSwaggerPath string - // Should the pptas api be served? - ServePPTAS bool - // The path to the ghc api swagger definition - PPTASSwaggerPath string - // Should devlocal auth be enabled? Definitely never enabled in // production ServeDevlocalAuth bool @@ -357,20 +351,6 @@ func mountPrimeAPI(appCtx appcontext.AppContext, routingConfig *Config, site chi tracingMiddleware := middleware.OpenAPITracing(api) r.Mount("/", api.Serve(tracingMiddleware)) }) - // Setup PPTAS API - primeRouter.Route("/pptas", func(r chi.Router) { - r.Method("GET", "/swagger.yaml", - handlers.NewFileHandler(routingConfig.FileSystem, - routingConfig.PPTASSwaggerPath)) - if routingConfig.ServeSwaggerUI { - r.Method("GET", "/docs", - handlers.NewFileHandler(routingConfig.FileSystem, - path.Join(routingConfig.BuildRoot, "swagger-ui", "pptas.html"))) - } else { - r.Method("GET", "/docs", http.NotFoundHandler()) - } - r.Mount("/", pptasapi.NewPPTASApiHandler(routingConfig.HandlerConfig)) - }) }) } } @@ -607,28 +587,6 @@ func mountPrimeSimulatorAPI(appCtx appcontext.AppContext, routingConfig *Config, }) }) } - site.Route("/prime/pptas", func(r chi.Router) { - r.Method("GET", "/swagger.yaml", - handlers.NewFileHandler(routingConfig.FileSystem, - routingConfig.PPTASSwaggerPath)) - if routingConfig.ServeSwaggerUI { - appCtx.Logger().Info("PPTAS API Swagger UI serving is enabled") - r.Method("GET", "/docs", - handlers.NewFileHandler(routingConfig.FileSystem, - path.Join(routingConfig.BuildRoot, "swagger-ui", "pptas.html"))) - } else { - r.Method("GET", "/docs", http.NotFoundHandler()) - } - - // Mux for PPTAS API that enforces auth - r.Route("/", func(rAuth chi.Router) { - rAuth.Use(userAuthMiddleware) - rAuth.Use(addAuditUserToRequestContextMiddleware) - rAuth.Use(authentication.PrimeSimulatorAuthorizationMiddleware(appCtx.Logger())) - rAuth.Use(middleware.NoCache()) - rAuth.Mount("/", pptasapi.NewPPTASApiHandler(routingConfig.HandlerConfig)) - }) - }) } } diff --git a/pkg/services/move.go b/pkg/services/move.go index 61dc21b9179..bad0f057e85 100644 --- a/pkg/services/move.go +++ b/pkg/services/move.go @@ -108,7 +108,6 @@ type SearchMovesParams struct { Order *string PickupDate *time.Time DeliveryDate *time.Time - MoveCreatedDate *time.Time } type MoveCloseoutOfficeUpdater interface { diff --git a/public/swagger-ui/pptas.html b/public/swagger-ui/pptas.html deleted file mode 100644 index 79e7991afc4..00000000000 --- a/public/swagger-ui/pptas.html +++ /dev/null @@ -1,114 +0,0 @@ - - - - - - Swagger UI - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - \ No newline at end of file diff --git a/scripts/gen-server b/scripts/gen-server index 0ad5349a1f0..8df53e10350 100755 --- a/scripts/gen-server +++ b/scripts/gen-server @@ -52,10 +52,8 @@ generate_server swagger/prime.yaml primemessages primeapi primeoperatio generate_server swagger/prime_v2.yaml primev2messages primev2api primev2operations generate_server swagger/prime_v3.yaml primev3messages primev3api primev3operations generate_server swagger/support.yaml supportmessages supportapi supportoperations -generate_server swagger/pptas.yaml pptasmessages pptasapi pptasoperations # Generate Client Code -generate_client swagger/pptas.yaml pptasmessages pptasclient generate_client swagger/prime.yaml primemessages primeclient generate_client swagger/prime_v2.yaml primev2messages primev2client generate_client swagger/prime_v3.yaml primev3messages primev3client diff --git a/swagger-def/definitions/ListMove.yaml b/swagger-def/definitions/ListMove.yaml deleted file mode 100644 index 0c26418a1d0..00000000000 --- a/swagger-def/definitions/ListMove.yaml +++ /dev/null @@ -1,41 +0,0 @@ -description: > - An abbreviated definition for a move, without all the nested information (shipments, service items, etc). Used to - fetch a list of moves more efficiently. -type: object -properties: - id: - example: 1f2270c7-7166-40ae-981e-b200ebdf3054 - format: uuid - type: string - moveCode: - type: string - example: 'HYXFJF' - readOnly: true - createdAt: - format: date-time - type: string - readOnly: true - orderID: - example: c56a4180-65aa-42ec-a945-5fd21dec0538 - format: uuid - type: string - referenceId: - example: 1001-3456 - type: string - availableToPrimeAt: - format: date-time - type: string - x-nullable: true - readOnly: true - updatedAt: - format: date-time - type: string - readOnly: true - ppmType: - type: string - enum: - - FULL - - PARTIAL - eTag: - type: string - readOnly: true diff --git a/swagger-def/definitions/ListMoves.yaml b/swagger-def/definitions/ListMoves.yaml deleted file mode 100644 index dd446f1e853..00000000000 --- a/swagger-def/definitions/ListMoves.yaml +++ /dev/null @@ -1,3 +0,0 @@ -type: array -items: - $ref: '../definitions/ListMove.yaml' diff --git a/swagger-def/definitions/MoveStatus.yaml b/swagger-def/definitions/MoveStatus.yaml deleted file mode 100644 index 6dbc55778df..00000000000 --- a/swagger-def/definitions/MoveStatus.yaml +++ /dev/null @@ -1,6 +0,0 @@ -type: string -enum: - - DRAFT - - SUBMITTED - - APPROVED - - CANCELED diff --git a/swagger-def/info/pptas_description.md b/swagger-def/info/pptas_description.md deleted file mode 100644 index 8c3592f39dd..00000000000 --- a/swagger-def/info/pptas_description.md +++ /dev/null @@ -1,4 +0,0 @@ -The PPTAS API is a RESTful API that enables the Navy's PPTAS system to request -information relating to current moves in progress. - -All endpoints are located at `/prime/pptas/`. diff --git a/swagger-def/pptas.yaml b/swagger-def/pptas.yaml deleted file mode 100644 index cf43eb77488..00000000000 --- a/swagger-def/pptas.yaml +++ /dev/null @@ -1,55 +0,0 @@ -swagger: '2.0' -info: - title: MilMove PPTAS API - version: 0.0.1 - license: - name: MIT - url: 'https://opensource.org/licenses/MIT' - contact: - email: milmove-developers@caci.com - description: - $ref: 'info/pptas_description.md' -basePath: /prime/pptas -host: primelocal -consumes: - - application/json -produces: - - application/json -schemes: - - http -tags: - - name: moves -paths: - /moves: - get: - summary: listMoves - description: | - Gets all moves that have been reviewed and approved by the TOO. The `since` parameter can be used to filter this - list down to only the moves that have been updated since the provided timestamp. A move will be considered - updated if the `updatedAt` timestamp on the move or on its orders, shipments, service items, or payment - requests, is later than the provided date and time. - - **WIP**: Include what causes moves to leave this list. Currently, once the `availableToPrimeAt` timestamp has - been set, that move will always appear in this list. - operationId: listMoves - tags: - - moves - produces: - - application/json - parameters: - - in: query - name: since - type: string - format: date-time - description: Only return moves updated since this time. Formatted like "2021-07-23T18:30:47.116Z" - responses: - '200': - description: Successfully retrieved moves. A successful fetch might still return zero moves. - schema: - $ref: 'definitions/ListMoves.yaml' - '401': - $ref: 'responses/PermissionDenied.yaml' - '403': - $ref: 'responses/PermissionDenied.yaml' - '500': - $ref: 'responses/ServerError.yaml' diff --git a/swagger-def/responses/ServerError.yaml b/swagger-def/responses/ServerError.yaml deleted file mode 100644 index ceaec327834..00000000000 --- a/swagger-def/responses/ServerError.yaml +++ /dev/null @@ -1,3 +0,0 @@ -description: An unexpected error has occurred in the server. -schema: - $ref: '../definitions/ClientError.yaml' diff --git a/swagger-def/tags/pptas_tags.yaml b/swagger-def/tags/pptas_tags.yaml deleted file mode 100644 index dc4f0761090..00000000000 --- a/swagger-def/tags/pptas_tags.yaml +++ /dev/null @@ -1,4 +0,0 @@ -- name: test - description: tag to describe test endpoints -- name: moves - description: describes all endpoints relating to moves diff --git a/swagger/pptas.yaml b/swagger/pptas.yaml deleted file mode 100644 index 63935669387..00000000000 --- a/swagger/pptas.yaml +++ /dev/null @@ -1,145 +0,0 @@ -swagger: '2.0' -info: - title: MilMove PPTAS API - version: 0.0.1 - license: - name: MIT - url: https://opensource.org/licenses/MIT - contact: - email: milmove-developers@caci.com - description: > - The PPTAS API is a RESTful API that enables the Navy's PPTAS system to - request - - information relating to current moves in progress. - - - All endpoints are located at `/prime/pptas/`. -basePath: /prime/pptas -host: primelocal -consumes: - - application/json -produces: - - application/json -schemes: - - http -tags: - - name: moves -paths: - /moves: - get: - summary: listMoves - description: > - Gets all moves that have been reviewed and approved by the TOO. The - `since` parameter can be used to filter this - - list down to only the moves that have been updated since the provided - timestamp. A move will be considered - - updated if the `updatedAt` timestamp on the move or on its orders, - shipments, service items, or payment - - requests, is later than the provided date and time. - - - **WIP**: Include what causes moves to leave this list. Currently, once - the `availableToPrimeAt` timestamp has - - been set, that move will always appear in this list. - operationId: listMoves - tags: - - moves - produces: - - application/json - parameters: - - in: query - name: since - type: string - format: date-time - description: >- - Only return moves updated since this time. Formatted like - "2021-07-23T18:30:47.116Z" - responses: - '200': - description: >- - Successfully retrieved moves. A successful fetch might still return - zero moves. - schema: - $ref: '#/definitions/ListMoves' - '401': - $ref: '#/responses/PermissionDenied' - '403': - $ref: '#/responses/PermissionDenied' - '500': - $ref: '#/responses/ServerError' -definitions: - ListMove: - description: > - An abbreviated definition for a move, without all the nested information - (shipments, service items, etc). Used to fetch a list of moves more - efficiently. - type: object - properties: - id: - example: 1f2270c7-7166-40ae-981e-b200ebdf3054 - format: uuid - type: string - moveCode: - type: string - example: HYXFJF - readOnly: true - createdAt: - format: date-time - type: string - readOnly: true - orderID: - example: c56a4180-65aa-42ec-a945-5fd21dec0538 - format: uuid - type: string - referenceId: - example: 1001-3456 - type: string - availableToPrimeAt: - format: date-time - type: string - x-nullable: true - readOnly: true - updatedAt: - format: date-time - type: string - readOnly: true - ppmType: - type: string - enum: - - FULL - - PARTIAL - eTag: - type: string - readOnly: true - ListMoves: - type: array - items: - $ref: '#/definitions/ListMove' - ClientError: - type: object - properties: - title: - type: string - detail: - type: string - instance: - type: string - format: uuid - required: - - title - - detail - - instance -responses: - PermissionDenied: - description: The request was denied. - schema: - $ref: '#/definitions/ClientError' - ServerError: - description: An unexpected error has occurred in the server. - schema: - $ref: '#/definitions/ClientError' diff --git a/swagger/redoc/pptas.html b/swagger/redoc/pptas.html deleted file mode 100644 index e8f32a587eb..00000000000 --- a/swagger/redoc/pptas.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - - PPTAS API Reference - - - - - - - - - - - - - - - - -
- - -
- - -
- - - - - -