-
Notifications
You must be signed in to change notification settings - Fork 359
How to Convert a V2 Endpoint to a V3 Endpoint
Greg Cobb edited this page May 9, 2019
·
2 revisions
This document covers the engineering work for converting a v2 api endpoint to a v3 endpoint. Check out the V3 API Styleguide for more information about the API design of v3.
Generally one will find logic pertaining to a particular v2 endpoint in these places:
- Access Classes (Allowy): app/access
- Sometimes Actions: app/actions/v2
- Controllers (RestController::ModelController): app/controllers/runtime
- Models (Sequel): app/models
- Sometimes Presenters: app/presenters/v2
To v3-ify this same logic, generally we must implement this logic to these places:
- Actions: app/actions
- Controllers (Rails ActionController): app/controllers/v3
- Fetchers: app/fetchers
- Messages (Rails ActiveModel): app/messages
- Models (Sequel): app/models
- Presenters: app/presenters/v3
See a more in-depth discussion of v3 architecture here.
Converting a given endpoint is sometimes more of an art than a science, but here is a rough algorithm:
- Move access logic from the access classes to controllers (collaborating with
permission_queryer
) - Move business logic from the access classes to actions
- If they exist, keep using the v2 actions or translate them to v3 actions as appropriate
- Translate the v2 controllers to v3 controllers. Move business logic to actions. Move any complex query logic to fetchers. Move presentation logic to presenters.
- Keep the models. Move validations that don't require database access to messages. Move business logic to actions. Move presentation logic to presenters. Move queries to fetchers. Because models are shared between v2 and v3, there will often be duplication between models and v3 messages/actions/presenters/fetchers.
- Move any presentation logic you want to preserve from v2 presenters to v3 presenter.
-
Pipelines
-
Contributing
- Tips and Tricks
- Cloud Controller API v3 Style Guide
- Playbooks
- Development configuration
- Testing
-
Architectural Details
-
CC Resources
- Apps
- Audit Events
- Deployments
- Labels
- Services
- Sidecars
-
Dependencies
-
Troubleshooting
- Ruby Console Script to Find Fields that Cannot Be Decrypted
- Logging database queries in unit tests
- Inspecting blobstore cc resources and cc packages(webdav)
- How to Use USR1 Trap for Diagnostics
- How to Perf: Finding and Fixing Bottlenecks
- How to get access to mysql database
- How To Get a Ruby Heap Dumps & GC Stats from CC
- How to curl v4 internal endpoints with mtls
- How to access Bosh Director console and restore an outdated Cloud Config
- Analyzing Cloud Controller's NGINX logs using the toplogs script
-
k8s
-
Archive