// Code generated by "enumer -type=ACL -json -transform=snake"; DO NOT EDIT.

package acl

import (
	"encoding/json"
	"fmt"
	"strings"
)

const _ACLName = "catbulkclustersearchremotecreatecountscriptsdeletedocsourcefield_capscloseanalyzeexistsgettemplateexplainindicesaliasaliasesdelete_by_querycacheindexmappingflushforcemergeupgradesettingsopenrecoverymappingsrolloverrefreshsegmentsshrinksplitshard_storesstatsingestvalidatemsearchmgetnodesmtermvectorsreindexupdate_by_queryrenderrank_evalsearch_shardssnapshottaskstermvectorsupdate"

var _ACLIndex = [...]uint16{0, 3, 7, 14, 20, 26, 32, 37, 44, 50, 53, 59, 69, 74, 81, 87, 90, 98, 105, 112, 117, 124, 139, 144, 149, 156, 161, 171, 178, 186, 190, 198, 206, 214, 221, 229, 235, 240, 252, 257, 263, 271, 278, 282, 287, 299, 306, 321, 327, 336, 349, 357, 362, 373, 379}

const _ACLLowerName = "catbulkclustersearchremotecreatecountscriptsdeletedocsourcefield_capscloseanalyzeexistsgettemplateexplainindicesaliasaliasesdelete_by_querycacheindexmappingflushforcemergeupgradesettingsopenrecoverymappingsrolloverrefreshsegmentsshrinksplitshard_storesstatsingestvalidatemsearchmgetnodesmtermvectorsreindexupdate_by_queryrenderrank_evalsearch_shardssnapshottaskstermvectorsupdate"

func (i ACL) String() string {
	if i < 0 || i >= ACL(len(_ACLIndex)-1) {
		return fmt.Sprintf("ACL(%d)", i)
	}
	return _ACLName[_ACLIndex[i]:_ACLIndex[i+1]]
}

// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _ACLNoOp() {
	var x [1]struct{}
	_ = x[Cat-(0)]
	_ = x[Bulk-(1)]
	_ = x[Cluster-(2)]
	_ = x[Search-(3)]
	_ = x[Remote-(4)]
	_ = x[Create-(5)]
	_ = x[Count-(6)]
	_ = x[Scripts-(7)]
	_ = x[Delete-(8)]
	_ = x[Doc-(9)]
	_ = x[Source-(10)]
	_ = x[FieldCaps-(11)]
	_ = x[Close-(12)]
	_ = x[Analyze-(13)]
	_ = x[Exists-(14)]
	_ = x[Get-(15)]
	_ = x[Template-(16)]
	_ = x[Explain-(17)]
	_ = x[Indices-(18)]
	_ = x[Alias-(19)]
	_ = x[Aliases-(20)]
	_ = x[DeleteByQuery-(21)]
	_ = x[Cache-(22)]
	_ = x[Index-(23)]
	_ = x[Mapping-(24)]
	_ = x[Flush-(25)]
	_ = x[Forcemerge-(26)]
	_ = x[Upgrade-(27)]
	_ = x[Settings-(28)]
	_ = x[Open-(29)]
	_ = x[Recovery-(30)]
	_ = x[Mappings-(31)]
	_ = x[Rollover-(32)]
	_ = x[Refresh-(33)]
	_ = x[Segments-(34)]
	_ = x[Shrink-(35)]
	_ = x[Split-(36)]
	_ = x[ShardStores-(37)]
	_ = x[Stats-(38)]
	_ = x[Ingest-(39)]
	_ = x[Validate-(40)]
	_ = x[Msearch-(41)]
	_ = x[Mget-(42)]
	_ = x[Nodes-(43)]
	_ = x[Mtermvectors-(44)]
	_ = x[Reindex-(45)]
	_ = x[UpdateByQuery-(46)]
	_ = x[Render-(47)]
	_ = x[RankEval-(48)]
	_ = x[SearchShards-(49)]
	_ = x[Snapshot-(50)]
	_ = x[Tasks-(51)]
	_ = x[Termvectors-(52)]
	_ = x[Update-(53)]
}

