147 lines
2.7 KiB
Markdown
147 lines
2.7 KiB
Markdown
# Cable Connections Bulk Operations - Quick Reference
|
|
|
|
## 🚀 Quick Start
|
|
|
|
### Bulk Create
|
|
```bash
|
|
POST /cable-connections/bulk/create
|
|
```
|
|
```json
|
|
{
|
|
"connections": [
|
|
{
|
|
"from_device_id": "uuid",
|
|
"to_device_id": "uuid",
|
|
"cable_length": 150.5,
|
|
"cable_type": "fiber_optic",
|
|
"status": "active"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
### Bulk Update
|
|
```bash
|
|
PUT /cable-connections/bulk/update
|
|
```
|
|
```json
|
|
{
|
|
"connection_ids": ["uuid1", "uuid2"],
|
|
"updates": {
|
|
"status": "maintenance"
|
|
}
|
|
}
|
|
```
|
|
|
|
### Bulk Delete
|
|
```bash
|
|
DELETE /cable-connections/bulk/delete
|
|
```
|
|
```json
|
|
{
|
|
"connection_ids": ["uuid1", "uuid2", "uuid3"]
|
|
}
|
|
```
|
|
|
|
## 📊 Response Format
|
|
```json
|
|
{
|
|
"total_requested": 10,
|
|
"successful": 8,
|
|
"failed": 2,
|
|
"errors": [
|
|
{
|
|
"index": 3,
|
|
"error": "Device not found",
|
|
"details": "..."
|
|
}
|
|
],
|
|
"results": [...],
|
|
"execution_time": "250ms"
|
|
}
|
|
```
|
|
|
|
## ✅ Validation
|
|
|
|
### Cable Types
|
|
- `PTP_SFP_BLD`
|
|
- `PTP_SFP_DUPLEX`
|
|
- `BB_MONEV`
|
|
- `fiber_optic`
|
|
- `drop_cable`
|
|
|
|
### Status Values
|
|
- `active`
|
|
- `inactive`
|
|
- `maintenance`
|
|
- `planned`
|
|
|
|
### Limits
|
|
- Max items per request: **100**
|
|
- Min cable length: **0.1m**
|
|
- Batch processing: **50 items**
|
|
|
|
## 🔐 Authorization
|
|
Requires role: `Teknisi` | `Admin` | `Super Admin`
|
|
|
|
## ⚡ Performance
|
|
- **4-10x faster** than individual operations
|
|
- Optimal batch size: 20-50 items
|
|
- Transaction-safe operations
|
|
|
|
## 📝 Example Usage
|
|
|
|
### PowerShell (Windows)
|
|
```powershell
|
|
$body = @{
|
|
connections = @(
|
|
@{
|
|
from_device_id = "uuid1"
|
|
to_device_id = "uuid2"
|
|
cable_length = 150.5
|
|
cable_type = "fiber_optic"
|
|
status = "active"
|
|
}
|
|
)
|
|
} | ConvertTo-Json
|
|
|
|
Invoke-RestMethod -Uri "http://localhost:8080/cable-connections/bulk/create" `
|
|
-Method POST `
|
|
-Headers @{
|
|
"Authorization" = "Bearer $token"
|
|
"Content-Type" = "application/json"
|
|
} `
|
|
-Body $body
|
|
```
|
|
|
|
### cURL (Linux/Mac)
|
|
```bash
|
|
curl -X POST http://localhost:8080/cable-connections/bulk/create \
|
|
-H "Authorization: Bearer $TOKEN" \
|
|
-H "Content-Type: application/json" \
|
|
-d '{
|
|
"connections": [
|
|
{
|
|
"from_device_id": "uuid1",
|
|
"to_device_id": "uuid2",
|
|
"cable_length": 150.5,
|
|
"cable_type": "fiber_optic",
|
|
"status": "active"
|
|
}
|
|
]
|
|
}'
|
|
```
|
|
|
|
## 🔧 Common Use Cases
|
|
|
|
1. **Initial Import**: Bulk create from external systems
|
|
2. **Maintenance Mode**: Bulk update status to 'maintenance'
|
|
3. **Data Cleanup**: Bulk delete obsolete connections
|
|
4. **Cable Upgrades**: Bulk update cable types
|
|
5. **Network Expansion**: Bulk create new connections
|
|
|
|
## 📚 Documentation
|
|
- Full Guide: `BULK_OPERATIONS_GUIDE.md`
|
|
- Summary: `BULK_OPERATIONS_SUMMARY.md`
|
|
- Test Examples: `test_data/cable_connections_bulk_test_examples.js`
|