-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #502 from inspec/CHEF-5566-MAGIC-MODULE-vertex_ai-…
…MetadataStores__context CHEF-5566-MAGIC-MODULE-vertex_ai-MetadataStores__context - Resource Implementation
- Loading branch information
Showing
9 changed files
with
444 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
docs/resources/google_vertex_ai_metadata_stores_context.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
title: About the google_vertex_ai_metadata_stores_context resource | ||
platform: gcp | ||
--- | ||
|
||
## Syntax | ||
A `google_vertex_ai_metadata_stores_context` is used to test a Google MetadataStoresContext resource | ||
|
||
## Examples | ||
``` | ||
describe google_vertex_ai_metadata_stores_context(name: "projects/#{gcp_project_id}/locations/#{metadata_stores_context['region']}/metadataStores/#{metadata_stores_context['metadataStore']}/contexts/#{metadata_stores_context['name']}", region: ' value_region') do | ||
it { should exist } | ||
its('name') { should cmp 'value_name' } | ||
its('schema_title') { should cmp 'value_schematitle' } | ||
its('etag') { should cmp 'value_etag' } | ||
its('description') { should cmp 'value_description' } | ||
its('display_name') { should cmp 'value_displayname' } | ||
its('schema_version') { should cmp 'value_schemaversion' } | ||
its('create_time') { should cmp 'value_createtime' } | ||
its('update_time') { should cmp 'value_updatetime' } | ||
end | ||
describe google_vertex_ai_metadata_stores_context(name: "does_not_exit", region: ' value_region') do | ||
it { should_not exist } | ||
end | ||
``` | ||
|
||
## Properties | ||
Properties that can be accessed from the `google_vertex_ai_metadata_stores_context` resource: | ||
|
||
|
||
* `name`: Immutable. The resource name of the Context. | ||
|
||
* `schema_title`: The title of the schema describing the metadata. Schema title and version is expected to be registered in earlier Create Schema calls. And both are used together as unique identifiers to identify schemas within the local metadata store. | ||
|
||
* `etag`: An eTag used to perform consistent read-modify-write updates. If not set, a blind "overwrite" update happens. | ||
|
||
* `description`: Description of the Context | ||
|
||
* `display_name`: User provided display name of the Context. May be up to 128 Unicode characters. | ||
|
||
* `schema_version`: The version of the schema in schema_name to use. Schema title and version is expected to be registered in earlier Create Schema calls. And both are used together as unique identifiers to identify schemas within the local metadata store. | ||
|
||
* `create_time`: Output only. Timestamp when this Context was created. | ||
|
||
* `labels`: The labels with user-defined metadata to organize your Contexts. 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 Context (System labels are excluded). | ||
|
||
* `additional_properties`: | ||
|
||
* `metadata`: Properties of the Context. Top level metadata keys' heading and trailing spaces will be trimmed. The size of this field should not exceed 200KB. | ||
|
||
* `additional_properties`: Properties of the object. | ||
|
||
* `update_time`: Output only. Timestamp when this Context was last updated. | ||
|
||
* `parent_contexts`: Output only. A list of resource names of Contexts that are parents of this Context. A Context may have at most 10 parent_contexts. | ||
|
||
|
||
## GCP Permissions |
36 changes: 36 additions & 0 deletions
36
docs/resources/google_vertex_ai_metadata_stores_contexts.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
title: About the google_vertex_ai_metadata_stores_contexts resource | ||
platform: gcp | ||
--- | ||
|
||
## Syntax | ||
A `google_vertex_ai_metadata_stores_contexts` is used to test a Google MetadataStoresContext resource | ||
|
||
## Examples | ||
``` | ||
describe google_vertex_ai_metadata_stores_contexts(parent: "projects/#{gcp_project_id}/locations/#{metadata_stores_context['region']}/metadataStores/#{metadata_stores_context['metadataStore']}", region: ' value_region') do | ||
it { should exist } | ||
end | ||
``` | ||
|
||
## Properties | ||
Properties that can be accessed from the `google_vertex_ai_metadata_stores_contexts` resource: | ||
|
||
See [google_vertex_ai_metadata_stores_context.md](google_vertex_ai_metadata_stores_context.md) for more detailed information | ||
* `names`: an array of `google_vertex_ai_metadata_stores_context` name | ||
* `schema_titles`: an array of `google_vertex_ai_metadata_stores_context` schema_title | ||
* `etags`: an array of `google_vertex_ai_metadata_stores_context` etag | ||
* `descriptions`: an array of `google_vertex_ai_metadata_stores_context` description | ||
* `display_names`: an array of `google_vertex_ai_metadata_stores_context` display_name | ||
* `schema_versions`: an array of `google_vertex_ai_metadata_stores_context` schema_version | ||
* `create_times`: an array of `google_vertex_ai_metadata_stores_context` create_time | ||
* `labels`: an array of `google_vertex_ai_metadata_stores_context` labels | ||
* `metadata`: an array of `google_vertex_ai_metadata_stores_context` metadata | ||
* `update_times`: an array of `google_vertex_ai_metadata_stores_context` update_time | ||
* `parent_contexts`: an array of `google_vertex_ai_metadata_stores_context` parent_contexts | ||
|
||
## 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
34
libraries/google/vertexai/property/metadatastorescontext_labels.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 MetadataStoresContextLabels | ||
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} MetadataStoresContextLabels" | ||
end | ||
end | ||
end | ||
end | ||
end |
34 changes: 34 additions & 0 deletions
34
libraries/google/vertexai/property/metadatastorescontext_metadata.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 MetadataStoresContextMetadata | ||
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} MetadataStoresContextMetadata" | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/metadatastorescontext_labels' | ||
require 'google/vertexai/property/metadatastorescontext_metadata' | ||
|
||
# A provider to manage Vertex AI resources. | ||
class VertexAIMetadataStoresContext < GcpResourceBase | ||
name 'google_vertex_ai_metadata_stores_context' | ||
desc 'MetadataStoresContext' | ||
supports platform: 'gcp' | ||
|
||
attr_reader :params | ||
attr_reader :name | ||
attr_reader :schema_title | ||
attr_reader :etag | ||
attr_reader :description | ||
attr_reader :display_name | ||
attr_reader :schema_version | ||
attr_reader :create_time | ||
attr_reader :labels | ||
attr_reader :metadata | ||
attr_reader :update_time | ||
attr_reader :parent_contexts | ||
|
||
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'] | ||
@schema_title = @fetched['schemaTitle'] | ||
@etag = @fetched['etag'] | ||
@description = @fetched['description'] | ||
@display_name = @fetched['displayName'] | ||
@schema_version = @fetched['schemaVersion'] | ||
@create_time = @fetched['createTime'] | ||
@labels = GoogleInSpec::VertexAI::Property::MetadataStoresContextLabels.new(@fetched['labels'], to_s) | ||
@metadata = GoogleInSpec::VertexAI::Property::MetadataStoresContextMetadata.new(@fetched['metadata'], to_s) | ||
@update_time = @fetched['updateTime'] | ||
@parent_contexts = @fetched['parentContexts'] | ||
end | ||
|
||
def exists? | ||
!@fetched.nil? | ||
end | ||
|
||
def to_s | ||
"MetadataStoresContext #{@params[:name]}" | ||
end | ||
|
||
private | ||
|
||
def product_url(_ = nil) | ||
'https://{{region}}-aiplatform.googleapis.com/v1/' | ||
end | ||
|
||
def resource_base_url | ||
'{{name}}' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# 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' | ||
class VertexAIMetadataStoresContexts < GcpResourceBase | ||
name 'google_vertex_ai_metadata_stores_contexts' | ||
desc 'MetadataStoresContext plural resource' | ||
supports platform: 'gcp' | ||
|
||
attr_reader :table | ||
|
||
filter_table_config = FilterTable.create | ||
|
||
filter_table_config.add(:names, field: :name) | ||
filter_table_config.add(:schema_titles, field: :schema_title) | ||
filter_table_config.add(:etags, field: :etag) | ||
filter_table_config.add(:descriptions, field: :description) | ||
filter_table_config.add(:display_names, field: :display_name) | ||
filter_table_config.add(:schema_versions, field: :schema_version) | ||
filter_table_config.add(:create_times, field: :create_time) | ||
filter_table_config.add(:labels, field: :labels) | ||
filter_table_config.add(:metadata, field: :metadata) | ||
filter_table_config.add(:update_times, field: :update_time) | ||
filter_table_config.add(:parent_contexts, field: :parent_contexts) | ||
|
||
filter_table_config.connect(self, :table) | ||
|
||
def initialize(params = {}) | ||
super(params.merge({ use_http_transport: true })) | ||
@params = params | ||
@table = fetch_wrapped_resource('contexts') | ||
end | ||
|
||
def fetch_wrapped_resource(wrap_path) | ||
# fetch_resource returns an array of responses (to handle pagination) | ||
result = @connection.fetch_all(product_url, resource_base_url, @params, 'Get') | ||
return if result.nil? | ||
# Conversion of string -> object hash to symbol -> object hash that InSpec needs | ||
converted = [] | ||
result.each do |response| | ||
next if response.nil? || !response.key?(wrap_path) | ||
response[wrap_path].each do |hash| | ||
hash_with_symbols = {} | ||
hash.each_key do |key| | ||
name, value = transform(key, hash) | ||
hash_with_symbols[name] = value | ||
end | ||
converted.push(hash_with_symbols) | ||
end | ||
end | ||
|
||
converted | ||
end | ||
|
||
def transform(key, value) | ||
return transformers[key].call(value) if transformers.key?(key) | ||
|
||
[key.to_sym, value] | ||
end | ||
|
||
def transformers | ||
{ | ||
'name' => ->(obj) { return :name, obj['name'] }, | ||
'schemaTitle' => ->(obj) { return :schema_title, obj['schemaTitle'] }, | ||
'etag' => ->(obj) { return :etag, obj['etag'] }, | ||
'description' => ->(obj) { return :description, obj['description'] }, | ||
'displayName' => ->(obj) { return :display_name, obj['displayName'] }, | ||
'schemaVersion' => ->(obj) { return :schema_version, obj['schemaVersion'] }, | ||
'createTime' => ->(obj) { return :create_time, obj['createTime'] }, | ||
'labels' => ->(obj) { return :labels, GoogleInSpec::VertexAI::Property::MetadataStoresContextLabels.new(obj['labels'], to_s) }, | ||
'metadata' => ->(obj) { return :metadata, GoogleInSpec::VertexAI::Property::MetadataStoresContextMetadata.new(obj['metadata'], to_s) }, | ||
'updateTime' => ->(obj) { return :update_time, obj['updateTime'] }, | ||
'parentContexts' => ->(obj) { return :parent_contexts, obj['parentContexts'] }, | ||
} | ||
end | ||
|
||
private | ||
|
||
def product_url(_ = nil) | ||
'https://{{region}}-aiplatform.googleapis.com/v1/' | ||
end | ||
|
||
def resource_base_url | ||
'{{parent}}/contexts' | ||
end | ||
end |
Oops, something went wrong.