model

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 0 Imported by: 0

README

Model synchronization for on-premise

Synchronization Date

  • Date: Thu Jul 4 14:42:07 KST 2024

Repository Details

Usage Instructions

  • Update the models with the command below:

    
    make onprem-model
    
  • This command synchronizes the models to the latest versions.

  • Do not edit these files directly as they are managed automatically.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiResponse added in v0.4.6

type ApiResponse[T any] struct {
	Success bool   `json:"success"`           // Indicates whether the API call was successful
	Item    *T     `json:"item,omitempty"`    // Contains a single object for successful responses
	Items   []T    `json:"items,omitempty"`   // Contains an array of objects for successful list responses
	Message string `json:"message,omitempty"` // Optional message for additional context
	Error   string `json:"error,omitempty"`   // Error message for failed responses
}

ApiResponse represents a standardized API response structure. It uses generics to support different data types for successful responses. For successful responses:

  • Item field contains a single object
  • Items field contains an array of objects

For error responses:

  • Error field contains the error message

The Message field is optional and can provide additional context when needed.

func ErrorResponse added in v0.4.6

func ErrorResponse(errorMessage, Message string) ApiResponse[any]

ErrorResponse creates an error API response with a structured error. When an error occurs, T cannot be a specific type, so we use 'any'. It returns an ApiResponse with success=false and the error message.

func SimpleErrorResponse added in v0.4.6

func SimpleErrorResponse(errorMessage string) ApiResponse[any]

SimpleErrorResponse creates an error API response from a simple error message. This is a convenience function for quick error responses. It returns an ApiResponse with success=false and the error message.

func SuccessListResponse added in v0.4.6

func SuccessListResponse[T any](items []T) ApiResponse[T]

SuccessListResponse creates a successful API response for a list of objects. It returns an ApiResponse with success=true and the provided items array.

func SuccessListResponseWithMessage added in v0.4.6

func SuccessListResponseWithMessage[T any](items []T, message string) ApiResponse[T]

SuccessListResponseWithMessage creates a successful list API response with a custom message. The message field can provide additional context about the successful operation.

func SuccessResponse added in v0.4.6

func SuccessResponse[T any](item T) ApiResponse[T]

SuccessResponse creates a successful API response for a single object. It returns an ApiResponse with success=true and the provided item.

func SuccessResponseWithMessage added in v0.4.6

func SuccessResponseWithMessage[T any](item T, message string) ApiResponse[T]

SuccessResponseWithMessage creates a successful API response with a custom message. The message field can provide additional context about the successful operation.

type MyUser

type MyUser struct {
	ID    int    `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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