var _ACLValues = []ACL{Cat, Bulk, Cluster, Search, Remote, Create, Count, Scripts, Delete, Doc, Source, FieldCaps, Close, Analyze, Exists, Get, Template, Explain, Indices, Alias, Aliases, DeleteByQuery, Cache, Index, Mapping, Flush, Forcemerge, Upgrade, Settings, Open, Recovery, Mappings, Rollover, Refresh, Segments, Shrink, Split, ShardStores, Stats, Ingest, Validate, Msearch, Mget, Nodes, Mtermvectors, Reindex, UpdateByQuery, Render, RankEval, SearchShards, Snapshot, Tasks, Termvectors, Update}

var _ACLNameToValueMap = map[string]ACL{
	_ACLName[0:3]:          Cat,
	_ACLLowerName[0:3]:     Cat,
	_ACLName[3:7]:          Bulk,
	_ACLLowerName[3:7]:     Bulk,
	_ACLName[7:14]:         Cluster,
	_ACLLowerName[7:14]:    Cluster,
	_ACLName[14:20]:        Search,
	_ACLLowerName[14:20]:   Search,
	_ACLName[20:26]:        Remote,
	_ACLLowerName[20:26]:   Remote,
	_ACLName[26:32]:        Create,
	_ACLLowerName[26:32]:   Create,
	_ACLName[32:37]:        Count,
	_ACLLowerName[32:37]:   Count,
	_ACLName[37:44]:        Scripts,
	_ACLLowerName[37:44]:   Scripts,
	_ACLName[44:50]:        Delete,
	_ACLLowerName[44:50]:   Delete,
	_ACLName[50:53]:        Doc,
	_ACLLowerName[50:53]:   Doc,
	_ACLName[53:59]:        Source,
	_ACLLowerName[53:59]:   Source,
	_ACLName[59:69]:        FieldCaps,
	_ACLLowerName[59:69]:   FieldCaps,
	_ACLName[69:74]:        Close,
	_ACLLowerName[69:74]:   Close,
	_ACLName[74:81]:        Analyze,
	_ACLLowerName[74:81]:   Analyze,
	_ACLName[81:87]:        Exists,
	_ACLLowerName[81:87]:   Exists,
	_ACLName[87:90]:        Get,
	_ACLLowerName[87:90]:   Get,
	_ACLName[90:98]:        Template,
	_ACLLowerName[90:98]:   Template,
	_ACLName[98:105]:       Explain,
	_ACLLowerName[98:105]:  Explain,
	_ACLName[105:112]:      Indices,
	_ACLLowerName[105:112]: Indices,
	_ACLName[112:117]:      Alias,
	_ACLLowerName[112:117]: Alias,
	_ACLName[117:124]:      Aliases,
	_ACLLowerName[117:124]: Aliases,
	_ACLName[124:139]:      DeleteByQuery,
	_ACLLowerName[124:139]: DeleteByQuery,
	_ACLName[139:144]:      Cache,
	_ACLLowerName[139:144]: Cache,
	_ACLName[144:149]:      Index,
	_ACLLowerName[144:149]: Index,
	_ACLName[149:156]:      Mapping,
	_ACLLowerName[149:156]: Mapping,
	_ACLName[156:161]:      Flush,
	_ACLLowerName[156:161]: Flush,
	_ACLName[161:171]:      Forcemerge,
	_ACLLowerName[161:171]: Forcemerge,
	_ACLName[171:178]:      Upgrade,
	_ACLLowerName[171:178]: Upgrade,
	_ACLName[178:186]:      Settings,
	_ACLLowerName[178:186]: Settings,
	_ACLName[186:190]:      Open,
	_ACLLowerName[186:190]: Open,
	_ACLName[190:198]:      Recovery,
	_ACLLowerName[190:198]: Recovery,
	_ACLName[198:206]:      Mappings,
	_ACLLowerName[198:206]: Mappings,
	_ACLName[206:214]:      Rollover,
	_ACLLowerName[206:214]: Rollover,
	_ACLName[214:221]:      Refresh,
	_ACLLowerName[214:221]: Refresh,
	_ACLName[221:229]:      Segments,
	_ACLLowerName[221:229]: Segments,
	_ACLName[229:235]:      Shrink,
	_ACLLowerName[229:235]: Shrink,
	_ACLName[235:240]:      Split,
	_ACLLowerName[235:240]: Split,
	_ACLName[240:252]:      ShardStores,
	_ACLLowerName[240:252]: ShardStores,
	_ACLName[252:257]:      Stats,
	_ACLLowerName[252:257]: Stats,
	_ACLName[257:263]:      Ingest,
	_ACLLowerName[257:263]: Ingest,
	_ACLName[263:271]:      Validate,
	_ACLLowerName[263:271]: Validate,
	_ACLName[271:278]:      Msearch,
	_ACLLowerName[271:278]: Msearch,
	_ACLName[278:282]:      Mget,
	_ACLLowerName[278:282]: Mget,
	_ACLName[282:287]:      Nodes,
	_ACLLowerName[282:287]: Nodes,
	_ACLName[287:299]:      Mtermvectors,
	_ACLLowerName[287:299]: Mtermvectors,
	_ACLName[299:306]:      Reindex,
	_ACLLowerName[299:306]: Reindex,
	_ACLName[306:321]:      UpdateByQuery,
	_ACLLowerName[306:321]: UpdateByQuery,
	_ACLName[321:327]:      Render,
	_ACLLowerName[321:327]: Render,
	_ACLName[327:336]:      RankEval,
	_ACLLowerName[327:336]: RankEval,
	_ACLName[336:349]:      SearchShards,
	_ACLLowerName[336:349]: SearchShards,
	_ACLName[349:357]:      Snapshot,
	_ACLLowerName[349:357]: Snapshot,
	_ACLName[357:362]:      Tasks,
	_ACLLowerName[357:362]: Tasks,
	_ACLName[362:373]:      Termvectors,
	_ACLLowerName[362:373]: Termvectors,
	_ACLName[373:379]:      Update,
	_ACLLowerName[373:379]: Update,
}

