Documentation
¶
Index ¶
- Variables
- func CallDeleteAPI(ctx context.Context, client *openApiClient.APIClient, data ResourceModel) diag.Diagnostics
- func GenerateCreatePayload(ctx context.Context, data ResourceModel) *openApiClient.UpdateDeviceRequest
- func GenerateDeletePayload(ctx context.Context, data ResourceModel) *openApiClient.UpdateDeviceRequest
- func GenerateUpdatePayload(ctx context.Context, data ResourceModel) *openApiClient.UpdateDeviceRequest
- func MarshalBeaconIdParamsFromAPI(ctx context.Context, apiData map[string]interface{}) (types.Object, diag.Diagnostics)
- func MarshalDetailsFromAPI(ctx context.Context, apiData map[string]interface{}) (types.List, diag.Diagnostics)
- func NewResource() resource.Resource
- type BeaconIdParamsModel
- type DetailsModel
- type Resource
- func (r *Resource) Configure(ctx context.Context, req resource.ConfigureRequest, ...)
- func (r *Resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
- func (r *Resource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
- func (r *Resource) ImportState(ctx context.Context, req resource.ImportStateRequest, ...)
- func (r *Resource) Metadata(ctx context.Context, req resource.MetadataRequest, ...)
- func (r *Resource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
- func (r *Resource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse)
- func (r *Resource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
- type ResourceModel
- func CallCreateAPI(ctx context.Context, client *openApiClient.APIClient, data ResourceModel) (ResourceModel, diag.Diagnostics)
- func CallReadAPI(ctx context.Context, client *openApiClient.APIClient, data ResourceModel) (ResourceModel, diag.Diagnostics)
- func CallUpdateAPI(ctx context.Context, client *openApiClient.APIClient, data ResourceModel) (ResourceModel, diag.Diagnostics)
- func MarshalStateFromAPI(ctx context.Context, apiData map[string]interface{}) (ResourceModel, diag.Diagnostics)
Constants ¶
This section is empty.
Variables ¶
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, }, }, }
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.
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, }, }, }, }
var DetailsType = map[string]attr.Type{ "name": types.StringType, "value": types.StringType, }
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 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 ¶
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 (r *Resource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse)
func (*Resource) Create ¶
func (r *Resource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse)
func (*Resource) Delete ¶
func (r *Resource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse)
func (*Resource) ImportState ¶
func (r *Resource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse)
ImportState function is used to import an existing resource into Terraform.
func (*Resource) Metadata ¶
func (r *Resource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse)
func (*Resource) Read ¶
func (r *Resource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse)
func (*Resource) Schema ¶
func (r *Resource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse)
func (*Resource) Update ¶
func (r *Resource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse)
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 ¶
func CallCreateAPI(ctx context.Context, client *openApiClient.APIClient, data ResourceModel) (ResourceModel, diag.Diagnostics)
CallCreateAPI Call the CREATE API
func CallReadAPI ¶
func CallReadAPI(ctx context.Context, client *openApiClient.APIClient, data ResourceModel) (ResourceModel, diag.Diagnostics)
CallReadAPI Call the READ API
func CallUpdateAPI ¶
func CallUpdateAPI(ctx context.Context, client *openApiClient.APIClient, data ResourceModel) (ResourceModel, diag.Diagnostics)
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.