MediaWiki  1.30.0
SwiftVirtualRESTService Class Reference

Example virtual rest service for OpenStack Swift @TODO: caching support (APC/memcached) More...

Inheritance diagram for SwiftVirtualRESTService:
Collaboration diagram for SwiftVirtualRESTService:

Public Member Functions

 __construct (array $params)
 
 onRequests (array $reqs, Closure $idGeneratorFunc)
 Prepare virtual HTTP(S) requests (for this service) for execution. More...
 
 onResponses (array $reqs, Closure $idGeneratorFunc)
 Mangle or replace virtual HTTP(S) requests which have been responded to. More...
 
- Public Member Functions inherited from VirtualRESTService
 getName ()
 Return the name of this service, in a form suitable for error reporting or debugging. More...
 

Protected Member Functions

 applyAuthResponse (array $req)
 
 needsAuthRequest ()
 

Protected Attributes

string $authCachedReason = null
 
int $authCachedStatus = null
 
array $authCreds
 
int $authErrorTimestamp = null
 UNIX timestamp. More...
 
int $authSessionTimestamp = 0
 UNIX timestamp. More...
 
- Protected Attributes inherited from VirtualRESTService
array $params = []
 Key/value map. More...
 

Detailed Description

Example virtual rest service for OpenStack Swift @TODO: caching support (APC/memcached)

Since
1.23

Definition at line 28 of file SwiftVirtualRESTService.php.

Constructor & Destructor Documentation

◆ __construct()

SwiftVirtualRESTService::__construct ( array  $params)
Parameters
array$paramsKey/value map
  • swiftAuthUrl : Swift authentication server URL
  • swiftUser : Swift user used by MediaWiki (account:username)
  • swiftKey : Swift authentication key for the above user
  • swiftAuthTTL : Swift authentication TTL (seconds)

Reimplemented from VirtualRESTService.

Definition at line 47 of file SwiftVirtualRESTService.php.

References VirtualRESTService\$params.

Member Function Documentation

◆ applyAuthResponse()

SwiftVirtualRESTService::applyAuthResponse ( array  $req)
protected

Definition at line 73 of file SwiftVirtualRESTService.php.

References $req, and list.

Referenced by onResponses().

◆ needsAuthRequest()

SwiftVirtualRESTService::needsAuthRequest ( )
protected
Returns
int|bool HTTP status on cached failure

Definition at line 58 of file SwiftVirtualRESTService.php.

References $authCachedStatus.

Referenced by onRequests().

◆ onRequests()

SwiftVirtualRESTService::onRequests ( array  $reqs,
Closure  $idGeneratorFunc 
)

Prepare virtual HTTP(S) requests (for this service) for execution.

This method should mangle any of the $reqs entry fields as needed:

  • url : munge the URL to have an absolute URL with a protocol and encode path components as needed by the backend [required]
  • query : include any authentication signatures/parameters [as needed]
  • headers : include any authentication tokens/headers [as needed]

The incoming URL parameter will be relative to the service mount point.

This method can also remove some of the requests as well as add new ones (using $idGenerator to set each of the entries' array keys). For any existing or added request, the 'response' array can be filled in, which will prevent the client from executing it. If an original request is removed, at some point it must be added back (with the same key) in onRequests() or onResponses(); it's reponse may be filled in as with other requests.

Parameters
array$reqsMap of Virtual HTTP request arrays
Closure$idGeneratorFuncMethod to generate unique keys for new requests
Returns
array Modified HTTP request array map

Reimplemented from VirtualRESTService.

Definition at line 96 of file SwiftVirtualRESTService.php.

References $authCachedReason, $authCachedStatus, $req, as, captcha-old\count, and needsAuthRequest().

Referenced by onResponses().

◆ onResponses()

SwiftVirtualRESTService::onResponses ( array  $reqs,
Closure  $idGeneratorFunc 
)

Mangle or replace virtual HTTP(S) requests which have been responded to.

This method may mangle any of the $reqs entry 'response' fields as needed:

  • code : perform any code normalization [as needed]
  • reason : perform any reason normalization [as needed]
  • headers : perform any header normalization [as needed]

This method can also remove some of the requests as well as add new ones (using $idGenerator to set each of the entries' array keys). For any existing or added request, the 'response' array can be filled in, which will prevent the client from executing it. If an original request is removed, at some point it must be added back (with the same key) in onRequests() or onResponses(); it's reponse may be filled in as with other requests. All requests added to $reqs will be passed through onRequests() to handle any munging required as normal.

The incoming URL parameter will be relative to the service mount point.

Parameters
array$reqsMap of Virtual HTTP request arrays with 'response' set
Closure$idGeneratorFuncMethod to generate unique keys for new requests
Returns
array Modified HTTP request array map

Reimplemented from VirtualRESTService.

Definition at line 151 of file SwiftVirtualRESTService.php.

References $authCachedReason, $authCachedStatus, $req, applyAuthResponse(), as, captcha-old\count, and onRequests().

Member Data Documentation

◆ $authCachedReason

string SwiftVirtualRESTService::$authCachedReason = null
protected

Definition at line 38 of file SwiftVirtualRESTService.php.

Referenced by onRequests(), and onResponses().

◆ $authCachedStatus

int SwiftVirtualRESTService::$authCachedStatus = null
protected

Definition at line 36 of file SwiftVirtualRESTService.php.

Referenced by needsAuthRequest(), onRequests(), and onResponses().

◆ $authCreds

array SwiftVirtualRESTService::$authCreds
protected

Definition at line 30 of file SwiftVirtualRESTService.php.

◆ $authErrorTimestamp

int SwiftVirtualRESTService::$authErrorTimestamp = null
protected

UNIX timestamp.

Definition at line 34 of file SwiftVirtualRESTService.php.

◆ $authSessionTimestamp

int SwiftVirtualRESTService::$authSessionTimestamp = 0
protected

UNIX timestamp.

Definition at line 32 of file SwiftVirtualRESTService.php.


The documentation for this class was generated from the following file: