// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. package provider 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" "github.com/hashicorp/terraform-plugin-framework/resource" "github.com/hashicorp/terraform-plugin-framework/types" ) var _ provider.Provider = &PlexAPIProvider{} type PlexAPIProvider struct { // version is set to the provider version on release, "dev" when the // provider is built and ran locally, and "test" when running acceptance // testing. version string } // PlexAPIProviderModel describes the provider data model. type PlexAPIProviderModel struct { ServerURL types.String `tfsdk:"server_url"` AccessToken types.String `tfsdk:"access_token"` } func (p *PlexAPIProvider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) { resp.TypeName = "PlexAPI" resp.Version = p.version } func (p *PlexAPIProvider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) { resp.Schema = schema.Schema{ 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)", Optional: true, Required: false, }, "access_token": schema.StringAttribute{ Optional: true, Sensitive: true, }, }, } } func (p *PlexAPIProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) { var data PlexAPIProviderModel resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) if resp.Diagnostics.HasError() { return } ServerURL := data.ServerURL.ValueString() if ServerURL == "" { ServerURL = "http://10.10.10.47:32400" } accessToken := data.AccessToken.ValueString() security := shared.Security{ AccessToken: accessToken, } opts := []sdk.SDKOption{ sdk.WithServerURL(ServerURL), sdk.WithSecurity(security), } client := sdk.New(opts...) resp.DataSourceData = client resp.ResourceData = client } func (p *PlexAPIProvider) Resources(ctx context.Context) []func() resource.Resource { return []func() resource.Resource{} } func (p *PlexAPIProvider) DataSources(ctx context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{} } func New(version string) func() provider.Provider { return func() provider.Provider { return &PlexAPIProvider{ version: version, } } }