// Code generated by qtc from "resource.qtpl". DO NOT EDIT.
// See https://github.com/valyala/quicktemplate for details.

//line templates/python/resource.qtpl:1
package python

//line templates/python/resource.qtpl:1
import "github.com/apibrew/apibrew/pkg/model"

//line templates/python/resource.qtpl:3
import (
	qtio422016 "io"

	qt422016 "github.com/valyala/quicktemplate"
)

//line templates/python/resource.qtpl:3
var (
	_ = qtio422016.Copy
	_ = qt422016.AcquireByteBuffer
)

//line templates/python/resource.qtpl:3
func StreamGenerateClassCode(qw422016 *qt422016.Writer, pkg string, resource *model.Resource) {
//line templates/python/resource.qtpl:3
	qw422016.N().S(`from datetime import datetime
from typing import List, Optional
from enum import Enum
from apibrew.entity import Entity, EntityInfo
from __future__ import annotations

`)
//line templates/python/resource.qtpl:10
	for _, reference := range getAllReferencedResources(resource) {
//line templates/python/resource.qtpl:10
		qw422016.N().S(`from `)
//line templates/python/resource.qtpl:11
		qw422016.E().S(pkg)
//line templates/python/resource.qtpl:11
		qw422016.N().S(`.`)
//line templates/python/resource.qtpl:11
		qw422016.N().S(fileName(reference.Resource))
//line templates/python/resource.qtpl:11
		qw422016.N().S(` import `)
//line templates/python/resource.qtpl:11
		qw422016.N().S(pythonClassName(reference.Resource))
//line templates/python/resource.qtpl:11
		qw422016.N().S(`
`)
//line templates/python/resource.qtpl:12
	}
//line templates/python/resource.qtpl:12
	qw422016.N().S(`

`)
//line templates/python/resource.qtpl:15
	for _, subType := range getAllSubTypes(resource) {
//line templates/python/resource.qtpl:15
		qw422016.N().S(`
class `)
//line templates/python/resource.qtpl:17
		qw422016.E().S(pythonClassName(subType.Name))
//line templates/python/resource.qtpl:17
		qw422016.N().S(`:
`)
//line templates/python/resource.qtpl:18
		for _, property := range subType.Properties {
//line templates/python/resource.qtpl:18
			qw422016.N().S(`    `)
//line templates/python/resource.qtpl:19
			qw422016.N().S(propertyName(property))
//line templates/python/resource.qtpl:19
			qw422016.N().S(`: `)
//line templates/python/resource.qtpl:19
			qw422016.N().S(getPythonType(resource, property, false))
//line templates/python/resource.qtpl:19
			qw422016.N().S(`
`)
//line templates/python/resource.qtpl:20
		}
//line templates/python/resource.qtpl:21
	}
//line templates/python/resource.qtpl:21
	qw422016.N().S(`
`)
//line templates/python/resource.qtpl:23
	for _, enum := range getAllEnums(resource) {
//line templates/python/resource.qtpl:23
		qw422016.N().S(`
class `)
//line templates/python/resource.qtpl:25
		qw422016.E().S(pythonClassName(enum.Name))
//line templates/python/resource.qtpl:25
		qw422016.N().S(`(Enum):
`)
//line templates/python/resource.qtpl:26
		for _, enumValue := range enum.EnumValues {
//line templates/python/resource.qtpl:26
			qw422016.N().S(`    `)
//line templates/python/resource.qtpl:27
			qw422016.N().S(enumName(enumValue))
//line templates/python/resource.qtpl:27
			qw422016.N().S(` = "`)
//line templates/python/resource.qtpl:27
			qw422016.E().S(enumValue)
//line templates/python/resource.qtpl:27
			qw422016.N().S(`"
`)
//line templates/python/resource.qtpl:28
		}
//line templates/python/resource.qtpl:28
		qw422016.N().S(`
`)
//line templates/python/resource.qtpl:30
	}
//line templates/python/resource.qtpl:30
	qw422016.N().S(`

class `)
//line templates/python/resource.qtpl:33
	qw422016.E().S(pythonClassName(resource.Name))
//line templates/python/resource.qtpl:33
	qw422016.N().S(`:
`)
//line templates/python/resource.qtpl:34
	for _, property := range resource.Properties {
//line templates/python/resource.qtpl:34
		qw422016.N().S(`    `)
//line templates/python/resource.qtpl:35
		qw422016.N().S(propertyName(property))
//line templates/python/resource.qtpl:35
		qw422016.N().S(`: `)
//line templates/python/resource.qtpl:35
		qw422016.N().S(getPythonType(resource, property, false))
//line templates/python/resource.qtpl:35
		qw422016.N().S(`
`)
//line templates/python/resource.qtpl:36
	}
//line templates/python/resource.qtpl:36
	qw422016.N().S(`
    @staticmethod
    def entity_info():
        return EntityInfo("`)
//line templates/python/resource.qtpl:40
	qw422016.E().S(resource.Namespace)
//line templates/python/resource.qtpl:40
	qw422016.N().S(`", "`)
//line templates/python/resource.qtpl:40
	qw422016.E().S(resource.Name)
//line templates/python/resource.qtpl:40
	qw422016.N().S(`", "`)
//line templates/python/resource.qtpl:40
	qw422016.E().S(getRestPath(resource))
//line templates/python/resource.qtpl:40
	qw422016.N().S(`")


`)
//line templates/python/resource.qtpl:43
	if len(resourceActions) > 0 {
//line templates/python/resource.qtpl:43
		qw422016.N().S(`

    export interface Service {

    private final Client client;

    public Service(Client client) {
        this.client = client;
    }

    `)
//line templates/python/resource.qtpl:53
		for _, resourceAction := range resourceActions {
//line templates/python/resource.qtpl:53
			qw422016.N().S(`
    `)
//line templates/python/resource.qtpl:54
			if hasInput(resourceAction) {
//line templates/python/resource.qtpl:54
				qw422016.N().S(`
    public `)
//line templates/python/resource.qtpl:55
				qw422016.N().S(outputType(resourceAction))
//line templates/python/resource.qtpl:55
				qw422016.N().S(` `)
//line templates/python/resource.qtpl:55
				qw422016.N().S(pythonVarName(resourceAction.Name))
//line templates/python/resource.qtpl:55
				qw422016.N().S(` (`)
//line templates/python/resource.qtpl:55
				qw422016.N().S(pythonClassName(resource.Name))
//line templates/python/resource.qtpl:55
				qw422016.N().S(` `)
//line templates/python/resource.qtpl:55
				qw422016.N().S(pythonVarName(resource.Name))
//line templates/python/resource.qtpl:55
				qw422016.N().S(`, `)
//line templates/python/resource.qtpl:55
				qw422016.N().S(pythonClassName(resourceAction.Name))
//line templates/python/resource.qtpl:55
				qw422016.N().S(`Input input) {
        `)
//line templates/python/resource.qtpl:56
				if len(resourceAction.Properties) > 0 {
//line templates/python/resource.qtpl:56
					qw422016.N().S(` return `)
//line templates/python/resource.qtpl:56
				}
//line templates/python/resource.qtpl:56
				qw422016.N().S(` client.executeRecordAction(`)
//line templates/python/resource.qtpl:56
				qw422016.N().S(outputType(resourceAction))
//line templates/python/resource.qtpl:56
				qw422016.N().S(`.class, `)
//line templates/python/resource.qtpl:56
				qw422016.E().S(pythonClassName(resource.Name))
//line templates/python/resource.qtpl:56
				qw422016.N().S(`.NAMESPACE, `)
//line templates/python/resource.qtpl:56
				qw422016.E().S(pythonClassName(resource.Name))
//line templates/python/resource.qtpl:56
				qw422016.N().S(`.RESOURCE, instance.getId().toString(), "`)
//line templates/python/resource.qtpl:56
				qw422016.E().S(resourceAction.Name)
//line templates/python/resource.qtpl:56
				qw422016.N().S(`", input);
    }
    `)
//line templates/python/resource.qtpl:58
			} else {
//line templates/python/resource.qtpl:58
				qw422016.N().S(`
    public `)
//line templates/python/resource.qtpl:59
				qw422016.N().S(outputType(resourceAction))
//line templates/python/resource.qtpl:59
				qw422016.N().S(` `)
//line templates/python/resource.qtpl:59
				qw422016.N().S(pythonVarName(resourceAction.Name))
//line templates/python/resource.qtpl:59
				qw422016.N().S(` (`)
//line templates/python/resource.qtpl:59
				qw422016.N().S(pythonClassName(resource.Name))
//line templates/python/resource.qtpl:59
				qw422016.N().S(` `)
//line templates/python/resource.qtpl:59
				qw422016.N().S(pythonVarName(resource.Name))
//line templates/python/resource.qtpl:59
				qw422016.N().S(`) {
        `)
//line templates/python/resource.qtpl:60
				if len(resourceAction.Properties) > 0 {
//line templates/python/resource.qtpl:60
					qw422016.N().S(` return `)
//line templates/python/resource.qtpl:60
				}
//line templates/python/resource.qtpl:60
				qw422016.N().S(`  client.executeRecordAction(`)
//line templates/python/resource.qtpl:60
				qw422016.N().S(outputType(resourceAction))
//line templates/python/resource.qtpl:60
				qw422016.N().S(`.class, `)
//line templates/python/resource.qtpl:60
				qw422016.E().S(pythonClassName(resource.Name))
//line templates/python/resource.qtpl:60
				qw422016.N().S(`.NAMESPACE, `)
//line templates/python/resource.qtpl:60
				qw422016.E().S(pythonClassName(resource.Name))
//line templates/python/resource.qtpl:60
				qw422016.N().S(`.RESOURCE, instance.getId().toString(), "`)
//line templates/python/resource.qtpl:60
				qw422016.E().S(resourceAction.Name)
//line templates/python/resource.qtpl:60
				qw422016.N().S(`", null);
    }
    `)
//line templates/python/resource.qtpl:62
			}
//line templates/python/resource.qtpl:62
			qw422016.N().S(`
    `)
//line templates/python/resource.qtpl:63
		}
//line templates/python/resource.qtpl:63
		qw422016.N().S(`
    }
`)
//line templates/python/resource.qtpl:65
	}
//line templates/python/resource.qtpl:65
	qw422016.N().S(`

`)
//line templates/python/resource.qtpl:67
}

//line templates/python/resource.qtpl:67
func WriteGenerateClassCode(qq422016 qtio422016.Writer, pkg string, resource *model.Resource) {
//line templates/python/resource.qtpl:67
	qw422016 := qt422016.AcquireWriter(qq422016)
//line templates/python/resource.qtpl:67
	StreamGenerateClassCode(qw422016, pkg, resource)
//line templates/python/resource.qtpl:67
	qt422016.ReleaseWriter(qw422016)
//line templates/python/resource.qtpl:67
}

//line templates/python/resource.qtpl:67
func GenerateClassCode(pkg string, resource *model.Resource) string {
//line templates/python/resource.qtpl:67
	qb422016 := qt422016.AcquireByteBuffer()
//line templates/python/resource.qtpl:67
	WriteGenerateClassCode(qb422016, pkg, resource)
//line templates/python/resource.qtpl:67
	qs422016 := string(qb422016.B)
//line templates/python/resource.qtpl:67
	qt422016.ReleaseByteBuffer(qb422016)
//line templates/python/resource.qtpl:67
	return qs422016
//line templates/python/resource.qtpl:67
}
