booksprovider

package
v0.0.0-...-dcf58f9 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package booksprovider implements the core Books Terraform Provider.

It is intended to be paired with `pkg/providershim`.

Index

Constants

View Source
const (
	// EnvVarBooksAPIAddr is the configuration environment variable that can
	// be used to specify the `addr` for the Books API. For example, this
	// value could equal `http://localhost:7534`.
	EnvVarBooksAPIAddr = "BOOKS_API_ADDR"
)

Variables

This section is empty.

Functions

func Configure

Configure is a function for configuring the provider.

Types

type DataSourceAuthor

type DataSourceAuthor struct {
	FirstName *string    `terraform:"first_name,required"`
	LastName  *string    `terraform:"last_name,required"`
	BookCount *int       `terraform:"book_count,computed"`
	ID        *uuid.UUID `terraform:"id,string,computed"`
	// contains filtered or unexported fields
}

DataSourceAuthor represents a `books_api_author` data source and directly interacts with the Terraform plugin SDK to check for new or updated values.

func NewDataSourceAuthor

func NewDataSourceAuthor(d *schema.ResourceData) (*DataSourceAuthor, error)

NewDataSourceAuthor creates a new `DataSourceAuthor` from a Terraform resource data struct.

func (*DataSourceAuthor) GetBookCount

func (dsa *DataSourceAuthor) GetBookCount() int

GetBookCount is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)

func (*DataSourceAuthor) GetFirstName

func (dsa *DataSourceAuthor) GetFirstName() string

GetFirstName is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)

func (*DataSourceAuthor) GetID

func (dsa *DataSourceAuthor) GetID() uuid.UUID

GetID is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)

func (*DataSourceAuthor) GetLastName

func (dsa *DataSourceAuthor) GetLastName() string

GetLastName is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)

func (*DataSourceAuthor) Persist

func (dsa *DataSourceAuthor) Persist() error

Persist writes back fields in this struct to the Terraform resource data struct based on the `terraform` struct tags. (The goal is to make code that can be autogenerated.)

NOTE: This method only takes a read lock for the exported fields,

`FirstName`, `LastName`, `BookCount` and `ID`. This method does do
some "writes" to `ra.d` but the lock is not intended to make
`schema.ResourceData` concurrency-safe (it is already via
`MapFieldWriter`).

func (*DataSourceAuthor) Populate

func (dsa *DataSourceAuthor) Populate() error

Populate populates the fields in this struct based on the `terraform` struct tags. (The goal is to make code that can be autogenerated.)

func (*DataSourceAuthor) Read

Read is the read (R) component of the CRUD lifecycle for the `books_api_author` data source.

NOTE: This assumes the called has already invoked `dsa.Populate()`, either

directly or indirectly, e.g. via `NewDataSourceAuthor()`.

func (*DataSourceAuthor) Schema

func (*DataSourceAuthor) Schema() map[string]*schema.Schema

Schema produces the Terraform Schema map. (The goal is to make code that can be autogenerated.)

type Date

type Date struct {
	time.Time
}

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

MarshalJSON marshals a `Date` into a JSON string in `YYYY-MM-DD` format.

func (Date) String

func (d Date) String() string

String presents the `Date` as a string in `YYYY-MM-DD` format.

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a string in `YYYY-MM-DD` format into a `Date`.

type ResourceAuthor

type ResourceAuthor struct {
	FirstName *string    `terraform:"first_name,required"`
	LastName  *string    `terraform:"last_name,required"`
	BookCount *int       `terraform:"book_count,computed"`
	ID        *uuid.UUID `terraform:"id,string,computed"`
	// contains filtered or unexported fields
}

ResourceAuthor represents a `books_api_author` resource and directly interacts with the Terraform plugin SDK to check for new or updated values.

func NewResourceAuthor

func NewResourceAuthor(d *schema.ResourceData) (*ResourceAuthor, error)

NewResourceAuthor creates a new `ResourceAuthor` from a Terraform resource data struct.

func (*ResourceAuthor) Changed

func (ra *ResourceAuthor) Changed() bool

Changed detects if any of the user input fields have changed. (The goal is to make code that can be autogenerated.)

func (*ResourceAuthor) Create

Create is the create (C) component of the CRUD lifecycle for the `books_api_author` resource.

NOTE: This assumes the called has already invoked `ra.Populate()`, either

directly or indirectly, e.g. via `NewResourceAuthor()`.

func (*ResourceAuthor) Delete

Delete is the delete (D) component of the CRUD lifecycle for the `books_api_author` resource.

NOTE: This assumes the called has already invoked `ra.Populate()`, either

directly or indirectly, e.g. via `NewResourceAuthor()`.

func (*ResourceAuthor) GetBookCount

func (ra *ResourceAuthor) GetBookCount() int

GetBookCount is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)

func (*ResourceAuthor) GetFirstName

func (ra *ResourceAuthor) GetFirstName() string

GetFirstName is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)

func (*ResourceAuthor) GetID

func (ra *ResourceAuthor) GetID() uuid.UUID

GetID is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)

func (*ResourceAuthor) GetLastName

