Fetch History

The history is designed to retrieve the history of a specific task based on its UUID.

The step is optional. If skipped, the history of the latest stage will be returned.

Get Rodin generation history and settings.

post
Authorizations
Body
uuidstringRequired
stepstring · enumOptionalPossible values:
Responses
201Success
application/json
post
POST /api/task/rodin_history HTTP/1.1
Host: 
Authorization: Bearer JWT
Content-Type: application/json
Accept: */*
Content-Length: 32

{
  "uuid": "text",
  "step": "Created"
}
201Success
{
  "error": "NO_SUCH_TASK",
  "history_info": {}
}

Examples

package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"time"
)

const BaseURI = "https://hyperhuman.deemos.com/api"

var client = &http.Client{Timeout: 10 * time.Second}

type HistoryInfoDto struct {
	Model          *string `json:"model,omitempty"`
	TextureDiffuse *string `json:"texture_diffuse,omitempty"`
	TexturePbr     *string `json:"texture_pbr,omitempty"`
	TextureShaded  *string `json:"texture_shaded,omitempty"`
	PreviewImage   *string `json:"preview_image,omitempty"`
	Settings       *string `json:"settings,omitempty"`
	GenerateTime   *string `json:"generate_time,omitempty"`
}

type CommonError struct {
	Error *string `json:"error,omitempty"`
}

type RodinModelHistoryResponse struct {
	CommonError
	HistoryInfo map[string]HistoryInfoDto `json:"history_info,omitempty"`
}

type RodinTextureHistoryResponse struct {
	CommonError
	HistoryInfo map[string]map[string]HistoryInfoDto `json:"history_info,omitempty"`
}

func rodinHistory(token string, taskUUID string, step string) (*http.Response, error) {
	// Create the request body
	data := map[string]string{"uuid": taskUUID, "step": step}
	jsonData, err := json.Marshal(data)
	if err != nil {
		return nil, err
	}

	// Create the request
	req, err := http.NewRequest("POST", fmt.Sprintf("%s/task/rodin_history", BaseURI), bytes.NewBuffer(jsonData))
	if err != nil {
		return nil, err
	}

	// Set headers
	req.Header.Set("Authorization", "Bearer "+token)
	req.Header.Set("Content-Type", "application/json")

	// Send the request
	return client.Do(req)
}

func RodinModelHistory(token string, taskUUID string) (*RodinModelHistoryResponse, error) {
	resp, err := rodinHistory(token, taskUUID, "ModelGenerate")
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	// Decode the response JSON
	var raw json.RawMessage
	var result RodinModelHistoryResponse
	err = json.NewDecoder(resp.Body).Decode(&raw)
	if err != nil {
		return nil, err
	}

	err = json.Unmarshal(raw, &result)
	if err != nil {
		return nil, err
	}

	err = json.Unmarshal(raw, &result.HistoryInfo)
	if err != nil {
		return nil, err
	}

	if result.Error != nil {
		return nil, fmt.Errorf("error: %s", *result.Error)
	}

	return &result, nil
}

func RodinTextureHistory(token string, taskUUID string) (*RodinTextureHistoryResponse, error) {
	resp, err := rodinHistory(token, taskUUID, "TextureGenerate")
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	// Decode the response JSON
	var raw json.RawMessage
	var result RodinTextureHistoryResponse
	err = json.NewDecoder(resp.Body).Decode(&raw)
	if err != nil {
		return nil, err
	}

	err = json.Unmarshal(raw, &result)
	if err != nil {
		return nil, err
	}

	err = json.Unmarshal(raw, &result.HistoryInfo)
	if err != nil {
		return nil, err
	}

	if result.Error != nil {
		return nil, fmt.Errorf("error: %s", *result.Error)
	}

	return &result, nil
}

func main() {
	token := "eyJhbGciOiJIUzI1NiJ9.your.token"

	modelResult, err := RodinModelHistory(token, "01234567-your-uuid-here-0123456789ab")
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(*modelResult.HistoryInfo["v1"].PreviewImage)

	textureResult, err := RodinTextureHistory(token, "01234567-your-uuid-here-0123456789ab")
	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(*textureResult.HistoryInfo["0000.png"]["v1"].PreviewImage)
}

Last updated