Skip to content

Commit

Permalink
Merge pull request #489 from inspec/CHEF-5581-MAGIC-MODULE-vertex_ai-…
Browse files Browse the repository at this point in the history
…Tensorboard

CHEF-5581-MAGIC-MODULE-vertex_ai-Tensorboard - Resource Implementation
  • Loading branch information
sa-progress authored Sep 19, 2023
2 parents 5e1a34c + 3431297 commit bc5b262
Show file tree
Hide file tree
Showing 10 changed files with 443 additions and 62 deletions.
69 changes: 7 additions & 62 deletions build/inspec/test/integration/build/gcp-mm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -1346,68 +1346,13 @@ resource "google_data_loss_prevention_stored_info_type" "basic" {
}
}

resource "google_healthcare_dataset" "default" {
name = "example-dataset-${local.name_suffix}"
location = "us-central1"
time_zone = "UTC"
}


resource "google_healthcare_dataset" "default" {
name = "example-dataset-${local.name_suffix}"
location = "us-central1"
time_zone = "UTC"
}

resource "google_service_directory_namespace" "example" {
provider = google-beta
namespace_id = "example-namespace-${local.name_suffix}"
location = "us-central1"
}

resource "google_service_directory_service" "example" {
provider = google-beta
service_id = "example-service-${local.name_suffix}"
namespace = google_service_directory_namespace.example.id
}

resource "google_service_directory_endpoint" "example" {
provider = google-beta
endpoint_id = "example-endpoint-${local.name_suffix}"
service = google_service_directory_service.example.id

metadata = {
stage = "prod"
region = "us-central1"
}

address = "1.2.3.4"
port = 5353
}


resource "google_service_directory_namespace" "example" {
provider = google-beta
namespace_id = "example-namespace-${local.name_suffix}"
location = "us-central1"
}

resource "google_service_directory_service" "example" {
provider = google-beta
service_id = "example-service-${local.name_suffix}"
namespace = google_service_directory_namespace.example.id
}

