@api_view(('<STR_LIT:GET>', '<STR_LIT:POST>'))<EOL>def metric_details(request, pk, format=None):
metric = get_object_or_404(Metric, pk=pk)<EOL>if request.method == '<STR_LIT:GET>':<EOL><INDENT>try:<EOL><INDENT>results = metric.select(q=request.query_params.get('<STR_LIT:q>', metric.query))<EOL><DEDENT>except InfluxDBClientError as e:<EOL><INDENT>return Response({'<STR_LIT>': e.content}, status=e.code)<EOL><DEDENT>return Response(list(results.get_points(metric.name)))<EOL><DEDENT>else:<EOL><INDENT>if not request.data:<EOL><INDENT>return Response({'<STR_LIT>': '<STR_LIT>'},<EOL>status=<NUM_LIT>)<EOL><DEDENT>data = request.data.copy()<EOL>if request.content_type != '<STR_LIT:application/json>':<EOL><INDENT>for key, value in data.items():<EOL><INDENT>try:<EOL><INDENT>data[key] = float(value) if '<STR_LIT:.>' in value else int(value)<EOL><DEDENT>except ValueError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>metric.write(data)<EOL>return Response({'<STR_LIT>': '<STR_LIT>'})<EOL><DEDENT>
Get or write metric values