Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Model Generator #61

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions atlan/assets/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type PermissionError struct{ AtlanError }
type ConflictError struct{ AtlanError }
type RateLimitError struct{ AtlanError }
type LogicError struct{ AtlanError }
type GenerationError struct{ AtlanError }

type ErrorCode int

Expand Down
46 changes: 46 additions & 0 deletions atlan/generator/create_typedefs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package generator

import (
"encoding/json"
"fmt"
"github.com/atlanhq/atlan-go/atlan/assets"
"log"
"os"
"path/filepath"
)

// GenerateTypedefsFile generates the typedefs.json file in the generator package.
func GenerateTypedefsFile() error {
// Fetch typedefs using the existing GetAll() function from the assets package
typedefs, err := assets.GetAll()
if err != nil {
return fmt.Errorf("failed to fetch typedefs: %v", err)
}

// Define the file path for typedefs.json in the generator folder
typedefsFilePath := filepath.Join("atlan", "generator", "typedefs.json")

// Create the typedefs.json file
file, err := os.Create(typedefsFilePath)
if err != nil {
return fmt.Errorf("failed to create typedefs.json: %v", err)
}
defer file.Close()

// Write the typedefs to the file in JSON format
encoder := json.NewEncoder(file)
encoder.SetIndent("", " ") // Add indentation for better readability
if err := encoder.Encode(typedefs); err != nil {
return fmt.Errorf("failed to write typedefs to file: %v", err)
}

fmt.Println("typedefs.json successfully generated at", typedefsFilePath)
return nil
}

// Main function to trigger the typedefs generation
func main() {
if err := GenerateTypedefsFile(); err != nil {
log.Fatalf("Error generating typedefs file: %v", err)
}
}
Loading
Loading