diff --git a/.basedpyright/baseline.json b/.basedpyright/baseline.json index 9656224cb..6b319a362 100644 --- a/.basedpyright/baseline.json +++ b/.basedpyright/baseline.json @@ -1527,6 +1527,278 @@ "lineCount": 1 } }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 8, + "endColumn": 13, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 8, + "endColumn": 13, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 8, + "endColumn": 11, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 8, + "endColumn": 11, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 8, + "endColumn": 15, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 8, + "endColumn": 15, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 8, + "endColumn": 15, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 8, + "endColumn": 15, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 10, + "endColumn": 15, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 10, + "endColumn": 15, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 12, + "endColumn": 24, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 59, + "endColumn": 85, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 8, + "endColumn": 19, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 39, + "endColumn": 50, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 54, + "endColumn": 59, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 8, + "endColumn": 20, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 8, + "endColumn": 20, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 8, + "endColumn": 13, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 8, + "endColumn": 13, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 8, + "endColumn": 11, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 8, + "endColumn": 11, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 8, + "endColumn": 15, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 8, + "endColumn": 15, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 8, + "endColumn": 15, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 8, + "endColumn": 15, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 10, + "endColumn": 15, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 10, + "endColumn": 15, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 12, + "endColumn": 24, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 61, + "endColumn": 87, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 8, + "endColumn": 19, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 41, + "endColumn": 52, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 56, + "endColumn": 61, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 8, + "endColumn": 20, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 8, + "endColumn": 20, + "lineCount": 1 + } + }, { "code": "reportMissingParameterType", "range": { @@ -2295,6 +2567,134 @@ "lineCount": 1 } }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 8, + "endColumn": 37, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 44, + "endColumn": 47, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 44, + "endColumn": 47, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 49, + "endColumn": 56, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 49, + "endColumn": 56, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 60, + "endColumn": 66, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 60, + "endColumn": 66, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 19, + "endColumn": 73, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 26, + "endColumn": 27, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 12, + "endColumn": 16, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 33, + "endColumn": 37, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 19, + "endColumn": 25, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 16, + "endColumn": 19, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 55, + "endColumn": 61, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 29, + "endColumn": 35, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 15, + "endColumn": 33, + "lineCount": 1 + } + }, { "code": "reportUnknownParameterType", "range": { @@ -2495,67 +2895,251 @@ "lineCount": 1 } }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 8, + "endColumn": 11, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 13, + "endColumn": 20, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 22, + "endColumn": 26, + "lineCount": 1 + } + }, { "code": "reportUnknownArgumentType", "range": { - "startColumn": 19, - "endColumn": 73, + "startColumn": 64, + "endColumn": 67, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 80, + "endColumn": 86, "lineCount": 1 } }, { "code": "reportUnknownVariableType", "range": { - "startColumn": 26, - "endColumn": 27, + "startColumn": 8, + "endColumn": 15, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 28, + "endColumn": 31, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 18, + "endColumn": 21, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 18, + "endColumn": 21, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 23, + "endColumn": 30, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 23, + "endColumn": 30, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 39, + "endColumn": 45, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 39, + "endColumn": 45, "lineCount": 1 } }, { "code": "reportUnknownVariableType", "range": { - "startColumn": 12, - "endColumn": 16, + "startColumn": 8, + "endColumn": 11, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 13, + "endColumn": 20, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 22, + "endColumn": 26, "lineCount": 1 } }, { "code": "reportUnknownArgumentType", "range": { - "startColumn": 33, - "endColumn": 37, + "startColumn": 64, + "endColumn": 67, "lineCount": 1 } }, { "code": "reportUnknownArgumentType", "range": { - "startColumn": 19, - "endColumn": 25, + "startColumn": 80, + "endColumn": 86, "lineCount": 1 } }, { "code": "reportUnknownVariableType", "range": { - "startColumn": 16, - "endColumn": 19, + "startColumn": 8, + "endColumn": 15, "lineCount": 1 } }, { "code": "reportUnknownArgumentType", "range": { - "startColumn": 55, - "endColumn": 61, + "startColumn": 28, + "endColumn": 31, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 41, + "endColumn": 47, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 41, + "endColumn": 47, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 8, + "endColumn": 11, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 13, + "endColumn": 20, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 22, + "endColumn": 26, "lineCount": 1 } }, { "code": "reportUnknownArgumentType", "range": { - "startColumn": 29, - "endColumn": 35, + "startColumn": 64, + "endColumn": 67, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 80, + "endColumn": 86, "lineCount": 1 } }, @@ -3154,8 +3738,16 @@ { "code": "reportPrivateUsage", "range": { - "startColumn": 40, - "endColumn": 66, + "startColumn": 26, + "endColumn": 52, + "lineCount": 1 + } + }, + { + "code": "reportUnnecessaryTypeIgnoreComment", + "range": { + "startColumn": 55, + "endColumn": 78, "lineCount": 1 } }, @@ -3402,10 +3994,42 @@ ], "./splunklib/client.py": [ { - "code": "reportDuplicateImport", + "code": "reportAssignmentType", "range": { - "startColumn": 21, - "endColumn": 29, + "startColumn": 25, + "endColumn": 35, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 19, + "endColumn": 26, + "lineCount": 1 + } + }, + { + "code": "reportUnusedParameter", + "range": { + "startColumn": 19, + "endColumn": 26, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 15, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportUnknownLambdaType", + "range": { + "startColumn": 22, + "endColumn": 26, "lineCount": 1 } }, @@ -7465,6 +8089,14 @@ "lineCount": 1 } }, + { + "code": "reportUntypedFunctionDecorator", + "range": { + "startColumn": 5, + "endColumn": 13, + "lineCount": 1 + } + }, { "code": "reportUnknownParameterType", "range": { @@ -32971,6 +33603,726 @@ "lineCount": 1 } }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 12, + "endColumn": 19, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnusedParameter", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 19, + "endColumn": 13, + "lineCount": 6 + } + }, + { + "code": "reportAttributeAccessIssue", + "range": { + "startColumn": 29, + "endColumn": 33, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 12, + "endColumn": 19, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnusedParameter", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 19, + "endColumn": 13, + "lineCount": 6 + } + }, + { + "code": "reportAttributeAccessIssue", + "range": { + "startColumn": 29, + "endColumn": 33, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 12, + "endColumn": 19, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnusedParameter", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 19, + "endColumn": 13, + "lineCount": 6 + } + }, + { + "code": "reportAttributeAccessIssue", + "range": { + "startColumn": 29, + "endColumn": 33, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 12, + "endColumn": 19, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnusedParameter", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 19, + "endColumn": 13, + "lineCount": 6 + } + }, + { + "code": "reportAttributeAccessIssue", + "range": { + "startColumn": 29, + "endColumn": 33, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 12, + "endColumn": 19, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnusedParameter", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 19, + "endColumn": 13, + "lineCount": 6 + } + }, + { + "code": "reportAttributeAccessIssue", + "range": { + "startColumn": 29, + "endColumn": 33, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 12, + "endColumn": 19, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnusedParameter", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 19, + "endColumn": 13, + "lineCount": 6 + } + }, + { + "code": "reportAttributeAccessIssue", + "range": { + "startColumn": 29, + "endColumn": 33, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 12, + "endColumn": 19, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnusedParameter", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 19, + "endColumn": 13, + "lineCount": 6 + } + }, + { + "code": "reportAttributeAccessIssue", + "range": { + "startColumn": 29, + "endColumn": 33, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 12, + "endColumn": 19, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnusedParameter", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 19, + "endColumn": 13, + "lineCount": 6 + } + }, + { + "code": "reportAttributeAccessIssue", + "range": { + "startColumn": 29, + "endColumn": 33, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 12, + "endColumn": 19, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 20, + "endColumn": 23, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 25, + "endColumn": 32, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnusedParameter", + "range": { + "startColumn": 36, + "endColumn": 42, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 19, + "endColumn": 13, + "lineCount": 6 + } + }, + { + "code": "reportAttributeAccessIssue", + "range": { + "startColumn": 29, + "endColumn": 33, + "lineCount": 1 + } + }, { "code": "reportUnknownParameterType", "range": { @@ -33395,6 +34747,230 @@ "lineCount": 1 } }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 30, + "endColumn": 34, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 27, + "endColumn": 34, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 27, + "endColumn": 34, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 25, + "endColumn": 65, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 12, + "endColumn": 16, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 27, + "endColumn": 34, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 27, + "endColumn": 34, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 25, + "endColumn": 65, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 12, + "endColumn": 16, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 30, + "endColumn": 34, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 27, + "endColumn": 34, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 27, + "endColumn": 34, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 25, + "endColumn": 65, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 12, + "endColumn": 16, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 30, + "endColumn": 34, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 27, + "endColumn": 34, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 27, + "endColumn": 34, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 25, + "endColumn": 65, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 12, + "endColumn": 16, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 27, + "endColumn": 34, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 27, + "endColumn": 34, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 25, + "endColumn": 65, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 12, + "endColumn": 16, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 30, + "endColumn": 34, + "lineCount": 1 + } + }, + { + "code": "reportUnknownParameterType", + "range": { + "startColumn": 27, + "endColumn": 34, + "lineCount": 1 + } + }, + { + "code": "reportMissingParameterType", + "range": { + "startColumn": 27, + "endColumn": 34, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 25, + "endColumn": 65, + "lineCount": 1 + } + }, + { + "code": "reportUnknownVariableType", + "range": { + "startColumn": 12, + "endColumn": 16, + "lineCount": 1 + } + }, { "code": "reportUnknownArgumentType", "range": { @@ -39120,26 +40696,42 @@ ], "./tests/system/test_cre_apps.py": [ { - "code": "reportUnusedImport", + "code": "reportUnannotatedClassAttribute", "range": { - "startColumn": 7, - "endColumn": 13, + "startColumn": 4, + "endColumn": 12, "lineCount": 1 } }, { - "code": "reportUnusedImport", + "code": "reportUnknownArgumentType", "range": { - "startColumn": 22, - "endColumn": 29, + "startColumn": 40, + "endColumn": 52, "lineCount": 1 } }, { - "code": "reportUnannotatedClassAttribute", + "code": "reportUnknownArgumentType", "range": { - "startColumn": 4, - "endColumn": 12, + "startColumn": 27, + "endColumn": 36, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 40, + "endColumn": 52, + "lineCount": 1 + } + }, + { + "code": "reportUnknownArgumentType", + "range": { + "startColumn": 27, + "endColumn": 36, "lineCount": 1 } }, diff --git a/docs/conf.py b/docs/conf.py index 25c60a3df..20d094dd7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -# # Splunk SDK for Python documentation build configuration file, created by # sphinx-quickstart on Fri Apr 13 12:28:15 2012. # diff --git a/sitecustomize.py b/sitecustomize.py index a9897d7e4..7f913e556 100644 --- a/sitecustomize.py +++ b/sitecustomize.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/__init__.py b/splunklib/__init__.py index 84c4a061b..049193458 100644 --- a/splunklib/__init__.py +++ b/splunklib/__init__.py @@ -1,4 +1,4 @@ -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/binding.py b/splunklib/binding.py index cddd32e29..1684a50e2 100644 --- a/splunklib/binding.py +++ b/splunklib/binding.py @@ -1,4 +1,4 @@ -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain @@ -862,6 +862,158 @@ def post( response = self.http.post(path, all_headers, **query) return response + @_authentication + @_log_duration + def put( + self, + path_segment, + owner=None, + app=None, + sharing=None, + headers=None, + **query, + ): + """Performs a PUT operation from the REST path segment with the given object, + namespace and query. + + This method is named to match the HTTP method. ``put`` makes at least + one round trip to the server, one additional round trip for each 303 + status returned, and at most two additional round trips if + the ``autologin`` field of :func:`connect` is set to ``True``. + + If *owner*, *app*, and *sharing* are omitted, this method uses the + default :class:`Context` namespace. All other keyword arguments are + included in the URL as query parameters. + + If you provide a ``body`` argument to ``put``, it will be used as the PUT body, + and all other keyword arguments will be passed as GET-style arguments in the URL. + + :raises AuthenticationError: Raised when the ``Context`` object is not + logged in. + :raises HTTPError: Raised when an error occurred in a PUT operation from + *path_segment*. + :param path_segment: A REST path segment. + :type path_segment: ``string`` + :param owner: The owner context of the namespace (optional). + :type owner: ``string`` + :param app: The app context of the namespace (optional). + :type app: ``string`` + :param sharing: The sharing mode of the namespace (optional). + :type sharing: ``string`` + :param headers: List of extra HTTP headers to send (optional). + :type headers: ``list`` of 2-tuples. + :param query: All other keyword arguments, which are used as query + parameters. + :param body: Parameters to be used in the put body. If specified, + any parameters in the query will be applied to the URL instead of + the body. If a dict is supplied, the key-value pairs will be form + encoded. If a string is supplied, the body will be passed through + in the request unchanged. + :type body: ``dict`` or ``str`` + :return: The response from the server. + :rtype: ``dict`` with keys ``body``, ``headers``, ``reason``, + and ``status`` + + **Example**:: + + c = binding.connect(...) + # Call an HTTP endpoint, exposed as Custom Rest Endpoint in a Splunk App. + # PUT /servicesNS/-/app_name/custom_rest_endpoint + c.put( + app="app_name", + path_segment="custom_rest_endpoint", + body=json.dumps({"key": "val"}), + headers=[("Content-Type", "application/json")], + ) + """ + if headers is None: + headers = [] + + path = self.authority + self._abspath( + path_segment, owner=owner, app=app, sharing=sharing + ) + + logger.debug("PUT request to %s (body: %s)", path, mask_sensitive_data(query)) + all_headers = headers + self.additional_headers + self._auth_headers + response = self.http.put(path, all_headers, **query) + return response + + @_authentication + @_log_duration + def patch( + self, + path_segment, + owner=None, + app=None, + sharing=None, + headers=None, + **query, + ): + """Performs a PATCH operation from the REST path segment with the given object, + namespace and query. + + This method is named to match the HTTP method. ``patch`` makes at least + one round trip to the server, one additional round trip for each 303 + status returned, and at most two additional round trips if + the ``autologin`` field of :func:`connect` is set to ``True``. + + If *owner*, *app*, and *sharing* are omitted, this method uses the + default :class:`Context` namespace. All other keyword arguments are + included in the URL as query parameters. + + If you provide a ``body`` argument to ``patch``, it will be used as the PATCH body, + and all other keyword arguments will be passed as GET-style arguments in the URL. + + :raises AuthenticationError: Raised when the ``Context`` object is not + logged in. + :raises HTTPError: Raised when an error occurred in a PATCH operation from + *path_segment*. + :param path_segment: A REST path segment. + :type path_segment: ``string`` + :param owner: The owner context of the namespace (optional). + :type owner: ``string`` + :param app: The app context of the namespace (optional). + :type app: ``string`` + :param sharing: The sharing mode of the namespace (optional). + :type sharing: ``string`` + :param headers: List of extra HTTP headers to send (optional). + :type headers: ``list`` of 2-tuples. + :param query: All other keyword arguments, which are used as query + parameters. + :param body: Parameters to be used in the patch body. If specified, + any parameters in the query will be applied to the URL instead of + the body. If a dict is supplied, the key-value pairs will be form + encoded. If a string is supplied, the body will be passed through + in the request unchanged. + :type body: ``dict`` or ``str`` + :return: The response from the server. + :rtype: ``dict`` with keys ``body``, ``headers``, ``reason``, + and ``status`` + + **Example**:: + + c = binding.connect(...) + # Call an HTTP endpoint, exposed as Custom Rest Endpoint in a Splunk App. + # PATCH /servicesNS/-/app_name/custom_rest_endpoint + c.patch( + app="app_name", + path_segment="custom_rest_endpoint", + body=json.dumps({"key": "val"}), + headers=[("Content-Type", "application/json")], + ) + """ + if headers is None: + headers = [] + + path = self.authority + self._abspath( + path_segment, owner=owner, app=app, sharing=sharing + ) + + logger.debug("PATCH request to %s (body: %s)", path, mask_sensitive_data(query)) + all_headers = headers + self.additional_headers + self._auth_headers + response = self.http.patch(path, all_headers, **query) + return response + @_authentication @_log_duration def request( @@ -1305,6 +1457,40 @@ def __init__( self.retries = retries self.retryDelay = retryDelay + def _prepare_request_body_and_url(self, url, headers, **kwargs): + """Helper function to prepare the request body and URL. + + :param url: The URL. + :type url: ``string`` + :param headers: A list of pairs specifying the headers for the HTTP request. + :type headers: ``list`` + :param kwargs: Additional keyword arguments (optional). + :type kwargs: ``dict`` + :returns: A tuple containing the updated URL, headers, and body. + :rtype: ``tuple`` + """ + if headers is None: + headers = [] + + # We handle GET-style arguments and an unstructured body. This is here + # to support the receivers/stream endpoint. + if "body" in kwargs: + # We only use application/x-www-form-urlencoded if there is no other + # Content-Type header present. This can happen in cases where we + # send requests as application/json, e.g. for KV Store. + if len([x for x in headers if x[0].lower() == "content-type"]) == 0: + headers.append(("Content-Type", "application/x-www-form-urlencoded")) + + body = kwargs.pop("body") + if isinstance(body, dict): + body = _encode(**body).encode("utf-8") + if len(kwargs) > 0: + url = url + UrlEncoded("?" + _encode(**kwargs), skip_encode=True) + else: + body = _encode(**kwargs).encode("utf-8") + + return url, headers, body + def delete(self, url, headers=None, **kwargs): """Sends a DELETE request to a URL. @@ -1379,26 +1565,52 @@ def post(self, url, headers=None, **kwargs): its structure). :rtype: ``dict`` """ - if headers is None: - headers = [] + url, headers, body = self._prepare_request_body_and_url(url, headers, **kwargs) + message = {"method": "POST", "headers": headers, "body": body} + return self.request(url, message) - # We handle GET-style arguments and an unstructured body. This is here - # to support the receivers/stream endpoint. - if "body" in kwargs: - # We only use application/x-www-form-urlencoded if there is no other - # Content-Type header present. This can happen in cases where we - # send requests as application/json, e.g. for KV Store. - if len([x for x in headers if x[0].lower() == "content-type"]) == 0: - headers.append(("Content-Type", "application/x-www-form-urlencoded")) + def put(self, url, headers=None, **kwargs): + """Sends a PUT request to a URL. - body = kwargs.pop("body") - if isinstance(body, dict): - body = _encode(**body).encode("utf-8") - if len(kwargs) > 0: - url = url + UrlEncoded("?" + _encode(**kwargs), skip_encode=True) - else: - body = _encode(**kwargs).encode("utf-8") - message = {"method": "POST", "headers": headers, "body": body} + :param url: The URL. + :type url: ``string`` + :param headers: A list of pairs specifying the headers for the HTTP + response (for example, ``[('Content-Type': 'text/cthulhu'), ('Token': 'boris')]``). + :type headers: ``list`` + :param kwargs: Additional keyword arguments (optional). If the argument + is ``body``, the value is used as the body for the request, and the + keywords and their arguments will be URL encoded. If there is no + ``body`` keyword argument, all the keyword arguments are encoded + into the body of the request in the format ``x-www-form-urlencoded``. + :type kwargs: ``dict`` + :returns: A dictionary describing the response (see :class:`HttpLib` for + its structure). + :rtype: ``dict`` + """ + url, headers, body = self._prepare_request_body_and_url(url, headers, **kwargs) + message = {"method": "PUT", "headers": headers, "body": body} + return self.request(url, message) + + def patch(self, url, headers=None, **kwargs): + """Sends a PATCH request to a URL. + + :param url: The URL. + :type url: ``string`` + :param headers: A list of pairs specifying the headers for the HTTP + response (for example, ``[('Content-Type': 'text/cthulhu'), ('Token': 'boris')]``). + :type headers: ``list`` + :param kwargs: Additional keyword arguments (optional). If the argument + is ``body``, the value is used as the body for the request, and the + keywords and their arguments will be URL encoded. If there is no + ``body`` keyword argument, all the keyword arguments are encoded + into the body of the request in the format ``x-www-form-urlencoded``. + :type kwargs: ``dict`` + :returns: A dictionary describing the response (see :class:`HttpLib` for + its structure). + :rtype: ``dict`` + """ + url, headers, body = self._prepare_request_body_and_url(url, headers, **kwargs) + message = {"method": "PATCH", "headers": headers, "body": body} return self.request(url, message) def request(self, url, message, **kwargs): @@ -1550,7 +1762,21 @@ def connect(scheme, host, port): kwargs["cert_file"] = cert_file if not verify: - kwargs["context"] = ssl._create_unverified_context() # nosemgrep + ctx = ssl._create_unverified_context() # nosemgrep + # Support all ML-KEM key exchange algorithms, by default OpenSSL only + # includes the X25519MLKEM768 from all of the below listed MLKEM key + # exchanges. + # + # set_groups method is only available with Python 3.15, but Splunk comes + # with patched python that includes set_groups on 3.9 and 3.13, thus we + # check for the existence of set_groups, not the python version. + if hasattr(ctx, "set_groups"): + ctx.set_groups( # pyright: ignore[reportUnknownMemberType, reportAttributeAccessIssue] + "X25519MLKEM768:SecP256r1MLKEM768:SecP384r1MLKEM1024:" + + "MLKEM512:MLKEM768:MLKEM1024:" + + "X25519:secp256r1:X448:secp384r1:secp521r1:ffdhe2048:ffdhe3072" + ) + kwargs["context"] = ctx elif context: # verify is True in elif branch and context is not None kwargs["context"] = context diff --git a/splunklib/client.py b/splunklib/client.py index 0d69773f8..8e745442e 100644 --- a/splunklib/client.py +++ b/splunklib/client.py @@ -1,4 +1,4 @@ -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain @@ -11,19 +11,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -# -# The purpose of this module is to provide a friendlier domain interface to -# various Splunk endpoints. The approach here is to leverage the binding -# layer to capture endpoint context and provide objects and methods that -# offer simplified access their corresponding endpoints. The design avoids -# caching resource state. From the perspective of this module, the 'policy' -# for caching resource state belongs in the application or a higher level -# framework, and its the purpose of this module to provide simplified -# access to that resource state. -# -# A side note, the objects below that provide helper methods for updating eg: -# Entity state, are written so that they may be used in a fluent style. -# """The **splunklib.client** module provides a Pythonic interface to the `Splunk REST API `_, @@ -56,10 +43,21 @@ print(my_app['author']) # Or: print(my_app.author) my_app.package() # Creates a compressed package of this application + +The purpose of this module is to provide a friendlier domain interface to +various Splunk endpoints. The approach here is to leverage the binding +layer to capture endpoint context and provide objects and methods that +offer simplified access their corresponding endpoints. The design avoids +caching resource state. From the perspective of this module, the 'policy' +for caching resource state belongs in the application or a higher level +framework, and its the purpose of this module to provide simplified +access to that resource state. + +A side note, the objects below that provide helper methods for updating eg: +Entity state, are written so that they may be used in a fluent style. """ import contextlib -import datetime import json import logging import re @@ -68,8 +66,15 @@ from time import sleep from urllib import parse +try: + from warnings import deprecated +except ImportError: + + def deprecated(message): # pyright: ignore[reportUnknownParameterType] + return lambda _msg: None + + from . import data -from .data import record from .binding import ( AuthenticationError, Context, @@ -80,17 +85,18 @@ _NoAuthenticationToken, namespace, ) +from .data import record logger = logging.getLogger(__name__) __all__ = [ - "connect", + "AuthenticationError", + "IncomparableException", "NotSupportedError", "OperationError", - "IncomparableException", "Service", + "connect", "namespace", - "AuthenticationError", ] PATH_APPS = "apps/local/" @@ -2007,6 +2013,9 @@ def clear_password(self): return self.content.get("clear_password") @property + @deprecated( + "To improve security, this field now returns an empty string and will be removed from Splunk in a future release.", + ) def encrypted_password(self): return self.content.get("encr_password") diff --git a/splunklib/data.py b/splunklib/data.py index 1f026ed83..2e8d42598 100644 --- a/splunklib/data.py +++ b/splunklib/data.py @@ -1,4 +1,4 @@ -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/modularinput/argument.py b/splunklib/modularinput/argument.py index 99203ca25..5fca9cd3c 100644 --- a/splunklib/modularinput/argument.py +++ b/splunklib/modularinput/argument.py @@ -1,4 +1,4 @@ -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/modularinput/event.py b/splunklib/modularinput/event.py index 4d243c753..ad541a5d2 100644 --- a/splunklib/modularinput/event.py +++ b/splunklib/modularinput/event.py @@ -1,4 +1,4 @@ -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/modularinput/event_writer.py b/splunklib/modularinput/event_writer.py index 51c3cb0fd..4305dcf63 100644 --- a/splunklib/modularinput/event_writer.py +++ b/splunklib/modularinput/event_writer.py @@ -1,4 +1,4 @@ -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/modularinput/input_definition.py b/splunklib/modularinput/input_definition.py index 9886374ca..1b8410986 100644 --- a/splunklib/modularinput/input_definition.py +++ b/splunklib/modularinput/input_definition.py @@ -1,4 +1,4 @@ -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/modularinput/scheme.py b/splunklib/modularinput/scheme.py index 76b13a631..a046ccf14 100644 --- a/splunklib/modularinput/scheme.py +++ b/splunklib/modularinput/scheme.py @@ -1,4 +1,4 @@ -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/modularinput/script.py b/splunklib/modularinput/script.py index 2192eb721..83d395647 100644 --- a/splunklib/modularinput/script.py +++ b/splunklib/modularinput/script.py @@ -1,4 +1,4 @@ -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/modularinput/utils.py b/splunklib/modularinput/utils.py index 2218c0d27..a8f7af588 100644 --- a/splunklib/modularinput/utils.py +++ b/splunklib/modularinput/utils.py @@ -1,4 +1,4 @@ -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/modularinput/validation_definition.py b/splunklib/modularinput/validation_definition.py index c90dc2aae..a87af1d39 100644 --- a/splunklib/modularinput/validation_definition.py +++ b/splunklib/modularinput/validation_definition.py @@ -1,4 +1,4 @@ -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/results.py b/splunklib/results.py index 7bce883fc..09cbe00ae 100644 --- a/splunklib/results.py +++ b/splunklib/results.py @@ -1,4 +1,4 @@ -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/searchcommands/__init__.py b/splunklib/searchcommands/__init__.py index 94dbbda9e..92cf983f8 100644 --- a/splunklib/searchcommands/__init__.py +++ b/splunklib/searchcommands/__init__.py @@ -1,6 +1,4 @@ -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/searchcommands/decorators.py b/splunklib/searchcommands/decorators.py index 6d2f7a282..505d2a228 100644 --- a/splunklib/searchcommands/decorators.py +++ b/splunklib/searchcommands/decorators.py @@ -1,6 +1,4 @@ -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/searchcommands/environment.py b/splunklib/searchcommands/environment.py index 7f8cb6d3f..96360b001 100644 --- a/splunklib/searchcommands/environment.py +++ b/splunklib/searchcommands/environment.py @@ -1,6 +1,4 @@ -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/searchcommands/eventing_command.py b/splunklib/searchcommands/eventing_command.py index d9f90b780..bf1555dfd 100644 --- a/splunklib/searchcommands/eventing_command.py +++ b/splunklib/searchcommands/eventing_command.py @@ -1,6 +1,4 @@ -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/searchcommands/external_search_command.py b/splunklib/searchcommands/external_search_command.py index cceeb5083..b54b62f50 100644 --- a/splunklib/searchcommands/external_search_command.py +++ b/splunklib/searchcommands/external_search_command.py @@ -1,6 +1,4 @@ -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/searchcommands/generating_command.py b/splunklib/searchcommands/generating_command.py index d2d129316..d02265c48 100644 --- a/splunklib/searchcommands/generating_command.py +++ b/splunklib/searchcommands/generating_command.py @@ -1,6 +1,4 @@ -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/searchcommands/internals.py b/splunklib/searchcommands/internals.py index 40b9107c9..cae74b786 100644 --- a/splunklib/searchcommands/internals.py +++ b/splunklib/searchcommands/internals.py @@ -1,6 +1,4 @@ -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/searchcommands/reporting_command.py b/splunklib/searchcommands/reporting_command.py index 39edebc79..600305104 100644 --- a/splunklib/searchcommands/reporting_command.py +++ b/splunklib/searchcommands/reporting_command.py @@ -1,6 +1,4 @@ -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/searchcommands/search_command.py b/splunklib/searchcommands/search_command.py index 2c4f2ab54..3e101630a 100644 --- a/splunklib/searchcommands/search_command.py +++ b/splunklib/searchcommands/search_command.py @@ -1,6 +1,4 @@ -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain @@ -1230,8 +1228,8 @@ def dispatch( .. code-block:: python :linenos: - #!/usr/bin/env python from splunklib.searchcommands import dispatch, StreamingCommand, Configuration, Option, validators + @Configuration() class SomeStreamingCommand(StreamingCommand): ... diff --git a/splunklib/searchcommands/streaming_command.py b/splunklib/searchcommands/streaming_command.py index 4a2548d37..26574ed45 100644 --- a/splunklib/searchcommands/streaming_command.py +++ b/splunklib/searchcommands/streaming_command.py @@ -1,6 +1,4 @@ -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/searchcommands/validators.py b/splunklib/searchcommands/validators.py index 17cae428e..80fbfb721 100644 --- a/splunklib/searchcommands/validators.py +++ b/splunklib/searchcommands/validators.py @@ -1,6 +1,4 @@ -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/splunklib/utils.py b/splunklib/utils.py index 9b1631dea..c4ae0f91c 100644 --- a/splunklib/utils.py +++ b/splunklib/utils.py @@ -1,4 +1,4 @@ -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_app.py b/tests/integration/test_app.py index 85b5c8d0b..0026cc570 100755 --- a/tests/integration/test_app.py +++ b/tests/integration/test_app.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_binding.py b/tests/integration/test_binding.py index 4a43c2b05..ef16d1c2c 100755 --- a/tests/integration/test_binding.py +++ b/tests/integration/test_binding.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain @@ -937,7 +935,31 @@ def handler(url, message, **kwargs): body={"testkey": "testvalue"}, ) - def test_post_with_params_and_no_body(self): + def test_post_with_params_and_body_json(self): + def handler(url, message, **kwargs): + assert ( + url + == "https://localhost:8089/servicesNS/testowner/testapp/foo/bar?extrakey=extraval" + ) + assert message["body"] == '{"testkey": "testvalue"}' + return splunklib.data.Record( + { + "status": 200, + "headers": [], + } + ) + + ctx = binding.Context(handler=handler) + ctx.post( + "foo/bar", + extrakey="extraval", + owner="testowner", + app="testapp", + body=json.dumps({"testkey": "testvalue"}), + headers=[("Content-Type", "application/json")], + ) + + def test_post_with_urlencoded_params(self): def handler(url, message, **kwargs): assert url == "https://localhost:8089/servicesNS/testowner/testapp/foo/bar" assert message["body"] == b"extrakey=extraval" @@ -952,6 +974,164 @@ def handler(url, message, **kwargs): ctx.post("foo/bar", extrakey="extraval", owner="testowner", app="testapp") +class TestPutWithBodyParam(unittest.TestCase): + def test_put(self): + def handler(url, message, **kwargs): + assert url == "https://localhost:8089/servicesNS/testowner/testapp/foo/bar" + assert message["body"] == b"testkey=testvalue" + return splunklib.data.Record( + { + "status": 200, + "headers": [], + } + ) + + ctx = binding.Context(handler=handler) + ctx.put( + "foo/bar", owner="testowner", app="testapp", body={"testkey": "testvalue"} + ) + + def test_put_with_params_and_body_form(self): + def handler(url, message, **kwargs): + assert ( + url + == "https://localhost:8089/servicesNS/testowner/testapp/foo/bar?extrakey=extraval" + ) + assert message["body"] == b"testkey=testvalue" + return splunklib.data.Record( + { + "status": 200, + "headers": [], + } + ) + + ctx = binding.Context(handler=handler) + ctx.put( + "foo/bar", + extrakey="extraval", + owner="testowner", + app="testapp", + body={"testkey": "testvalue"}, + ) + + def test_put_with_params_and_body_json(self): + def handler(url, message, **kwargs): + assert ( + url + == "https://localhost:8089/servicesNS/testowner/testapp/foo/bar?extrakey=extraval" + ) + assert message["body"] == '{"testkey": "testvalue"}' + return splunklib.data.Record( + { + "status": 200, + "headers": [], + } + ) + + ctx = binding.Context(handler=handler) + ctx.put( + "foo/bar", + extrakey="extraval", + owner="testowner", + app="testapp", + body=json.dumps({"testkey": "testvalue"}), + headers=[("Content-Type", "application/json")], + ) + + def test_put_with_urlencoded_params(self): + def handler(url, message, **kwargs): + assert url == "https://localhost:8089/servicesNS/testowner/testapp/foo/bar" + assert message["body"] == b"extrakey=extraval" + return splunklib.data.Record( + { + "status": 200, + "headers": [], + } + ) + + ctx = binding.Context(handler=handler) + ctx.put("foo/bar", extrakey="extraval", owner="testowner", app="testapp") + + +class TestPatchWithBodyParam(unittest.TestCase): + def test_patch(self): + def handler(url, message, **kwargs): + assert url == "https://localhost:8089/servicesNS/testowner/testapp/foo/bar" + assert message["body"] == b"testkey=testvalue" + return splunklib.data.Record( + { + "status": 200, + "headers": [], + } + ) + + ctx = binding.Context(handler=handler) + ctx.patch( + "foo/bar", owner="testowner", app="testapp", body={"testkey": "testvalue"} + ) + + def test_patch_with_params_and_body_form(self): + def handler(url, message, **kwargs): + assert ( + url + == "https://localhost:8089/servicesNS/testowner/testapp/foo/bar?extrakey=extraval" + ) + assert message["body"] == b"testkey=testvalue" + return splunklib.data.Record( + { + "status": 200, + "headers": [], + } + ) + + ctx = binding.Context(handler=handler) + ctx.patch( + "foo/bar", + extrakey="extraval", + owner="testowner", + app="testapp", + body={"testkey": "testvalue"}, + ) + + def test_patch_with_params_and_body_json(self): + def handler(url, message, **kwargs): + assert ( + url + == "https://localhost:8089/servicesNS/testowner/testapp/foo/bar?extrakey=extraval" + ) + assert message["body"] == '{"testkey": "testvalue"}' + return splunklib.data.Record( + { + "status": 200, + "headers": [], + } + ) + + ctx = binding.Context(handler=handler) + ctx.patch( + "foo/bar", + extrakey="extraval", + owner="testowner", + app="testapp", + body=json.dumps({"testkey": "testvalue"}), + headers=[("Content-Type", "application/json")], + ) + + def test_patch_with_urlencoded_params(self): + def handler(url, message, **kwargs): + assert url == "https://localhost:8089/servicesNS/testowner/testapp/foo/bar" + assert message["body"] == b"extrakey=extraval" + return splunklib.data.Record( + { + "status": 200, + "headers": [], + } + ) + + ctx = binding.Context(handler=handler) + ctx.patch("foo/bar", extrakey="extraval", owner="testowner", app="testapp") + + def _wrap_handler(func, response_code=200, body=""): def wrapped(handler_self): result = func(handler_self) @@ -1038,5 +1218,87 @@ def check_response(handler): ctx.post("/", foo="bar", body={"baz": "baf", "hep": "cat"}) +class TestFullPut(unittest.TestCase): + def test_put_with_body_urlencoded(self): + def check_response(handler): + length = int(handler.headers.get("content-length", 0)) + body = handler.rfile.read(length) + assert body.decode("utf-8") == "foo=bar" + + with MockServer(PUT=check_response): + ctx = binding.connect(port=9093, scheme="http", token="waffle") + ctx.put("/", foo="bar") + + def test_put_with_body_string(self): + def check_response(handler): + length = int(handler.headers.get("content-length", 0)) + body = handler.rfile.read(length) + assert handler.headers["content-type"] == "application/json" + assert json.loads(body)["baz"] == "baf" + + with MockServer(PUT=check_response): + ctx = binding.connect( + port=9093, + scheme="http", + token="waffle", + headers=[("Content-Type", "application/json")], + ) + ctx.put("/", foo="bar", body='{"baz": "baf"}') + + def test_put_with_body_dict(self): + def check_response(handler): + length = int(handler.headers.get("content-length", 0)) + body = handler.rfile.read(length) + assert ( + handler.headers["content-type"] == "application/x-www-form-urlencoded" + ) + assert ensure_str(body) in ["baz=baf&hep=cat", "hep=cat&baz=baf"] + + with MockServer(PUT=check_response): + ctx = binding.connect(port=9093, scheme="http", token="waffle") + ctx.put("/", foo="bar", body={"baz": "baf", "hep": "cat"}) + + +class TestFullPatch(unittest.TestCase): + def test_patch_with_body_urlencoded(self): + def check_response(handler): + length = int(handler.headers.get("content-length", 0)) + body = handler.rfile.read(length) + assert body.decode("utf-8") == "foo=bar" + + with MockServer(PATCH=check_response): + ctx = binding.connect(port=9093, scheme="http", token="waffle") + ctx.patch("/", foo="bar") + + def test_patch_with_body_string(self): + def check_response(handler): + length = int(handler.headers.get("content-length", 0)) + body = handler.rfile.read(length) + assert handler.headers["content-type"] == "application/json" + assert json.loads(body)["baz"] == "baf" + + with MockServer(PATCH=check_response): + ctx = binding.connect( + port=9093, + scheme="http", + token="waffle", + headers=[("Content-Type", "application/json")], + ) + ctx.patch("/", foo="bar", body='{"baz": "baf"}') + + def test_patch_with_body_dict(self): + def check_response(handler): + length = int(handler.headers.get("content-length", 0)) + body = handler.rfile.read(length) + assert ( + handler.headers["content-type"] == "application/x-www-form-urlencoded" + ) + assert ensure_str(body) in ["baz=baf&hep=cat", "hep=cat&baz=baf"] + + with MockServer(PATCH=check_response): + ctx = binding.connect(port=9093, scheme="http", token="waffle") + ctx.patch("/", foo="bar", body={"baz": "baf", "hep": "cat"}) + + if __name__ == "__main__": unittest.main() diff --git a/tests/integration/test_collection.py b/tests/integration/test_collection.py index eb37dadb6..bed2df578 100755 --- a/tests/integration/test_collection.py +++ b/tests/integration/test_collection.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_conf.py b/tests/integration/test_conf.py index 248fd53a1..6d424494c 100755 --- a/tests/integration/test_conf.py +++ b/tests/integration/test_conf.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_event_type.py b/tests/integration/test_event_type.py index cacb95736..7b83e1e66 100755 --- a/tests/integration/test_event_type.py +++ b/tests/integration/test_event_type.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_fired_alert.py b/tests/integration/test_fired_alert.py index 803287e08..49cc2ecc1 100755 --- a/tests/integration/test_fired_alert.py +++ b/tests/integration/test_fired_alert.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_index.py b/tests/integration/test_index.py index 5135682ad..a452d9025 100755 --- a/tests/integration/test_index.py +++ b/tests/integration/test_index.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_input.py b/tests/integration/test_input.py index ad5027218..ba99aaf3a 100755 --- a/tests/integration/test_input.py +++ b/tests/integration/test_input.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_job.py b/tests/integration/test_job.py index 95c4f8721..590bd6524 100755 --- a/tests/integration/test_job.py +++ b/tests/integration/test_job.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_kvstore_batch.py b/tests/integration/test_kvstore_batch.py index 5cba9085a..1d67ad0af 100755 --- a/tests/integration/test_kvstore_batch.py +++ b/tests/integration/test_kvstore_batch.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_kvstore_conf.py b/tests/integration/test_kvstore_conf.py index 78e2e67d5..79f60c51f 100755 --- a/tests/integration/test_kvstore_conf.py +++ b/tests/integration/test_kvstore_conf.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright 2011-2020 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_kvstore_data.py b/tests/integration/test_kvstore_data.py index 40c892644..0fa2eef87 100755 --- a/tests/integration/test_kvstore_data.py +++ b/tests/integration/test_kvstore_data.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_logger.py b/tests/integration/test_logger.py index f67d743a2..0bd2af279 100755 --- a/tests/integration/test_logger.py +++ b/tests/integration/test_logger.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_macro.py b/tests/integration/test_macro.py index 580613176..e8fd8b639 100755 --- a/tests/integration/test_macro.py +++ b/tests/integration/test_macro.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright 2011-2015 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_message.py b/tests/integration/test_message.py index b4026a00e..fea376af9 100755 --- a/tests/integration/test_message.py +++ b/tests/integration/test_message.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_modular_input_kinds.py b/tests/integration/test_modular_input_kinds.py index 654a1112b..730808e6f 100755 --- a/tests/integration/test_modular_input_kinds.py +++ b/tests/integration/test_modular_input_kinds.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_role.py b/tests/integration/test_role.py index 768787204..ed41b9838 100755 --- a/tests/integration/test_role.py +++ b/tests/integration/test_role.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_saved_search.py b/tests/integration/test_saved_search.py index 39d3c6517..ca6ce8945 100755 --- a/tests/integration/test_saved_search.py +++ b/tests/integration/test_saved_search.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_service.py b/tests/integration/test_service.py index 2c94faf96..c46323f62 100755 --- a/tests/integration/test_service.py +++ b/tests/integration/test_service.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_storage_passwords.py b/tests/integration/test_storage_passwords.py index c9fbd42c1..2b412c2e6 100644 --- a/tests/integration/test_storage_passwords.py +++ b/tests/integration/test_storage_passwords.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/integration/test_user.py b/tests/integration/test_user.py index 94f525290..6ec4212d4 100755 --- a/tests/integration/test_user.py +++ b/tests/integration/test_user.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/system/test_apps/eventing_app/bin/eventingcsc.py b/tests/system/test_apps/eventing_app/bin/eventingcsc.py index 94cfee895..4420ad750 100644 --- a/tests/system/test_apps/eventing_app/bin/eventingcsc.py +++ b/tests/system/test_apps/eventing_app/bin/eventingcsc.py @@ -1,7 +1,4 @@ -#!/usr/bin/env python -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/system/test_apps/generating_app/bin/generatingcsc.py b/tests/system/test_apps/generating_app/bin/generatingcsc.py index e4d03f6bf..278ad30c6 100644 --- a/tests/system/test_apps/generating_app/bin/generatingcsc.py +++ b/tests/system/test_apps/generating_app/bin/generatingcsc.py @@ -1,7 +1,4 @@ -#!/usr/bin/env python -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/system/test_apps/modularinput_app/bin/modularinput.py b/tests/system/test_apps/modularinput_app/bin/modularinput.py index 0b12660d4..cf032f22b 100755 --- a/tests/system/test_apps/modularinput_app/bin/modularinput.py +++ b/tests/system/test_apps/modularinput_app/bin/modularinput.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python - -# Copyright © 2011-2025 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/system/test_apps/reporting_app/bin/reportingcsc.py b/tests/system/test_apps/reporting_app/bin/reportingcsc.py index f676e691d..32eaf262c 100644 --- a/tests/system/test_apps/reporting_app/bin/reportingcsc.py +++ b/tests/system/test_apps/reporting_app/bin/reportingcsc.py @@ -1,7 +1,4 @@ -#!/usr/bin/env python -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/system/test_apps/streaming_app/bin/streamingcsc.py b/tests/system/test_apps/streaming_app/bin/streamingcsc.py index d3b3ea181..e1644f827 100644 --- a/tests/system/test_apps/streaming_app/bin/streamingcsc.py +++ b/tests/system/test_apps/streaming_app/bin/streamingcsc.py @@ -1,7 +1,4 @@ -#!/usr/bin/env python -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/system/test_cre_apps.py b/tests/system/test_cre_apps.py index e1f5c9fbc..780f5e919 100644 --- a/tests/system/test_cre_apps.py +++ b/tests/system/test_cre_apps.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2025 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain @@ -15,10 +13,8 @@ # under the License. import json -import pytest from tests import testlib -from splunklib import results class TestJSONCustomRestEndpointsSpecialMethodHelpers(testlib.SDKTestCase): @@ -59,6 +55,47 @@ def test_POST(self): }, ) + def test_PUT(self): + body = json.dumps({"foo": "bar"}) + resp = self.service.put( + app=self.app_name, + path_segment="execute", + body=body, + headers=[("x-bar", "baz")], + ) + self.assertIn(("x-foo", "bar"), resp.headers) + self.assertEqual(resp.status, 200) + self.assertEqual( + json.loads(str(resp.body)), + { + "payload": '{"foo": "bar"}', + "headers": {"x-bar": "baz"}, + "method": "PUT", + }, + ) + + def test_PATCH(self): + if self.service.splunk_version[0] < 10: + self.skipTest("PATCH custom REST endpoints not supported on splunk < 10") + + body = json.dumps({"foo": "bar"}) + resp = self.service.patch( + app=self.app_name, + path_segment="execute", + body=body, + headers=[("x-bar", "baz")], + ) + self.assertIn(("x-foo", "bar"), resp.headers) + self.assertEqual(resp.status, 200) + self.assertEqual( + json.loads(str(resp.body)), + { + "payload": '{"foo": "bar"}', + "headers": {"x-bar": "baz"}, + "method": "PATCH", + }, + ) + def test_DELETE(self): # delete does allow specifying body and custom headers. resp = self.service.delete( diff --git a/tests/system/test_csc_apps.py b/tests/system/test_csc_apps.py index e269be9df..a4a590e71 100755 --- a/tests/system/test_csc_apps.py +++ b/tests/system/test_csc_apps.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/system/test_modularinput_app.py b/tests/system/test_modularinput_app.py index d408601af..a17949863 100644 --- a/tests/system/test_modularinput_app.py +++ b/tests/system/test_modularinput_app.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2025 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/testlib.py b/tests/testlib.py index 4d6a376ad..5648036a7 100644 --- a/tests/testlib.py +++ b/tests/testlib.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/unit/modularinput/modularinput_testlib.py b/tests/unit/modularinput/modularinput_testlib.py index 5abc1edde..d81942ef4 100644 --- a/tests/unit/modularinput/modularinput_testlib.py +++ b/tests/unit/modularinput/modularinput_testlib.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/unit/modularinput/test_event.py b/tests/unit/modularinput/test_event.py index 4fd8e1771..31968ea7e 100644 --- a/tests/unit/modularinput/test_event.py +++ b/tests/unit/modularinput/test_event.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/unit/modularinput/test_input_definition.py b/tests/unit/modularinput/test_input_definition.py index 7ac617e62..e2c29df70 100644 --- a/tests/unit/modularinput/test_input_definition.py +++ b/tests/unit/modularinput/test_input_definition.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/unit/modularinput/test_scheme.py b/tests/unit/modularinput/test_scheme.py index 6fa3260ce..fc37063f7 100644 --- a/tests/unit/modularinput/test_scheme.py +++ b/tests/unit/modularinput/test_scheme.py @@ -1,5 +1,4 @@ -# -*- coding: utf-8 -*- -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/unit/modularinput/test_validation_definition.py b/tests/unit/modularinput/test_validation_definition.py index 53e8426b9..bde82e7be 100644 --- a/tests/unit/modularinput/test_validation_definition.py +++ b/tests/unit/modularinput/test_validation_definition.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/unit/searchcommands/__init__.py b/tests/unit/searchcommands/__init__.py index 1cbd2bb8f..ab42e8921 100644 --- a/tests/unit/searchcommands/__init__.py +++ b/tests/unit/searchcommands/__init__.py @@ -1,7 +1,4 @@ -#!/usr/bin/env python -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/unit/searchcommands/test_builtin_options.py b/tests/unit/searchcommands/test_builtin_options.py index aa9648372..feabdfe1a 100644 --- a/tests/unit/searchcommands/test_builtin_options.py +++ b/tests/unit/searchcommands/test_builtin_options.py @@ -1,7 +1,4 @@ -#!/usr/bin/env python -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/unit/searchcommands/test_configuration_settings.py b/tests/unit/searchcommands/test_configuration_settings.py index 9c4f4170f..a74249e6a 100644 --- a/tests/unit/searchcommands/test_configuration_settings.py +++ b/tests/unit/searchcommands/test_configuration_settings.py @@ -1,7 +1,4 @@ -#!/usr/bin/env python -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/unit/searchcommands/test_decorators.py b/tests/unit/searchcommands/test_decorators.py index 1ac657b74..205782327 100755 --- a/tests/unit/searchcommands/test_decorators.py +++ b/tests/unit/searchcommands/test_decorators.py @@ -1,7 +1,4 @@ -#!/usr/bin/env python -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/unit/searchcommands/test_internals_v1.py b/tests/unit/searchcommands/test_internals_v1.py index 7ac8e50f8..8e0541805 100755 --- a/tests/unit/searchcommands/test_internals_v1.py +++ b/tests/unit/searchcommands/test_internals_v1.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/unit/searchcommands/test_internals_v2.py b/tests/unit/searchcommands/test_internals_v2.py index 03255c07b..c55a7e3ff 100755 --- a/tests/unit/searchcommands/test_internals_v2.py +++ b/tests/unit/searchcommands/test_internals_v2.py @@ -1,7 +1,4 @@ -#!/usr/bin/env python -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/unit/searchcommands/test_search_command.py b/tests/unit/searchcommands/test_search_command.py index 6bd289447..e4b8a8b57 100755 --- a/tests/unit/searchcommands/test_search_command.py +++ b/tests/unit/searchcommands/test_search_command.py @@ -1,7 +1,4 @@ -#!/usr/bin/env python -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/unit/searchcommands/test_validators.py b/tests/unit/searchcommands/test_validators.py index 62e6fcc93..98d831d92 100755 --- a/tests/unit/searchcommands/test_validators.py +++ b/tests/unit/searchcommands/test_validators.py @@ -1,7 +1,4 @@ -#!/usr/bin/env python -# coding=utf-8 -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/unit/test_data.py b/tests/unit/test_data.py index 7fb24f967..54883cd4f 100755 --- a/tests/unit/test_data.py +++ b/tests/unit/test_data.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index c6f826eda..fb9b870b9 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -# -# Copyright © 2011-2025 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/utils/__init__.py b/utils/__init__.py index b542f0174..5f811ad0e 100644 --- a/utils/__init__.py +++ b/utils/__init__.py @@ -1,4 +1,4 @@ -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain diff --git a/utils/cmdopts.py b/utils/cmdopts.py index cd0d08a61..3e7316670 100644 --- a/utils/cmdopts.py +++ b/utils/cmdopts.py @@ -1,4 +1,4 @@ -# Copyright © 2011-2024 Splunk, Inc. +# Copyright © 2011-2026 Splunk, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"): you may # not use this file except in compliance with the License. You may obtain