apikey

package
v0.34.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MultiLevelResourceImporter = &schema.ResourceImporter{
	State: func(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
		parts := strings.Split(d.Id(), "/")

		partCount := len(parts)
		isAccountToken := partCount == 3
		isOrgToken := partCount == 4
		isProjectToken := partCount == 5

		if isAccountToken {
			d.SetId(parts[1])
			d.Set("parent_id", parts[0])
			d.Set("identifier", parts[1])
			d.Set("apikey_type", parts[2])
			return []*schema.ResourceData{d}, nil
		}

		if isOrgToken {
			d.SetId(parts[2])
			d.Set("org_id", parts[0])
			d.Set("parent_id", parts[1])
			d.Set("identifier", parts[2])
			d.Set("apikey_type", parts[3])
			return []*schema.ResourceData{d}, nil
		}

		if isProjectToken {
			d.SetId(parts[3])
			d.Set("org_id", parts[0])
			d.Set("project_id", parts[1])
			d.Set("parent_id", parts[2])
			d.Set("identifier", parts[3])
			d.Set("apikey_type", parts[4])
			return []*schema.ResourceData{d}, nil
		}

		return nil, fmt.Errorf("invalid identifier: %s", d.Id())
	},
}

Functions

func DataSourceApiKey

func DataSourceApiKey() *schema.Resource

func ResourceApiKey

func ResourceApiKey() *schema.Resource

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL