ci: regenerated with OpenAPI Doc 0.0.3, Speakeasy CLI 1.133.1

This commit is contained in:
speakeasybot
2024-01-05 19:51:29 +00:00
parent eccef7b78c
commit 0538f5b367
20 changed files with 272 additions and 52 deletions

View File

@@ -1,19 +1,19 @@
lockVersion: 2.0.0
id: e742591b-391d-4f4e-8484-d01a093b32ec
management:
docChecksum: 550154cf1b4d0c237436fb18c418b5db
docChecksum: 34d22936f2456c2c461abdfc773e3fc4
docVersion: 0.0.3
speakeasyVersion: internal
generationVersion: 2.225.2
releaseVersion: 0.1.0
configChecksum: d92408a91beb4360d3ade54235c386a6
generationVersion: 2.228.1
releaseVersion: 0.2.0
configChecksum: aa46c3314b27098c848b44960a4abd53
repoURL: https://github.com/LukeHagar/plexterraform.git
repoSubDirectory: .
published: true
features:
terraform:
constsAndDefaults: 0.1.2
core: 3.7.0
core: 3.8.0
globalSecurity: 2.81.2
globalServerURLs: 2.82.1
nameOverrides: 2.81.1

View File

@@ -61,7 +61,7 @@ terraform {
required_providers {
PlexAPI = {
source = "LukeHagar/PlexAPI"
version = "0.1.0"
version = "0.2.0"
}
}
}

View File

@@ -14,4 +14,12 @@ Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.130.1 (2.225.2) https://github.com/speakeasy-api/speakeasy
### Generated
- [terraform v0.1.0] .
- [terraform v0.1.0] .
## 2024-01-05 19:50:57
### Changes
Based on:
- OpenAPI Doc 0.0.3
- Speakeasy CLI 1.133.1 (2.228.1) https://github.com/speakeasy-api/speakeasy
### Generated
- [terraform v0.2.0] .

View File

