{
 "openapi": "3.1.0",
 "info": {
  "title": "Gyro Public API",
  "version": "2.30.0",
  "summary": "Manage Gyro cloud servers, SSH keys and billing programmatically.",
  "x-summary-tr": "Gyro bulut sunucularınızı, SSH anahtarlarınızı ve faturalarınızı programla yönetin.",
  "contact": {
   "name": "Gyro Hosting",
   "url": "https://www.gyrohosting.com"
  },
  "license": {
   "name": "Proprietary",
   "identifier": "LicenseRef-Gyro-API-Terms"
  }
 },
 "servers": [
  {
   "url": "https://www.gyrohosting.com/api/v1/client",
   "description": "Production"
  }
 ],
 "paths": {
  "/cloud/containers/{id}/pipelines": {
   "post": {
    "tags": [
     "Containers"
    ],
    "operationId": "pipeline_create",
    "summary": "Create a pipeline",
    "x-summary-tr": "Pipeline oluştur",
    "x-scope": "services_write",
    "description": "Connects a repository. The answer contains `webhook_url` and (only here and in GET .../webhook) `webhook_secret`: add both to the repository's webhook (GitHub: application/json + Secret, push event; GitLab: Secret token, push + tag push; Gitea: secret; other: X-Gyro-Signature HMAC). Optional `token` for a private repository.  `repo` is required unless `provider` is `archive` (archive pipelines build only uploaded archives: POST .../uploads, then a run with `upload_id`).",
    "x-description-tr": "Depoyu bağlar. Yanıtta `webhook_url` ve `webhook_secret` (yalnız burada ve GET .../webhook) vardır; ikisini deponun webhook ayarına ekleyin. Özel depo için `token`.  `provider` `archive` değilse `repo` zorunludur (arşiv pipeline'ı yalnız yüklenen arşivi derler: POST .../uploads, ardından `upload_id` ile çalıştırma).",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "integer"
      },
      "description": "Service id"
     }
    ],
    "responses": {
     "200": {
      "description": "OK",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "data": {
           "type": "object",
           "properties": {
            "pipeline": {
             "$ref": "#/components/schemas/ContainerPipeline"
            }
           }
          }
         }
        }
       }
      }
     },
     "404": {
      "$ref": "#/components/responses/NotFound"
     },
     "409": {
      "$ref": "#/components/responses/Conflict"
     },
     "422": {
      "$ref": "#/components/responses/Validation"
     }
    },
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "name": {
          "type": "string",
          "description": "Display name (1-48)",
          "x-description-tr": "Görünen ad (1-48)"
         },
         "provider": {
          "type": "string",
          "enum": [
           "github",
           "gitlab",
           "gitea",
           "git",
           "archive"
          ],
          "default": "github"
         },
         "repo": {
          "type": "string",
          "description": "Required for github / gitlab / gitea / git: https clone URL (no credentials) or SSH address git@host:org/repo.git / ssh://user@host[:port]/path (needs a deploy key). Leave it out for provider `archive` (an archive pipeline has no repository; a value sent with `archive` is ignored and the answer shows `repo` empty).",
          "x-description-tr": "github / gitlab / gitea / git için zorunlu: https klon adresi (kimlik bilgisi yok) ya da SSH adresi git@sunucu:kurum/depo.git / ssh://kullanici@sunucu[:port]/yol (deploy key gerekir). provider `archive` için göndermeyin (arşiv pipeline deposuz çalışır; `archive` ile gönderilen değer yok sayılır, yanıtta `repo` boş görünür).",
          "example": "https://github.com/gyro-ornek/uygulama"
         },
         "token": {
          "type": "string",
          "format": "password",
          "description": "Read-only access token for a private repository (stored encrypted, never returned; \"-\" on update removes it)",
          "x-description-tr": "Özel depo için yalnız okuma erişim belirteci (şifreli saklanır, geri dönmez; güncellemede \"-\" siler)"
         },
         "git_user": {
          "type": "string",
          "description": "User name for the token (default: x-access-token / oauth2 / git)"
         },
         "branch": {
          "type": "string",
          "description": "Branches whose pushes build (comma separated globs, empty = none)",
          "x-description-tr": "Push'u derlenen dallar (virgüllü glob, boş = yok)",
          "default": "main"
         },
         "tags": {
          "type": "string",
          "description": "Tags that build (globs, e.g. v*)",
          "x-description-tr": "Derlenen etiketler (glob, ör. v*)"
         },
         "auto": {
          "type": "boolean",
          "default": true,
          "description": "Webhook pushes start runs"
         },
         "repo_file": {
          "type": "boolean",
          "default": true,
          "description": "Read gyro-pipeline.yml from the repository (GitHub, GitLab, Gitea)"
         },
         "image": {
          "type": "string",
          "description": "Image name in the environment registry (<registry>/<code>/<image>:<sha7> + :latest)",
          "x-description-tr": "Ortam deposundaki imaj adı"
         },
         "dockerfile": {
          "type": "string",
          "default": "Dockerfile"
         },
         "context": {
          "type": "string",
          "description": "Build folder (empty = repository root)"
         },
         "build_target": {
          "type": "string",
          "pattern": "^[A-Za-z0-9._-]{0,64}$",
          "example": "production",
          "description": "Stage of a multi-stage Dockerfile to build (`FROM node:20 AS production` -> `production`, same as `docker build --target`). Empty = the last stage. Stage names are case-insensitive (stored lowercase). A stage the Dockerfile does not have fails the run with `build_target_not_found`. gyro-pipeline.yml: `build_target:` overrides it per run. CLI: `--target` (or `--build-target`).",
          "x-description-tr": "Çok aşamalı Dockerfile'da derlenecek aşama (`FROM node:20 AS production` -> `production`, `docker build --target` ile aynı). Boş = son aşama. Aşama adı büyük/küçük harf duyarsızdır (küçük harfle saklanır). Dockerfile'da olmayan aşama `build_target_not_found` hatasıyla çalıştırmayı durdurur. gyro-pipeline.yml: `build_target:` çalıştırma için bunu ezer. CLI: `--target` (ya da `--build-target`)."
         },
         "targets": {
          "type": "array",
          "items": {
           "type": "string"
          },
          "description": "Services that get the new image (empty = build only)",
          "x-description-tr": "Yeni imaja geçecek servisler (boş = yalnız derle)"
         },
         "approval": {
          "type": "boolean",
          "default": false,
          "description": "Wait for approval before deploying (24 h)"
         },
         "auto_rollback": {
          "type": "boolean",
          "default": true,
          "description": "Roll back when the new version is unhealthy"
         },
         "build_image": {
          "type": "string",
          "description": "Image that runs `commands` (e.g. node:22-alpine)"
         },
         "commands": {
          "type": "array",
          "items": {
           "type": "string"
          },
          "description": "Shell commands run in the repository root before the Dockerfile (tests, npm ci ...); build secrets are environment variables here"
         },
         "build_env": {
          "type": "object",
          "additionalProperties": {
           "type": "string"
          },
          "description": "Variables for `commands`"
         },
         "build_args": {
          "type": "object",
          "additionalProperties": {
           "type": "string"
          },
          "description": "Dockerfile ARG values (visible in the image history)"
         },
         "cpu_m": {
          "type": "integer",
          "description": "Build CPU (millicores, plan limit)"
         },
         "memory_mi": {
          "type": "integer",
          "description": "Build memory (MiB, plan limit)"
         },
         "timeout_min": {
          "type": "integer",
          "description": "Build time limit (minutes, plan limit)"
         },
         "verify_min": {
          "type": "integer",
          "description": "Health wait after deploy (1-30 minutes)"
         },
         "notify": {
          "type": "array",
          "items": {
           "type": "string",
           "enum": [
            "failed",
            "succeeded",
            "approval",
            "rolled_back"
           ]
          },
          "description": "Notifications (channels: the environment's alert settings)"
         },
         "confirm": {
          "type": "boolean"
         }
        },
        "required": [
         "name",
         "image"
        ]
       }
      }
     }
    },
    "x-cli": {
     "command": "container pipeline create",
     "confirm": false
    }
   }
  }
 },
 "components": {
  "responses": {
   "Validation": {
    "description": "Validation or business rule failure (`confirm_required`, `invalid_image`, `tool_action_failed` ...)",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   },
   "Conflict": {
    "description": "State conflict (`server_locked`, `not_actionable`, `ssh_key_exists`, `server_limit`, `idempotency_in_flight`)",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   },
   "NotFound": {
    "description": "Not found — also returned for objects owned by someone else",
    "content": {
     "application/json": {
      "schema": {
       "$ref": "#/components/schemas/Error"
      }
     }
    }
   }
  },
  "schemas": {
   "Error": {
    "type": "object",
    "required": [
     "error"
    ],
    "properties": {
     "error": {
      "type": "object",
      "required": [
       "code",
       "message"
      ],
      "properties": {
       "code": {
        "type": "string",
        "example": "server_not_found"
       },
       "message": {
        "type": "string"
       },
       "details": {
        "type": "object",
        "additionalProperties": true,
        "description": "Extra data. Limit refusals add the LimitHint fields (`limit_exceeded: true`, `limit_key`, `limit`, `current`, `how_to_increase`, `support_ticket`, `hint`): account limits are raised with a support ticket. Validation errors (length, format) never carry the limit hint.",
        "x-description-tr": "Ek veri. Sınır retlerinde LimitHint alanları gelir: hesap sınırları destek talebiyle artırılır. Doğrulama hataları (uzunluk, biçim) sınır ipucu taşımaz."
       }
      }
     }
    }
   },
   "ContainerPipeline": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "example": "p1a2b3c4d"
     },
     "name": {
      "type": "string",
      "example": "web"
     },
     "provider": {
      "type": "string",
      "enum": [
       "github",
       "gitlab",
       "gitea",
       "git",
       "archive"
      ],
      "description": "`archive`: no repository, builds only from uploaded archives"
     },
     "repo": {
      "type": "string",
      "example": "https://github.com/gyro-ornek/uygulama",
      "description": "https clone URL (no credentials) or SSH address (git@host:org/repo.git, ssh://user@host[:port]/path)"
     },
     "git_user": {
      "type": "string"
     },
     "branch": {
      "type": "string",
      "example": "main, release/*"
     },
     "tags": {
      "type": "string",
      "example": "v*"
     },
     "auto": {
      "type": "boolean"
     },
     "repo_file": {
      "type": "boolean"
     },
     "dockerfile": {
      "type": "string"
     },
     "context": {
      "type": "string"
     },
     "image": {
      "type": "string",
      "example": "web"
     },
     "targets": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "approval": {
      "type": "boolean"
     },
     "auto_rollback": {
      "type": "boolean"
     },
     "build_image": {
      "type": "string"
     },
     "commands": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "build_env": {
      "type": "object",
      "additionalProperties": {
       "type": "string"
      }
     },
     "build_args": {
      "type": "object",
      "additionalProperties": {
       "type": "string"
      }
     },
     "cpu_m": {
      "type": "integer"
     },
     "memory_mi": {
      "type": "integer"
     },
     "timeout_min": {
      "type": "integer"
     },
     "verify_min": {
      "type": "integer"
     },
     "notify": {
      "type": "object",
      "additionalProperties": {
       "type": "boolean"
      }
     },
     "webhook_url": {
      "type": "string",
      "example": "https://ecs-api.ist.gyrohosting.com/hook/ab12cd/p1a2b3c4d"
     },
     "has_token": {
      "type": "boolean"
     },
     "secret_names": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "registry_image": {
      "type": "string",
      "example": "registry.ist.gyrohosting.com/ab12cd/web"
     },
     "last_run": {
      "$ref": "#/components/schemas/ContainerPipelineRun"
     },
     "created": {
      "type": "string",
      "format": "date-time"
     },
     "updated": {
      "type": "string",
      "format": "date-time"
     },
     "auth": {
      "type": "string",
      "enum": [
       "none",
       "token",
       "ssh",
       "archive"
      ],
      "description": "How the source is reached"
     },
     "ssh": {
      "type": "object",
      "description": "SSH repositories only",
      "properties": {
       "host": {
        "type": "string"
       },
       "port": {
        "type": "integer"
       },
       "user": {
        "type": "string"
       },
       "pinned": {
        "type": "boolean",
        "description": "GitHub / GitLab / Bitbucket: published host keys are pinned"
       },
       "host_key_trusted": {
        "type": "boolean"
       },
       "host_keys": {
        "type": "array",
        "items": {
         "type": "object",
         "properties": {
          "type": {
           "type": "string"
          },
          "fingerprint": {
           "type": "string",
           "example": "SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU"
          }
         }
        }
       },
       "deploy_key": {
        "type": "object",
        "nullable": true,
        "properties": {
         "public_key": {
          "type": "string",
          "example": "ssh-ed25519 AAAAC3Nza... gyro-pipeline"
         },
         "fingerprint": {
          "type": "string"
         },
         "type": {
          "type": "string",
          "example": "ed25519"
         }
        }
       }
      }
     },
     "archive": {
      "type": "object",
      "properties": {
       "enabled": {
        "type": "boolean"
       },
       "max_bytes": {
        "type": "integer",
        "example": 209715200
       },
       "retention_hours": {
        "type": "integer",
        "example": 24
       }
      }
     },
     "build_target": {
      "type": "string",
      "description": "Dockerfile stage that is built (empty = last stage)",
      "x-description-tr": "Derlenen Dockerfile aşaması (boş = son aşama)"
     }
    }
   },
   "ContainerPipelineRun": {
    "type": "object",
    "properties": {
     "id": {
      "type": "string",
      "example": "rt0gbqcbw5r1"
     },
     "pipeline": {
      "type": "string"
     },
     "n": {
      "type": "integer",
      "description": "run number of the pipeline"
     },
     "trigger": {
      "type": "string",
      "enum": [
       "push",
       "tag",
       "manual",
       "api",
       "redeploy",
       "archive"
      ]
     },
     "ref": {
      "type": "string",
      "example": "refs/heads/main"
     },
     "sha": {
      "type": "string"
     },
     "short_sha": {
      "type": "string"
     },
     "message": {
      "type": "string"
     },
     "author": {
      "type": "string"
     },
     "state": {
      "type": "string",
      "enum": [
       "queued",
       "preparing",
       "building",
       "awaiting_approval",
       "deploying",
       "verifying",
       "succeeded",
       "failed",
       "cancelled",
       "rolled_back",
       "skipped",
       "expired"
      ]
     },
     "step": {
      "type": "string",
      "enum": [
       "prepare",
       "queued_node",
       "starting",
       "clone",
       "steps",
       "build",
       "approval",
       "deploy",
       "verify"
      ]
     },
     "error": {
      "type": "string",
      "description": "repo_auth, repo_not_found, repo_unreachable, repo_blocked, ref_not_found, target_missing, clone_failed, commands_failed, build_failed, build_target_not_found (detail = the stage name), invalid_build_target, push_failed, timeout, out_of_memory, no_capacity, build_image_pull, deploy_unhealthy, deploy_timeout, deploy_failed, minutes_exhausted, pipeline_file_invalid, cancelled, rejected, approval_expired, internal, archive_invalid (detail says why: links, ../ paths, device files, > 20 000 files, > 2 GB unpacked, damaged), archive_download, upload_not_found, archive_format, archive_too_large, host_key_unconfirmed, host_key_mismatch, deploy_key_missing"
     },
     "image": {
      "type": "string",
      "example": "registry.ist.gyrohosting.com/ab12cd/web:1a2b3c4"
     },
     "digest": {
      "type": "string"
     },
     "deployed": {
      "type": "array",
      "items": {
       "type": "object",
       "properties": {
        "service": {
         "type": "string"
        },
        "from_revision": {
         "type": "integer"
        },
        "to_revision": {
         "type": "integer"
        },
        "state": {
         "type": "string",
         "enum": [
          "pending",
          "running",
          "failing",
          "rolled_back",
          "missing"
         ]
        },
        "problem": {
         "type": "string"
        }
       }
      }
     },
     "build_seconds": {
      "type": "integer"
     },
     "billed_minutes": {
      "type": "integer"
     },
     "duration_seconds": {
      "type": "integer"
     },
     "created": {
      "type": "string",
      "format": "date-time"
     },
     "started": {
      "type": "string",
      "format": "date-time"
     },
     "finished": {
      "type": "string",
      "format": "date-time"
     },
     "deadline": {
      "type": "string",
      "format": "date-time",
      "description": "approval / health wait deadline"
     },
     "from_run": {
      "type": "string",
      "description": "redeploy: source run"
     },
     "archive": {
      "type": "string",
      "description": "upload id (archive runs)"
     },
     "archive_name": {
      "type": "string"
     },
     "archive_size": {
      "type": "integer"
     },
     "archive_format": {
      "type": "string",
      "enum": [
       "tar.gz",
       "zip"
      ]
     },
     "image_tag": {
      "type": "string",
      "description": "<sha7> for commits, arc-<upload> for archives"
     }
    }
   }
  }
 },
 "security": [
  {
   "bearerAuth": []
  }
 ]
}