{
  "components": {
    "parameters": {
      "messageIdPathParam": {
        "in": "path",
        "name": "messageId",
        "required": true,
        "schema": {
          "$ref": "#/components/schemas/MessageId"
        }
      },
      "queueNamePathParam": {
        "in": "path",
        "name": "queueName",
        "required": true,
        "schema": {
          "$ref": "#/components/schemas/QueueName"
        }
      }
    },
    "schemas": {
      "Error": {
        "description": "error content",
        "properties": {
          "code": {
            "format": "int64",
            "type": "integer"
          },
          "message": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "Message": {
        "allOf": [
          {
            "$ref": "#/components/schemas/NewMessage"
          },
          {
            "properties": {
              "acquired_at": {
                "description": "最新のメッセージ取得時刻 (Epochからのミリ秒)",
                "format": "int64",
                "type": "integer"
              },
              "visibility_timeout_at": {
                "description": "可視性タイムアウトする時点 (Epochからのミリ秒)",
                "format": "int64",
                "type": "integer"
              }
            },
            "required": [
              "acquired_at",
              "visibility_timeout_at"
            ],
            "type": "object"
          }
        ]
      },
      "MessageContent": {
        "description": "メッセージ本文",
        "maxLength": 256000,
        "pattern": "^[0-9a-zA-Z+/=]*$",
        "type": "string"
      },
      "MessageId": {
        "description": "メッセージID",
        "example": "0193b878-1b25-7775-87f5-9c698206a7e7",
        "maxLength": 36,
        "minLength": 36,
        "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$",
        "type": "string"
      },
      "NewMessage": {
        "properties": {
          "content": {
            "$ref": "#/components/schemas/MessageContent",
            "description": "メッセージ本文"
          },
          "created_at": {
            "description": "登録時刻 (Epochからのミリ秒)",
            "format": "int64",
            "type": "integer"
          },
          "expires_at": {
            "description": "未処理メッセージ保存期間が過ぎる時点 (Epochからのミリ秒)",
            "format": "int64",
            "type": "integer"
          },
          "id": {
            "$ref": "#/components/schemas/MessageId"
          },
          "updated_at": {
            "description": "更新時刻 (Epochからのミリ秒)",
            "format": "int64",
            "type": "integer"
          }
        },
        "required": [
          "id",
          "content",
          "created_at",
          "updated_at",
          "expires_at"
        ],
        "type": "object"
      },
      "QueueName": {
        "description": "キュー名",
        "example": "my-own-queue-00",
        "maxLength": 64,
        "minLength": 5,
        "pattern": "^[0-9a-zA-Z]+(-[0-9a-zA-Z]+)*$",
        "type": "string"
      },
      "SendRequest": {
        "properties": {
          "content": {
            "$ref": "#/components/schemas/MessageContent"
          }
        },
        "required": [
          "content"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "ApiKeyAuth": {
        "description": "キュー認証用のAPIキー",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "contact": {
      "url": "https://help.sakura.ad.jp/contact/"
    },
    "description": "---\nCopyright SAKURA internet Inc.\n\n# はじめに\n\n「シンプルMQ」は、ソフトウェア同士を非同期に連携するために、ソフトウェアコンポーネント間でのデータの送受信ができる、マネージド型のメッセージキューサービスです。\nシンプルMQを使うには、さくらのクラウド コントロールパネルもしくは [シンプルMQ さくらのクラウドAPI](https://manual.sakura.ad.jp/api/cloud/portal/?api=simplemq-sacloud-api) でシンプルMQのキューを作成します。\nキューを作成するとAPIキーが発行されます。\nAPIリクエストは、そのキーを `Authorization header` の `Bearer token` に使用します。\n\nAPIエンドポイント：https://simplemq.tk1b.api.sacloud.jp\n",
    "title": "シンプルMQ API",
    "version": "1.1.2"
  },
  "openapi": "3.1.0",
  "paths": {
    "/v1/queues/{queueName}/messages": {
      "get": {
        "description": "キューからのメッセージの受信 (dequeue)",
        "operationId": "receiveMessage",
        "parameters": [
          {
            "$ref": "#/components/parameters/queueNamePathParam"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "messages": {
                      "items": {
                        "$ref": "#/components/schemas/Message"
                      },
                      "type": "array"
                    },
                    "result": {
                      "example": "success",
                      "type": "string"
                    }
                  },
                  "required": [
                    "result",
                    "messages"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "成功"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "bad request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "unauthorized"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "rate limit exceeded"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "internal server error"
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "summary": "メッセージの受信"
      },
      "post": {
        "description": "キューに対するメッセージの送信 (enqueue)",
        "operationId": "sendMessage",
        "parameters": [
          {
            "$ref": "#/components/parameters/queueNamePathParam"
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "message": {
                      "$ref": "#/components/schemas/NewMessage"
                    },
                    "result": {
                      "example": "success",
                      "type": "string"
                    }
                  },
                  "required": [
                    "result",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "成功"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "bad request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "unauthorized"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "rate limit exceeded"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "internal server error"
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "summary": "メッセージの送信"
      }
    },
    "/v1/queues/{queueName}/messages/{messageId}": {
      "delete": {
        "description": "読み取り済みのメッセージを削除 (ack)",
        "operationId": "deleteMessage",
        "parameters": [
          {
            "$ref": "#/components/parameters/queueNamePathParam"
          },
          {
            "$ref": "#/components/parameters/messageIdPathParam"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "result": {
                      "example": "success",
                      "type": "string"
                    }
                  },
                  "required": [
                    "result"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "成功"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "bad request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "unauthorized"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "not found"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "rate limit exceeded"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "internal server error"
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "summary": "メッセージの削除"
      },
      "put": {
        "description": "メッセージのタイムアウトをキューの設定値で延長",
        "operationId": "extendMessageTimeout",
        "parameters": [
          {
            "$ref": "#/components/parameters/queueNamePathParam"
          },
          {
            "$ref": "#/components/parameters/messageIdPathParam"
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "message": {
                      "$ref": "#/components/schemas/Message"
                    },
                    "result": {
                      "example": "success",
                      "type": "string"
                    }
                  },
                  "required": [
                    "result",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "成功"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "bad request"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "unauthorized"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "not found"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "rate limit exceeded"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "internal server error"
          }
        },
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "summary": "メッセージのタイムアウト延長"
      }
    }
  },
  "servers": [
    {
      "url": "https://simplemq.tk1b.api.sacloud.jp"
    }
  ]
}