@@ -17,7 +17,7 @@ terraform {
required_providers {
PlexAPI = {
source = "LukeHagar/PlexAPI"
version = "0.1.0"
version = "0.2.0"
}
}
}
@@ -33,4 +33,4 @@ provider "PlexAPI" {
### Optional
- `access_token` (String, Sensitive)
- `server_url` (String) Server URL (defaults to http://10.10.10.47:32400)
- `server_url` (String) Server URL (defaults to {protocol}://{ip}:{port})

View File

@@ -2,7 +2,7 @@ terraform {
required_providers {
PlexAPI = {
source = "LukeHagar/PlexAPI"
version = "0.1.0"
version = "0.2.0"
}
}
}

View File

@@ -8,7 +8,7 @@ generation:
fixes:
nameResolutionDec2023: false
terraform:
version: 0.1.0
version: 0.2.0
author: LukeHagar
imports:
option: openapi

View File

@@ -9,13 +9,24 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
)
const (
// Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions]
Standard = iota
// ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation
ExplicitSuppress = iota
)
// SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown
func SuppressDiff() planmodifier.Bool {
return suppressDiff{}
func SuppressDiff(strategy int) planmodifier.Bool {
return suppressDiff{
strategy: strategy,
}
}
// suppressDiff implements the plan modifier.
type suppressDiff struct{}
type suppressDiff struct {
strategy int
}
// Description returns a human-readable description of the plan modifier.
func (m suppressDiff) Description(_ context.Context) string {
@@ -42,6 +53,9 @@ func (m suppressDiff) PlanModifyBool(ctx context.Context, req planmodifier.BoolR
if utils.IsAllStateUnknown(ctx, req.State) {
return
}
if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) {
return
}
resp.PlanValue = req.StateValue
}

View File

@@ -9,13 +9,24 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
)
const (
// Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions]
Standard = iota
// ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation
ExplicitSuppress = iota
)
// SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown
func SuppressDiff() planmodifier.Float64 {
return suppressDiff{}
func SuppressDiff(strategy int) planmodifier.Float64 {
return suppressDiff{
strategy: strategy,
}
}
// suppressDiff implements the plan modifier.
type suppressDiff struct{}
type suppressDiff struct {
strategy int
}
// Description returns a human-readable description of the plan modifier.
func (m suppressDiff) Description(_ context.Context) string {
@@ -42,6 +53,9 @@ func (m suppressDiff) PlanModifyFloat64(ctx context.Context, req planmodifier.Fl
if utils.IsAllStateUnknown(ctx, req.State) {
return
}
if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) {
return
}
resp.PlanValue = req.StateValue
}

View File

@@ -9,13 +9,24 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
)
const (
// Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions]
Standard = iota
// ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation
ExplicitSuppress = iota
)
// SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown
func SuppressDiff() planmodifier.Int64 {
return suppressDiff{}
func SuppressDiff(strategy int) planmodifier.Int64 {
return suppressDiff{
strategy: strategy,
}
}
// suppressDiff implements the plan modifier.
type suppressDiff struct{}
type suppressDiff struct {
strategy int
}
// Description returns a human-readable description of the plan modifier.
func (m suppressDiff) Description(_ context.Context) string {
@@ -42,6 +53,9 @@ func (m suppressDiff) PlanModifyInt64(ctx context.Context, req planmodifier.Int6
if utils.IsAllStateUnknown(ctx, req.State) {
return
}
if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) {
return
}
resp.PlanValue = req.StateValue
}

View File

@@ -9,13 +9,24 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
)
const (
// Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions]
Standard = iota
// ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation
ExplicitSuppress = iota
)
// SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown
func SuppressDiff() planmodifier.List {
return suppressDiff{}
func SuppressDiff(strategy int) planmodifier.List {
return suppressDiff{
strategy: strategy,
}
}
// suppressDiff implements the plan modifier.
type suppressDiff struct{}
type suppressDiff struct {
strategy int
}
// Description returns a human-readable description of the plan modifier.
func (m suppressDiff) Description(_ context.Context) string {
@@ -42,6 +53,9 @@ func (m suppressDiff) PlanModifyList(ctx context.Context, req planmodifier.ListR
if utils.IsAllStateUnknown(ctx, req.State) {
return
}
if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) {
return
}
resp.PlanValue = req.StateValue
}

View File

@@ -9,13 +9,24 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
)
const (
// Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions]
Standard = iota
// ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation
ExplicitSuppress = iota
)
// SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown
func SuppressDiff() planmodifier.Map {
return suppressDiff{}
func SuppressDiff(strategy int) planmodifier.Map {
return suppressDiff{
strategy: strategy,
}
}
// suppressDiff implements the plan modifier.
type suppressDiff struct{}
type suppressDiff struct {
strategy int
}
// Description returns a human-readable description of the plan modifier.
func (m suppressDiff) Description(_ context.Context) string {
@@ -42,6 +53,9 @@ func (m suppressDiff) PlanModifyMap(ctx context.Context, req planmodifier.MapReq
if utils.IsAllStateUnknown(ctx, req.State) {
return
}
if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) {
return
}
resp.PlanValue = req.StateValue
}

View File

@@ -9,13 +9,24 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
)
const (
// Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions]
Standard = iota
// ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation
ExplicitSuppress = iota
)
// SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown
func SuppressDiff() planmodifier.Number {
return suppressDiff{}
func SuppressDiff(strategy int) planmodifier.Number {
return suppressDiff{
strategy: strategy,
}
}
// suppressDiff implements the plan modifier.
type suppressDiff struct{}
type suppressDiff struct {
strategy int
}
// Description returns a human-readable description of the plan modifier.
func (m suppressDiff) Description(_ context.Context) string {
@@ -42,6 +53,9 @@ func (m suppressDiff) PlanModifyNumber(ctx context.Context, req planmodifier.Num
if utils.IsAllStateUnknown(ctx, req.State) {
return
}
if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) {
return
}
resp.PlanValue = req.StateValue
}

View File

@@ -9,13 +9,24 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
)
const (
// Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions]
Standard = iota
// ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation
ExplicitSuppress = iota
)
// SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown
func SuppressDiff() planmodifier.Object {
return suppressDiff{}
func SuppressDiff(strategy int) planmodifier.Object {
return suppressDiff{
strategy: strategy,
}
}
// suppressDiff implements the plan modifier.
type suppressDiff struct{}
type suppressDiff struct {
strategy int
}
// Description returns a human-readable description of the plan modifier.
func (m suppressDiff) Description(_ context.Context) string {
@@ -42,6 +53,9 @@ func (m suppressDiff) PlanModifyObject(ctx context.Context, req planmodifier.Obj
if utils.IsAllStateUnknown(ctx, req.State) {
return
}
if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) {
return
}
resp.PlanValue = req.StateValue
}

View File

@@ -9,13 +9,24 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
)
const (
// Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions]
Standard = iota
// ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation
ExplicitSuppress = iota
)
// SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown
func SuppressDiff() planmodifier.Set {
return suppressDiff{}
func SuppressDiff(strategy int) planmodifier.Set {
return suppressDiff{
strategy: strategy,
}
}
// suppressDiff implements the plan modifier.
type suppressDiff struct{}
type suppressDiff struct {
strategy int
}
// Description returns a human-readable description of the plan modifier.
func (m suppressDiff) Description(_ context.Context) string {
@@ -42,6 +53,9 @@ func (m suppressDiff) PlanModifySet(ctx context.Context, req planmodifier.SetReq
if utils.IsAllStateUnknown(ctx, req.State) {
return
}
if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) {
return
}
resp.PlanValue = req.StateValue
}

View File

@@ -9,13 +9,24 @@ import (
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
)
const (
// Standard suppresses "(known after changes)" messages unless there's an explicit change in state [excluding null <=> unknown transitions]
Standard = iota
// ExplicitSuppress strategy suppresses "(known after changes)" messages unless we're in the initial creation
ExplicitSuppress = iota
)
// SuppressDiff returns a plan modifier that propagates a state value into the planned value, when it is Known, and the Plan Value is Unknown
func SuppressDiff() planmodifier.String {
return suppressDiff{}
func SuppressDiff(strategy int) planmodifier.String {
return suppressDiff{
strategy: strategy,
}
}
// suppressDiff implements the plan modifier.
type suppressDiff struct{}
type suppressDiff struct {
strategy int
}
// Description returns a human-readable description of the plan modifier.
func (m suppressDiff) Description(_ context.Context) string {
@@ -42,6 +53,9 @@ func (m suppressDiff) PlanModifyString(ctx context.Context, req planmodifier.Str
if utils.IsAllStateUnknown(ctx, req.State) {
return
}
if m.strategy == Standard && utils.IsAnyKnownChange(ctx, req.Plan, req.State) {
return
}
resp.PlanValue = req.StateValue
}

View File

@@ -23,3 +23,91 @@ func IsAllStateUnknown(ctx context.Context, state tfsdk.State) bool {
return !anyFound
}
func IsAnyKnownChange(ctx context.Context, plan tfsdk.Plan, state tfsdk.State) bool {
attrs := state.Schema.GetAttributes()
anyFound := false
for k, _ := range attrs {
stateValue := new(attr.Value)
planValue := new(attr.Value)
state.GetAttribute(ctx, path.Root(k), stateValue)
plan.GetAttribute(ctx, path.Root(k), planValue)
anyFound = !isKnownEqual(ctx, stateValue, planValue)
if anyFound {
break
}
}
return anyFound
}
type HasElements interface {
Elements() []attr.Value
IsUnknown() bool
IsNull() bool
}
type HasAttributes interface {
Attributes() map[string]attr.Value
IsUnknown() bool
IsNull() bool
}
func isKnownEqual(ctx context.Context, a *attr.Value, b *attr.Value) bool {
if (*a).IsUnknown() || (*b).IsUnknown() {
return true
}
aType := (*a).Type(ctx)
bType := (*b).Type(ctx)
if !aType.Equal(bType) {
return false
}
attributeTypes, ok := aType.(attr.TypeWithAttributeTypes)
if ok {
check := true
for k, _ := range attributeTypes.AttributeTypes() {
objValA, isObjA := (*a).(HasAttributes)
objValB, isObjB := (*b).(HasAttributes)
if isObjA && isObjB {
if objValA.IsUnknown() || objValB.IsUnknown() {
continue
}
attrA, foundA := objValA.Attributes()[k]
attrB, foundB := objValB.Attributes()[k]
if foundA != foundB {
return false
}
if foundA {
check = isKnownEqual(ctx, &attrA, &attrB)
}
}
if !check {
break
}
}
return check
}
_, ok = aType.(attr.TypeWithElementType)
if ok {
aVal, aValList := (*a).(HasElements)
bVal, bValList := (*b).(HasElements)
if aValList && bValList {
if ((aVal).IsUnknown() || (aVal).IsNull()) && ((bVal).IsUnknown() || (bVal).IsNull()) {
return true
}
if len(aVal.Elements()) != len(bVal.Elements()) {
return false
} else {
for i, _ := range aVal.Elements() {
if !isKnownEqual(ctx, &aVal.Elements()[i], &bVal.Elements()[i]) {
return false
}
}
}
return true
}
return false
}
isEqual := (*a).Equal(*b)
return isEqual
}

View File

@@ -6,7 +6,6 @@ import (
"context"
"github.com/LukeHagar/terraform-provider-PlexAPI/internal/sdk"
"github.com/LukeHagar/terraform-provider-PlexAPI/internal/sdk/pkg/models/shared"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/provider/schema"
@@ -39,7 +38,7 @@ func (p *PlexAPIProvider) Schema(ctx context.Context, req provider.SchemaRequest
Description: `An Open API Spec for interacting with Plex.tv and Plex Servers`,
Attributes: map[string]schema.Attribute{
"server_url": schema.StringAttribute{
MarkdownDescription: "Server URL (defaults to http://10.10.10.47:32400)",
MarkdownDescription: "Server URL (defaults to {protocol}://{ip}:{port})",
Optional: true,
Required: false,
},
@@ -63,7 +62,7 @@ func (p *PlexAPIProvider) Configure(ctx context.Context, req provider.ConfigureR
ServerURL := data.ServerURL.ValueString()
if ServerURL == "" {
ServerURL = "http://10.10.10.47:32400"
ServerURL = "{protocol}://{ip}:{port}"
}
accessToken := data.AccessToken.ValueString()

View File

@@ -69,15 +69,17 @@ func merge(ctx context.Context, req resource.UpdateRequest, resp *resource.Updat
return
}
// we need a tftypes.Value for this Object to be able to use it with
// our reflection code
refreshPlan(ctx, plan, target, resp.Diagnostics)
}
func refreshPlan(ctx context.Context, plan types.Object, target interface{}, diagnostics diag.Diagnostics) {
obj := types.ObjectType{AttrTypes: plan.AttributeTypes(ctx)}
val, err := plan.ToTerraformValue(ctx)
if err != nil {
resp.Diagnostics.Append(diag.NewErrorDiagnostic("Object Conversion Error", "An unexpected error was encountered trying to convert object. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error()))
diagnostics.Append(diag.NewErrorDiagnostic("Object Conversion Error", "An unexpected error was encountered trying to convert object. This is always an error in the provider. Please report the following to the provider developer:\n\n"+err.Error()))
return
}
resp.Diagnostics.Append(tfReflect.Into(ctx, obj, val, target, tfReflect.Options{
diagnostics.Append(tfReflect.Into(ctx, obj, val, target, tfReflect.Options{
UnhandledNullAsEmpty: true,
UnhandledUnknownAsEmpty: true,
}, path.Empty())...)

View File

@@ -14,8 +14,6 @@ import (
// ServerList contains the list of servers available to the SDK
var ServerList = []string{
// The full address of your Plex Server
"http://10.10.10.47:32400",
// The full address of your Plex Server
"{protocol}://{ip}:{port}",
}
@@ -261,11 +259,10 @@ func New(opts ...SDKOption) *PlexAPI {
sdkConfiguration: sdkConfiguration{
Language: "go",
OpenAPIDocVersion: "0.0.3",
SDKVersion: "0.1.0",
GenVersion: "2.225.2",
UserAgent: "speakeasy-sdk/go 0.1.0 2.225.2 0.0.3 PlexAPI",
SDKVersion: "0.2.0",
GenVersion: "2.228.1",
UserAgent: "speakeasy-sdk/go 0.2.0 2.228.1 0.0.3 PlexAPI",
ServerDefaults: []map[string]string{
{},
{
"protocol": "http",
"ip": "10.10.10.47",

View File

@@ -15,7 +15,7 @@ import (
// Run the docs generation tool, check its repository for more information on how it works and how docs
// can be customized.
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs generate --rendered-provider-name terraform-provider-plex-api
var (
// these will be set by the goreleaser configuration