id: mattermost
name: Mattermost
version: 1.0.0
description: "Mattermost (REST API v4) — SOC ChatOps: create posts, look up channels by name, search posts, create channels, and look up users. Bearer-token authentication; stdlib-only, no extra Python dependencies."
changelog: "1.0.0 — Initial release: create post, get channel by name, search posts, create channel, get user."
category: notification

# Per-instance configuration. Auth header 'Authorization: Bearer <token>'.
config_schema:
  properties:
    base_url:
      type: string
      description: "Mattermost server URL (e.g. https://mm.example.com)"
    token:
      type: string
      description: "Personal access / bot token"
      x-soar-sensitive: true
  required:
    - base_url
    - token

commands:
  - id: create_post
    name: mattermost-create-post
    description: "Create a post in a channel."
    inputs_schema:
      properties:
        channel_id: { type: string, description: "Channel ID" }
        message: { type: string, description: "Message text (Markdown supported)" }
      required: [channel_id, message]
    outputs_schema: { properties: {} }
  - id: get_channel_by_name
    name: mattermost-get-channel-by-name
    description: "Get a channel by team name and channel name."
    risk: read
    inputs_schema:
      properties:
        team_name: { type: string, description: "Team name" }
        channel_name: { type: string, description: "Channel name" }
      required: [team_name, channel_name]
    outputs_schema: { properties: {} }
  - id: search_posts
    name: mattermost-search-posts
    description: "Search posts within a team."
    risk: read
    inputs_schema:
      properties:
        team_id: { type: string, description: "Team ID" }
        terms: { type: string, description: "Search terms" }
      required: [team_id, terms]
    outputs_schema: { properties: {} }
  - id: create_channel
    name: mattermost-create-channel
    description: "Create a channel."
    inputs_schema:
      properties:
        team_id: { type: string, description: "Team ID" }
        name: { type: string, description: "Channel URL name (lowercase)" }
        display_name: { type: string, description: "Display name" }
        channel_type: { type: string, description: "O (public) or P (private), default O" }
      required: [team_id, name, display_name]
    outputs_schema: { properties: {} }
  - id: get_user
    name: mattermost-get-user
    description: "Look up a user by username."
    risk: read
    inputs_schema:
      properties:
        username: { type: string, description: "Username" }
      required: [username]
    outputs_schema: { properties: {} }

  - id: test_connection
    name: mattermost-test-connection
    description: "Verify connectivity and the token (used by the Test button)."
    risk: read
    inputs_schema:
      properties: {}
      required: []
    outputs_schema: { properties: {} }
