Best Python code snippet using localstack_python
views.py
Source:views.py  
...20class ServiceClassCollectionView(CustomGenericAPIView):21    serializer_class = ServiceClassCollectionSerializer22    service_class = ServiceClassService23    permission_classes = (IsAdminOrReadOnly, )24    @serialize_to_response(many=True)25    def get(self, request, *args, **kwargs):26        return self.service.get_all_service_classes()27    @serialize_to_response(many=False, status_code=status.HTTP_201_CREATED)28    @deserialize_input(partial=False)29    def post(self, request, *args, **kwargs):30        # kwargs['deserialized_object'] has been deseralized and validated31        return self.service.create(kwargs['deserialized_object'])32class ServiceClassItemView(CustomGenericAPIView):33    serializer_class = ServiceClassItemSerializer34    service_class = ServiceClassService35    permission_classes = (IsAdminOrClassPermissionOrReadOnly, )36    @serialize_to_response(many=False)37    def get(self, request, *args, **kwargs):38        return self.service.get(kwargs['class_name'])39    @serialize_to_response(many=False, status_code=status.HTTP_200_OK)40    @deserialize_input(partial=True)41    def post(self, request, *args, **kwargs):42        return self.service.update(kwargs['deserialized_object'])43    @serialize_to_response(status_code=status.HTTP_204_NO_CONTENT)44    def delete(self, request, *args, **kwargs):45        return self.service.delete(kwargs['class_name'])46class ServiceInstanceView(CustomGenericAPIView):47    """48    View for dealing with collection instances49    """50    serializer_class = ServiceInstanceSerializer51    service_class = ServiceInstanceService52    permission_classes = (IsAdminOrClassPermissionOrReadOnly, )53    @serialize_to_response(many=True, status_code=status.HTTP_200_OK)54    @check_regex_query_params(settings.QUERY_PARAMS_GET_ENDPOINTS)55    @check_duplicated_query_params56    @check_empty_query_params57    def get(self, request, *args, **kwargs):58        # Transforms the dictionary key to lowerCase and exclude filters query param59        filter_param = settings.REQUEST_FILTER_PARAM60        request_params = dict(((key.lower(), value) for key, value in request.QUERY_PARAMS.items()61                                                        if key not in (filter_param,)))62        return self.service.discover_service_instances(kwargs['class_name'], request_params)63    @serialize_to_response(many=False, status_code=status.HTTP_201_CREATED)64    @deserialize_input(partial=False)65    def post(self, request, *args, **kwargs):66        # kwargs['deserialized_object'] has been deseralized and validated67        return self.service.create(kwargs['deserialized_object'])68class ServiceInstanceItemView(CustomGenericAPIView):69    """70    View for modifying a single instance71    """72    serializer_class = ServiceInstanceSerializer73    serializer_class_put = ServiceInstanceItemSerializer74    service_class = ServiceInstanceService75    permission_classes = (IsAdminOrClassPermissionOrReadOnly, )76    @serialize_to_response(many=False, status_code=status.HTTP_200_OK)77    def get(self, request, *args, **kwargs):78        return self.service.get_service_instance(kwargs['class_name'], kwargs['id'])79    @serialize_to_response(many=False, status_code=status.HTTP_200_OK)80    @deserialize_input(partial=False)81    def put(self, request, *args, **kwargs):82        return self.service.update(kwargs['deserialized_object'])83    @serialize_to_response(status_code=status.HTTP_204_NO_CONTENT)84    def delete(self, request, *args, **kwargs):85        return self.service.delete(kwargs['class_name'], kwargs['id'])86class InfoView(CustomGenericAPIView):87    def get(self, request, *args, **kwargs):88        return Response({'app_name': settings.APP_NAME, 'default_version': settings.VERSION},...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
