{
    "openapi": "3.0.3",
    "info": {
        "title": "notifications-push",
        "version": "0.0.1",
        "description": "This app provides a backend and frontend for the notification API available in Nextcloud.",
        "license": {
            "name": "agpl"
        }
    },
    "components": {
        "securitySchemes": {
            "basic_auth": {
                "type": "http",
                "scheme": "basic"
            },
            "bearer_auth": {
                "type": "http",
                "scheme": "bearer"
            }
        },
        "schemas": {
            "Capabilities": {
                "type": "object",
                "required": [
                    "notifications"
                ],
                "properties": {
                    "notifications": {
                        "type": "object",
                        "required": [
                            "ocs-endpoints",
                            "push",
                            "admin-notifications"
                        ],
                        "properties": {
                            "ocs-endpoints": {
                                "type": "array",
                                "items": {
                                    "type": "string"
                                }
                            },
                            "push": {
                                "type": "array",
                                "items": {
                                    "type": "string"
                                }
                            },
                            "admin-notifications": {
                                "type": "array",
                                "items": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                }
            },
            "OCSMeta": {
                "type": "object",
                "required": [
                    "status",
                    "statuscode"
                ],
                "properties": {
                    "status": {
                        "type": "string"
                    },
                    "statuscode": {
                        "type": "integer"
                    },
                    "message": {
                        "type": "string"
                    },
                    "totalitems": {
                        "type": "string"
                    },
                    "itemsperpage": {
                        "type": "string"
                    }
                }
            },
            "PushDevice": {
                "type": "object",
                "required": [
                    "publicKey",
                    "deviceIdentifier",
                    "signature"
                ],
                "properties": {
                    "publicKey": {
                        "type": "string"
                    },
                    "deviceIdentifier": {
                        "type": "string"
                    },
                    "signature": {
                        "type": "string"
                    }
                }
            }
        }
    },
    "paths": {
        "/ocs/v2.php/apps/notifications/api/{apiVersion3}/test/self": {
            "post": {
                "operationId": "api-self-test-push",
                "summary": "Send a test notification to push registered mobile apps",
                "description": "Required capability: `ocs-endpoints > test-push`",
                "tags": [
                    "api"
                ],
                "security": [
                    {
                        "bearer_auth": []
                    },
                    {
                        "basic_auth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "apiVersion3",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "pattern": "^(v3)$"
                        }
                    },
                    {
                        "name": "OCS-APIRequest",
                        "in": "header",
                        "description": "Required to be true for the API request to pass",
                        "required": true,
                        "schema": {
                            "type": "boolean",
                            "default": true
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Test notification generated successfully, but the device should still show the message to the user",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "ocs"
                                    ],
                                    "properties": {
                                        "ocs": {
                                            "type": "object",
                                            "required": [
                                                "meta",
                                                "data"
                                            ],
                                            "properties": {
                                                "meta": {
                                                    "$ref": "#/components/schemas/OCSMeta"
                                                },
                                                "data": {
                                                    "type": "object",
                                                    "required": [
                                                        "message",
                                                        "nid"
                                                    ],
                                                    "properties": {
                                                        "message": {
                                                            "type": "string"
                                                        },
                                                        "nid": {
                                                            "type": "integer",
                                                            "format": "int64"
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Test notification could not be generated, show the message to the user",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "ocs"
                                    ],
                                    "properties": {
                                        "ocs": {
                                            "type": "object",
                                            "required": [
                                                "meta",
                                                "data"
                                            ],
                                            "properties": {
                                                "meta": {
                                                    "$ref": "#/components/schemas/OCSMeta"
                                                },
                                                "data": {
                                                    "type": "object",
                                                    "required": [
                                                        "message"
                                                    ],
                                                    "properties": {
                                                        "message": {
                                                            "type": "string"
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Current user is not logged in",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "ocs"
                                    ],
                                    "properties": {
                                        "ocs": {
                                            "type": "object",
                                            "required": [
                                                "meta",
                                                "data"
                                            ],
                                            "properties": {
                                                "meta": {
                                                    "$ref": "#/components/schemas/OCSMeta"
                                                },
                                                "data": {}
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        },
        "/ocs/v2.php/apps/notifications/api/{apiVersion}/push": {
            "post": {
                "operationId": "push-register-device",
                "summary": "Register device for push notifications",
                "tags": [
                    "push"
                ],
                "security": [
                    {
                        "bearer_auth": []
                    },
                    {
                        "basic_auth": []
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "pushTokenHash",
                                    "devicePublicKey",
                                    "proxyServer"
                                ],
                                "properties": {
                                    "pushTokenHash": {
                                        "type": "string",
                                        "description": "Hash of the push token"
                                    },
                                    "devicePublicKey": {
                                        "type": "string",
                                        "description": "Public key of the device"
                                    },
                                    "proxyServer": {
                                        "type": "string",
                                        "description": "Proxy server to be used"
                                    }
                                }
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "apiVersion",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "v2"
                            ],
                            "default": "v2"
                        }
                    },
                    {
                        "name": "OCS-APIRequest",
                        "in": "header",
                        "description": "Required to be true for the API request to pass",
                        "required": true,
                        "schema": {
                            "type": "boolean",
                            "default": true
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Device was already registered",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "ocs"
                                    ],
                                    "properties": {
                                        "ocs": {
                                            "type": "object",
                                            "required": [
                                                "meta",
                                                "data"
                                            ],
                                            "properties": {
                                                "meta": {
                                                    "$ref": "#/components/schemas/OCSMeta"
                                                },
                                                "data": {
                                                    "$ref": "#/components/schemas/PushDevice"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "201": {
                        "description": "Device registered successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "ocs"
                                    ],
                                    "properties": {
                                        "ocs": {
                                            "type": "object",
                                            "required": [
                                                "meta",
                                                "data"
                                            ],
                                            "properties": {
                                                "meta": {
                                                    "$ref": "#/components/schemas/OCSMeta"
                                                },
                                                "data": {
                                                    "$ref": "#/components/schemas/PushDevice"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Registering device is not possible",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "ocs"
                                    ],
                                    "properties": {
                                        "ocs": {
                                            "type": "object",
                                            "required": [
                                                "meta",
                                                "data"
                                            ],
                                            "properties": {
                                                "meta": {
                                                    "$ref": "#/components/schemas/OCSMeta"
                                                },
                                                "data": {
                                                    "type": "object",
                                                    "required": [
                                                        "message"
                                                    ],
                                                    "properties": {
                                                        "message": {
                                                            "type": "string"
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing permissions to register device",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "anyOf": [
                                        {
                                            "type": "object",
                                            "required": [
                                                "ocs"
                                            ],
                                            "properties": {
                                                "ocs": {
                                                    "type": "object",
                                                    "required": [
                                                        "meta",
                                                        "data"
                                                    ],
                                                    "properties": {
                                                        "meta": {
                                                            "$ref": "#/components/schemas/OCSMeta"
                                                        },
                                                        "data": {}
                                                    }
                                                }
                                            }
                                        },
                                        {
                                            "type": "object",
                                            "required": [
                                                "ocs"
                                            ],
                                            "properties": {
                                                "ocs": {
                                                    "type": "object",
                                                    "required": [
                                                        "meta",
                                                        "data"
                                                    ],
                                                    "properties": {
                                                        "meta": {
                                                            "$ref": "#/components/schemas/OCSMeta"
                                                        },
                                                        "data": {}
                                                    }
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    }
                }
            },
            "delete": {
                "operationId": "push-remove-device",
                "summary": "Remove a device from push notifications",
                "tags": [
                    "push"
                ],
                "security": [
                    {
                        "bearer_auth": []
                    },
                    {
                        "basic_auth": []
                    }
                ],
                "parameters": [
                    {
                        "name": "apiVersion",
                        "in": "path",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "enum": [
                                "v2"
                            ],
                            "default": "v2"
                        }
                    },
                    {
                        "name": "OCS-APIRequest",
                        "in": "header",
                        "description": "Required to be true for the API request to pass",
                        "required": true,
                        "schema": {
                            "type": "boolean",
                            "default": true
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "No device registered",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "ocs"
                                    ],
                                    "properties": {
                                        "ocs": {
                                            "type": "object",
                                            "required": [
                                                "meta",
                                                "data"
                                            ],
                                            "properties": {
                                                "meta": {
                                                    "$ref": "#/components/schemas/OCSMeta"
                                                },
                                                "data": {}
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "202": {
                        "description": "Device removed successfully",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "ocs"
                                    ],
                                    "properties": {
                                        "ocs": {
                                            "type": "object",
                                            "required": [
                                                "meta",
                                                "data"
                                            ],
                                            "properties": {
                                                "meta": {
                                                    "$ref": "#/components/schemas/OCSMeta"
                                                },
                                                "data": {}
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "401": {
                        "description": "Missing permissions to remove device",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "anyOf": [
                                        {
                                            "type": "object",
                                            "required": [
                                                "ocs"
                                            ],
                                            "properties": {
                                                "ocs": {
                                                    "type": "object",
                                                    "required": [
                                                        "meta",
                                                        "data"
                                                    ],
                                                    "properties": {
                                                        "meta": {
                                                            "$ref": "#/components/schemas/OCSMeta"
                                                        },
                                                        "data": {}
                                                    }
                                                }
                                            }
                                        },
                                        {
                                            "type": "object",
                                            "required": [
                                                "ocs"
                                            ],
                                            "properties": {
                                                "ocs": {
                                                    "type": "object",
                                                    "required": [
                                                        "meta",
                                                        "data"
                                                    ],
                                                    "properties": {
                                                        "meta": {
                                                            "$ref": "#/components/schemas/OCSMeta"
                                                        },
                                                        "data": {}
                                                    }
                                                }
                                            }
                                        }
                                    ]
                                }
                            }
                        }
                    },
                    "400": {
                        "description": "Removing device is not possible",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "required": [
                                        "ocs"
                                    ],
                                    "properties": {
                                        "ocs": {
                                            "type": "object",
                                            "required": [
                                                "meta",
                                                "data"
                                            ],
                                            "properties": {
                                                "meta": {
                                                    "$ref": "#/components/schemas/OCSMeta"
                                                },
                                                "data": {
                                                    "type": "object",
                                                    "required": [
                                                        "message"
                                                    ],
                                                    "properties": {
                                                        "message": {
                                                            "type": "string"
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "tags": []
}
