use of com.google.cloud.securitycenter.v1.OrganizationSettings in project google-cloud-java by GoogleCloudPlatform.
the class OrganizationSnippets method getOrganizationSettings.
/**
* Gets current settings for an organization.
*
* @param organizationName The organization to get settings for.
*/
// [START securitycenter_get_org_settings]
static OrganizationSettings getOrganizationSettings(OrganizationName organizationName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// Start setting up a request to get OrganizationSettings for.
// OrganizationName organizationName = OrganizationName.of(/*organizationId=*/"123234324");
GetOrganizationSettingsRequest.Builder request = GetOrganizationSettingsRequest.newBuilder().setName(organizationName.toString() + "/organizationSettings");
// Call the API.
OrganizationSettings response = client.getOrganizationSettings(request.build());
System.out.println("Organization Settings:");
System.out.println(response);
return response;
} catch (IOException e) {
throw new RuntimeException("Couldn't create client.", e);
}
}
use of com.google.cloud.securitycenter.v1.OrganizationSettings in project google-cloud-java by GoogleCloudPlatform.
the class OrganizationSnippets method updateOrganizationSettings.
// [END securitycenter_get_org_settings]
/**
* Update Asset Discovery OrganizationSettings for an organization
*
* @param organizationName The organization to update settings for.
*/
// [START securitycenter_enable_asset_discovery]
static OrganizationSettings updateOrganizationSettings(OrganizationName organizationName) {
try (SecurityCenterClient client = SecurityCenterClient.create()) {
// Start setting up a request to update OrganizationSettings for.
// OrganizationName organizationName = OrganizationName.of(/*organizationId=*/"123234324");
OrganizationSettings organizationSettings = OrganizationSettings.newBuilder().setName(organizationName.toString() + "/organizationSettings").setEnableAssetDiscovery(true).build();
FieldMask updateMask = FieldMask.newBuilder().addPaths("enable_asset_discovery").build();
UpdateOrganizationSettingsRequest.Builder request = UpdateOrganizationSettingsRequest.newBuilder().setOrganizationSettings(organizationSettings).setUpdateMask(updateMask);
// Call the API.
OrganizationSettings response = client.updateOrganizationSettings(request.build());
System.out.println("Organization Settings have been updated:");
System.out.println(response);
return response;
} catch (IOException e) {
throw new RuntimeException("Couldn't create client.", e);
}
}
Aggregations