Skip to main content

specs

Creates, updates, deletes, gets or lists a specs resource.

Overview

Namespecs
TypeResource
Idgoogle.apihub.specs

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringIdentifier. The name of the spec. Format: projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec}
attributesobjectOptional. The list of user defined attributes associated with the spec. The key is the attribute name. It will be of the format: projects/{project}/locations/{location}/attributes/{attribute}. The value is the attribute values associated with the resource.
contentsobjectOptional. Input only. The contents of the uploaded spec. (id: GoogleCloudApihubV1SpecContents)
createTimestring (google-datetime)Output only. The time at which the spec was created.
detailsobjectOutput only. Details parsed from the spec. (id: GoogleCloudApihubV1SpecDetails)
displayNamestringRequired. The display name of the spec. This can contain the file name of the spec.
documentationobjectOptional. The documentation of the spec. For OpenAPI spec, this will be populated from externalDocs in OpenAPI spec. (id: GoogleCloudApihubV1Documentation)
lintResponseobjectOptional. The lint response for the spec. (id: GoogleCloudApihubV1LintResponse)
parsingModestringOptional. Input only. Enum specifying the parsing mode for OpenAPI Specification (OAS) parsing.
sourceMetadataarrayOutput only. The list of sources and metadata from the sources of the spec.
sourceUristringOptional. The URI of the spec source in case file is uploaded from an external version control system.
specTypeobjectThe attribute values associated with resource. (id: GoogleCloudApihubV1AttributeValues)
updateTimestring (google-datetime)Output only. The time at which the spec was last updated.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectprojectsId, locationsId, apisId, versionsId, specsIdGet details about the information parsed from a spec. Note that this method does not return the raw spec contents. Use GetSpecContents method to retrieve the same.
listselectprojectsId, locationsId, apisId, versionsIdfilter, pageSize, pageTokenList specs corresponding to a particular API resource.
createinsertprojectsId, locationsId, apisId, versionsIdspecIdAdd a spec to an API version in the API hub. Multiple specs can be added to an API version. Note, while adding a spec, at least one of contents or source_uri must be provided. If contents is provided, then spec_type must also be provided. On adding a spec with contents to the version, the operations present in it will be added to the version.Note that the file contents in the spec should be of the same type as defined in the projects/{project}/locations/{location}/attributes/system-spec-type attribute associated with spec resource. Note that specs of various types can be uploaded, however parsing of details is supported for OpenAPI spec currently. In order to access the information parsed from the spec, use the GetSpec method. In order to access the raw contents for a particular spec, use the GetSpecContents method. In order to access the operations parsed from the spec, use the ListAPIOperations method.
patchupdateprojectsId, locationsId, apisId, versionsId, specsIdupdateMaskUpdate spec. The following fields in the spec can be updated: * display_name * source_uri * lint_response * attributes * contents * spec_type In case of an OAS spec, updating spec contents can lead to: 1. Creation, deletion and update of operations. 2. Creation, deletion and update of definitions. 3. Update of other info parsed out from the new spec. In case of contents or source_uri being present in update mask, spec_type must also be present. Also, spec_type can not be present in update mask if contents or source_uri is not present. The update_mask should be used to specify the fields being updated.
deletedeleteprojectsId, locationsId, apisId, versionsId, specsIdDelete a spec. Deleting a spec will also delete the associated operations from the version.
lintexecprojectsId, locationsId, apisId, versionsId, specsIdLints 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.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
apisIdstring
locationsIdstring
projectsIdstring
specsIdstring
versionsIdstring
filterstring
pageSizeinteger (int32)
pageTokenstring
specIdstring
updateMaskstring (google-fieldmask)

SELECT examples

Get details about the information parsed from a spec. Note that this method does not return the raw spec contents. Use GetSpecContents method to retrieve the same.

