get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/69017/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 69017,
    "url": "https://patches.dpdk.org/api/patches/69017/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20200421123949.38270-7-ciara.power@intel.com/",
    "project": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20200421123949.38270-7-ciara.power@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200421123949.38270-7-ciara.power@intel.com",
    "date": "2020-04-21T12:39:38",
    "name": "[v3,06/17] telemetry: add utility functions for creating json",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "d55c8e80caa0a537b49d11ebe68540d3fbf9e67b",
    "submitter": {
        "id": 978,
        "url": "https://patches.dpdk.org/api/people/978/?format=api",
        "name": "Power, Ciara",
        "email": "ciara.power@intel.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20200421123949.38270-7-ciara.power@intel.com/mbox/",
    "series": [
        {
            "id": 9543,
            "url": "https://patches.dpdk.org/api/series/9543/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=9543",
            "date": "2020-04-21T12:39:32",
            "name": "update and simplify telemetry library.",
            "version": 3,
            "mbox": "https://patches.dpdk.org/series/9543/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/69017/comments/",
    "check": "success",
    "checks": "https://patches.dpdk.org/api/patches/69017/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id D4253A0597;\n\tTue, 21 Apr 2020 15:00:54 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 0914B1D5AD;\n\tTue, 21 Apr 2020 14:59:42 +0200 (CEST)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n by dpdk.org (Postfix) with ESMTP id 2E0D91D598\n for <dev@dpdk.org>; Tue, 21 Apr 2020 14:59:39 +0200 (CEST)",
            "from fmsmga004.fm.intel.com ([10.253.24.48])\n by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 21 Apr 2020 05:59:38 -0700",
            "from silpixa00399953.ir.intel.com (HELO\n silpixa00399953.ger.corp.intel.com) ([10.237.222.53])\n by fmsmga004.fm.intel.com with ESMTP; 21 Apr 2020 05:59:36 -0700"
        ],
        "IronPort-SDR": [
            "\n ybOXhLDYEuVAHVTnczO/i75WWNPdakqvEiEwxBCG6W5IsvAhsiXPRWzAis84uBrWe/W7v9UM2I\n 6KaGIOAS37Dg==",
            "\n h4qeyP7GCVjzVNy4Kp1+7ubAa32I2LaP9/Ly2AVP82tX1j4NQFH/fNxKB1ggj7ki4y7HVmfgiI\n rkr7VLKuI4gw=="
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.72,410,1580803200\"; d=\"scan'208\";a=\"279629100\"",
        "From": "Ciara Power <ciara.power@intel.com>",
        "To": "dev@dpdk.org,\n\tkevin.laatz@intel.com",
        "Cc": "reshma.pattan@intel.com, jerinjacobk@gmail.com, david.marchand@redhat.com,\n keith.wiles@intel.com, mb@smartsharesystems.com, thomas@monjalon.net,\n Bruce Richardson <bruce.richardson@intel.com>",
        "Date": "Tue, 21 Apr 2020 13:39:38 +0100",
        "Message-Id": "<20200421123949.38270-7-ciara.power@intel.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20200421123949.38270-1-ciara.power@intel.com>",
        "References": "<20200319171907.60891-1-ciara.power@intel.com>\n <20200421123949.38270-1-ciara.power@intel.com>",
        "Subject": "[dpdk-dev] [PATCH v3 06/17] telemetry: add utility functions for\n\tcreating json",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "From: Bruce Richardson <bruce.richardson@intel.com>\n\nThe functions added in this patch will make it easier for applications\nto build up correct JSON responses to telemetry requests.\n\nSigned-off-by: Bruce Richardson <bruce.richardson@intel.com>\n---\n lib/librte_telemetry/Makefile             |   1 +\n lib/librte_telemetry/meson.build          |   2 +-\n lib/librte_telemetry/rte_telemetry.h      |   1 +\n lib/librte_telemetry/rte_telemetry_json.h | 206 ++++++++++++++++++++++\n 4 files changed, 209 insertions(+), 1 deletion(-)\n create mode 100644 lib/librte_telemetry/rte_telemetry_json.h",
    "diff": "diff --git a/lib/librte_telemetry/Makefile b/lib/librte_telemetry/Makefile\nindex 270e1aac54..dbf16f4bec 100644\n--- a/lib/librte_telemetry/Makefile\n+++ b/lib/librte_telemetry/Makefile\n@@ -27,5 +27,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_TELEMETRY) += telemetry.c\n \n # export include files\n SYMLINK-$(CONFIG_RTE_LIBRTE_TELEMETRY)-include := rte_telemetry.h\n+SYMLINK-$(CONFIG_RTE_LIBRTE_TELEMETRY)-include += rte_telemetry_json.h\n \n include $(RTE_SDK)/mk/rte.lib.mk\ndiff --git a/lib/librte_telemetry/meson.build b/lib/librte_telemetry/meson.build\nindex 0cdae414a4..c8e2fdd0b2 100644\n--- a/lib/librte_telemetry/meson.build\n+++ b/lib/librte_telemetry/meson.build\n@@ -5,7 +5,7 @@ includes = [global_inc]\n \n sources = files('rte_telemetry.c', 'rte_telemetry_parser.c', 'rte_telemetry_parser_test.c',\n \t'telemetry.c')\n-headers = files('rte_telemetry.h', 'rte_telemetry_internal.h', 'rte_telemetry_parser.h')\n+headers = files('rte_telemetry.h', 'rte_telemetry_internal.h', 'rte_telemetry_parser.h', 'rte_telemetry_json.h')\n includes += include_directories('../librte_metrics')\n \n jansson = dependency('jansson', required: false)\ndiff --git a/lib/librte_telemetry/rte_telemetry.h b/lib/librte_telemetry/rte_telemetry.h\nindex 27067b1250..dc63b54423 100644\n--- a/lib/librte_telemetry/rte_telemetry.h\n+++ b/lib/librte_telemetry/rte_telemetry.h\n@@ -4,6 +4,7 @@\n \n #include <stdint.h>\n #include <rte_compat.h>\n+#include <rte_telemetry_json.h>\n \n #ifndef _RTE_TELEMETRY_H_\n #define _RTE_TELEMETRY_H_\ndiff --git a/lib/librte_telemetry/rte_telemetry_json.h b/lib/librte_telemetry/rte_telemetry_json.h\nnew file mode 100644\nindex 0000000000..bb926b918b\n--- /dev/null\n+++ b/lib/librte_telemetry/rte_telemetry_json.h\n@@ -0,0 +1,206 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2020 Intel Corporation\n+ */\n+\n+#ifndef _RTE_TELEMETRY_JSON_H_\n+#define _RTE_TELEMETRY_JSON_H_\n+\n+#include <inttypes.h>\n+#include <stdarg.h>\n+#include <stdio.h>\n+#include <rte_common.h>\n+\n+/**\n+ * @warning\n+ * @b EXPERIMENTAL: all functions in this file may change without prior notice\n+ *\n+ * @file\n+ * RTE Telemetry Utility Functions for Creating JSON Responses\n+ *\n+ * This file contains small inline functions to make it easier for applications\n+ * to build up valid JSON responses to telemetry requests.\n+ *\n+ ***/\n+\n+/**\n+ * @internal\n+ *\n+ * Copies a value into a buffer if the buffer has enough available space.\n+ * Nothing written to buffer if an overflow ocurs.\n+ * This function is not for use for values larger than 1k.\n+ *\n+ * @param buf\n+ * Buffer for data to be appended to.\n+ * @param len\n+ * Length of buffer.\n+ * @param format\n+ * Format string.\n+ * @param ...\n+ * Optional arguments that may be required by the format string.\n+ *\n+ * @return\n+ *  Number of characters added to buffer\n+ */\n+__rte_format_printf(3, 4)\n+static inline int\n+__json_snprintf(char *buf, const int len, const char *format, ...)\n+{\n+\tchar tmp[1024];\n+\tva_list ap;\n+\tint ret;\n+\n+\tva_start(ap, format);\n+\tret = vsnprintf(tmp, sizeof(tmp), format, ap);\n+\tva_end(ap);\n+\tif (ret > 0 && ret < (int)sizeof(tmp) && ret < len) {\n+\t\tstrcpy(buf, tmp);\n+\t\treturn ret;\n+\t}\n+\treturn 0; /* nothing written or modified */\n+}\n+\n+/**\n+ * Copies an empty array into the provided buffer.\n+ *\n+ * @param buf\n+ * Buffer to hold the empty array.\n+ * @param len\n+ * Length of buffer.\n+ * @param used\n+ * The number of used characters in the buffer.\n+ *\n+ * @return\n+ *  Total number of characters in buffer.\n+ */\n+static inline int\n+rte_tel_json_empty_array(char *buf, const int len, const int used)\n+{\n+\treturn used + __json_snprintf(buf + used, len - used, \"[]\");\n+}\n+\n+/**\n+ * Copies an empty object into the provided buffer.\n+ *\n+ * @param buf\n+ * Buffer to hold the empty object.\n+ * @param len\n+ * Length of buffer.\n+ * @param used\n+ * The number of used characters in the buffer.\n+ *\n+ * @return\n+ *  Total number of characters in buffer\n+ */\n+static inline int\n+rte_tel_json_empty_obj(char *buf, const int len, const int used)\n+{\n+\treturn used + __json_snprintf(buf + used, len - used, \"{}\");\n+}\n+\n+/**\n+ * Copies a string into the provided buffer, in JSON format.\n+ *\n+ * @param buf\n+ * Buffer to copy string into.\n+ * @param len\n+ * Length of buffer.\n+ * @param used\n+ * The number of used characters in the buffer.\n+ * @param str\n+ * String value to copy into buffer.\n+ *\n+ * @return\n+ *  Total number of characters in buffer\n+ */\n+static inline int\n+rte_tel_json_str(char *buf, const int len, const int used, const char *str)\n+{\n+\treturn used + __json_snprintf(buf + used, len - used, \"\\\"%s\\\"\", str);\n+}\n+\n+/**\n+ * Appends a string into the JSON array in the provided buffer.\n+ *\n+ * @param buf\n+ * Buffer to append array string to.\n+ * @param len\n+ * Length of buffer.\n+ * @param used\n+ * The number of used characters in the buffer.\n+ * @param str\n+ * String value to append to buffer.\n+ *\n+ * @return\n+ *  Total number of characters in buffer\n+ */\n+static inline int\n+rte_tel_json_add_array_string(char *buf, const int len, const int used,\n+\t\tconst char *str)\n+{\n+\tint ret, end = used - 1; /* strip off final delimiter */\n+\tif (used <= 2) /* assume empty, since minimum is '[]' */\n+\t\treturn __json_snprintf(buf, len, \"[\\\"%s\\\"]\", str);\n+\n+\tret = __json_snprintf(buf + end, len - end, \",\\\"%s\\\"]\", str);\n+\treturn ret == 0 ? used : end + ret;\n+}\n+\n+/**\n+ * Appends an integer into the JSON array in the provided buffer.\n+ *\n+ * @param buf\n+ * Buffer to append array integer to.\n+ * @param len\n+ * Length of buffer.\n+ * @param used\n+ * The number of used characters in the buffer.\n+ * @param val\n+ * Integer value to append to buffer.\n+ *\n+ * @return\n+ *  Total number of characters in buffer\n+ */\n+static inline int\n+rte_tel_json_add_array_int(char *buf, const int len, const int used, int val)\n+{\n+\tint ret, end = used - 1; /* strip off final delimiter */\n+\tif (used <= 2) /* assume empty, since minimum is '[]' */\n+\t\treturn __json_snprintf(buf, len, \"[%d]\", val);\n+\n+\tret = __json_snprintf(buf + end, len - end, \",%d]\", val);\n+\treturn ret == 0 ? used : end + ret;\n+}\n+\n+/**\n+ * Add a new element with uint64_t value to the JSON object stored in the\n+ * provided buffer.\n+ *\n+ * @param buf\n+ * Buffer to append object element to.\n+ * @param len\n+ * Length of buffer.\n+ * @param used\n+ * The number of used characters in the buffer.\n+ * @param name\n+ * String for object element key.\n+ * @param val\n+ * Uint64_t for object element value.\n+ *\n+ * @return\n+ *  Total number of characters in buffer\n+ */\n+static inline int\n+rte_tel_json_add_obj_u64(char *buf, const int len, const int used,\n+\t\tconst char *name, uint64_t val)\n+{\n+\tint ret, end = used - 1;\n+\tif (used <= 2) /* assume empty, since minimum is '{}' */\n+\t\treturn __json_snprintf(buf, len, \"{\\\"%s\\\":%\"PRIu64\"}\", name,\n+\t\t\t\tval);\n+\n+\tret = __json_snprintf(buf + end, len - end, \",\\\"%s\\\":%\"PRIu64\"}\",\n+\t\t\tname, val);\n+\treturn ret == 0 ? used : end + ret;\n+}\n+\n+#endif /*_RTE_TELEMETRY_JSON_H_*/\n",
    "prefixes": [
        "v3",
        "06/17"
    ]
}