Skip to content

Commit

Permalink
Veeam backup for Microsoft 365
Browse files Browse the repository at this point in the history
Merge pull request #6 from shellrent/veeam365
  • Loading branch information
svdigital-development authored Jul 1, 2024
2 parents f3baea8 + ab79092 commit e93d7fa
Show file tree
Hide file tree
Showing 5 changed files with 215 additions and 0 deletions.
68 changes: 68 additions & 0 deletions src/Payloads/CreateCompanyMicrosoft365BackupResourcePayload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace Shellrent\VeeamVspcApiClient\Payloads;

class CreateCompanyMicrosoft365BackupResourcePayload implements Payload {
private $RepositoryUid;

private $ProxyUid;

private $UsersQuota;

private $IsUsersQuotaUnlimited;


/**
* @param mixed $RepositoryUid
*/
public function setRepositoryUid( $RepositoryUid ) {
$this->RepositoryUid = $RepositoryUid;

return $this;
}


/**
* @param mixed $ProxyUid
*/
public function setProxyUid( $ProxyUid ) {
$this->ProxyUid = $ProxyUid;

return $this;
}


/**
* @param mixed $UsersQuota
*/
public function setUsersQuota( $UsersQuota ) {
$this->UsersQuota = $UsersQuota;

return $this;
}


/**
* @param mixed $IsUsersQuotaUnlimited
*/
public function setIsUsersQuotaUnlimited( $IsUsersQuotaUnlimited ) {
$this->IsUsersQuotaUnlimited = $IsUsersQuotaUnlimited;

return $this;
}

public function getBody() {
$body = [
"repositoryUid" => $this->RepositoryUid,
"proxyUid" => $this->ProxyUid,
"usersQuota" => $this->UsersQuota ?? null,
"isUsersQuotaUnlimited" => $this->IsUsersQuotaUnlimited ?? null,
];

return json_encode( $body );
}

public function getContentType(): string {
return 'application/json';
}
}
54 changes: 54 additions & 0 deletions src/Payloads/CreateCompanyMicrosoft365ResourcePayload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php

namespace Shellrent\VeeamVspcApiClient\Payloads;

class CreateCompanyMicrosoft365ResourcePayload implements Payload {
private $Vb365ServerUid;

private $FriendlyName;

private $IsJobSchedulingEnabled;

/**
* @param mixed $Vb365ServerUid
*/
public function setVb365ServerUid( $Vb365ServerUid ) {
$this->Vb365ServerUid = $Vb365ServerUid;

return $this;
}


/**
* @param mixed $FriendlyName
*/
public function setFriendlyName( $FriendlyName ) {
$this->FriendlyName = $FriendlyName;

return $this;
}


/**
* @param mixed $IsJobSchedulingEnabled
*/
public function setIsJobSchedulingEnabled( $IsJobSchedulingEnabled ) {
$this->IsJobSchedulingEnabled = $IsJobSchedulingEnabled;

return $this;
}

public function getBody() {
$body = [
"vb365ServerUid" => $this->Vb365ServerUid,
"friendlyName" => $this->FriendlyName,
"isJobSchedulingEnabled" => $this->IsJobSchedulingEnabled ?? false,
];

return json_encode( $body );
}

public function getContentType(): string {
return 'application/json';
}
}
47 changes: 47 additions & 0 deletions src/Payloads/ModifyCompanyResourcePayload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Shellrent\VeeamVspcApiClient\Payloads;

class ModifyCompanyResourcePayload implements Payload {
private ?int $UsersQuota = null;

private ?int $UsersQuotaUnlimited = null;

public function setUsersQuota( ?int $UsersQuota ) {
$this->UsersQuota = $UsersQuota;

return $this;
}

public function setUsersQuotaUnlimited( ?int $UsersQuotaUnlimited ) {
$this->UsersQuotaUnlimited = $UsersQuotaUnlimited;

return $this;
}

public function getBody() {
$body = [];

if ( !is_null( $this->UsersQuota ) ) {
$body[] = [
'value' => $this->UsersQuota,
'path' => '/usersQuota',
'op' => 'replace',
];
}

if ( !is_null( $this->UsersQuotaUnlimited ) ) {
$body[] = [
'value' => $this->UsersQuotaUnlimited,
'path' => '/isUsersQuotaUnlimited',
'op' => 'replace',
];
}

return json_encode( $body );
}

public function getContentType(): string {
return 'application/json';
}
}
38 changes: 38 additions & 0 deletions src/Repositories/CompanyRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
namespace Shellrent\VeeamVspcApiClient\Repositories;