resource "google_service_directory_endpoint" "example" {
provider = google-beta
endpoint_id = "example-endpoint-${local.name_suffix}"
service = google_service_directory_service.example.id

metadata = {
stage = "prod"
region = "us-central1"
resource "google_vertex_ai_tensorboard" "tensorboard" {
display_name = "terraform-${local.name_suffix}"
description = "sample description"
labels = {
"key1" : "value1",
"key2" : "value2"
}

address = "1.2.3.4"
port = 5353
region = "us-central1"
}
11 changes: 11 additions & 0 deletions build/inspec/test/integration/configuration/mm-attributes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,17 @@ training_pipeline:
region : "value_region"
parent : "value_parent"

tensorboard:
name : "value_name"
region : "value_region"
parent : "value_parent"
update_time : "value_updatetime"
blob_storage_path_prefix : "value_blobstoragepathprefix"
etag : "value_etag"
create_time : "value_createtime"
display_name : "value_displayname"
description : "value_description"

nas_job:
name : "value_name"
region : "value_region"
Expand Down
59 changes: 59 additions & 0 deletions docs/resources/google_vertex_ai_tensorboard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
title: About the google_vertex_ai_tensorboard resource
platform: gcp
---

## Syntax
A `google_vertex_ai_tensorboard` is used to test a Google Tensorboard resource

## Examples
```
describe google_vertex_ai_tensorboard(name: "projects/#{gcp_project_id}/locations/#{tensorboard['region']}/tensorboards/#{tensorboard['name']}", region: ' value_region') do
it { should exist }
its('name') { should cmp 'value_name' }
its('update_time') { should cmp 'value_updatetime' }
its('blob_storage_path_prefix') { should cmp 'value_blobstoragepathprefix' }
its('etag') { should cmp 'value_etag' }
its('create_time') { should cmp 'value_createtime' }
its('display_name') { should cmp 'value_displayname' }
its('description') { should cmp 'value_description' }
end
describe google_vertex_ai_tensorboard(name: "does_not_exit", region: ' value_region') do
it { should_not exist }
end
```

## Properties
Properties that can be accessed from the `google_vertex_ai_tensorboard` resource:


* `name`: Output only. Name of the Tensorboard. Format: `projects/{project}/locations/{location}/tensorboards/{tensorboard}`

* `is_default`: Used to indicate if the TensorBoard instance is the default one. Each project & region can have at most one default TensorBoard instance. Creation of a default TensorBoard instance and updating an existing TensorBoard instance to be default will mark all other TensorBoard instances (if any) as non default.

* `update_time`: Output only. Timestamp when this Tensorboard was last updated.

* `labels`: The labels with user-defined metadata to organize your Tensorboards. Label keys and values can be no longer than 64 characters (Unicode codepoints), can only contain lowercase letters, numeric characters, underscores and dashes. International characters are allowed. No more than 64 user labels can be associated with one Tensorboard (System labels are excluded). See https://goo.gl/xmQnxf for more information and examples of labels. System reserved label keys are prefixed with "aiplatform.googleapis.com/" and are immutable.

* `additional_properties`:

* `blob_storage_path_prefix`: Output only. Consumer project Cloud Storage path prefix used to store blob data, which can either be a bucket or directory. Does not end with a '/'.

* `etag`: Used to perform a consistent read-modify-write updates. If not set, a blind "overwrite" update happens.

* `create_time`: Output only. Timestamp when this Tensorboard was created.

* `run_count`: Output only. The number of Runs stored in this Tensorboard.

* `encryption_spec`: Represents a customer-managed encryption key spec that can be applied to a top-level resource.

* `kms_key_name`: Required. The Cloud KMS resource identifier of the customer managed encryption key used to protect a resource. Has the form: `projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key`. The key needs to be in the same region as where the compute resource is created.

* `display_name`: Required. User provided name of this Tensorboard.

* `description`: Description of this Tensorboard.


## GCP Permissions
36 changes: 36 additions & 0 deletions docs/resources/google_vertex_ai_tensorboards.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
title: About the google_vertex_ai_tensorboards resource
platform: gcp
---

## Syntax
A `google_vertex_ai_tensorboards` is used to test a Google Tensorboard resource

## Examples
```
describe google_vertex_ai_tensorboards(parent: "projects/#{gcp_project_id}/locations/#{tensorboard['region']}", region: ' value_region') do
it { should exist }
end
```

## Properties
Properties that can be accessed from the `google_vertex_ai_tensorboards` resource:

See [google_vertex_ai_tensorboard.md](google_vertex_ai_tensorboard.md) for more detailed information
* `names`: an array of `google_vertex_ai_tensorboard` name
* `is_defaults`: an array of `google_vertex_ai_tensorboard` is_default
* `update_times`: an array of `google_vertex_ai_tensorboard` update_time
* `labels`: an array of `google_vertex_ai_tensorboard` labels
* `blob_storage_path_prefixes`: an array of `google_vertex_ai_tensorboard` blob_storage_path_prefix
* `etags`: an array of `google_vertex_ai_tensorboard` etag
* `create_times`: an array of `google_vertex_ai_tensorboard` create_time
* `run_counts`: an array of `google_vertex_ai_tensorboard` run_count
* `encryption_specs`: an array of `google_vertex_ai_tensorboard` encryption_spec
* `display_names`: an array of `google_vertex_ai_tensorboard` display_name
* `descriptions`: an array of `google_vertex_ai_tensorboard` description

## Filter Criteria
This resource supports all of the above properties as filter criteria, which can be used
with `where` as a block or a method.

## GCP Permissions
34 changes: 34 additions & 0 deletions libraries/google/vertexai/property/tensorboard_encryption_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
module GoogleInSpec
module VertexAI
module Property
class TensorboardEncryptionSpec
attr_reader :kms_key_name

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@kms_key_name = args['kmsKeyName']
end

def to_s
"#{@parent_identifier} TensorboardEncryptionSpec"
end
end
end
end
end
34 changes: 34 additions & 0 deletions libraries/google/vertexai/property/tensorboard_labels.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
module GoogleInSpec
module VertexAI
module Property
class TensorboardLabels
attr_reader :additional_properties

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@additional_properties = args['additionalProperties']
end

def to_s
"#{@parent_identifier} TensorboardLabels"
end
end
end
end
end
77 changes: 77 additions & 0 deletions libraries/google_vertex_ai_tensorboard.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: MMv1 ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'gcp_backend'
require 'google/vertexai/property/tensorboard_encryption_spec'
require 'google/vertexai/property/tensorboard_labels'

# A provider to manage Vertex AI resources.
class VertexAITensorboard < GcpResourceBase
name 'google_vertex_ai_tensorboard'
desc 'Tensorboard'
supports platform: 'gcp'

attr_reader :params
attr_reader :name
attr_reader :is_default
attr_reader :update_time
attr_reader :labels
attr_reader :blob_storage_path_prefix
attr_reader :etag
attr_reader :create_time
attr_reader :run_count
attr_reader :encryption_spec
attr_reader :display_name
attr_reader :description

def initialize(params)
super(params.merge({ use_http_transport: true }))
@params = params
@fetched = @connection.fetch(product_url(params[:beta]), resource_base_url, params, 'Get')
parse unless @fetched.nil?
end

def parse
@name = @fetched['name']
@is_default = @fetched['isDefault']
@update_time = @fetched['updateTime']
@labels = GoogleInSpec::VertexAI::Property::TensorboardLabels.new(@fetched['labels'], to_s)
@blob_storage_path_prefix = @fetched['blobStoragePathPrefix']
@etag = @fetched['etag']
@create_time = @fetched['createTime']
@run_count = @fetched['runCount']
@encryption_spec = GoogleInSpec::VertexAI::Property::TensorboardEncryptionSpec.new(@fetched['encryptionSpec'], to_s)
@display_name = @fetched['displayName']
@description = @fetched['description']
end

def exists?
!@fetched.nil?
end

def to_s
"Tensorboard #{@params[:name]}"
end

private

def product_url(_ = nil)
'https://{{region}}-aiplatform.googleapis.com/v1/'
end

def resource_base_url
'{{name}}'
end
end
Loading

0 comments on commit bc5b262

Please sign in to comment.