# SRS-04: Tape Library Management

## 1. Overview
Tape Library Management module provides management of physical and virtual tape libraries, drives, slots, and media.

## 2. Functional Requirements

### 2.1 Physical Tape Library
**FR-TAPE-001**: System shall discover physical tape libraries
- **Action**: Scan for attached tape libraries
- **Output**: List of discovered libraries

**FR-TAPE-002**: System shall list physical tape libraries
- **Output**: Library list with vendor, model, serial number

**FR-TAPE-003**: System shall display physical library details
- **Output**: Library properties, drives, slots, media

**FR-TAPE-004**: System shall allow users to load media
- **Input**: Library ID, drive ID, slot ID
- **Action**: Load tape from slot to drive

**FR-TAPE-005**: System shall allow users to unload media
- **Input**: Library ID, drive ID, slot ID
- **Action**: Unload tape from drive to slot

### 2.2 Virtual Tape Library (VTL)
**FR-TAPE-006**: System shall allow users to create VTL libraries
- **Input**: Library name, vendor, model, drive count, slot count
- **Output**: Created VTL with ID

**FR-TAPE-007**: System shall allow users to list VTL libraries
- **Output**: VTL list with status, drive count, slot count

**FR-TAPE-008**: System shall allow users to view VTL details
- **Output**: VTL configuration, drives, slots, media

**FR-TAPE-009**: System shall allow users to update VTL libraries
- **Input**: VTL ID, updated configuration

**FR-TAPE-010**: System shall allow users to delete VTL libraries
- **Input**: VTL ID
- **Validation**: VTL must not be in use

**FR-TAPE-011**: System shall allow users to start/stop VTL libraries
- **Input**: VTL ID, action (start/stop)

### 2.3 Drive Management
**FR-TAPE-012**: System shall display drive information
- **Output**: Drive status, media loaded, position

**FR-TAPE-013**: System shall allow users to control drives
- **Actions**: Load, unload, eject, rewind

### 2.4 Slot Management
**FR-TAPE-014**: System shall display slot information
- **Output**: Slot status, media present, media label

**FR-TAPE-015**: System shall allow users to manage slots
- **Actions**: View media, move media

### 2.5 Media Management
**FR-TAPE-016**: System shall display media inventory
- **Output**: Media list with label, type, status, location

**FR-TAPE-017**: System shall allow users to label media
- **Input**: Media ID, label
- **Validation**: Valid label format

## 3. User Interface Requirements

### 3.1 Library List View
- Physical and VTL library cards
- Status indicators
- Quick actions (discover, create VTL)

### 3.2 Library Detail View
- Overview tab (library info, status)
- Drives tab (drive list, controls)
- Slots tab (slot grid, media info)
- Media tab (media inventory)

### 3.3 VTL Creation Wizard
- Library name and configuration
- Drive and slot count
- Vendor and model selection

## 4. API Endpoints

```
GET    /api/v1/tape/physical/libraries
POST   /api/v1/tape/physical/libraries/discover
GET    /api/v1/tape/physical/libraries/:id

GET    /api/v1/tape/vtl/libraries
GET    /api/v1/tape/vtl/libraries/:id
POST   /api/v1/tape/vtl/libraries
PUT    /api/v1/tape/vtl/libraries/:id
DELETE /api/v1/tape/vtl/libraries/:id
POST   /api/v1/tape/vtl/libraries/:id/start
POST   /api/v1/tape/vtl/libraries/:id/stop
```

## 5. Permissions
- **tape:read**: Required for viewing libraries
- **tape:write**: Required for creating, updating, deleting, controlling

## 6. Error Handling
- Library not found
- Drive not available
- Slot already occupied
- Media not found
- MHVTL service errors
- Insufficient permissions

