import (
"fmt"
gateway "github.com/GatewayLabs/gateway-go-sdk/client"
)
func createEmployeeModel(client *gateway.SDK) error {
// Define the schema properties
schema := map[string]interface{}{
"title": "Employee",
"type": "object",
"required": []string{"firstName", "email", "department"},
"properties": map[string]interface{}{
"firstName": map[string]interface{}{
"type": "string",
"title": "First Name",
"description": "Employee's first name",
"minLength": 2,
},
"lastName": map[string]interface{}{
"type": "string",
"title": "Last Name",
"description": "Employee's last name",
"minLength": 2,
},
"email": map[string]interface{}{
"type": "string",
"title": "Email",
"description": "Corporate email address",
"format": "email",
},
"department": map[string]interface{}{
"type": "string",
"title": "Department",
"description": "Employee's department",
},
"profilePhoto": map[string]interface{}{
"type": "string",
"title": "Profile Photo",
"description": "Employee's profile picture",
"contentMediaType": "image/png",
},
},
"additionalProperties": false,
}
// Create the data model
tags := []string{"HR", "Employee", "Profile"}
model, err := client.DataModel.Create(gateway.CreateDataModelRequest{
Title: "Employee Profile",
Description: "Standard employee information schema",
Tags: &tags,
Schema: schema,
})
if err != nil {
return fmt.Errorf("failed to create data model: %w", err)
}
fmt.Printf("Created Data Model with ID: %d\n", model.Id)
return nil
}