Documentation
¶
Overview ¶
Copyright 2024 Google Inc. 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
http://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.
Index ¶
- Constants
- func CompareByName(a, b *Type) int
- func Compile(yamlPath string, obj interface{})
- func DeepMerge(arr1, arr2 reflect.Value, version string)
- func ImportIdFormats(importFormat, identity []string, baseUrl string) []string
- func Merge(self, otherObj reflect.Value, version string)
- type Async
- type OpAsync
- type OpAsyncOperation
- type OpAsyncResult
- type Operation
- type PollAsync
- type Product
- func (p *Product) ExistsAtVersion(name string) bool
- func (p *Product) ExistsAtVersionOrLower(name string) bool
- func (p Product) Lineage() string
- func (p *Product) ServiceBaseUrl() string
- func (p *Product) ServiceName() string
- func (p *Product) ServiceVersion() string
- func (p *Product) SetApiName()
- func (p *Product) SetCompiler(t string)
- func (p *Product) SetDisplayName()
- func (p *Product) SetPropertiesBasedOnVersion(version *product.Version)
- func (p *Product) TerraformName() string
- func (p *Product) UnmarshalYAML(value *yaml.Node) error
- func (p *Product) Validate()
- func (p Product) VersionObjOrClosest(name string) *product.Version
- type Resource
- func (r *Resource) AddExtraFields(props []*Type, parent *Type) []*Type
- func (r Resource) AllNestedProperties(props []*Type) []*Type
- func (r Resource) AllProperties() []*Type
- func (r Resource) AllPropertiesInVersion() []*Type
- func (r Resource) AllUserProperties() []*Type
- func (r Resource) CAIFormatOverride() string
- func (r Resource) Cai2hclAssetNameTemplate() string
- func (r Resource) CaiApiVersion(productBackendName, caiProductBaseUrl string) string
- func (r Resource) CaiAssetType() string
- func (r Resource) CaiIamAssetNameTemplate(productBackendName string) string
- func (r Resource) CaiIamResourceParams() []string
- func (r Resource) CaiProductBackendName(caiProductBaseUrl string) string
- func (r Resource) CaiProductBaseUrl() string
- func (r Resource) CaiProductLegacyBaseUrl() string
- func (r Resource) CaiResourceName() string
- func (r Resource) CaiResourceType() string
- func (r Resource) ClientNamePascal() string
- func (r Resource) CodeHeader(templatePath string) string
- func (r Resource) CollectionUrl() string
- func (r Resource) CreateUri() string
- func (r Resource) CustomUpdatePropertiesByKey(properties []*Type, updateUrl string, updateId string, fingerprintName string, ...) []*Type
- func (r Resource) DatasourceOptionalFields() []string
- func (r Resource) DatasourceRequiredFields() []string
- func (r Resource) DefineAssetTypeForResourceInProduct() bool
- func (r Resource) DeleteUri() string
- func (r Resource) DeleteUrlTemplate() string
- func (r Resource) ExamplePrimaryResourceId() string
- func (r *Resource) ExcludeIfNotInVersion(version *product.Version)
- func (r Resource) ExtractIdentifiers(url string) []string
- func (r Resource) FieldSpecificUpdateMethods() bool
- func (r Resource) FirstIamImportIdFormat() string
- func (r Resource) FirstIdentityProp() *Type
- func (r Resource) FirstTestConfig() TestConfig
- func (r Resource) FirstTestExample() *resource.Examples
- func (r Resource) FlattenedProperties() []*Type
- func (r Resource) FormatDocDescription(desc string, indent bool) string
- func (r Resource) GetAsync() *Async
- func (r Resource) GetCaiAssetNameFormat() string
- func (r Resource) GetCaiAssetNameTemplate() string
- func (r Resource) GetIdFormat() string
- func (r Resource) GetIdentity() []*Type
- func (r Resource) GetPropertyUpdateMasksGroupKeys(properties []*Type) []string
- func (r Resource) GetPropertyUpdateMasksGroups(properties []*Type, maskPrefix string) map[string][]string
- func (r Resource) GetTimeouts() *Timeouts
- func (r Resource) GettableProperties() []*Type
- func (r Resource) GithubURL() string
- func (r *Resource) HasLabelsField() bool
- func (r Resource) HasPostCreateComputedFields() bool
- func (r Resource) HasProject() bool
- func (r Resource) HasRegion() bool
- func (r Resource) HasZone() bool
- func (r Resource) IamAttributes() []string
- func (r Resource) IamImportFormat() string
- func (r Resource) IamImportFormatTemplate() string
- func (r Resource) IamImportFormats() []string
- func (r Resource) IamImportParams() []string
- func (r Resource) IamImportQualifiersForTest() string
- func (r Resource) IamImportQualifiersForTestSample() string
- func (r Resource) IamParentResourceName() string
- func (r Resource) IamParentSourceType() string
- func (r Resource) IamResourceParams() []string
- func (r Resource) IamResourceProperties() []*Type
- func (r Resource) IamResourceUri() string
- func (r Resource) IamResourceUriFormat() string
- func (r Resource) IamResourceUriStringQualifiers() string
- func (r Resource) IamSelfLinkIdentifiers() []string
- func (r Resource) IamTerraformName() string
- func (r Resource) IgnoreCaiAssetName() bool
- func (r Resource) IgnoreReadLabelsFields(props []*Type) []string
- func (r Resource) IgnoreReadProperties(s *resource.Step) []string
- func (r Resource) IgnoreReadPropertiesLegacy(e *resource.Examples) []string
- func (r Resource) IgnoreReadPropertiesToString(s *resource.Step) string
- func (r Resource) IgnoreReadPropertiesToStringLegacy(e *resource.Examples) string
- func (r Resource) ImportIdFormatsFromIam() []string
- func (r Resource) ImportIdFormatsFromResource() []string
- func (r Resource) ImportIdRegexesFromIam() string
- func (r Resource) InPostCreateComputed(prop Type) bool
- func (r Resource) IncludeProjectForOperation() bool
- func (r Resource) IsExcluded() bool
- func (r Resource) IsInIamResourceParams(param string) bool
- func (r Resource) IsInIdentity(t Type) bool
- func (r Resource) IsSettableProperty(t *Type) bool
- func (r Resource) IsTgcCompiler() bool
- func (r Resource) LastNestedQueryKey() string
- func (r Resource) Lineage() string
- func (r Resource) ListUrlTemplate() string
- func (r Resource) MarkdownHeader(templatePath string) string
- func (r *Resource) MarshalYAML() (interface{}, error)
- func (r Resource) MinVersionObj() *product.Version
- func (r Resource) NotInVersion(version *product.Version) bool
- func (r Resource) OrderProperties(props []*Type) []*Type
- func (r Resource) OutputFieldSetStr() string
- func (r Resource) PackageName() string
- func (r Resource) PropertiesByCustomUpdate(properties []*Type) map[UpdateGroup][]*Type
- func (r Resource) PropertiesByCustomUpdateGroups() []UpdateGroup
- func (r Resource) PropertiesWithExcluded() []*Type
- func (r Resource) PropertyNamesToStrings(properties []*Type) []string
- func (r Resource) RawImportIdFormatsFromIam() []string
- func (r Resource) ReadProperties() []*Type
- func (r Resource) ReadPropertiesForTgc() []*Type
- func (r Resource) RequiredProperties() []*Type
- func (r Resource) ResourceListKey() string
- func (r Resource) ResourceName() string
- func (r Resource) RootLabels() bool
- func (r Resource) RootProperties() []*Type
- func (r Resource) SamplePrimaryResourceId() string
- func (r Resource) SelfLinkUri() string
- func (r Resource) SelfLinkUrl() string
- func (r Resource) SensitiveProps() []*Type
- func (r Resource) SensitivePropsToString() string
- func (r Resource) ServiceVersion() string
- func (r *Resource) SetCompiler(t string)
- func (r *Resource) SetDefault(product *Product)
- func (r Resource) SettableProperties() []*Type
- func (r Resource) ShouldDatasourceSetAnnotations() bool
- func (r Resource) ShouldDatasourceSetLabels() bool
- func (r *Resource) ShouldGenerateSingularDataSource() bool
- func (r *Resource) ShouldGenerateSingularDataSourceTests() bool
- func (r Resource) ShouldGenerateSweepers() bool
- func (r Resource) StateMigrationFile() string
- func (r Resource) StateUpgradersCount() []int
- func (r Resource) TGCTestIgnorePropertiesToStrings() []string
- func (r Resource) TerraformName() string
- func (r Resource) TestExamples() []*resource.Examples
- func (r Resource) TestSampleSetUp(sysfs fs.FS)
- func (r Resource) TestSamples() []*resource.Sample
- func (r Resource) UnorderedListProperties() []*Type
- func (r Resource) Updatable() bool
- func (r Resource) UpdateBodyProperties() []*Type
- func (r Resource) UpdateUri() string
- func (r Resource) UserParameters() []*Type
- func (r Resource) UserProperites() []*Type
- func (r Resource) UserVirtualFields() []*Type
- func (r *Resource) Validate()
- func (r Resource) VersionedProvider(exampleVersion string) bool
- func (r Resource) WriteOnlyProps() []*Type
- func (r Resource) WriteOnlyPropsToString() string
- type TGCResource
- type TestConfig
- type Timeouts
- type Type
- func (t Type) AllProperties() []*Type
- func (t Type) ApiLineage() []string
- func (t Type) AtLeastOneOfList() []string
- func (t Type) CamelizeProperty() string
- func (t Type) Conflicting() []string
- func (t Type) Deprecated() bool
- func (t Type) EnumValuesToString(quoteSeperator string, addEmpty bool) string
- func (t Type) ExactlyOneOfList() []string
- func (t *Type) ExcludeIfNotInVersion(version *product.Version)
- func (t Type) FWResourceType() string
- func (t *Type) FieldType() []string
- func (t *Type) GetDescription() string
- func (t Type) GetFWType() string
- func (t *Type) GetIdFormat() string
- func (t *Type) GetPrefix() string
- func (t *Type) GetPropertySchemaPath(schemaPath string) string
- func (t Type) GetPropertySchemaPathList(propertyList []string) []string
- func (t *Type) GoLiteral(value interface{}) string
- func (t Type) IsA(clazz string) bool
- func (t *Type) IsForceNew() bool
- func (t Type) IsJsonField() bool
- func (t Type) IsResourceRefFound() bool
- func (t Type) ItemTypeClass() string
- func (t Type) Lineage() []string
- func (t *Type) MarshalYAML() (interface{}, error)
- func (t Type) MinVersionObj() *product.Version
- func (t Type) NamespaceProperty() string
- func (t Type) NestedProperties() []*Type
- func (t Type) Parent() *Type
- func (t Type) PropertyNsPrefix() []string
- func (t *Type) ProviderOnly() bool
- func (t Type) Removed() bool
- func (t Type) RequiredWithList() []string
- func (t Type) ResourceRef() *Resource
- func (t Type) ResourceType() string
- func (t *Type) RootProperties() []*Type
- func (t *Type) SetDefault(r *Resource)
- func (t Type) ShouldIgnoreCustomFlatten() bool
- func (t Type) TFType(s string) string
- func (t Type) TGCSendEmptyValue() bool
- func (t Type) TitlelizeProperty() string
- func (t Type) UserProperties() []*Type
- func (t *Type) Validate(rName string)
- func (t Type) WriteOnlyProperties() []*Type
- type UpdateGroup
Constants ¶
const DEFAULT_DELETE_TIMEOUT_MINUTES = 20
const DEFAULT_INSERT_TIMEOUT_MINUTES = 20
Default timeout for all operation types is 20, the Terraform default (https://www.terraform.io/plugin/sdkv2/resources/retries-and-customizable-timeouts) minutes. This can be overridden for each resource.
const DEFAULT_UPDATE_TIMEOUT_MINUTES = 20
const GITHUB_BASE_URL = "https://github.com/GoogleCloudPlatform/magic-modules/tree/main/" + RELATIVE_MAGICIAN_LOCATION
const MAX_NAME = 20
const RELATIVE_MAGICIAN_LOCATION = "mmv1/"
Variables ¶
This section is empty.
Functions ¶
func CompareByName ¶
func ImportIdFormats ¶
Returns a list of import id formats for a given resource. If an id contains provider-default values, this fn will return formats both including and omitting the value.
If a resource has an explicit import_format value set, that will be the base import url used. Next, the values of `identity` will be used to construct a URL. Finally, `{{name}}` will be used by default.
For instance, if the resource base url is:
projects/{{project}}/global/networks
It returns 3 formats: a) self_link: projects/{{project}}/global/networks/{{name}} b) short id: {{project}}/{{name}} c) short id w/o defaults: {{name}}
Types ¶
type Async ¶
type Async struct {
// Describes an operation, one of "OpAsync", "PollAsync"
Type string `yaml:"type,omitempty"`
// Describes an operation
Operation *Operation `yaml:"operation,omitempty"`
// The list of methods where operations are used.
Actions []string `yaml:"actions,omitempty"`
OpAsync `yaml:",inline"`
PollAsync `yaml:",inline"`
}
Base class from which other Async classes can inherit.
func (*Async) MarshalYAML ¶
MarshalYAML implements a custom marshaller for the Async struct. It omits fields that are set to their default values.
type OpAsync ¶
type OpAsync struct {
Result OpAsyncResult `yaml:"result,omitempty"`
// If true, include project as an argument to OperationWaitTime.
// It is intended for resources that calculate project/region from a selflink field
IncludeProject bool `yaml:"include_project,omitempty"`
}
Represents an asynchronous operation definition
type OpAsyncOperation ¶
type OpAsyncResult ¶
type OpAsyncResult struct {
ResourceInsideResponse bool `yaml:"resource_inside_response,omitempty"`
}
Represents the results of an Operation request
type Operation ¶
type Operation struct {
Timeouts *Timeouts
OpAsyncOperation `yaml:",inline"`
}
The main implementation of Operation, corresponding to common GCP Operation resources.
func NewOperation ¶
func NewOperation() *Operation
type PollAsync ¶
type PollAsync struct {
// Function to call for checking the Poll response for
// creating and updating a resource
CheckResponseFuncExistence string `yaml:"check_response_func_existence,omitempty"`
// Function to call for checking the Poll response for
// deleting a resource
CheckResponseFuncAbsence string `yaml:"check_response_func_absence,omitempty"`
// If true, will suppress errors from polling and default to the
// result of the final Read()
SuppressError bool `yaml:"suppress_error,omitempty"`
// Number of times the desired state has to occur continuously
// during polling before returning a success
TargetOccurrences int `yaml:"target_occurrences,omitempty"`
}
Async implementation for polling in Terraform
type Product ¶
type Product struct {
// The name of the product's API capitalised in the appropriate places.
// This isn't just the API name because it doesn't meaningfully separate
// words in the api name - "accesscontextmanager" vs "AccessContextManager"
// Example inputs: "Compute", "AccessContextManager"
Name string
// This is the name of the package path relative to mmv1 root repo
PackagePath string `yaml:"package_path,omitempty"`
// original value of :name before the provider override happens
// same as :name if not overridden in provider
ApiName string `yaml:"api_name,omitempty"`
// Display Name: The full name of the GCP product; eg "Cloud Bigtable"
DisplayName string `yaml:"display_name,omitempty"`
Objects []*Resource `yaml:"objects,omitempty"`
// The list of permission scopes available for the service
// For example: `https://www.googleapis.com/auth/compute`
Scopes []string
// The API versions of this product
Versions []*product.Version
// The base URL for the service API endpoint
// For example: `https://www.googleapis.com/compute/v1/`
BaseUrl string `yaml:"base_url,omitempty"`
// The validator "relative URI" of a resource, relative to the product
// base URL. Specific to defining the resource as a CAI asset.
CaiBaseUrl string `yaml:"caibaseurl,omitempty"`
// The service name from CAI asset name, e.g. bigtable.googleapis.com.
CaiAssetService string `yaml:"cai_asset_service,omitempty"`
// CaiResourceType of resources that already have an AssetType constant defined in the product.
ResourcesWithCaiAssetType map[string]struct{} `yaml:"resourceswithcaiassettype,omitempty"`
// A function reference designed for the rare case where you
// need to use retries in operation calls. Used for the service api
// as it enables itself (self referential) and can result in occasional
// failures on operation_get. see github.com/hashicorp/terraform-provider-google/issues/9489
OperationRetry string `yaml:"operation_retry,omitempty"`
Async *Async `yaml:"async,omitempty"`
LegacyName string `yaml:"legacy_name,omitempty"`
ClientName string `yaml:"client_name,omitempty"`
// The compiler to generate the downstream files, for example "terraformgoogleconversion-codegen".
Compiler string `yaml:"-"`
}
Represents a product to be managed
func (*Product) ExistsAtVersion ¶
func (*Product) ExistsAtVersionOrLower ¶
func (Product) Lineage ¶
Prints a dot notation path to where the field is nested within the parent object when called on a property. eg: parent.meta.label.foo Redefined on Product to terminate the calls up the parent chain.
func (*Product) ServiceBaseUrl ¶
func (*Product) ServiceName ¶
func (*Product) ServiceVersion ¶
func (*Product) SetApiName ¶
func (p *Product) SetApiName()
func (*Product) SetCompiler ¶
func (*Product) SetDisplayName ¶
func (p *Product) SetDisplayName()
The product full name is the "display name" in string form intended for users to read in documentation; "Google Compute Engine", "Cloud Bigtable"
func (*Product) SetPropertiesBasedOnVersion ¶
func (*Product) TerraformName ¶
type Resource ¶
type Resource struct {
Name string
// original value of :name before the provider override happens
// same as :name if not overridden in provider
ApiName string `yaml:"api_name,omitempty"`
// [Required] A description of the resource that's surfaced in provider
// documentation.
Description string
// [Required] Reference links provided in
// downstream documentation. Expected to follow the format as follows:
//
// references:
// guides:
// 'Guide name': 'official_documentation_url'
// api: 'rest_api_reference_url/version'
//
References resource.ReferenceLinks `yaml:"references,omitempty"`
Docs resource.Docs `yaml:"docs,omitempty"`
// [Required] The GCP "relative URI" of a resource, relative to the product
// base URL. It can often be inferred from the `create` path.
BaseUrl string `yaml:"base_url,omitempty"`
// ====================
// Common Configuration
// ====================
//
// [Optional] The minimum API version this resource is in. Defaults to ga.
MinVersion string `yaml:"min_version,omitempty"`
// [Optional] If set to true, don't generate the resource.
Exclude bool `yaml:"exclude,omitempty"`
// [Optional] If set to true, the resource is not able to be updated.
Immutable bool `yaml:"immutable,omitempty"`
// [Optional] If set to true, this resource uses an update mask to perform
// updates. This is typical of newer GCP APIs.
UpdateMask bool `yaml:"update_mask,omitempty"`
// [Optional] If set to true, the object has a `self_link` field. This is
// typical of older GCP APIs.
HasSelfLink bool `yaml:"has_self_link,omitempty"`
// [Optional] The validator "relative URI" of a resource, relative to the product
// base URL. Specific to defining the resource as a CAI asset.
CaiBaseUrl string `yaml:"cai_base_url,omitempty"`
// ====================
// URL / HTTP Configuration
// ====================
//
// [Optional] The "identity" URL of the resource. Defaults to:
// * base_url when the create_verb is POST
// * self_link when the create_verb is PUT or PATCH
SelfLink string `yaml:"self_link,omitempty"`
// [Optional] The URL used to creating the resource. Defaults to:
// * collection url when the create_verb is POST
// * self_link when the create_verb is PUT or PATCH
CreateUrl string `yaml:"create_url,omitempty"`
// [Optional] The URL used to delete the resource. Defaults to the self
// link.
DeleteUrl string `yaml:"delete_url,omitempty"`
// [Optional] The URL used to update the resource. Defaults to the self
// link.
UpdateUrl string `yaml:"update_url,omitempty"`
// [Optional] The HTTP verb used during create. Defaults to POST.
CreateVerb string `yaml:"create_verb,omitempty"`
// [Optional] The HTTP verb used during read. Defaults to GET.
ReadVerb string `yaml:"read_verb,omitempty"`
// [Optional] The HTTP verb used during update. Defaults to PUT.
UpdateVerb string `yaml:"update_verb,omitempty"`
// [Optional] The HTTP verb used during delete. Defaults to DELETE.
DeleteVerb string `yaml:"delete_verb,omitempty"`
// [Optional] Additional Query Parameters to append to GET. Defaults to ""
ReadQueryParams string `yaml:"read_query_params,omitempty"`
// ====================
// Collection / Identity URL Configuration
// ====================
//
// [Optional] This is the name of the list of items
// within the collection (list) json. Will default to the
// camelcase plural name of the resource.
CollectionUrlKey string `yaml:"collection_url_key,omitempty"`
// [Optional] An ordered list of names of parameters that uniquely identify
// the resource.
// Generally, it's safe to leave empty, in which case it defaults to `name`.
// Other values are normally useful in cases where an object has a parent
// and is identified by some non-name value, such as an ip+port pair.
// If you're writing a fine-grained resource (eg with nested_query) a value
// must be set.
Identity []string `yaml:"identity,omitempty"`
// [Optional] (Api::Resource::NestedQuery) This is useful in case you need
// to change the query made for GET requests only. In particular, this is
// often used to extract an object from a parent object or a collection.
// Note that if both nested_query and custom_code.decoder are provided,
// the decoder will be included within the code handling the nested query.
NestedQuery *resource.NestedQuery `yaml:"nested_query,omitempty"`
// ====================
// IAM Configuration
// ====================
//
// [Optional] (Api::Resource::IamPolicy) Configuration of a resource's
// resource-specific IAM Policy.
IamPolicy *resource.IamPolicy `yaml:"iam_policy,omitempty"`
// [Optional] If set to true, don't generate the resource itself; only
// generate the IAM policy.
// TODO rewrite: rename?
ExcludeResource bool `yaml:"exclude_resource,omitempty"`
// [Optional] GCP kind, e.g. `compute//disk`
Kind string `yaml:"kind,omitempty"`
// [Optional] If set to true, indicates that a resource is not configurable
// such as GCP regions.
Readonly bool `yaml:"readonly,omitempty"`
// ====================
// Terraform Overrides
// ====================
// [Optional] If non-empty, overrides the full filename prefix
// i.e. google/resource_product_{{resource_filename_override}}.go
// i.e. google/resource_product_{{resource_filename_override}}_test.go
FilenameOverride string `yaml:"filename_override,omitempty"`
// If non-empty, overrides the full given resource name.
// i.e. 'google_project' for resourcemanager.Project
// Use Provider::Terraform::Config.legacy_name to override just
// product name.
// Note: This should not be used for vanity names for new products.
// This was added to handle preexisting handwritten resources that
// don't match the natural generated name exactly, and to support
// services with a mix of handwritten and generated resources.
LegacyName string `yaml:"legacy_name,omitempty"`
// The Terraform resource id format used when calling //setId(...).
// For instance, `{{name}}` means the id will be the resource name.
IdFormat string `yaml:"id_format,omitempty"`
// Override attribute used to handwrite the formats for generating regex strings
// that match templated values to a self_link when importing, only necessary when
// a resource is not adequately covered by the standard provider generated options.
// Leading a token with `%`
// i.e. {{%parent}}/resource/{{resource}}
// will allow that token to hold multiple /'s.
//
// Expected to be formatted as follows:
//
// import_format:
// - example_import_one
// - example_import_two
//
ImportFormat []string `yaml:"import_format,omitempty"`
CustomCode resource.CustomCode `yaml:"custom_code,omitempty"`
// This block inserts entries into the customdiff.All() block in the
// resource schema -- the code for these custom diff functions must
// be included in the resource constants or come from tpgresource
CustomDiff []string `yaml:"custom_diff,omitempty"`
// Lock name for a mutex to prevent concurrent API calls for a given
// resource.
Mutex string `yaml:"mutex,omitempty"`
// Examples in documentation. Backed by generated tests, and have
// corresponding OiCS walkthroughs.
Examples []*resource.Examples `yaml:"examples,omitempty"`
// Samples for generating tests and documentation
Samples []*resource.Sample `yaml:"samples,omitempty"`
// If true, generates product operation handling logic.
AutogenAsync bool `yaml:"autogen_async,omitempty"`
// If true, resource is not importable
ExcludeImport bool `yaml:"exclude_import,omitempty"`
// If true, resource should be autogenerated as a data source
Datasource *resource.Datasource `yaml:"datasource,omitempty"`
// If true, skip sweeper generation for this resource
ExcludeSweeper bool `yaml:"exclude_sweeper,omitempty"`
// Override sweeper settings
Sweeper resource.Sweeper `yaml:"sweeper,omitempty"`
Timeouts *Timeouts `yaml:"timeouts,omitempty"`
Async *Async `yaml:"async,omitempty"`
// An array of function names that determine whether an error is retryable.
ErrorRetryPredicates []string `yaml:"error_retry_predicates,omitempty"`
// An array of function names that determine whether an error is not retryable.
ErrorAbortPredicates []string `yaml:"error_abort_predicates,omitempty"`
// Optional attributes for declaring a resource's current version and generating
// state_upgrader code to the output .go file from files stored at
// mmv1/templates/terraform/state_migrations/
// used for maintaining state stability with resources first provisioned on older api versions.
SchemaVersion int `yaml:"schema_version,omitempty"`
// From this schema version on, state_upgrader code is generated for the resource.
// When unset, state_upgrade_base_schema_version defauts to 0.
// Normally, it is not needed to be set.
StateUpgradeBaseSchemaVersion int `yaml:"state_upgrade_base_schema_version,omitempty"`
StateUpgraders bool `yaml:"state_upgraders,omitempty"`
// Do not apply the default attribution label
ExcludeAttributionLabel bool `yaml:"exclude_attribution_label,omitempty"`
// This block inserts the named function and its attribute into the
// resource schema -- the code for the migrate_state function must
// be included in the resource constants or come from tpgresource
// included for backwards compatibility as an older state migration method
// and should not be used for new resources.
MigrateState string `yaml:"migrate_state,omitempty"`
// Set to true for resources that are unable to be deleted, such as KMS keyrings or project
// level resources such as firebase project
ExcludeDelete bool `yaml:"exclude_delete,omitempty"`
// Set to true for resources that are unable to be read from the API, such as
// public ca external account keys
ExcludeRead bool `yaml:"exclude_read,omitempty"`
// Set to true for resources that wish to disable automatic generation of default provider
// value customdiff functions
// TODO rewrite: 1 instance used
ExcludeDefaultCdiff bool `yaml:"exclude_default_cdiff,omitempty"`
// This enables resources that get their project via a reference to a different resource
// instead of a project field to use User Project Overrides
SupportsIndirectUserProjectOverride bool `yaml:"supports_indirect_user_project_override,omitempty"`
// If true, the resource's project field can be specified as either the short form project
// id or the long form projects/project-id. The extra projects/ string will be removed from
// urls and ids. This should only be used for resources that previously supported long form
// project ids for backwards compatibility.
LegacyLongFormProject bool `yaml:"legacy_long_form_project,omitempty"`
// Function to transform a read error so that handleNotFound recognises
// it as a 404. This should be added as a handwritten fn that takes in
// an error and returns one.
ReadErrorTransform string `yaml:"read_error_transform,omitempty"`
// If true, resources that failed creation will be marked as tainted. As a consequence
// these resources will be deleted and recreated on the next apply call. This pattern
// is preferred over deleting the resource directly in post_create_failure hooks.
TaintResourceOnFailedCreate bool `yaml:"taint_resource_on_failed_create,omitempty"`
// Add a deprecation message for a resource that's been deprecated in the API.
DeprecationMessage string `yaml:"deprecation_message,omitempty"`
// Tag autogen resources so that we can track them. In the future this will
// control if a resource is continuously generated from public OpenAPI docs
AutogenStatus string `yaml:"autogen_status"`
// WARNING: this is an incomplete feature and may have several build errors.
// If true, this resource generates with the new plugin framework resource template
FrameworkResource bool `yaml:"plugin_framework,omitempty"`
// Virtual fields are Terraform-only fields that control Terraform's
// behaviour. They don't map to underlying API fields (although they
// may map to parameters), and will require custom code to be added to
// control them.
//
// Virtual fields are similar to url_param_only fields in that they create
// a schema entry which is not read from or submitted to the API. However
// virtual fields are meant to provide toggles for Terraform-specific behavior in a resource
// (eg: delete_contents_on_destroy) whereas url_param_only fields _should_
// be used for url construction.
//
// Both are resource level fields and do not make sense, and are also not
// supported, for nested fields. Nested fields that shouldn't be included
// in API payloads are better handled with custom expand/encoder logic.
VirtualFields []*Type `yaml:"virtual_fields,omitempty"`
Parameters []*Type
Properties []*Type
ProductMetadata *Product `yaml:"-"`
// The version name provided by the user through CI
TargetVersionName string `yaml:"-"`
// The compiler to generate the downstream files, for example "terraformgoogleconversion-codegen".
Compiler string `yaml:"-"`
// The API "resource type kind" used for this resource e.g., "Function".
// If this is not set, then :name is used instead, which is strongly
// preferred wherever possible. Its main purpose is for supporting
// fine-grained resources and legacy resources.
ApiResourceTypeKind string `yaml:"api_resource_type_kind,omitempty"`
// The API URL patterns used by this resource that represent variants e.g.,
// "folders/{folder}/feeds/{feed}". Each pattern must match the value
// defined in the API exactly. The use of `api_variant_patterns` is only
// meaningful when the resource type has multiple parent types available.
// This is commonly used for resources that have a project, folder, and
// organization variant, however most resources do not need it.
ApiVariantPatterns []string `yaml:"api_variant_patterns,omitempty"`
// ApiResourceField indicates what field on the API resource is managed by a resource.
// This is generally relevant for fine-grained resources. For example,
// google_compute_router_nat manages the `nat` field on the `Router` resource.
ApiResourceField string `yaml:"api_resource_field,omitempty"`
ImportPath string `yaml:"-"`
SourceYamlFile string `yaml:"-"`
// ====================
// TGC
// ====================
TGCResource `yaml:",inline"`
// contains filtered or unexported fields
}
func (*Resource) AddExtraFields ¶
AddExtraFields processes properties and adds supplementary fields based on property types. It handles write-only properties, labels, and annotations.
func (Resource) AllNestedProperties ¶
func (Resource) AllProperties ¶
Returns all properties and parameters including the ones that are excluded. This is used for PropertyOverride validation
func (Resource) AllPropertiesInVersion ¶
func (Resource) AllUserProperties ¶
Return the user-facing properties in client tools; this ends up meaning both properties and parameters but without any that are excluded due to version mismatches or manual exclusion
func (Resource) CAIFormatOverride ¶
Gets a format string that is used to override the default format from resource id format
func (Resource) Cai2hclAssetNameTemplate ¶
Gets a format string for CAI asset name
func (Resource) CaiApiVersion ¶
Gets the Cai API version
func (Resource) CaiAssetType ¶
Returns the asset type for this resource.
func (Resource) CaiIamAssetNameTemplate ¶
Gets the Cai IAM asset name template For example: //monitoring.googleapis.com/v3/projects/{{project}}/services/{{service_id}}
func (Resource) CaiIamResourceParams ¶
For example: the uri "projects/{{project}}/schemas/{{name}}" The paramerter is "schema" as "project" is not returned.
func (Resource) CaiProductBackendName ¶
Returns the Cai product backend name from the version base url base_url: https://accessapproval.googleapis.com/v1/ -> accessapproval
func (Resource) CaiProductBaseUrl ¶
func (Resource) CaiProductLegacyBaseUrl ¶
Gets the CAI product legacy base url. For example, https://www.googleapis.com/compute/v1/ for compute
func (Resource) CaiResourceName ¶
The API resource type of the resource. Normally, it is the resource name. Rarely, it is the API "resource type kind" or CAI "resource kind" For example, the CAI resource type of "google_compute_autoscaler" is "Autoscaler". The CAI resource type of "google_compute_region_autoscaler" is also "Autoscaler".
func (Resource) CaiResourceType ¶
For example, the CAI resource type with product of "google_compute_autoscaler" is "ComputeAutoscalerAssetType". The CAI resource type with product of "google_compute_region_autoscaler" is also "ComputeAutoscalerAssetType".
func (Resource) ClientNamePascal ¶
Handwritten TF Operation objects will be shaped like accessContextManager while the Google Go Client will have a name like accesscontextmanager
func (Resource) CodeHeader ¶
func (Resource) CollectionUrl ¶
func (Resource) CustomUpdatePropertiesByKey ¶
func (Resource) DatasourceOptionalFields ¶
DatasourceOptionalFields returns a list of fields from the resource's URI that should be marked as "Optional".
func (Resource) DatasourceRequiredFields ¶
DatasourceOptionalFields returns a list of fields from the resource's URI that should be marked as "Required".
func (Resource) DefineAssetTypeForResourceInProduct ¶
DefineAssetTypeForResourceInProduct marks the AssetType constant for this resource as defined. It returns true if this is the first time it's been called for this resource, and false otherwise, preventing duplicate definitions.
func (Resource) DeleteUrlTemplate ¶
func (Resource) ExamplePrimaryResourceId ¶
func (*Resource) ExcludeIfNotInVersion ¶
Recurses through all nested properties and parameters and changes their 'exclude' instance variable if the property is at a version below the one that is passed in.
func (Resource) ExtractIdentifiers ¶
For example, for the url "projects/{{project}}/schemas/{{schema}}", the identifiers are "project", "schema".
func (Resource) FieldSpecificUpdateMethods ¶
func (Resource) FirstIamImportIdFormat ¶
For example, projects/{{project}}/schemas/{{schema}}
func (Resource) FirstIdentityProp ¶
func (Resource) FirstTestConfig ¶
func (r Resource) FirstTestConfig() TestConfig
Use the first valid config to create datasource and IAM resource test
func (Resource) FirstTestExample ¶
Since most resources define a "basic" config as their first example, we can reuse that config to create a resource to test IAM resources with.
func (Resource) FlattenedProperties ¶
func (Resource) FormatDocDescription ¶
Formats whitespace in the style of the old Ruby generator's descriptions in documentation
func (Resource) GetAsync ¶
Return the product-level async object, or the resource-specific one if one exists.
func (Resource) GetCaiAssetNameFormat ¶
Gets the Cai asset name format
func (Resource) GetCaiAssetNameTemplate ¶
Gets a format string for CAI asset name
func (Resource) GetIdFormat ¶
Returns the id format of an object, or self_link_uri if none is explicitly defined We prefer the long name of a resource as the id so that users can reference resources in a standard way, and most APIs accept short name, long name or self_link
func (Resource) GetIdentity ¶
Return the resource-specific identity properties, or a best guess of the `name` value for the resource.
func (Resource) GetPropertyUpdateMasksGroupKeys ¶
func (Resource) GetPropertyUpdateMasksGroups ¶
func (Resource) GetTimeouts ¶
In order of preference, use TF override, general defined timeouts, or default Timeouts
func (Resource) GettableProperties ¶
Properties that will be returned in the API body
func (*Resource) HasLabelsField ¶
func (Resource) HasPostCreateComputedFields ¶
Returns true if at least one of the fields in the ID format is computed
func (Resource) HasProject ¶
func (Resource) IamAttributes ¶
Returns the attributes from the selflink url
func (Resource) IamImportFormat ¶
func (Resource) IamImportFormatTemplate ¶
func (Resource) IamImportFormats ¶
func (Resource) IamImportParams ¶
func (Resource) IamImportQualifiersForTest ¶
func (Resource) IamImportQualifiersForTestSample ¶
func (Resource) IamParentResourceName ¶
==================== Iam Methods ====================
func (Resource) IamParentSourceType ¶
func (Resource) IamResourceParams ¶
For example: the uri "projects/{{project}}/schemas/{{name}}" The paramerters are "project", "schema".
func (Resource) IamResourceProperties ¶
Returns the resource properties that are idenfifires in Iam resource when generating the docs. The "project" and "organization" properties are excluded, as they are handled seperated in the docs.
func (Resource) IamResourceUri ¶
For example: "projects/{{project}}/schemas/{{name}}"
func (Resource) IamResourceUriFormat ¶
For example: "projects/%s/schemas/%s"
func (Resource) IamResourceUriStringQualifiers ¶
For example: for the uri "projects/{{project}}/schemas/{{name}}", the string qualifiers are "u.project, u.schema"
func (Resource) IamSelfLinkIdentifiers ¶
func (Resource) IamTerraformName ¶
func (Resource) IgnoreCaiAssetName ¶
Ignores verifying CAI asset name if it is one computed field For example, the CAI asset name format is //monitoring.googleapis.com/{{name}} for google_monitoring_notification_channel
func (Resource) IgnoreReadLabelsFields ¶
Return labels fields that should be added to ImportStateVerifyIgnore
func (Resource) IgnoreReadProperties ¶
IgnoreReadProperties returns a sorted slice of property names (snake_case) that should be ignored when reading. This is useful for downstream code that needs to iterate over these properties.
func (Resource) IgnoreReadPropertiesLegacy ¶
IgnoreReadPropertiesLegacy is the legacy version of IgnoreReadProperties for Examples IgnoreReadProperties returns a sorted slice of property names (snake_case) that should be ignored when reading. This is useful for downstream code that needs to iterate over these properties.
func (Resource) IgnoreReadPropertiesToString ¶
IgnoreReadPropertiesToString returns the ignore read properties as a Go-syntax string slice. This is a wrapper around IgnoreReadProperties for backwards compatibility.
func (Resource) IgnoreReadPropertiesToStringLegacy ¶
IgnoreReadPropertiesToStringLegacy is the legacy version of IgnoreReadPropertiesToString for Examples IgnoreReadPropertiesToString returns the ignore read properties as a Go-syntax string slice. This is a wrapper around IgnoreReadProperties for backwards compatibility.
func (Resource) ImportIdFormatsFromIam ¶
For example, "projects/{{project}}/schemas/{{name}}", "{{project}}/{{name}}", "{{name}}"
func (Resource) ImportIdFormatsFromResource ¶
func (Resource) ImportIdRegexesFromIam ¶
For example, projects/(?P<project>[^/]+)/schemas/(?P<schema>[^/]+)", "(?P<project>[^/]+)/(?P<schema>[^/]+)", "(?P<schema>[^/]+)
func (Resource) InPostCreateComputed ¶
Returns true if the Type is in the ID format and false otherwise.
func (Resource) IncludeProjectForOperation ¶
func (Resource) IsExcluded ¶
func (Resource) IsInIamResourceParams ¶
func (Resource) IsInIdentity ¶
func (Resource) IsSettableProperty ¶
func (Resource) IsTgcCompiler ¶
func (Resource) LastNestedQueryKey ¶
func (Resource) Lineage ¶
Prints a dot notation path to where the field is nested within the parent object when called on a property. eg: parent.meta.label.foo Redefined on Resource to terminate the calls up the parent chain.
func (Resource) ListUrlTemplate ¶
func (Resource) MarkdownHeader ¶
func (*Resource) MarshalYAML ¶
// MarshalYAML implements a custom marshaller to omit dynamic default values.
func (Resource) MinVersionObj ¶
==================== Version-related methods ====================
func (Resource) OrderProperties ¶
func (Resource) OutputFieldSetStr ¶
OutputFieldSetStr returns a Go-syntax string representation of a set containing all the output properties for a resource. The property names are converted to snake_case. This is useful for generating code that requires a map literal of field names.
func (Resource) PackageName ¶
func (Resource) PropertiesByCustomUpdate ¶
func (r Resource) PropertiesByCustomUpdate(properties []*Type) map[UpdateGroup][]*Type
func (Resource) PropertiesByCustomUpdateGroups ¶
func (r Resource) PropertiesByCustomUpdateGroups() []UpdateGroup
func (Resource) PropertiesWithExcluded ¶
func (Resource) PropertyNamesToStrings ¶
func (Resource) RawImportIdFormatsFromIam ¶
For example, "projects/{{project}}/schemas/{{name}}", "{{project}}/{{name}}", "{{name}}"
func (Resource) ReadProperties ¶
==================== Template Methods ==================== Functions used to create slices of resource properties that could not otherwise be called from within generating templates.
func (Resource) ReadPropertiesForTgc ¶
Filters out computed properties during cai2hcl
func (Resource) RequiredProperties ¶
func (Resource) ResourceListKey ¶
Returns the key of the list of resources in the List API response Used to get the list of resources to sweep
func (Resource) ResourceName ¶
func (Resource) RootLabels ¶
Check if the resource has root "labels" field
func (Resource) RootProperties ¶
Returns the list of top-level properties once any nested objects with flatten_object set to true have been collapsed
func (Resource) SamplePrimaryResourceId ¶
func (Resource) SelfLinkUri ¶
Returns the partial uri / relative path of a resource. In newer resources, this is the name. This fn is named self_link_uri for consistency, but could otherwise be considered to be "path"
func (Resource) SelfLinkUrl ¶
Returns the "self_link_url" which is generally really the resource's GET URL. In older resources generally, this was the self_link value & was the product.base_url + resource.base_url + '/name' In newer resources there is much less standardisation in terms of value. Generally for them though, it's the product.base_url + resource.name
func (Resource) SensitiveProps ¶
func (Resource) SensitivePropsToString ¶
func (Resource) ServiceVersion ¶
func (*Resource) SetCompiler ¶
func (*Resource) SetDefault ¶
SetDefault sets default values for this Resource and all its properties.
func (Resource) SettableProperties ¶
All settable properties in the resource. Fingerprints aren't *really" settable properties, but they behave like one. At Create, they have no value but they can just be read in anyways, and after a Read they will need to be set in every Update.
func (Resource) ShouldDatasourceSetAnnotations ¶
func (Resource) ShouldDatasourceSetLabels ¶
func (*Resource) ShouldGenerateSingularDataSource ¶
func (*Resource) ShouldGenerateSingularDataSourceTests ¶
func (Resource) ShouldGenerateSweepers ¶
func (Resource) StateMigrationFile ¶
func (Resource) StateUpgradersCount ¶
func (Resource) TGCTestIgnorePropertiesToStrings ¶
TGC Methods ==================== Lists fields that test.BidirectionalConversion should ignore
func (Resource) TerraformName ¶
func (Resource) TestExamples ¶
func (Resource) TestSampleSetUp ¶
func (Resource) TestSamples ¶
func (Resource) UnorderedListProperties ¶
func (Resource) Updatable ¶
resource functions needed for template that previously existed in terraform.go but due to how files are being inherited here it was easier to put in here taken wholesale from tpgtools
func (Resource) UpdateBodyProperties ¶
func (Resource) UserParameters ¶
func (Resource) UserProperites ¶
func (Resource) UserVirtualFields ¶
func (Resource) VersionedProvider ¶
func (Resource) WriteOnlyProps ¶
func (Resource) WriteOnlyPropsToString ¶
type TGCResource ¶
type TGCResource struct {
// If true, exclude resource from Terraform Validator
// (i.e. terraform-provider-conversion)
ExcludeTgc bool `yaml:"exclude_tgc,omitempty"`
// If true, include resource in the new package of TGC (terraform-provider-conversion)
IncludeInTGCNext bool `yaml:"include_in_tgc_next,omitempty"`
// The resource kind in CAI.
// If this is not set, then :name is used instead.
// For example: compute.googleapis.com/Address has Address for CaiResourceKind,
// and compute.googleapis.com/GlobalAddress has GlobalAddress for CaiResourceKind.
// But they have the same api resource type: address
CaiResourceKind string `yaml:"cai_resource_kind,omitempty"`
// If true, the Terraform custom encoder is not applied during tfplan2cai
TGCIgnoreTerraformEncoder bool `yaml:"tgc_ignore_terraform_encoder,omitempty"`
// If true, the Terraform custom decoder is not applied during cai2hcl
TGCIgnoreTerraformDecoder bool `yaml:"tgc_ignore_terraform_decoder,omitempty"`
// [Optional] The parameter that uniquely identifies the resource.
// Generally, it shouldn't be set when the identity can be decided.
// Otherswise, it should be set.
CaiIdentity string `yaml:"cai_identity,omitempty"`
// If true, create TGC tests automatically for all handwritten provider tests.
TGCIncludeHandwrittenTests bool `yaml:"tgc_include_handwritten_tests,omitempty"`
// Tests for TGC, will automatically be filled with resource's examples
// and handwritten tests. Can be specified in order to skip specific tests.
TGCTests []resource.TGCTest `yaml:"tgc_tests,omitempty"`
// [Optional] It overrides the default Cai asset name format, which is the resource id format
CaiAssetNameFormat string `yaml:"cai_asset_name_format,omitempty"`
// [Optional] It overrides the Cai asset name format during cai2hcl conversion.
// Its usage is strictly limited to scenarios requiring the extraction of parameters
// from the Google Cloud Asset Inventory (CAI) asset name format
Cai2hclNameFormat string `yaml:"cai2hcl_name_format,omitempty"`
}
type Timeouts ¶
type Timeouts struct {
InsertMinutes int `yaml:"insert_minutes"`
UpdateMinutes int `yaml:"update_minutes"`
DeleteMinutes int `yaml:"delete_minutes"`
}
Provides timeout information for the different operation types
func NewTimeouts ¶
func NewTimeouts() *Timeouts
type Type ¶
type Type struct {
Name string `yaml:"name,omitempty"`
// original value of :name before the provider override happens
// same as :name if not overridden in provider
ApiName string `yaml:"api_name,omitempty"`
// TODO rewrite: improve the parsing of properties based on type in resource yaml files.
Type string
// For nested fields, this only applies within the parent.
// For example, an optional parent can contain a required child.
Required bool `yaml:"required,omitempty"`
DefaultValue interface{} `yaml:"default_value,omitempty"`
// Expected to follow the format as follows:
//
// description: |
// This is a description of a field.
// If it comprises multiple lines, it must continue to be indented.
//
Description string `yaml:"description,omitempty"`
Exclude bool `yaml:"exclude,omitempty"`
// Add a deprecation message for a field that's been deprecated in the API
// use the YAML chomping folding indicator (>-) if this is a multiline
// string, as providers expect a single-line one w/o a newline.
DeprecationMessage string `yaml:"deprecation_message,omitempty"`
// Add a removed message for fields no longer supported in the API. This should
// be used for fields supported in one version but have been removed from
// a different version.
RemovedMessage string `yaml:"removed_message,omitempty"`
// If set value will not be sent to server on sync.
// For nested fields, this also needs to be set on each descendant (ie. self,
// child, etc.).
Output bool `yaml:"output,omitempty"`
// If set to true, changes in the field's value require recreating the
// resource.
// For nested fields, this only applies at the current level. This means
// it should be explicitly added to each field that needs the ForceNew
// behavior.
Immutable bool `yaml:"immutable,omitempty"`
// Indicates that this field is client-side only (aka virtual.)
ClientSide bool `yaml:"client_side,omitempty"`
// url_param_only will not send the field in the resource body and will
// not attempt to read the field from the API response.
// NOTE - this doesn't work for nested fields
UrlParamOnly bool `yaml:"url_param_only,omitempty"`
// Additional query Parameters to append to GET calls.
ReadQueryParams string `yaml:"read_query_params,omitempty"`
UpdateVerb string `yaml:"update_verb,omitempty"`
UpdateUrl string `yaml:"update_url,omitempty"`
// Some updates only allow updating certain fields at once (generally each
// top-level field can be updated one-at-a-time). If this is set, we group
// fields to update by (verb, url, fingerprint, id) instead of just
// (verb, url, fingerprint), to allow multiple fields to reuse the same
// endpoints.
UpdateId string `yaml:"update_id,omitempty"`
// The fingerprint value required to update this field. Downstreams should
// GET the resource and parse the fingerprint value while doing each update
// call. This ensures we can supply the fingerprint to each distinct
// request.
FingerprintName string `yaml:"fingerprint_name,omitempty"`
// If true, we will include the empty value in requests made including
// this attribute (both creates and updates). This rarely needs to be
// set to true, and corresponds to both the "NullFields" and
// "ForceSendFields" concepts in the autogenerated API clients.
SendEmptyValue bool `yaml:"send_empty_value,omitempty"`
// [Optional] If true, empty nested objects are sent to / read from the
// API instead of flattened to null.
// The difference between this and send_empty_value is that send_empty_value
// applies when the key of an object is empty; this applies when the values
// are all nil / default. eg: "expiration: null" vs "expiration: {}"
// In the case of Terraform, this occurs when a block in config has optional
// values, and none of them are used. Terraform returns a nil instead of an
// empty map[string]interface{} like we'd expect.
AllowEmptyObject bool `yaml:"allow_empty_object,omitempty"`
MinVersion string `yaml:"min_version,omitempty"`
ExactVersion string `yaml:"exact_version,omitempty"`
// A list of properties that conflict with this property. Uses the "lineage"
// field to identify the property eg: parent.meta.label.foo
Conflicts []string `yaml:"conflicts,omitempty"`
// A list of properties that at least one of must be set.
AtLeastOneOf []string `yaml:"at_least_one_of,omitempty"`
// A list of properties that exactly one of must be set.
ExactlyOneOf []string `yaml:"exactly_one_of,omitempty"`
// A list of properties that are required to be set together.
RequiredWith []string `yaml:"required_with,omitempty"`
// Shared constraint group pointers (populated post-unmarshal)
ConflictsGroup *([]string) `yaml:"-"`
AtLeastOneOfGroup *([]string) `yaml:"-"`
ExactlyOneOfGroup *([]string) `yaml:"-"`
RequiredWithGroup *([]string) `yaml:"-"`
// Can only be overridden - we should never set this ourselves.
NewType string `yaml:"-"`
Properties []*Type `yaml:"properties,omitempty"`
EnumValues []string `yaml:"enum_values,omitempty"`
ExcludeDocsValues bool `yaml:"exclude_docs_values,omitempty"`
// ====================
// Array Fields
// ====================
ItemType *Type `yaml:"item_type,omitempty"`
MinSize string `yaml:"min_size,omitempty"`
MaxSize string `yaml:"max_size,omitempty"`
// Adds a ValidateFunc to the item schema
ItemValidation resource.Validation `yaml:"item_validation,omitempty"`
ParentName string `yaml:"parent_name,omitempty"`
// ====================
// ResourceRef Fields
// ====================
Resource string `yaml:"resource,omitempty"`
Imports string `yaml:"imports,omitempty"`
// Adds a DiffSuppressFunc to the schema
DiffSuppressFunc string `yaml:"diff_suppress_func,omitempty"`
StateFunc string `yaml:"state_func,omitempty"` // Adds a StateFunc to the schema
Sensitive bool `yaml:"sensitive,omitempty"` // Adds `Sensitive: true` to the schema
// If true, write-only arguments will be automatically generated for this field.
// (`[field_name]_wo` and `[field_name]_wo_version`).
// For more information, see: https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/write-only-arguments
WriteOnly bool `yaml:"write_only,omitempty"`
// TODO: remove this field after all references are migrated
// see: https://github.com/GoogleCloudPlatform/magic-modules/pull/14933#pullrequestreview-3166578379
WriteOnlyLegacy bool `yaml:"write_only_legacy,omitempty"` // Adds `WriteOnlyLegacy: true` to the schema
// Does not set this value to the returned API value. Useful for fields
// like secrets where the returned API value is not helpful.
IgnoreRead bool `yaml:"ignore_read,omitempty"`
// Adds a ValidateFunc to the schema
Validation resource.Validation `yaml:"validation,omitempty"`
// Indicates that this is an Array that should have Set diff semantics.
UnorderedList bool `yaml:"unordered_list,omitempty"`
IsSet bool `yaml:"is_set,omitempty"` // Uses a Set instead of an Array
// Optional function to determine the unique ID of an item in the set
// If not specified, schema.HashString (when elements are string) or
// schema.HashSchema are used.
SetHashFunc string `yaml:"set_hash_func,omitempty"`
// if true, then we get the default value from the Google API if no value
// is set in the terraform configuration for this field.
// It translates to setting the field to Computed & Optional in the schema.
// For nested fields, this only applies at the current level. This means
// it should be explicitly added to each field that needs the defaulting
// behavior.
DefaultFromApi bool `yaml:"default_from_api,omitempty"`
// https://github.com/hashicorp/terraform/pull/20837
// Apply a ConfigMode of SchemaConfigModeAttr to the field.
// This should be avoided for new fields, and only used with old ones.
SchemaConfigModeAttr bool `yaml:"schema_config_mode_attr,omitempty"`
// Names of fields that should be included in the updateMask.
UpdateMaskFields []string `yaml:"update_mask_fields,omitempty"`
// For a TypeMap, the expander function to call on the key.
// Defaults to expandString.
KeyExpander string `yaml:"key_expander,omitempty"`
// For a TypeMap, the DSF to apply to the key.
KeyDiffSuppressFunc string `yaml:"key_diff_suppress_func,omitempty"`
// ====================
// Map Fields
// ====================
// The type definition of the contents of the map.
ValueType *Type `yaml:"value_type,omitempty"`
// While the API doesn't give keys an explicit name, we specify one
// because in Terraform the key has to be a property of the object.
//
// The name of the key. Used in the Terraform schema as a field name.
KeyName string `yaml:"key_name,omitempty"`
// A description of the key's format. Used in Terraform to describe
// the field in documentation.
KeyDescription string `yaml:"key_description,omitempty"`
// ====================
// KeyValuePairs Fields
// ====================
// Ignore writing the "effective_labels" and "effective_annotations" fields to API.
IgnoreWrite bool `yaml:"ignore_write,omitempty"`
// Flattens a NestedObject by removing that field from the Terraform
// schema but will preserve it in the JSON sent/retrieved from the API
//
// EX: a API schema where fields are nested (eg: `one.two.three`) and we
// desire the properties of the deepest nested object (eg: `three`) to
// become top level properties in the Terraform schema. By overriding
// the properties `one` and `one.two` and setting flatten_object then
// all the properties in `three` will be at the root of the TF schema.
//
// We need this for cases where a field inside a nested object has a
// default, if we can't spend a breaking change to fix a misshapen
// field, or if the UX is _much_ better otherwise.
//
// WARN: only fully flattened properties are currently supported. In the
// example above you could not flatten `one.two` without also flattening
// all of it's parents such as `one`
FlattenObject bool `yaml:"flatten_object,omitempty"`
// A custom expander replaces the default expander for an attribute.
// It is called as part of Create, and as part of Update if
// object.input is false. It can return an object of any type,
// so the function header *is* part of the custom code template.
// As with flatten, `property` and `prefix` are available.
CustomExpand string `yaml:"custom_expand,omitempty"`
// A custom flattener replaces the default flattener for an attribute.
// It is called as part of Read. It can return an object of any
// type, and may sometimes need to return an object with non-interface{}
// type so that the d.Set() call will succeed, so the function
// header *is* a part of the custom code template. To help with
// creating the function header, `property` and `prefix` are available,
// just as they are in the standard flattener template.
CustomFlatten string `yaml:"custom_flatten,omitempty"`
ResourceMetadata *Resource `yaml:"-"`
ParentMetadata *Type `yaml:"-"`
// The prefix used as part of the property expand/flatten function name
// flatten{{$.GetPrefix}}{{$.TitlelizeProperty}}
Prefix string `yaml:"prefix,omitempty"`
// The field is not present in CAI asset
IsMissingInCai bool `yaml:"is_missing_in_cai,omitempty"`
// A custom expander replaces the default expander for an attribute.
// It is called as part of tfplan2cai conversion if
// object.input is false. It can return an object of any type,
// so the function header *is* part of the custom code template.
// As with flatten, `property` and `prefix` are available.
CustomTgcExpand string `yaml:"custom_tgc_expand,omitempty"`
// A custom flattener replaces the default flattener for an attribute.
// It is called as part of cai2hcl conversion. It can return an object of any type,
// so the function header *is* a part of the custom code template. To help with
// creating the function header, `property` and `prefix` are available,
// just as they are in the standard flattener template.
CustomTgcFlatten string `yaml:"custom_tgc_flatten,omitempty"`
// If true, the empty value of this attribute in CAI asset is included.
IncludeEmptyValueInCai bool `yaml:"include_empty_value_in_cai,omitempty"`
// If the property is type of bool and has `defaul_from_api: true`,
// include empty value in CAI asset by default during tfplan2cai conversion.
// Use `exclude_false_in_cai` to override the default behavior
// when the default value on API side is true.
//
// If a property is missing in CAI asset, use `is_missing_in_cai: true`
// and `exclude_false_in_cai: true` is not needed
ExcludeFalseInCai bool `yaml:"exclude_false_in_cai,omitempty"`
// If true, the custom flatten function is not applied during cai2hcl
TGCIgnoreTerraformCustomFlatten bool `yaml:"tgc_ignore_terraform_custom_flatten,omitempty"`
TGCIgnoreRead bool `yaml:"tgc_ignore_read,omitempty"`
}
Represents a property type
func NewProperty ¶
An array of string -> string key -> value pairs, such as labels. While this is technically a map, it's split out because it's a much simpler property to generate and means we can avoid conditional logic in Map.
func (Type) AllProperties ¶
Returns all properties including the ones that are excluded This is used for PropertyOverride validation
func (Type) ApiLineage ¶
Returns a slice of API field names representing where the field is nested within the parent resource. For example, []string{"parentField", "meta", "label", "fooBar"}. For fine-grained resources, this will include the field on the API resource that the fine-grained resource manages.
func (Type) AtLeastOneOfList ¶
Returns list of properties that needs at least one of their fields set. func (t *Type) at_least_one_of_list() {
func (Type) CamelizeProperty ¶
func (Type) Conflicting ¶
Returns list of properties that are in conflict with this property. func (t *Type) conflicting() {
func (Type) Deprecated ¶
func (Type) EnumValuesToString ¶
func (Type) ExactlyOneOfList ¶
Returns list of properties that needs exactly one of their fields set. func (t *Type) exactly_one_of_list() {
func (*Type) ExcludeIfNotInVersion ¶
func (Type) FWResourceType ¶
func (*Type) GetDescription ¶
func (*Type) GetIdFormat ¶
func (*Type) GetPrefix ¶
If the Prefix field is already set, returns the value. Otherwise, set the Prefix field and returns the value.
func (*Type) GetPropertySchemaPath ¶
Returns an updated path for a given Terraform field path (e.g. 'a_field', 'parent_field.0.child_name'). Returns nil if the property is not included in the resource's properties and removes keys that have been flattened FYI: Fields that have been renamed should use the new name, however, flattened fields still need to be included, ie: flattenedField > newParent > renameMe should be passed to this function as flattened_field.0.new_parent.0.im_renamed TODO: Change format of input for exactly_one_of/at_least_one_of/etc to use camelcase, MM properities and convert to snake in this method
func (Type) GetPropertySchemaPathList ¶
func (*Type) IsForceNew ¶
func (Type) IsJsonField ¶
func (Type) IsResourceRefFound ¶
Checks if the referenced resource is in the same product or not
func (Type) Lineage ¶
Returns a slice of Terraform field names representing where the field is nested within the parent resource. For example, []string{"parent_field", "meta", "label", "foo_bar"}.
func (*Type) MarshalYAML ¶
func (Type) MinVersionObj ¶
func (Type) NamespaceProperty ¶
"Namespace" - prefix with product and resource - a property with information from the "object" variable
func (Type) NestedProperties ¶
Returns nested properties for this property.
func (Type) PropertyNsPrefix ¶
func (*Type) ProviderOnly ¶
Returns true if the type does not correspond to an API type
func (Type) RequiredWithList ¶
Returns list of properties that needs required with their fields set.
func (Type) ResourceRef ¶
func (Type) ResourceType ¶
func (*Type) RootProperties ¶
Returns the list of top-level properties once any nested objects with flatten_object set to true have been collapsed
func (*Type) SetDefault ¶
SetDefault recursively sets default values for this Type and all its children. This is used during the initial unmarshalling/compilation phase.
func (Type) ShouldIgnoreCustomFlatten ¶
func (Type) TGCSendEmptyValue ¶
Checks if the empty value should be set in CAI assets during tfplan2cai conversion
func (Type) TitlelizeProperty ¶
func (Type) UserProperties ¶
func (Type) WriteOnlyProperties ¶
Returns write-only properties for this property.