ServiceProvisioningController
extends AbstractBaseProvisioningController
in package
Table of Contents
- DEFAULT_SOURCE = \Athomos\Bennu\Modules\Crm\Enums\ExternalSource::Whmcs
- The source for the entities that are provisioned via this controlled
- sso_login_user_action = "service_sso_login_user"
- Actions for endpoints that do not have a process job behind
- $errorLogName : string
- $warningLogName : string
- $apiVersionManager : ApiVersionManager
- This service manages the api versions
- $async : bool
- Wherever the jobs launched by this controller should be executed asynchronously
- $ensureApiVersions : array<string|int, mixed>
- Array of api versions for which, the controller that extends this Base, is available
- $jobsLogName : string
- The name of the log in which we are going to log actions performed by jobs
- __construct() : mixed
- change_package() : ProvisioningResource|JsonResponse
- Change package for a service
- change_password() : ProvisioningResource|JsonResponse
- Change password for a service
- create() : ProvisioningResource|JsonResponse
- Store a newly created resource in storage.
- generic401JsonError() : JsonResponse
- This function can be used anywhere in the code if you need to return a standard 401 unauth response
- generic403JsonError() : JsonResponse
- This function can be used anywhere in the code if you need to return a standard 403 unauth response
- generic404JsonError() : JsonResponse
- This function can be used anywhere in the code if you need to return a standard 404 unauth response
- generic500JsonError() : JsonResponse
- This function can be used anywhere in code if there is an application error
- jsonResponse() : JsonResponse
- logEntry() : Activity
- logEntryWithoutModel() : Activity
- logError() : Activity
- logWarning() : Activity
- renew() : ProvisioningResource|JsonResponse
- Renew a service
- sso_login_admin() : ProvisioningResource|JsonResponse
- Admin login, used for SSO
- sso_login_user() : ProvisioningResource|JsonResponse
- User login, used for SSO
- stats() : ProvisioningResource|JsonResponse
- Get stats for a service
- suspend() : ProvisioningResource|JsonResponse
- Suspend a service
- terminate() : ProvisioningResource|JsonResponse
- Create a termination request
- terminate_confirm() : ProvisioningResource|JsonResponse
- Confirm a previously requested termination
- unsuspend() : ProvisioningResource|JsonResponse
- Unsuspend a previously suspended service
- validationJsonError() : JsonResponse
- Returns a 422 error
- can() : mixed
- This function will check if the user can, given the policy for the $model, do the specified $action In case it will satisfy the requirements the $callback will be used to build a response, otherwise a json with the system wide defined response will be used as a return value.
- ensureApiVersions() : void
- This method will just save the apiVersions that have to checked.
- getSource() : ExternalSource
- Get the source for the current request
- log() : array<string|int, Activity>
- jsonError() : JsonResponse
Constants
DEFAULT_SOURCE
The source for the entities that are provisioned via this controlled
private
mixed
DEFAULT_SOURCE
= \Athomos\Bennu\Modules\Crm\Enums\ExternalSource::Whmcs
sso_login_user_action
Actions for endpoints that do not have a process job behind
private
mixed
sso_login_user_action
= "service_sso_login_user"
Properties
$errorLogName
public
static string
$errorLogName
= "error"
$warningLogName
public
static string
$warningLogName
= "warning"
$apiVersionManager
This service manages the api versions
protected
ApiVersionManager
$apiVersionManager
$async
Wherever the jobs launched by this controller should be executed asynchronously
protected
bool
$async
$ensureApiVersions
Array of api versions for which, the controller that extends this Base, is available
protected
array<string|int, mixed>
$ensureApiVersions
$jobsLogName
The name of the log in which we are going to log actions performed by jobs
protected
string
$jobsLogName
= "jobs"
Methods
__construct()
public
__construct(ApiVersionManager $apiVersionManager) : mixed
Parameters
- $apiVersionManager : ApiVersionManager
Return values
mixed —change_package()
Change package for a service
public
change_package(Request $request) : ProvisioningResource|JsonResponse
Parameters
- $request : Request
Return values
ProvisioningResource|JsonResponse —change_password()
Change password for a service
public
change_password(Request $request) : ProvisioningResource|JsonResponse
Parameters
- $request : Request
Return values
ProvisioningResource|JsonResponse —create()
Store a newly created resource in storage.
public
create(Request $request) : ProvisioningResource|JsonResponse
Parameters
- $request : Request
Return values
ProvisioningResource|JsonResponse —generic401JsonError()
This function can be used anywhere in the code if you need to return a standard 401 unauth response
public
static generic401JsonError() : JsonResponse
Return values
JsonResponse —generic403JsonError()
This function can be used anywhere in the code if you need to return a standard 403 unauth response
public
static generic403JsonError() : JsonResponse
Return values
JsonResponse —generic404JsonError()
This function can be used anywhere in the code if you need to return a standard 404 unauth response
public
static generic404JsonError() : JsonResponse
Return values
JsonResponse —generic500JsonError()
This function can be used anywhere in code if there is an application error
public
static generic500JsonError(array<string|int, mixed> $errors) : JsonResponse
Parameters
- $errors : array<string|int, mixed>
Return values
JsonResponse —jsonResponse()
public
static jsonResponse(array<string|int, mixed> $data) : JsonResponse
Parameters
- $data : array<string|int, mixed>
Return values
JsonResponse —logEntry()
public
static logEntry(Model $model, array<string|int, mixed> $properties, string $description, string $event, string $logName) : Activity
Parameters
- $model : Model
- $properties : array<string|int, mixed>
- $description : string
- $event : string
- $logName : string
Return values
Activity —logEntryWithoutModel()
public
static logEntryWithoutModel(array<string|int, mixed> $properties, string $description, string $event, string $logName) : Activity
Parameters
- $properties : array<string|int, mixed>
- $description : string
- $event : string
- $logName : string
Return values
Activity —logError()
public
static logError(Model $model, array<string|int, mixed> $properties, string $description, string $event) : Activity
Parameters
- $model : Model
- $properties : array<string|int, mixed>
- $description : string
- $event : string
Return values
Activity —logWarning()
public
static logWarning(Model $model, array<string|int, mixed> $properties, string $description, string $event) : Activity
Parameters
- $model : Model
- $properties : array<string|int, mixed>
- $description : string
- $event : string
Return values
Activity —renew()
Renew a service
public
renew(Request $request) : ProvisioningResource|JsonResponse
Parameters
- $request : Request
Return values
ProvisioningResource|JsonResponse —sso_login_admin()
Admin login, used for SSO
public
sso_login_admin(Request $request) : ProvisioningResource|JsonResponse
Parameters
- $request : Request
Tags
Return values
ProvisioningResource|JsonResponse —sso_login_user()
User login, used for SSO
public
sso_login_user(Request $request) : ProvisioningResource|JsonResponse
Parameters
- $request : Request
Tags
Return values
ProvisioningResource|JsonResponse —stats()
Get stats for a service
public
stats(Request $request) : ProvisioningResource|JsonResponse
Parameters
- $request : Request
Tags
Return values
ProvisioningResource|JsonResponse —suspend()
Suspend a service
public
suspend(Request $request) : ProvisioningResource|JsonResponse
Parameters
- $request : Request
Return values
ProvisioningResource|JsonResponse —terminate()
Create a termination request
public
terminate(Request $request) : ProvisioningResource|JsonResponse
Parameters
- $request : Request
Return values
ProvisioningResource|JsonResponse —terminate_confirm()
Confirm a previously requested termination
public
terminate_confirm(Request $request) : ProvisioningResource|JsonResponse
Parameters
- $request : Request
Return values
ProvisioningResource|JsonResponse —unsuspend()
Unsuspend a previously suspended service
public
unsuspend(Request $request) : ProvisioningResource|JsonResponse
Parameters
- $request : Request
Return values
ProvisioningResource|JsonResponse —validationJsonError()
Returns a 422 error
public
static validationJsonError(array<string|int, mixed> $data, string $errorKey, string $message) : JsonResponse
Parameters
- $data : array<string|int, mixed>
- $errorKey : string
- $message : string
Return values
JsonResponse —can()
This function will check if the user can, given the policy for the $model, do the specified $action In case it will satisfy the requirements the $callback will be used to build a response, otherwise a json with the system wide defined response will be used as a return value.
protected
can(Request $request, string $action, string|Model $model, $callback[, bool $forceYes = false ]) : mixed
This function will also check if the current apiVersion is one of those for which the controller that extends this Base is available.
Parameters
- $request : Request
- $action : string
- $model : string|Model
- $callback :
- $forceYes : bool = false
-
If this parameter is true this function will not check the policy
Return values
mixed —ensureApiVersions()
This method will just save the apiVersions that have to checked.
protected
ensureApiVersions(array<string|int, mixed> $versions) : void
The real check will be done in the "can" function
Parameters
- $versions : array<string|int, mixed>
Return values
void —getSource()
Get the source for the current request
protected
getSource(Request $request) : ExternalSource
Parameters
- $request : Request
Tags
Return values
ExternalSource —log()
protected
log(Model|array<string|int, mixed> $models, array<string|int, mixed> $properties, string $description[, null $logName = null ]) : array<string|int, Activity>
Parameters
- $models : Model|array<string|int, mixed>
- $properties : array<string|int, mixed>
- $description : string
- $logName : null = null
Return values
array<string|int, Activity> —jsonError()
private
static jsonError(int $code, array<string|int, mixed> $errors) : JsonResponse
Parameters
- $code : int
- $errors : array<string|int, mixed>