add get and patch operations
This commit is contained in:
parent
7c7f315e52
commit
a4850683c9
3 changed files with 72 additions and 2 deletions
|
@ -127,3 +127,20 @@ class ServiceOfferingSerializer(serializers.ModelSerializer):
|
|||
|
||||
class CatalogSerializer(serializers.Serializer):
|
||||
services = ServiceOfferingSerializer(many=True)
|
||||
|
||||
|
||||
class ServiceInstanceUpdateSerializer(serializers.Serializer):
|
||||
plan_id = serializers.CharField()
|
||||
|
||||
def validate_plan_id(self, value):
|
||||
try:
|
||||
plan = Plan.objects.get(pk=value)
|
||||
# Get instance from context
|
||||
instance = self.context.get("instance")
|
||||
if str(plan.offering.id) != str(instance.offering.id):
|
||||
raise serializers.ValidationError(
|
||||
"Plan does not belong to the current offering"
|
||||
)
|
||||
return plan
|
||||
except Plan.DoesNotExist:
|
||||
raise serializers.ValidationError("Invalid plan_id")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue