示例#1
0
 def retrieve(self,
              request,
              tenant_pk=None,
              aws_env_pk=None,
              region_pk=None,
              service_pk=None,
              pk=None):
     log = NarukoLogging(request)
     logger = log.get_logger(__name__)
     logger.info("START: retrieve")
     try:
         aws_environment = AwsEnvironmentModel.objects.get(
             id=aws_env_pk, tenant_id=tenant_pk)
         resource = ControlResourceUseCase(log).describe_resource(
             request.user, aws_environment,
             Resource.get_service_resource(region_pk, service_pk, pk))
     except (TypeError, ValueError, KeyError, NarukoException) as e:
         # リクエストデータが不正
         logger.exception(e)
         return Response(status=status.HTTP_400_BAD_REQUEST)
     except ObjectDoesNotExist as e:
         # AWS環境が存在しない
         logger.exception(e)
         return Response(status=status.HTTP_404_NOT_FOUND)
     except Exception as e:
         logger.exception(e)
         raise
     else:
         logger.info("END: retrieve")
         return Response(data=resource.serialize(aws_environment),
                         status=status.HTTP_200_OK)
示例#2
0
 def retrieve(self, request, tenant_pk=None, aws_env_pk=None,
              region_pk=None, service_pk=None, pk=None):
     log = NarukoLogging(request)
     logger = log.get_logger(__name__)
     logger.info("START: retrieve")
     aws_environment = AwsEnvironmentModel.objects.get(id=aws_env_pk, tenant_id=tenant_pk)
     resource = ControlResourceUseCase(log).describe_resource(
         request.user,
         aws_environment,
         Resource.get_service_resource(region_pk, service_pk, pk))
     logger.info("END: retrieve")
     return Response(data=resource.serialize(aws_environment),
                     status=status.HTTP_200_OK)