token

package
v0.30.4 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 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 == 4
		isOrgToken := partCount == 5
		isProjectToken := partCount == 6

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

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

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

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

Functions

func DataSourceToken

func DataSourceToken() *schema.Resource

func ResourceToken

func ResourceToken() *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