func (ra *ResourceAuthor) GetLastName() string

GetLastName is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)

func (*ResourceAuthor) Persist

func (ra *ResourceAuthor) Persist() error

Persist writes back fields in this struct to the Terraform resource data struct based on the `terraform` struct tags. (The goal is to make code that can be autogenerated.)

NOTE: This method only takes a read lock for the exported fields,

`FirstName`, `LastName`, `BookCount` and `ID`. This method does do
some "writes" to `ra.d` but the lock is not intended to make
`schema.ResourceData` concurrency-safe (it is already via
`MapFieldWriter`).

func (*ResourceAuthor) Populate

func (ra *ResourceAuthor) Populate() error

Populate populates the fields in this struct based on the `terraform` struct tags. (The goal is to make code that can be autogenerated.)

func (*ResourceAuthor) Read

Read is the read (R) component of the CRUD lifecycle for the `books_api_author` resource.

NOTE: This assumes the called has already invoked `ra.Populate()`, either

directly or indirectly, e.g. via `NewResourceAuthor()`.

func (*ResourceAuthor) Schema

func (*ResourceAuthor) Schema() map[string]*schema.Schema

Schema produces the Terraform Schema map. (The goal is to make code that can be autogenerated.)

func (*ResourceAuthor) Update

Update is the update (U) component of the CRUD lifecycle for the `books_api_author` resource.

NOTE: This assumes the called has already invoked `ra.Populate()`, either

directly or indirectly, e.g. via `NewResourceAuthor()`.

type ResourceBook

type ResourceBook struct {
	Title       *string    `terraform:"title,required"`
	AuthorID    *uuid.UUID `terraform:"author_id,string,required"`
	PublishDate *Date      `terraform:"publish_date,string,required"`
	ID          *uuid.UUID `terraform:"id,string,computed"`
	// contains filtered or unexported fields
}

ResourceBook represents a `books_api_book` resource and directly interacts with the Terraform plugin SDK to check for new or updated values.

func NewResourceBook

func NewResourceBook(d *schema.ResourceData) (*ResourceBook, error)

NewResourceBook creates a new `ResourceBook` from a Terraform resource data struct.

func (*ResourceBook) Changed

func (rb *ResourceBook) Changed() bool

Changed detects if any of the user input fields have changed. (The goal is to make code that can be autogenerated.)

func (*ResourceBook) Create

func (rb *ResourceBook) Create(ctx context.Context, c booksclient.Client) error

Create is the create (C) component of the CRUD lifecycle for the `books_api_book` resource.

NOTE: This assumes the called has already invoked `rb.Populate()`, either

directly or indirectly, e.g. via `NewResourceBook()`.

func (*ResourceBook) Delete

func (rb *ResourceBook) Delete(ctx context.Context, c booksclient.Client) error

Delete is the delete (D) component of the CRUD lifecycle for the `books_api_book` resource.

NOTE: This assumes the called has already invoked `rb.Populate()`, either

directly or indirectly, e.g. via `NewResourceBook()`.

func (*ResourceBook) GetAuthorID

func (rb *ResourceBook) GetAuthorID() uuid.UUID

GetAuthorID is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)

func (*ResourceBook) GetID

func (rb *ResourceBook) GetID() uuid.UUID

GetID is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)

func (*ResourceBook) GetPublishDate

func (rb *ResourceBook) GetPublishDate() Date

GetPublishDate is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)

func (*ResourceBook) GetTitle

func (rb *ResourceBook) GetTitle() string

GetTitle is a value accessor for a pointer field; a safe dereference. (The goal is to make code that can be autogenerated.)

func (*ResourceBook) Persist

func (rb *ResourceBook) Persist() error

Persist writes back fields in this struct to the Terraform resource data struct based on the `terraform` struct tags. (The goal is to make code that can be autogenerated.)

NOTE: This method only takes a read lock for the exported fields,

`Title`, `AuthorID`, `PublishDate` and `ID`. This method does do
some "writes" to `ra.d` but the lock is not intended to make
`schema.ResourceData` concurrency-safe (it is already via
`MapFieldWriter`).

func (*ResourceBook) Populate

func (rb *ResourceBook) Populate() error

Populate populates the fields in this struct based on the `terraform` struct tags. (The goal is to make code that can be autogenerated.)

func (*ResourceBook) Read

Read is the read (R) component of the CRUD lifecycle for the `books_api_book` resource.

NOTE: This assumes the called has already invoked `rb.Populate()`, either

directly or indirectly, e.g. via `NewResourceBook()`.

func (*ResourceBook) Schema

func (*ResourceBook) Schema() map[string]*schema.Schema

Schema produces the Terraform Schema map. (The goal is to make code that can be autogenerated.)

func (*ResourceBook) Update

func (rb *ResourceBook) Update(ctx context.Context, c booksclient.Client) error

Update is the update (U) component of the CRUD lifecycle for the `books_api_book` resource.

NOTE: This assumes the called has already invoked `rb.Populate()`, either

directly or indirectly, e.g. via `NewResourceBook()`.

Jump to

Keyboard shortcuts

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