unstructured

package
v1.67.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: Apache-2.0 Imports: 6 Imported by: 9

Documentation

Overview

Copyright 2024 Google LLC. All Rights Reserved.

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. Package unstructured provides a generic unstructured client to invoke DCL.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNoSuchMethod is the error returned when calling Get, List, Apply, or Delete
	// on an API that doesn't support the requested method.
	ErrNoSuchMethod = errors.New("non-existent API method")
)

Functions

func Delete

func Delete(ctx context.Context, config *dcl.Config, r *Resource) error

Delete deletes the provided resource.

func DeletePolicyMember added in v1.1.0

func DeletePolicyMember(ctx context.Context, config *dcl.Config, r *Resource, m *Resource) error

DeletePolicyMember deletes the IAMPolicyMember for the provided resource.

func HasDiff

func HasDiff(ctx context.Context, config *dcl.Config, r *Resource, opts ...dcl.ApplyOption) (bool, error)

HasDiff returns whether the provided resource config matches the live resource, i.e., a return value of true indicates that calling Apply() will cause a creation or update of the live resource. The `opts` parameter can optionally include a state hint.

func ID

func ID(r *Resource) (string, error)

ID returns a unique ID for the provided resource.

func Register

func Register(rr RegisteredResource)

Register adds the provided resource to the list of resources available via the generic Get/List/Apply/Delete functions.

func WithStateHint

func WithStateHint(r *Resource) dcl.ApplyOption

WithStateHint performs the same function as dcl.WithStateHint, but takes an unstructured resource.

Types

type RegisteredResource

type RegisteredResource interface {
	// STV indicates the type of this resource.
	STV() ServiceTypeVersion

	// Get provides an indirection for the type-specific Get call.
	Get(ctx context.Context, config *dcl.Config, r *Resource) (*Resource, error)

	// Apply provides an indirection for the type-specific Apply call.
	Apply(ctx context.Context, config *dcl.Config, r *Resource, opts ...dcl.ApplyOption) (*Resource, error)

	// HasDiff provides an indirection for the type-specific HasDiff call.
	HasDiff(ctx context.Context, config *dcl.Config, r *Resource, opts ...dcl.ApplyOption) (bool, error)

	// Delete provides an indirection for the type-specific Delete call.
	Delete(ctx context.Context, config *dcl.Config, r *Resource) error

	// GetPolicy provides an indirection for the type-specific GetPolicy call.
	GetPolicy(ctx context.Context, config *dcl.Config, r *Resource) (*Resource, error)

	// SetPolicy provides an indirection for the type-specific SetPolicy call.
	SetPolicy(ctx context.Context, config *dcl.Config, r *Resource, p *Resource) (*Resource, error)

	// SetPolicyWithEtag provides an indirection for the type-specific SetPolicy call.
	SetPolicyWithEtag(ctx context.Context, config *dcl.Config, r *Resource, p *Resource) (*Resource, error)

	// GetPolicyMember provides an indirection for the type-specific GetPolicyMember call.
	GetPolicyMember(ctx context.Context, config *dcl.Config, r *Resource, role, member string) (*Resource, error)

	// SetPolicyMember provides an indirection for the type-specific SetPolicyMember call.
	SetPolicyMember(ctx context.Context, config *dcl.Config, r *Resource, m *Resource) (*Resource, error)

	// DeletePolicyMember provides an indirection for the type-specific DeletePolicyMember call.
	DeletePolicyMember(ctx context.Context, config *dcl.Config, r *Resource, m *Resource) error

	// ID returns a string uniquely identifying this resource.
	ID(r *Resource) (string, error)
}

RegisteredResource is used by generated unstructured library code to make type-specific operations available in a type-agnostic manner.

type Resource

type Resource struct {
	// ResourceWithPolicy is included so that the Resource struct can interact with the
	// IAMClient (IAMClient methods expect a ResourceWithPolicy)
	iam.ResourceWithPolicy

	// Object is a JSON compatible map with string, float, int,
	// bool, []interface{}, or map[string]interface{} children.
	Object map[string]interface{}

	// STV indicates the type of this resource
	STV ServiceTypeVersion
}

Resource is the untyped representation of a typed DCL resource.

func Apply

func Apply(ctx context.Context, config *dcl.Config, r *Resource, opts ...dcl.ApplyOption) (*Resource, error)

Apply creates or updates the provided resource.

func FetchStateHint

func FetchStateHint(c []dcl.ApplyOption) *Resource

FetchStateHint returns either nil or a Resource representing the pre-apply state.

func Get

func Get(ctx context.Context, config *dcl.Config, r *Resource) (*Resource, error)

Get returns the current version of a given resource (usually from the result of a previous Apply()).

func GetPolicy

func GetPolicy(ctx context.Context, config *dcl.Config, r *Resource) (*Resource, error)

GetPolicy gets the IAMPolicy for the provided resource.

func GetPolicyMember

func GetPolicyMember(ctx context.Context, config *dcl.Config, r *Resource, role, member string) (*Resource, error)

GetPolicyMember gets the IAMPolicyMember for the provided resource.

func SetPolicy

func SetPolicy(ctx context.Context, config *dcl.Config, r *Resource, p *Resource) (*Resource, error)

SetPolicy sets the IAMPolicy for the provided resource.

func SetPolicyMember

func SetPolicyMember(ctx context.Context, config *dcl.Config, r *Resource, m *Resource) (*Resource, error)

SetPolicyMember sets the IAMPolicyMember for the provided resource.

func SetPolicyWithEtag added in v1.1.0

func SetPolicyWithEtag(ctx context.Context, config *dcl.Config, r *Resource, p *Resource) (*Resource, error)

SetPolicyWithEtag sets the IAMPolicy using the etag container for the provided resource.

type ServiceTypeVersion

type ServiceTypeVersion struct {
	// Service to which this resource belongs, e.g., "compute".
	Service string
	// Type of the resource, e.g., "ComputeInstance"
	Type string
	// Version of the resource, e.g., "ga". There may be multiple versions of the
	// same Type and Service in a single DCL build.
	Version string
}

ServiceTypeVersion describes a single DCL resource.

func (ServiceTypeVersion) Equals

Equals compares two ServiceTypeVersion structures.

func (ServiceTypeVersion) String

func (stv ServiceTypeVersion) String() string

String returns a loggable description of this ServiceTypeVersion.

Directories

Path Synopsis
dlp
iam
iap

Jump to

Keyboard shortcuts

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