# Episodes_LinkTaskLabels

`POST /v1/accounts/{account}/datasets/{dataset}/episodes:linkTaskLabels`

Links the unlinked episodes, uploads and merged datasets of the caller's
workspace whose free-text task label is a task's name (a merged
dataset by its own labels.task, and never an upload a merge
took, which keeps its Task, though its episodes are linked). Publishing a
task links its exact matches on its own; this call previews them
(validate_only) beside the near misses, labels that differ from the name
only in case, spacing or punctuation, and links the labels the caller
picks. A link already set, to this task or another, is never changed,
and labels stay as they are. Each upload or merged dataset it links
anything in records one TASK_ASSIGNED.

- Base URL: `https://junction-api.qualiastudios.dev`
- Authentication: an API key in the `X-API-Key` header

## Parameters

- `account` (path, string, required): The account id.
- `dataset` (path, string, required): The dataset id.

## Request body

Required: `application/json` `qualia.v1.LinkTaskLabelsRequest`

## Responses

- `200` OK: `application/json` `qualia.v1.LinkTaskLabelsResponse`
- `default` Default error response: `application/json` `google.rpc.Status`

## Schemas

```yaml
qualia.v1.LinkTaskLabelsRequest:
  required:
    - parent
    - linkedTask
  type: object
  properties:
    parent:
      type: string
      description: |-
        accounts/{account}/datasets/-: every upload of the account in the
        caller's workspace.
    linkedTask:
      type: string
      description: |-
        accounts/{account}/tasks/{task}: the task to link to. A task of the
        parent's account; NOT_FOUND otherwise.
    labels:
      type: array
      items:
        type: string
      description: |-
        The labels to link, each exactly as a match reports it: the task's name
        or a near miss of it, at most 100. Empty links the exact matches only,
        as publishing does. A label that is neither is INVALID_ARGUMENT.
    validateOnly:
      type: boolean
      description: Report what the call would link and write nothing.
  description: Request for Episodes.LinkTaskLabels.
qualia.v1.LinkTaskLabelsResponse:
  type: object
  properties:
    matches:
      type: array
      items:
        $ref: "#/components/schemas/qualia.v1.TaskLabelMatch"
      description: |-
        Every label that matches the task's name, as it stood before the call:
        exact ones first, then by episode count.
    linkedEpisodeCount:
      type: integer
      description: Episodes linked (with validate_only, that would be).
      format: int32
    linkedDatasetCount:
      type: integer
      description: Uploads and merged datasets linked (with validate_only, that would be).
      format: int32
  description: Response for Episodes.LinkTaskLabels.
qualia.v1.TaskLabelMatch:
  type: object
  properties:
    label:
      type: string
      description: The label as stored.
    exact:
      type: boolean
      description: |-
        Whether it is the task's name, surrounding whitespace aside. Other
        matches are near misses.
    episodeCount:
      type: integer
      description: Unlinked episodes whose task label it is.
      format: int32
    datasetCount:
      type: integer
      description: Unlinked uploads and merged datasets whose task label it is.
      format: int32
  description: Unlinked episodes, uploads and merged datasets that carry one label.
google.rpc.Status:
  oneOf:
    - $ref: "#/components/schemas/ApiError"
    - $ref: "#/components/schemas/GatewayError"
  description: "The body of a failed call: one of the two shapes below."
ApiError:
  title: API error
  type: object
  required:
    - code
    - message
    - retryable
    - details
  properties:
    code:
      type: string
      description: The gRPC code name in upper case, e.g. `NOT_FOUND`.
    message:
      type: string
    retryable:
      type: boolean
      description: Whether the same call may succeed if retried.
    details:
      type: array
      items:
        type: object
      description: "Empty, except when a dataset copy or move is refused: then one `google.rpc.ErrorInfo` with the refusal's `reason` code, its `domain` and, in `metadata`, the datasets it names."
  description: A refusal from the API itself.
GatewayError:
  title: Gateway error
  type: object
  required:
    - detail
  properties:
    detail:
      type: string
      description: What went wrong.
  description: A refusal from the gateway before the call reaches the API, for example `401` bad or missing API key, `403` key lacks the scope or environment closed, `413` body too large.
```