SELECT
name,
attributes,
contents,
createTime,
details,
displayName,
documentation,
lintResponse,
parsingMode,
sourceMetadata,
sourceUri,
specType,
updateTime
FROM google.apihub.specs
WHERE projectsId = '{{ projectsId }}' -- required
AND locationsId = '{{ locationsId }}' -- required
AND apisId = '{{ apisId }}' -- required
AND versionsId = '{{ versionsId }}' -- required
AND specsId = '{{ specsId }}' -- required;

INSERT examples

Add a spec to an API version in the API hub. Multiple specs can be added to an API version. Note, while adding a spec, at least one of contents or source_uri must be provided. If contents is provided, then spec_type must also be provided. On adding a spec with contents to the version, the operations present in it will be added to the version.Note that the file contents in the spec should be of the same type as defined in the projects/{project}/locations/{location}/attributes/system-spec-type attribute associated with spec resource. Note that specs of various types can be uploaded, however parsing of details is supported for OpenAPI spec currently. In order to access the information parsed from the spec, use the GetSpec method. In order to access the raw contents for a particular spec, use the GetSpecContents method. In order to access the operations parsed from the spec, use the ListAPIOperations method.

INSERT INTO google.apihub.specs (
data__name,
data__displayName,
data__specType,
data__contents,
data__sourceUri,
data__lintResponse,
data__attributes,
data__documentation,
data__parsingMode,
projectsId,
locationsId,
apisId,
versionsId,
specId
)
SELECT
'{{ name }}',
'{{ displayName }}',
'{{ specType }}',
'{{ contents }}',
'{{ sourceUri }}',
'{{ lintResponse }}',
'{{ attributes }}',
'{{ documentation }}',
'{{ parsingMode }}',
'{{ projectsId }}',
'{{ locationsId }}',
'{{ apisId }}',
'{{ versionsId }}',
'{{ specId }}'
RETURNING
name,
attributes,
contents,
createTime,
details,
displayName,
documentation,
lintResponse,
parsingMode,
sourceMetadata,
sourceUri,
specType,
updateTime
;

UPDATE examples

Update spec. The following fields in the spec can be updated: * display_name * source_uri * lint_response * attributes * contents * spec_type In case of an OAS spec, updating spec contents can lead to: 1. Creation, deletion and update of operations. 2. Creation, deletion and update of definitions. 3. Update of other info parsed out from the new spec. In case of contents or source_uri being present in update mask, spec_type must also be present. Also, spec_type can not be present in update mask if contents or source_uri is not present. The update_mask should be used to specify the fields being updated.

UPDATE google.apihub.specs
SET
data__name = '{{ name }}',
data__displayName = '{{ displayName }}',
data__specType = '{{ specType }}',
data__contents = '{{ contents }}',
data__sourceUri = '{{ sourceUri }}',
data__lintResponse = '{{ lintResponse }}',
data__attributes = '{{ attributes }}',
data__documentation = '{{ documentation }}',
data__parsingMode = '{{ parsingMode }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND apisId = '{{ apisId }}' --required
AND versionsId = '{{ versionsId }}' --required
AND specsId = '{{ specsId }}' --required
AND updateMask = '{{ updateMask}}'
RETURNING
name,
attributes,
contents,
createTime,
details,
displayName,
documentation,
lintResponse,
parsingMode,
sourceMetadata,
sourceUri,
specType,
updateTime;

DELETE examples

Delete a spec. Deleting a spec will also delete the associated operations from the version.

DELETE FROM google.apihub.specs
WHERE projectsId = '{{ projectsId }}' --required
AND locationsId = '{{ locationsId }}' --required
AND apisId = '{{ apisId }}' --required
AND versionsId = '{{ versionsId }}' --required
AND specsId = '{{ specsId }}' --required;

Lifecycle Methods

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.

EXEC google.apihub.specs.lint 
@projectsId='{{ projectsId }}' --required,
@locationsId='{{ locationsId }}' --required,
@apisId='{{ apisId }}' --required,
@versionsId='{{ versionsId }}' --required,
@specsId='{{ specsId }}' --required;