use Shellrent\VeeamVspcApiClient\Payloads\CreateCompanyBackupResourcePayload;
use Shellrent\VeeamVspcApiClient\Payloads\CreateCompanyMicrosoft365BackupResourcePayload;
use Shellrent\VeeamVspcApiClient\Payloads\CreateCompanyMicrosoft365ResourcePayload;
use Shellrent\VeeamVspcApiClient\Payloads\CreateCompanyPayload;
use Shellrent\VeeamVspcApiClient\Payloads\CreateCompanySiteResourcePayload;
use Shellrent\VeeamVspcApiClient\Payloads\EditCompanyBackupResourcePayload;
use Shellrent\VeeamVspcApiClient\Payloads\ModifyCompanyPayload;
use Shellrent\VeeamVspcApiClient\Payloads\ModifyCompanyResourcePayload;
use Shellrent\VeeamVspcApiClient\Support\CreateDeleteRequest;
use Shellrent\VeeamVspcApiClient\Support\CreateGetRequest;
use Shellrent\VeeamVspcApiClient\Support\CreatePatchRequest;
Expand Down Expand Up @@ -69,4 +72,39 @@ public function get( string $companyUid ): RequestBuilder {
public function deleteCompanyBackupResource( string $companyUid, string $siteUid, string $resourceUid ): RequestBuilder {
return $this->createDeleteRequest( sprintf( '/%s/sites/%s/backupResources/%s', $companyUid, $siteUid, $resourceUid ) );
}

public function getAllCompanyVb365Resources( string $companyId ): RequestBuilder {
return $this->createGetRequest( sprintf( '/%s/vb365Resources', $companyId ) );
}

public function getAllCompanyVb365BackupResources( string $companyId, string $vb365ResourceUid ): RequestBuilder {
return $this->createGetRequest( sprintf( '/%s/vb365Resources/%s/backupResources', $companyId, $vb365ResourceUid ) );
}

public function getCompanyVb365BackupResource( string $companyId, string $vb365ResourceUid, string $vb365BackupResourceUid ): RequestBuilder {
return $this->createGetRequest( sprintf( '/%s/vb365Resources/%s/backupResources/%s', $companyId, $vb365ResourceUid, $vb365BackupResourceUid ) );
}

public function patchModifyCompanyVb365Resource( string $companyId, string $vb365ResourceUid, string $vb365BackupResourceUid, ModifyCompanyResourcePayload $request ): RequestBuilder {
return $this->createPatchRequest(
sprintf( '/%s/vb365Resources/%s/backupResources/%s', $companyId, $vb365ResourceUid, $vb365BackupResourceUid ),
$request
);
}

public function deleteCompanyVb365Resource( string $companyId, string $vb365ResourceUid ): RequestBuilder {
return $this->createDeleteRequest( sprintf( '/%s/vb365Resources/%s', $companyId, $vb365ResourceUid ) );
}

public function deleteCompanyVb365BackupResources( string $companyId, string $vb365ResourceUid, string $vb365BackupResourceUid ): RequestBuilder {
return $this->createDeleteRequest( sprintf( '/%s/vb365Resources/%s/backupResources/%s', $companyId, $vb365ResourceUid, $vb365BackupResourceUid ) );
}

public function createCompanyVb365Resource( string $companyId, CreateCompanyMicrosoft365ResourcePayload $request ): RequestBuilder {
return $this->createPostRequest( sprintf( '/%s/vb365Resources', $companyId ), $request );
}

public function createCompanyVb365BackupResource( string $companyId, string $vb365ResourceUid, CreateCompanyMicrosoft365BackupResourcePayload $request ): RequestBuilder {
return $this->createPostRequest( sprintf( '/%s/vb365Resources/%s/backupResources', $companyId, $vb365ResourceUid ), $request );
}
}
8 changes: 8 additions & 0 deletions src/Repositories/Microsoft365ServerRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ public function getBaseRoute(): string {
public function getAll(): RequestBuilder {
return $this->createGetRequest( '' );
}

public function getAllRepositoriesForServer( string $vb365ServerUid ): RequestBuilder {
return $this->createGetRequest( sprintf( '/%s/backupRepositories', $vb365ServerUid ) );
}

public function getAllProxiesForServer( string $vb365ServerUid ): RequestBuilder {
return $this->createGetRequest( sprintf( '/%s/backupProxies', $vb365ServerUid ) );
}
}

0 comments on commit e93d7fa

Please sign in to comment.