device

package
v0.0.0-...-8fb3fdf Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BeaconIdParamsSchema = schema.SingleNestedAttribute{
	MarkdownDescription: "Beacon ID parameters of the device.",
	Computed:            true,
	Optional:            true,
	Attributes: map[string]schema.Attribute{
		"uuid": schema.StringAttribute{
			MarkdownDescription: "UUID of the beacon identifier.",
			Computed:            true,
			Optional:            true,
		},
		"major": schema.Int64Attribute{
			MarkdownDescription: "Major number of the beacon identifier.",
			Computed:            true,
			Optional:            true,
		},
		"minor": schema.Int64Attribute{
			MarkdownDescription: "Minor number of the beacon identifier.",
			Computed:            true,
			Optional:            true,
		},
		"beacon_id": schema.StringAttribute{
			MarkdownDescription: "Beacon ID (alternative to UUID).",
			Computed:            true,
			Optional:            true,
		},
		"proximity": schema.StringAttribute{
			MarkdownDescription: "Proximity of the beacon.",
			Computed:            true,
			Optional:            true,
		},
	},
}
View Source
var BeaconIdParamsType = map[string]attr.Type{
	"uuid":      types.StringType,
	"major":     types.Int64Type,
	"minor":     types.Int64Type,
	"beacon_id": types.StringType,
	"proximity": types.StringType,
}

BeaconIdParamsType represents the beacon ID parameters of a device.

View Source
var DetailsSchema = schema.ListNestedAttribute{
	MarkdownDescription: "Additional details about the device.",
	Computed:            true,
	Optional:            true,
	NestedObject: schema.NestedAttributeObject{
		Attributes: map[string]schema.Attribute{
			"name": schema.StringAttribute{
				MarkdownDescription: "The name of the detail.",
				Required:            true,
			},
			"value": schema.StringAttribute{
				MarkdownDescription: "The value of the detail.",
				Required:            true,
			},
		},
	},
}
View Source
var DetailsType = map[string]attr.Type{
	"name":  types.StringType,
	"value": types.StringType,
}
View Source
var GetResourceSchema = schema.Schema{
	MarkdownDescription: "Manage Meraki devices resource. This resource allows updating device attributes for devices associated with a network.",

	Attributes: map[string]schema.Attribute{
		"id": schema.StringAttribute{
			Computed: true,
		},
		"network_id": schema.StringAttribute{
			MarkdownDescription: "Network ID to which the device belongs.",
			Optional:            true,
			Computed:            true,
			PlanModifiers: []planmodifier.String{
				stringplanmodifier.UseStateForUnknown(),
			},
		},
		"serial": schema.StringAttribute{
			MarkdownDescription: "The serial number of the device.",
			Required:            true,
			Validators: []validator.String{
				stringvalidator.LengthBetween(14, 14),
			},
		},
		"name": schema.StringAttribute{
			MarkdownDescription: "The name of the device.",
			Optional:            true,
			Computed:            true,
		},
		"tags": schema.ListAttribute{
			MarkdownDescription: "Tags associated with the device.",
			Optional:            true,
			Computed:            true,
			ElementType:         types.StringType,
			PlanModifiers: []planmodifier.List{
				listplanmodifier.UseStateForUnknown(),
			},
		},
		"lat": schema.Float64Attribute{
			MarkdownDescription: "The latitude of the device.",
			Optional:            true,
			Computed:            true,
		},
		"lng": schema.Float64Attribute{
			MarkdownDescription: "The longitude of the device.",
			Optional:            true,
			Computed:            true,
		},
		"address": schema.StringAttribute{
			MarkdownDescription: "The physical address of the device.",
			Optional:            true,
			Computed:            true,
		},
		"notes": schema.StringAttribute{
			MarkdownDescription: "Notes about the device, limited to 255 characters.",
			Optional:            true,
			Computed:            true,
		},
		"details": DetailsSchema,
		"move_map_marker": schema.BoolAttribute{
			MarkdownDescription: "Indicates whether to set latitude and longitude based on the address. Ignored if `lat` and `lng` are provided.",
			Computed:            true,
			Default:             utils.NewBoolDefault(false),
		},
		"switch_profile_id": schema.StringAttribute{
			MarkdownDescription: "ID of the switch profile to bind to the device. Use `null` to unbind.",
			Optional:            true,
			Computed:            true,
		},
		"floor_plan_id": schema.StringAttribute{
			MarkdownDescription: "Floor plan ID associated with the device. Use `null` to disassociate.",
			Optional:            true,
			Computed:            true,
		},
		"mac": schema.StringAttribute{
			MarkdownDescription: "MAC address of the device.",
			Computed:            true,
		},
		"model": schema.StringAttribute{
			MarkdownDescription: "Model of the device.",
			Computed:            true,
		},
		"lan_ip": schema.StringAttribute{
			MarkdownDescription: "LAN IP address of the device.",
			Computed:            true,
		},
		"firmware": schema.StringAttribute{
			MarkdownDescription: "Firmware version of the device.",
			Computed:            true,
		},
		"url": schema.StringAttribute{
			MarkdownDescription: "URL of the network associated with the device.",
			Computed:            true,
		},
		"beacon_id_params": BeaconIdParamsSchema,
	},
}