var _ACLNames = []string{
	_ACLName[0:3],
	_ACLName[3:7],
	_ACLName[7:14],
	_ACLName[14:20],
	_ACLName[20:26],
	_ACLName[26:32],
	_ACLName[32:37],
	_ACLName[37:44],
	_ACLName[44:50],
	_ACLName[50:53],
	_ACLName[53:59],
	_ACLName[59:69],
	_ACLName[69:74],
	_ACLName[74:81],
	_ACLName[81:87],
	_ACLName[87:90],
	_ACLName[90:98],
	_ACLName[98:105],
	_ACLName[105:112],
	_ACLName[112:117],
	_ACLName[117:124],
	_ACLName[124:139],
	_ACLName[139:144],
	_ACLName[144:149],
	_ACLName[149:156],
	_ACLName[156:161],
	_ACLName[161:171],
	_ACLName[171:178],
	_ACLName[178:186],
	_ACLName[186:190],
	_ACLName[190:198],
	_ACLName[198:206],
	_ACLName[206:214],
	_ACLName[214:221],
	_ACLName[221:229],
	_ACLName[229:235],
	_ACLName[235:240],
	_ACLName[240:252],
	_ACLName[252:257],
	_ACLName[257:263],
	_ACLName[263:271],
	_ACLName[271:278],
	_ACLName[278:282],
	_ACLName[282:287],
	_ACLName[287:299],
	_ACLName[299:306],
	_ACLName[306:321],
	_ACLName[321:327],
	_ACLName[327:336],
	_ACLName[336:349],
	_ACLName[349:357],
	_ACLName[357:362],
	_ACLName[362:373],
	_ACLName[373:379],
}

// ACLString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func ACLString(s string) (ACL, error) {
	if val, ok := _ACLNameToValueMap[s]; ok {
		return val, nil
	}

	if val, ok := _ACLNameToValueMap[strings.ToLower(s)]; ok {
		return val, nil
	}
	return 0, fmt.Errorf("%s does not belong to ACL values", s)
}

// ACLValues returns all values of the enum
func ACLValues() []ACL {
	return _ACLValues
}

// ACLStrings returns a slice of all String values of the enum
func ACLStrings() []string {
	strs := make([]string, len(_ACLNames))
	copy(strs, _ACLNames)
	return strs
}

// IsAACL returns "true" if the value is listed in the enum definition. "false" otherwise
func (i ACL) IsAACL() bool {
	for _, v := range _ACLValues {
		if i == v {
			return true
		}
	}
	return false
}

// MarshalJSON implements the json.Marshaler interface for ACL
func (i ACL) MarshalJSON() ([]byte, error) {
	return json.Marshal(i.String())
}

// UnmarshalJSON implements the json.Unmarshaler interface for ACL
func (i *ACL) UnmarshalJSON(data []byte) error {
	var s string
	if err := json.Unmarshal(data, &s); err != nil {
		return fmt.Errorf("ACL should be a string, got %s", data)
	}

	var err error
	*i, err = ACLString(s)
	return err
}
