Google Professional Cloud Developer Question 330
Select 2Google Cloud PlatformYou are developing an API for a payment processing system using Apigee. The API is currently versioned as 'v1', and you need to release a breaking change that modifies the structure of the payment request payload. How should you handle API versioning to minimize disruption for existing consumers while allowing new consumers to adopt the change?
- A
Deprecate the 'v1' version immediately and replace it with 'v2', forcing all consumers to migrate to the new version.
- B
Create a new version 'v2' of the API alongside 'v1', and communicate the changes to consumers, allowing them to migrate at their own pace.
- C
Overwrite the existing 'v1' API implementation with the new changes, as consumers should always use the latest version.
- D
Provide a migration guide and sunset the 'v1' API after a grace period, ensuring consumers have time to migrate to 'v2'.
Show answer and explanation
Correct answers: B, D
Explanation
When introducing breaking changes to an API, it is important to follow proper versioning practices to avoid disrupting existing consumers. Creating a new version ('v2') alongside the existing version ('v1') ensures that current users can continue using their version without interruption. Providing a migration guide and a sunset period further helps users transition smoothly to the new version, maintaining trust and reliability in your API.
- A. Incorrect.
Forcing all consumers to migrate immediately to a new version without prior notice can cause significant disruption and is not a recommended practice in API management.
- B. Correct.
Creating a new version 'v2' alongside 'v1' is the correct approach to handle breaking changes while ensuring existing consumers can continue using the API without disruption. This provides a smooth migration path.
- C. Incorrect.
Overwriting 'v1' with breaking changes violates API versioning best practices, as it can break existing consumers who rely on the current implementation.
- D. Correct.
Providing a migration guide and a sunset period is essential for transparent communication and allows consumers sufficient time to transition to the new version. This aligns with good API management practices.