定制 vanguardbackup/vanguard-php-sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

vanguardbackup/vanguard-php-sdk

最新稳定版本:0.2.7

Composer 安装命令:

composer require vanguardbackup/vanguard-php-sdk

包简介

The official Vanguard PHP SDK.

README 文档

README

Vanguard Logo

License: MIT Tests GitHub Release Packagist Downloads

Vanguard PHP SDK

Overview

The Vanguard PHP SDK provides a fluent interface for interacting with Vanguard's API, enabling efficient management of your backup operations.

API Documentation

For comprehensive API documentation, including request/response schemas and example payloads, please refer to our official API documentation:

Vanguard API Documentation

This resource is invaluable when constructing requests or handling responses, especially for complex operations not fully abstracted by the SDK.

Getting Started

Installation

Add the Vanguard PHP SDK to your project using Composer:

composer require vanguardbackup/vanguard-php-sdk

Initializing the SDK

Create a new instance of the VanguardBackup client:

$vanguard = new VanguardBackup\Vanguard\VanguardClient('YOUR_API_KEY');

For custom Vanguard installations, specify the API base URL:

$vanguard = new VanguardBackup\Vanguard\VanguardClient('YOUR_API_KEY', 'https://your-vanguard-instance.com');

Core Functionalities

User Authentication

Retrieve the authenticated user's information:

$user = $vanguard->user();

Backup Task Management

Manage your backup tasks:

// List all backup tasks
$tasks = $vanguard->backupTasks();

// Get a specific backup task
$task = $vanguard->backupTask($taskId);

// Create a new backup task
$newTask = $vanguard->createBackupTask([
    'label' => 'Daily Database Backup',
    'source_type' => 'database',
    // ... other task parameters
]);

// Update an existing backup task
$updatedTask = $vanguard->updateBackupTask($taskId, [
    'frequency' => 'daily',
    // ... other parameters to update
]);

// Delete a backup task
$vanguard->deleteBackupTask($taskId);

// Get the status of a backup task
$status = $vanguard->getBackupTaskStatus($taskId);

// Retrieve the latest log for a backup task
$log = $vanguard->getLatestBackupTaskLog($taskId);

// Manually trigger a backup task
$vanguard->runBackupTask($taskId);

Individual BackupTask instances also provide methods for common operations:

$task->update(['label' => 'Weekly Full Backup']);
$task->delete();
$task->getStatus();
$task->getLatestLog();
$task->run();

Backup Task Log Management

Manage logs for your backup tasks:

// List all backup task logs
$logs = $vanguard->backupTaskLogs();

// Get a specific backup task log
$log = $vanguard->backupTaskLog($logId);

// Delete a backup task log
$vanguard->deleteBackupTaskLog($logId);

Individual BackupTaskLog instances also provide methods for common operations:

$log->delete();
$log->isSuccessful();
$log->isFailed();

Remote Server Management

Manage the servers from which you're backing up data:

// List all remote servers
$servers = $vanguard->remoteServers();

// Get a specific remote server
$server = $vanguard->remoteServer($serverId);

// Add a new remote server
$newServer = $vanguard->createRemoteServer([
    'label' => 'Production DB Server',
    'ip_address' => '192.168.1.100',
    // ... other server details
]);

// Update a remote server
$updatedServer = $vanguard->updateRemoteServer($serverId, [
    'label' => 'Updated Production DB Server',
]);

// Remove a remote server
$vanguard->deleteRemoteServer($serverId);

Backup Destination Management

Control where your backups are stored:

// List all backup destinations
$destinations = $vanguard->backupDestinations();

// Get a specific backup destination
$destination = $vanguard->backupDestination($destinationId);

// Create a new backup destination
$newDestination = $vanguard->createBackupDestination([
    'type' => 's3',
    'bucket' => 'my-backups',
    // ... other destination details
]);

// Update a backup destination
$updatedDestination = $vanguard->updateBackupDestination($destinationId, [
    'bucket' => 'new-backup-bucket',
]);

// Remove a backup destination
$vanguard->deleteBackupDestination($destinationId);

Tag Management

Organize your backup resources with tags:

// List all tags
$tags = $vanguard->tags();

// Get a specific tag
$tag = $vanguard->tag($tagId);

// Create a new tag
$newTag = $vanguard->createTag(['label' => 'Production']);

// Update a tag
$updatedTag = $vanguard->updateTag($tagId, ['label' => 'Staging']);

// Delete a tag
$vanguard->deleteTag($tagId);

Notification Stream Management

Configure how you receive alerts about your backups:

// List all notification streams
$streams = $vanguard->notificationStreams();

// Get a specific notification stream
$stream = $vanguard->notificationStream($streamId);

// Create a new notification stream
$newStream = $vanguard->createNotificationStream([
    'type' => 'slack',
    'webhook_url' => 'https://hooks.slack.com/services/...',
]);

// Update a notification stream
$updatedStream = $vanguard->updateNotificationStream($streamId, [
    'events' => ['backup_failed', 'backup_successful'],
]);

// Delete a notification stream
$vanguard->deleteNotificationStream($streamId);

SSH Key Management

Retrieve the Vanguard instance SSH public key:

// Get the instance SSH public key
$sshKey = $vanguard->getInstanceSshKey();

// Access the public key as a string
echo $sshKey->publicKey;

// Or cast the object to a string to get the public key
echo (string) $sshKey;

Security

For reporting security vulnerabilities, please refer to our security policy.

License

The Vanguard PHP SDK is open-source software, released under the MIT licence.

Acknowledgments

We'd like to express our gratitude to the Laravel Forge PHP SDK, which served as an inspiration for the structure and design of this SDK.

统计信息

  • 总下载量: 14
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-09