// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.

package shared

import (
	"encoding/json"
	"fmt"
)

// PermissionType - Describes what actions/endpoints the permission entitles to
type PermissionType string

const (
	PermissionTypeInstanceAdmin      PermissionType = "instance_admin"
	PermissionTypeOrganizationAdmin  PermissionType = "organization_admin"
	PermissionTypeOrganizationEditor PermissionType = "organization_editor"
	PermissionTypeOrganizationRunner PermissionType = "organization_runner"
	PermissionTypeOrganizationReader PermissionType = "organization_reader"
	PermissionTypeOrganizationMember PermissionType = "organization_member"
	PermissionTypeWorkspaceOwner     PermissionType = "workspace_owner"
	PermissionTypeWorkspaceAdmin     PermissionType = "workspace_admin"
	PermissionTypeWorkspaceRunner    PermissionType = "workspace_runner"
	PermissionTypeWorkspaceEditor    PermissionType = "workspace_editor"
	PermissionTypeWorkspaceReader    PermissionType = "workspace_reader"
)

func (e PermissionType) ToPointer() *PermissionType {
	return &e
}
func (e *PermissionType) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "instance_admin":
		fallthrough
	case "organization_admin":
		fallthrough
	case "organization_editor":
		fallthrough
	case "organization_runner":
		fallthrough
	case "organization_reader":
		fallthrough
	case "organization_member":
		fallthrough
	case "workspace_owner":
		fallthrough
	case "workspace_admin":
		fallthrough
	case "workspace_runner":
		fallthrough
	case "workspace_editor":
		fallthrough
	case "workspace_reader":
		*e = PermissionType(v)
		return nil
	default:
		return fmt.Errorf("invalid value for PermissionType: %v", v)
	}
}
