Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(schema): schema changes for custom REST endpoints #1509

Merged
merged 4 commits into from
Jan 3, 2025

Conversation

kkedziak-splunk
Copy link
Contributor

@kkedziak-splunk kkedziak-splunk commented Dec 17, 2024

Issue number: ADDON-76812

PR Type

What kind of change does this PR introduce?

  • Feature
  • Bug Fix
  • Refactoring (no functional or API changes)
  • Documentation Update
  • Maintenance (dependency updates, CI, etc.)

Summary

Changes

Schema changes required for the future feature for adding custom REST endpoints.

This change adds new options section with restHandlers.

{
  "meta": {},
  "pages": {
    "configuration": {},
    "inputs": {},
    "dashboards": {}
  },
  "alerts": [],
  "options": {
    "restHandlers": []  // <--- here 
  }
}

The array above consists of entries of the following form (example):

{
  "endpoint": "some_endpoint",
  "handlerType": "EAI",
  "registerHandler": {
    "file": "my_handler.py",
    "actions": ["list", "create", "edit", "remove"]
  },
  "requestParameters": {
    "create": {
      "some_param": {"type": "string"},
      "other_param": {"type": "number"},
      "other_param_nullable": {
        "type": "number",
        "nullable": true,
      }
    },
    "list": {
      "array_param": {
        "type": "array",
        "items": {"type": "string"},
      },
      "obj_param": {
        "type": "object",
        "properties": {
          "key": {"type": "string"},
        }
      }
    }
  },
  "responseParams": {
    // similar to requestParameters
  }
}
  • endpoint - it denotes the URL path that handler is connected to
  • handlerType - currently only EAI is specified here, to denote, that only EAI endpoints are supported. This is added in case we would like to support other handlers as well in the future.
  • registerHandler - optional. If specified, it registers the handler in web.conf and restmap.conf.
  • requestParameters - an object with action name as a key and value being a dictionary containing keys (parameter names) to values (OpenAPI data types).
  • responseParameters - similar to the above one

The data types are based on OpenAPI data types.
Example data types:

  • {"type": "string"}
  • {"type": "number", "nullable": true}
  • {"type": "boolean"}
  • {"type": "array", "items": {"type": "string"}}
  • {"type": "object", "parameters": {"some_param": {"type": "string"}}}
  • {"anyOf": [...]}
  • {"allOf": [...]}

User experience

No changes to the current user experience.

Checklist

If an item doesn't apply to your changes, leave it unchecked.

@artemrys artemrys enabled auto-merge (squash) January 3, 2025 14:13
@artemrys artemrys merged commit 451111a into develop Jan 3, 2025
98 checks passed
@artemrys artemrys deleted the feat/handlers-custom-schema branch January 3, 2025 14:31
@github-actions github-actions bot locked and limited conversation to collaborators Jan 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants