Skip to content

Commit

Permalink
feat: add apis for AssuredWorkload monitoring feature and to restrict…
Browse files Browse the repository at this point in the history
… allowed resources (#192)

* feat: add apis for AssuredWorkload monitoring feature and to restrict allowed resources

AssuredWorkload monitoring is a new feature which provides apis to fetch compliance violation for AssuredWorkloads. It also provides an api to acknowledge an unresolved violation.

RestrictAllowedResources api allows restricting list of available resources in Workload environment.

Committer: @ViswasK
PiperOrigin-RevId: 477959383

Source-Link: googleapis/googleapis@0cad78c

Source-Link: googleapis/googleapis-gen@3052e0d
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMzA1MmUwZDdhYzk4OWJjNTcxZmIzMDU4OTRhZGE4NTI1ZDFmMjQ4ZSJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored Oct 6, 2022
1 parent d073994 commit fc6b73e
Show file tree
Hide file tree
Showing 16 changed files with 8,574 additions and 194 deletions.

Large diffs are not rendered by default.

1,600 changes: 1,580 additions & 20 deletions packages/google-cloud-assuredworkloads/protos/protos.d.ts

Large diffs are not rendered by default.

3,896 changes: 3,855 additions & 41 deletions packages/google-cloud-assuredworkloads/protos/protos.js

Large diffs are not rendered by default.

449 changes: 429 additions & 20 deletions packages/google-cloud-assuredworkloads/protos/protos.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **



'use strict';

function main(name, comment) {
// [START assuredworkloads_v1_generated_AssuredWorkloadsService_AcknowledgeViolation_async]
/**
* This snippet 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.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the Violation to acknowledge.
* Format:
* organizations/{organization}/locations/{location}/workloads/{workload}/violations/{violation}
*/
// const name = 'abc123'
/**
* Required. Business justification explaining the need for violation acknowledgement
*/
// const comment = 'abc123'
/**
* Optional. Name of the OrgPolicy which was modified with non-compliant change and
* resulted in this violation.
* Format:
* projects/{project_number}/policies/{constraint_name}
* folders/{folder_id}/policies/{constraint_name}
* organizations/{organization_id}/policies/{constraint_name}
*/
// const nonCompliantOrgPolicy = 'abc123'

// Imports the Assuredworkloads library
const {AssuredWorkloadsServiceClient} = require('@google-cloud/assured-workloads').v1;

// Instantiates a client
const assuredworkloadsClient = new AssuredWorkloadsServiceClient();

async function callAcknowledgeViolation() {
// Construct request
const request = {
name,
comment,
};

// Run request
const response = await assuredworkloadsClient.acknowledgeViolation(request);
console.log(response);
}

callAcknowledgeViolation();
// [END assuredworkloads_v1_generated_AssuredWorkloadsService_AcknowledgeViolation_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ function main(parent, workload) {
*/
// const workload = {}
/**
* Optional. A identifier associated with the workload and underlying projects
* which allows for the break down of billing costs for a workload. The value
* Optional. A identifier associated with the workload and underlying projects which
* allows for the break down of billing costs for a workload. The value
* provided for the identifier will add a label to the workload and contained
* projects with the identifier as the value.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **



'use strict';

function main(name) {
// [START assuredworkloads_v1_generated_AssuredWorkloadsService_GetViolation_async]
/**
* This snippet 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.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the Violation to fetch (ie. Violation.name).
* Format:
* organizations/{organization}/locations/{location}/workloads/{workload}/violations/{violation}
*/
// const name = 'abc123'

// Imports the Assuredworkloads library
const {AssuredWorkloadsServiceClient} = require('@google-cloud/assured-workloads').v1;

// Instantiates a client
const assuredworkloadsClient = new AssuredWorkloadsServiceClient();

async function callGetViolation() {
// Construct request
const request = {
name,
};

// Run request
const response = await assuredworkloadsClient.getViolation(request);
console.log(response);
}

callGetViolation();
// [END assuredworkloads_v1_generated_AssuredWorkloadsService_GetViolation_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ function main(name) {
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the Workload to fetch. This is the
* workloads's relative path in the API, formatted as
* Required. The resource name of the Workload to fetch. This is the workloads's
* relative path in the API, formatted as
* "organizations/{organization_id}/locations/{location_id}/workloads/{workload_id}".
* For example,
* "organizations/123/locations/us-east1/workloads/assured-workload-1".
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **



'use strict';

function main(parent) {
// [START assuredworkloads_v1_generated_AssuredWorkloadsService_ListViolations_async]
/**
* This snippet 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.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The Workload name.
* Format `organizations/{org_id}/locations/{location}/workloads/{workload}`.
*/
// const parent = 'abc123'
/**
* Optional. Specifies the time window for retrieving active Violations.
* When specified, retrieves Violations that were active between start_time
* and end_time.
*/
// const interval = {}
/**
* Optional. Page size.
*/
// const pageSize = 1234
/**
* Optional. Page token returned from previous request.
*/
// const pageToken = 'abc123'
/**
* Optional. A custom filter for filtering by the Violations properties.
*/
// const filter = 'abc123'

// Imports the Assuredworkloads library
const {AssuredWorkloadsServiceClient} = require('@google-cloud/assured-workloads').v1;

// Instantiates a client
const assuredworkloadsClient = new AssuredWorkloadsServiceClient();

async function callListViolations() {
// Construct request
const request = {
parent,
};

// Run request
const iterable = await assuredworkloadsClient.listViolationsAsync(request);
for await (const response of iterable) {
console.log(response);
}
}

callListViolations();
// [END assuredworkloads_v1_generated_AssuredWorkloadsService_ListViolations_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ** This file is automatically generated by gapic-generator-typescript. **
// ** https://github.com/googleapis/gapic-generator-typescript **
// ** All changes to this file may be overwritten. **



'use strict';

function main(name, restrictionType) {
// [START assuredworkloads_v1_generated_AssuredWorkloadsService_RestrictAllowedResources_async]
/**
* This snippet 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.
* TODO(developer): Uncomment these variables before running the sample.
*/
/**
* Required. The resource name of the Workload. This is the workloads's
* relative path in the API, formatted as
* "organizations/{organization_id}/locations/{location_id}/workloads/{workload_id}".
* For example,
* "organizations/123/locations/us-east1/workloads/assured-workload-1".
*/
// const name = 'abc123'
/**
* Required. The type of restriction for using gcp products in the Workload environment.
*/
// const restrictionType = {}

// Imports the Assuredworkloads library
const {AssuredWorkloadsServiceClient} = require('@google-cloud/assured-workloads').v1;

// Instantiates a client
const assuredworkloadsClient = new AssuredWorkloadsServiceClient();

async function callRestrictAllowedResources() {
// Construct request
const request = {
name,
restrictionType,
};

// Run request
const response = await assuredworkloadsClient.restrictAllowedResources(request);
console.log(response);
}

callRestrictAllowedResources();
// [END assuredworkloads_v1_generated_AssuredWorkloadsService_RestrictAllowedResources_async]
}

process.on('unhandledRejection', err => {
console.error(err.message);
process.exitCode = 1;
});
main(...process.argv.slice(2));
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function main(workload, updateMask) {
*/
/**
* Required. The workload to update.
* The workloads `name` field is used to identify the workload to be updated.
* The workload's `name` field is used to identify the workload to be updated.
* Format:
* organizations/{org_id}/locations/{location_id}/workloads/{workload_id}
*/
Expand Down
Loading

0 comments on commit fc6b73e

Please sign in to comment.