Marc_M

JOLT transform

May 21st, 2024 (edited)
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. [
  2. {
  3. "operation": "shift",
  4. "spec": {
  5. "*": {
  6. "*": "&",
  7. "pim_network": {
  8. "*": {
  9. "*": "&",
  10. "addresses": {
  11. "*": {
  12. "*": "&4.&1.others.&", //the elements other than "addr_info"
  13. "addr_info": {
  14. "*": {
  15. "*": "&6.&3.&2[&1].&"
  16. }
  17. }
  18. }
  19. }
  20. }
  21. }
  22. }
  23. }
  24. },
  25. {
  26. "operation": "shift",
  27. "spec": {
  28. "*": "&",
  29. "pim_network": { //outermost level, eg. the level of "pim_network"
  30. "*": { // the indexes(0,1,2) of "pim_network" derived within the previous spec
  31. "addr_info": {
  32. "*": {
  33. "@2,others": { "*": "&5.&4_&2.&" }, // go two levels up the tree to grab the values of the "others" object
  34. "*": "&4.&3_&1.&" // &4 stands for the key literal "pim_network"
  35. }
  36. }
  37. }
  38. }
  39. }
  40. },
  41. { //get rid of the object keys
  42. "operation": "shift",
  43. "spec": {
  44. "*": "&",
  45. "pim_network": {
  46. "*": "&1[]" //add the literal "pim_network" by &1
  47. }
  48. }
  49. },
  50. {
  51. "operation": "shift",
  52. "spec": {
  53. "*": "&",
  54. "pim_network": {
  55. "*": {
  56. "family": {
  57. "inet": {
  58. "@2,ifindex": "pim_network[#4].ifindex",
  59. "@2,local": "pim_network[#4].ip_address",
  60. "@2,prefixlen": "pim_network[#4].ip_subnet",
  61. "@2,label": "pim_network[#4].description",
  62. "@2,address": "pim_network[#4].mac_address"
  63. }
  64. }
  65. }
  66. }
  67. }
  68. },
  69. {
  70. "operation": "modify-default-beta",
  71. "spec": {
  72. "pim_storage": {
  73. "*": {
  74. "asset_id": ""
  75. }
  76. },
  77. "pim_network": {
  78. "*": {
  79. "asset_id": ""
  80. }
  81. },
  82. "pim_software": {
  83. "*": {
  84. "asset_id": ""
  85. }
  86. },
  87. "pim_services": {
  88. "*": {
  89. "asset_id": ""
  90. }
  91. }
  92. }
  93. },
  94. {
  95. "operation": "shift",
  96. "spec": {
  97. "*": "&",
  98. "pim_hostname": {
  99. "SHORT_HOSTNAME": "hostname"
  100. },
  101. "pim_distro": {
  102. "PRETTY_NAME": "os_type"
  103. },
  104. "pim_hardware": {
  105. "processor_count": "cpu_count",
  106. "hw_memory": "memory"
  107. },
  108. "pim_storage": {
  109. "*": {
  110. "NAME": "pim_storage.[&1].drive_name",
  111. "SIZE": "pim_storage.[&1].capacity",
  112. "TYPE": "pim_storage.[&1].type_enum"
  113. }
  114. },
  115. "pim_software": {
  116. "*": {
  117. "Name": "pim_software.[&1].name",
  118. "Version": "pim_software.[&1].version"
  119. }
  120. },
  121. "pim_services": {
  122. "*": {
  123. "Id": "pim_services.[&1].id",
  124. "Names": "pim_services.[&1].name",
  125. "Description": "pim_services.[&1].friendly_name",
  126. "LoadState": "pim_services.[&1].loadstate",
  127. "ActiveState": "pim_services.[&1].state",
  128. "UnitFileState": "pim_services.[&1].unitfilestate",
  129. "UnitFilePreset": "pim_services.[&1].start_mode"
  130. }
  131. }
  132. }
  133. }
  134. ]
  135.  
Tags: JOLT
Advertisement
Add Comment
Please, Sign In to add comment