Functions

func CallDeleteAPI

func CallDeleteAPI(ctx context.Context, client *openApiClient.APIClient, data ResourceModel) diag.Diagnostics

CallDeleteAPI Call the DELETE API

func GenerateCreatePayload

func GenerateCreatePayload(ctx context.Context, data ResourceModel) *openApiClient.UpdateDeviceRequest

GenerateCreatePayload Generate payload for CREATE operation

func GenerateDeletePayload

func GenerateDeletePayload(ctx context.Context, data ResourceModel) *openApiClient.UpdateDeviceRequest

GenerateDeletePayload Generate blank payload for DELETE operation

func GenerateUpdatePayload

func GenerateUpdatePayload(ctx context.Context, data ResourceModel) *openApiClient.UpdateDeviceRequest

GenerateUpdatePayload Generate payload for UPDATE operation

func MarshalBeaconIdParamsFromAPI

func MarshalBeaconIdParamsFromAPI(ctx context.Context, apiData map[string]interface{}) (types.Object, diag.Diagnostics)

func MarshalDetailsFromAPI

func MarshalDetailsFromAPI(ctx context.Context, apiData map[string]interface{}) (types.List, diag.Diagnostics)

MarshalDetailsFromAPI handles extracting and marshaling the 'details' attribute from the API response.

func NewResource

func NewResource() resource.Resource

Types

type BeaconIdParamsModel

type BeaconIdParamsModel struct {
	Uuid  types.String `tfsdk:"uuid" json:"uuid"`
	Major types.Int64  `tfsdk:"major" json:"major"`
	Minor types.Int64  `tfsdk:"minor" json:"minor"`
}

BeaconIdParamsModel represents the beacon ID parameters of a device.

type DetailsModel

type DetailsModel struct {
	Name  types.String `tfsdk:"name" json:"name"`
	Value types.String `tfsdk:"value" json:"value"`
}

DetailsModel represents additional details of a device.

type Resource

type Resource struct {
	// contains filtered or unexported fields
}

Resource defines the resource implementation.

func (*Resource) Configure

func (*Resource) Create

func (*Resource) Delete

func (*Resource) ImportState

ImportState function is used to import an existing resource into Terraform.

func (*Resource) Metadata

func (*Resource) Read

func (*Resource) Schema

func (*Resource) Update

type ResourceModel

type ResourceModel struct {
	Id              types.String  `tfsdk:"id" json:"id"`
	Serial          types.String  `tfsdk:"serial" json:"serial"`
	Name            types.String  `tfsdk:"name" json:"name"`
	Mac             types.String  `tfsdk:"mac" json:"mac"`
	Model           types.String  `tfsdk:"model" json:"model"`
	Tags            types.List    `tfsdk:"tags" json:"tags"`
	Details         types.List    `tfsdk:"details" json:"details"`
	LanIp           types.String  `tfsdk:"lan_ip" json:"lanIp"`
	Firmware        types.String  `tfsdk:"firmware" json:"firmware"`
	Lat             types.Float64 `tfsdk:"lat" json:"lat"`
	Lng             types.Float64 `tfsdk:"lng" json:"lng"`
	Address         types.String  `tfsdk:"address" json:"address"`
	Notes           types.String  `tfsdk:"notes" json:"notes"`
	Url             types.String  `tfsdk:"url" json:"url"`
	FloorPlanId     types.String  `tfsdk:"floor_plan_id" json:"floorPlanId"`
	NetworkId       types.String  `tfsdk:"network_id" json:"networkId"`
	BeaconIdParams  types.Object  `tfsdk:"beacon_id_params" json:"beaconIdParams"`
	SwitchProfileId types.String  `tfsdk:"switch_profile_id" json:"switchProfileId"`
	MoveMapMarker   types.Bool    `tfsdk:"move_map_marker" json:"moveMapMarker"`
}

ResourceModel represents the device resource in Terraform.

func CallCreateAPI

CallCreateAPI Call the CREATE API

func CallReadAPI

CallReadAPI Call the READ API

func CallUpdateAPI

CallUpdateAPI Call the UPDATE API

func MarshalStateFromAPI

func MarshalStateFromAPI(ctx context.Context, apiData map[string]interface{}) (ResourceModel, diag.Diagnostics)

MarshalStateFromAPI marshals the API response (map) to the Terraform state model.

Jump to

Keyboard shortcuts

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