Skip to content

外部AI連携向けに提出物CRUD APIを追加する #10000

@komagata

Description

@komagata

機能の説明

外部AIエージェントが提出物を作成・更新・削除できるように、提出物CRUD APIを追加する。

現状、APIでは提出物の Read は可能だが、POST /api/products, PATCH /api/products/:id, DELETE /api/products/:id は存在しない。

追加したいAPI候補:

  • POST /api/products.json
  • PATCH /api/products/:id.json
  • DELETE /api/products/:id.json

権限は既存の画面側の提出物作成・編集ルールに合わせる。基本的には本人の提出物を本人が作成・更新・削除できることを想定する。メンターやadminの代理操作を許すかは既存仕様に合わせて検討する。

何故この機能が必要なのか

pjord/hermes agent が生徒サポートを行う場合、提出物の下書き作成、WIP保存、本文修正などをAPI経由で支援できる必要がある。

現状は画面経由では提出物を作成・更新できるが、外部クライアントから機械処理しやすいJSON APIとしては提供されていない。

受け入れ条件

  • Bearer token で認証したユーザーが提出物を作成できる
  • Bearer token で認証したユーザーが自分の提出物を更新できる
  • Bearer token で認証したユーザーが自分の提出物を削除できる
  • practice_id, body, wip など提出物作成・更新に必要な属性を受け取れる
  • 公開時は既存HTML controllerと同等に published_at が設定される
  • validation error と権限エラーをJSONで返す
  • integration test で作成・更新・削除・権限不足・validation error を確認する

関連コード

  • config/routes/api.rb: 現状 resources :products, only: %i(index show)
  • app/controllers/api/products_controller.rb
  • app/controllers/products_controller.rb: HTML側の create/update/destroy
  • app/models/product.rb
  • test/integration/api/products_test.rb

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    やる

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions