Reference documentation and code samples for the Google Cloud Api Hub V1 Client class LintingServiceClient.
Service Description: This service provides all methods related to the 1p Linter.
This class provides the ability to make remote calls to the backing service through method calls that map to API methods.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parseName method to extract the individual identifiers contained within formatted names that are returned by the API.
Namespace
Google \ Cloud \ ApiHub \ V1 \ ClientMethods
__construct
Constructor.
Parameters | |
---|---|
Name | Description |
options |
array
Optional. Options for configuring the service API wrapper. |
↳ apiEndpoint |
string
The address of the API remote host. May optionally include the port, formatted as "
|
↳ credentials |
string|array|FetchAuthTokenInterface|CredentialsWrapper
The credentials to be used by the client to authorize API calls. This option accepts either a path to a credentials file, or a decoded credentials file as a PHP array. Advanced usage: In addition, this option can also accept a pre-constructed Google\Auth\FetchAuthTokenInterface object or Google\ApiCore\CredentialsWrapper object. Note that when one of these objects are provided, any settings in $credentialsConfig will be ignored. |
↳ credentialsConfig |
array
Options used to configure credentials, including auth token caching, for the client. For a full list of supporting configuration options, see Google\ApiCore\CredentialsWrapper::build() . |
↳ disableRetries |
bool
Determines whether or not retries defined by the client configuration should be disabled. Defaults to |
↳ clientConfig |
string|array
Client method configuration, including retry settings. This option can be either a path to a JSON file, or a PHP array containing the decoded JSON data. By default this settings points to the default client config file, which is provided in the resources folder. |
↳ transport |
string|TransportInterface
The transport used for executing network requests. At the moment, supports only |
↳ transportConfig |
array
Configuration options that will be used to construct the transport. Options for each supported transport type should be passed in a key for that transport. For example: $transportConfig = [ 'rest' => [...], ]; See the Google\ApiCore\Transport\RestTransport::build() method for the supported options. |
↳ clientCertSource |
callable
A callable which returns the client cert as a string. This can be used to provide a certificate and private key to the transport layer for mTLS. |
getStyleGuide
Get the style guide being used for linting.
The async variant is Google\Cloud\ApiHub\V1\Client\LintingServiceClient::getStyleGuideAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\ApiHub\V1\GetStyleGuideRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\ApiHub\V1\StyleGuide |
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\LintingServiceClient;
use Google\Cloud\ApiHub\V1\GetStyleGuideRequest;
use Google\Cloud\ApiHub\V1\StyleGuide;
/**
* @param string $formattedName The name of the spec to retrieve.
* Format:
* `projects/{project}/locations/{location}/plugins/{plugin}/styleGuide`. Please see
* {@see LintingServiceClient::styleGuideName()} for help formatting this field.
*/
function get_style_guide_sample(string $formattedName): void
{
// Create a client.
$lintingServiceClient = new LintingServiceClient();
// Prepare the request message.
$request = (new GetStyleGuideRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var StyleGuide $response */
$response = $lintingServiceClient->getStyleGuide($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = LintingServiceClient::styleGuideName('[PROJECT]', '[LOCATION]', '[PLUGIN]');
get_style_guide_sample($formattedName);
}
getStyleGuideContents
Get the contents of the style guide.
The async variant is Google\Cloud\ApiHub\V1\Client\LintingServiceClient::getStyleGuideContentsAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\ApiHub\V1\GetStyleGuideContentsRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\ApiHub\V1\StyleGuideContents |
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\LintingServiceClient;
use Google\Cloud\ApiHub\V1\GetStyleGuideContentsRequest;
use Google\Cloud\ApiHub\V1\StyleGuideContents;
/**
* @param string $formattedName The name of the StyleGuide whose contents need to be retrieved.
* There is exactly one style guide resource per project per location.
* The expected format is
* `projects/{project}/locations/{location}/plugins/{plugin}/styleGuide`. Please see
* {@see LintingServiceClient::styleGuideName()} for help formatting this field.
*/
function get_style_guide_contents_sample(string $formattedName): void
{
// Create a client.
$lintingServiceClient = new LintingServiceClient();
// Prepare the request message.
$request = (new GetStyleGuideContentsRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
/** @var StyleGuideContents $response */
$response = $lintingServiceClient->getStyleGuideContents($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = LintingServiceClient::styleGuideName('[PROJECT]', '[LOCATION]', '[PLUGIN]');
get_style_guide_contents_sample($formattedName);
}
lintSpec
Lints the requested spec and updates the corresponding API Spec with the lint response. This lint response will be available in all subsequent Get and List Spec calls to Core service.
The async variant is Google\Cloud\ApiHub\V1\Client\LintingServiceClient::lintSpecAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\ApiHub\V1\LintSpecRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\LintingServiceClient;
use Google\Cloud\ApiHub\V1\LintSpecRequest;
/**
* @param string $formattedName The name of the spec to be linted.
* Format:
* `projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec}`
* Please see {@see LintingServiceClient::specName()} for help formatting this field.
*/
function lint_spec_sample(string $formattedName): void
{
// Create a client.
$lintingServiceClient = new LintingServiceClient();
// Prepare the request message.
$request = (new LintSpecRequest())
->setName($formattedName);
// Call the API and handle any network failures.
try {
$lintingServiceClient->lintSpec($request);
printf('Call completed successfully.' . PHP_EOL);
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$formattedName = LintingServiceClient::specName(
'[PROJECT]',
'[LOCATION]',
'[API]',
'[VERSION]',
'[SPEC]'
);
lint_spec_sample($formattedName);
}
updateStyleGuide
Update the styleGuide to be used for liniting in by API hub.
The async variant is Google\Cloud\ApiHub\V1\Client\LintingServiceClient::updateStyleGuideAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\ApiHub\V1\UpdateStyleGuideRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\ApiHub\V1\StyleGuide |
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\LintingServiceClient;
use Google\Cloud\ApiHub\V1\Linter;
use Google\Cloud\ApiHub\V1\StyleGuide;
use Google\Cloud\ApiHub\V1\StyleGuideContents;
use Google\Cloud\ApiHub\V1\UpdateStyleGuideRequest;
/**
* @param int $styleGuideLinter Target linter for the style guide.
* @param string $styleGuideContentsContents The contents of the style guide.
* @param string $styleGuideContentsMimeType The mime type of the content.
*/
function update_style_guide_sample(
int $styleGuideLinter,
string $styleGuideContentsContents,
string $styleGuideContentsMimeType
): void {
// Create a client.
$lintingServiceClient = new LintingServiceClient();
// Prepare the request message.
$styleGuideContents = (new StyleGuideContents())
->setContents($styleGuideContentsContents)
->setMimeType($styleGuideContentsMimeType);
$styleGuide = (new StyleGuide())
->setLinter($styleGuideLinter)
->setContents($styleGuideContents);
$request = (new UpdateStyleGuideRequest())
->setStyleGuide($styleGuide);
// Call the API and handle any network failures.
try {
/** @var StyleGuide $response */
$response = $lintingServiceClient->updateStyleGuide($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
/**
* Helper to execute the sample.
*
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function callSample(): void
{
$styleGuideLinter = Linter::LINTER_UNSPECIFIED;
$styleGuideContentsContents = '...';
$styleGuideContentsMimeType = '[MIME_TYPE]';
update_style_guide_sample(
$styleGuideLinter,
$styleGuideContentsContents,
$styleGuideContentsMimeType
);
}
getLocation
Gets information about a location.
The async variant is Google\Cloud\ApiHub\V1\Client\LintingServiceClient::getLocationAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Location\GetLocationRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\Cloud\Location\Location |
use Google\ApiCore\ApiException;
use Google\Cloud\ApiHub\V1\Client\LintingServiceClient;
use Google\Cloud\Location\GetLocationRequest;
use Google\Cloud\Location\Location;
/**
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function get_location_sample(): void
{
// Create a client.
$lintingServiceClient = new LintingServiceClient();
// Prepare the request message.
$request = new GetLocationRequest();
// Call the API and handle any network failures.
try {
/** @var Location $response */
$response = $lintingServiceClient->getLocation($request);
printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
listLocations
Lists information about the supported locations for this service.
The async variant is Google\Cloud\ApiHub\V1\Client\LintingServiceClient::listLocationsAsync() .
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Location\ListLocationsRequest
A request to house fields associated with the call. |
callOptions |
array
Optional. |
↳ retrySettings |
RetrySettings|array
Retry settings to use for this call. Can be a Google\ApiCore\RetrySettings object, or an associative array of retry settings parameters. See the documentation on Google\ApiCore\RetrySettings for example usage. |
Returns | |
---|---|
Type | Description |
Google\ApiCore\PagedListResponse |
use Google\ApiCore\ApiException;
use Google\ApiCore\PagedListResponse;
use Google\Cloud\ApiHub\V1\Client\LintingServiceClient;
use Google\Cloud\Location\ListLocationsRequest;
/**
* This sample has been automatically generated and should be regarded as a code
* template only. It will require modifications to work:
* - It may require correct/in-range values for request initialization.
* - It may require specifying regional endpoints when creating the service client,
* please see the apiEndpoint client configuration option for more details.
*/
function list_locations_sample(): void
{
// Create a client.
$lintingServiceClient = new LintingServiceClient();
// Prepare the request message.
$request = new ListLocationsRequest();
// Call the API and handle any network failures.
try {
/** @var PagedListResponse $response */
$response = $lintingServiceClient->listLocations($request);
foreach ($response as $element) {
printf('Element data: %s' . PHP_EOL, $element->serializeToJsonString());
}
} catch (ApiException $ex) {
printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}
}
getStyleGuideAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\ApiHub\V1\GetStyleGuideRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
getStyleGuideContentsAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\ApiHub\V1\GetStyleGuideContentsRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
lintSpecAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\ApiHub\V1\LintSpecRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
updateStyleGuideAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\ApiHub\V1\UpdateStyleGuideRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
getLocationAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Location\GetLocationRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
listLocationsAsync
Parameters | |
---|---|
Name | Description |
request |
Google\Cloud\Location\ListLocationsRequest
|
optionalArgs = [] |
array
|
Returns | |
---|---|
Type | Description |
GuzzleHttp\Promise\PromiseInterface |
static::specName
Formats a string containing the fully-qualified path to represent a spec resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
api |
string
|
version |
string
|
spec |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted spec resource. |
static::styleGuideName
Formats a string containing the fully-qualified path to represent a style_guide resource.
Parameters | |
---|---|
Name | Description |
project |
string
|
location |
string
|
plugin |
string
|
Returns | |
---|---|
Type | Description |
string |
The formatted style_guide resource. |
static::parseName
Parses a formatted name string and returns an associative array of the components in the name.
The following name formats are supported: Template: Pattern
- spec: projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec}
- styleGuide: projects/{project}/locations/{location}/plugins/{plugin}/styleGuide
The optional $template argument can be supplied to specify a particular pattern, and must match one of the templates listed above. If no $template argument is provided, or if the $template argument does not match one of the templates listed, then parseName will check each of the supported templates, and return the first match.
Parameters | |
---|---|
Name | Description |
formattedName |
string
The formatted name string |
template |
string
Optional name of template to match |
Returns | |
---|---|
Type | Description |
array |
An associative array from name component IDs to component values. |