Skip to main content

policies

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

Overview

Namepolicies
TypeResource
Idgoogle.binaryauthorization.policies

Fields

The following fields are returned by SELECT queries:

Successful response

NameDatatypeDescription
namestringOutput only. The relative resource name of the Binary Authorization platform policy, in the form of projects/*/platforms/*/policies/*.
descriptionstringOptional. A description comment about the policy.
etagstringOptional. Used to prevent updating the policy when another request has updated it since it was retrieved.
gkePolicyobjectOptional. GKE platform-specific policy. (id: GkePolicy)
updateTimestring (google-datetime)Output only. Time when the policy was last updated.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectprojectsId, platformsId, policiesIdGets a platform policy. Returns NOT_FOUND if the policy doesn't exist.
listselectprojectsId, platformsIdpageSize, pageTokenLists platform policies owned by a project in the specified platform. Returns INVALID_ARGUMENT if the project or the platform doesn't exist.
get_policyselectprojectsIdA policy specifies the attestors that must attest to a container image, before the project is allowed to deploy that image. There is at most one policy per project. All image admission requests are permitted if a project has no policy. Gets the policy for this project. Returns a default policy if the project does not have one.
createinsertprojectsId, platformsIdpolicyIdCreates a platform policy, and returns a copy of it. Returns NOT_FOUND if the project or platform doesn't exist, INVALID_ARGUMENT if the request is malformed, ALREADY_EXISTS if the policy already exists, and INVALID_ARGUMENT if the policy contains a platform-specific policy that does not match the platform value specified in the URL.
replace_platform_policyreplaceprojectsId, platformsId, policiesIdReplaces a platform policy. Returns NOT_FOUND if the policy doesn't exist.
update_policyreplaceprojectsIdCreates or updates a project's policy, and returns a copy of the new policy. A policy is always updated as a whole, to avoid race conditions with concurrent policy enforcement (or management!) requests. Returns NOT_FOUND if the project does not exist, INVALID_ARGUMENT if the request is malformed.
deletedeleteprojectsId, platformsId, policiesIdetagDeletes a platform policy. Returns NOT_FOUND if the policy doesn't exist.
evaluateexecprojectsId, policiesIdEvaluates a Kubernetes object versus a GKE platform policy. Returns NOT_FOUND if the policy doesn't exist, INVALID_ARGUMENT if the policy or request is malformed and PERMISSION_DENIED if the client does not have sufficient permissions.

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
platformsIdstring
policiesIdstring
projectsIdstring
etagstring
pageSizeinteger (int32)
pageTokenstring
policyIdstring

SELECT examples

Gets a platform policy. Returns NOT_FOUND if the policy doesn't exist.

SELECT
name,
description,
etag,
gkePolicy,
updateTime
FROM google.binaryauthorization.policies
WHERE projectsId = '{{ projectsId }}' -- required
AND platformsId = '{{ platformsId }}' -- required
AND policiesId = '{{ policiesId }}' -- required;

INSERT examples

Creates a platform policy, and returns a copy of it. Returns NOT_FOUND if the project or platform doesn't exist, INVALID_ARGUMENT if the request is malformed, ALREADY_EXISTS if the policy already exists, and INVALID_ARGUMENT if the policy contains a platform-specific policy that does not match the platform value specified in the URL.

INSERT INTO google.binaryauthorization.policies (
data__description,
data__gkePolicy,
data__etag,
projectsId,
platformsId,
policyId
)
SELECT
'{{ description }}',
'{{ gkePolicy }}',
'{{ etag }}',
'{{ projectsId }}',
'{{ platformsId }}',
'{{ policyId }}'
RETURNING
name,
description,
etag,
gkePolicy,
updateTime
;

REPLACE examples

Replaces a platform policy. Returns NOT_FOUND if the policy doesn't exist.

REPLACE google.binaryauthorization.policies
SET
data__description = '{{ description }}',
data__gkePolicy = '{{ gkePolicy }}',
data__etag = '{{ etag }}'
WHERE
projectsId = '{{ projectsId }}' --required
AND platformsId = '{{ platformsId }}' --required
AND policiesId = '{{ policiesId }}' --required
RETURNING
name,
description,
etag,
gkePolicy,
updateTime;

DELETE examples

Deletes a platform policy. Returns NOT_FOUND if the policy doesn't exist.

DELETE FROM google.binaryauthorization.policies
WHERE projectsId = '{{ projectsId }}' --required
AND platformsId = '{{ platformsId }}' --required
AND policiesId = '{{ policiesId }}' --required
AND etag = '{{ etag }}';

Lifecycle Methods

Evaluates a Kubernetes object versus a GKE platform policy. Returns NOT_FOUND if the policy doesn't exist, INVALID_ARGUMENT if the policy or request is malformed and PERMISSION_DENIED if the client does not have sufficient permissions.

EXEC google.binaryauthorization.policies.evaluate 
@projectsId='{{ projectsId }}' --required,
@policiesId='{{ policiesId }}' --required
@@json=
'{
"resource": "{{ resource }}"
}';