func DecodeModel(r io.Reader, optFns ...func(*DecodeModelOptions)) (Resolver, error) {
	var opts DecodeModelOptions
	opts.Set(optFns...)

	// Get the version of the partition file to determine what
	// unmarshaling model to use.
	modelDef := modelDefinition{}
	if err := json.NewDecoder(r).Decode(&modelDef); err != nil {
		return nil, newDecodeModelError("failed to decode endpoints model", err)
	}

	var version string
	if b, ok := modelDef["version"]; ok {
		version = string(b)
	} else {
		return nil, newDecodeModelError("endpoints version not found in model", nil)
	}

	if version == "3" {
		return decodeV3Endpoints(modelDef, opts)
	}

	return nil, newDecodeModelError(
		fmt.Sprintf("endpoints version %s, not supported", version), nil)
}
// DecodeModel unmarshals a Regions and Endpoint model definition file into
// a endpoint Resolver. If the file format is not supported, or an error occurs
// when unmarshaling the model an error will be returned.
//
// Casting the return value of this func to a EnumPartitions will
// allow you to get a list of the partitions in the order the endpoints
// will be resolved in.
//
//    resolver, err := endpoints.DecodeModel(reader)
//
//    partitions := resolver.(endpoints.EnumPartitions).Partitions()
//    for _, p := range partitions {
//        // ... inspect partitions
//    }
DecodeModel unmarshals a Regions and Endpoint model definition file into
a endpoint Resolver. If the file format is not supported, or an error occurs
when unmarshaling the model an error will be returned.

Casting the return value of this func to a EnumPartitions will
allow you to get a list of the partitions in the order the endpoints
will be resolved in.

resolver, err := endpoints.DecodeModel(reader)

partitions := resolver.(endpoints.EnumPartitions).Partitions()
for _, p := range partitions {
inspect partitions
}
// DecodeModel unmarshals a Regions and Endpoint model definition file into // a endpoint Resolver . If the file format is not supported or an error occurs // when unmarshaling the model an error will be returned . // // Casting the return value of this func to a EnumPartitions will // allow you to get a list of the partitions in the order the endpoints // will be resolved in . // // resolver err : = endpoints . DecodeModel ( reader ) // // partitions : = resolver . ( endpoints . EnumPartitions ) . Partitions () // for _ p : = range partitions { // // ... inspect partitions // }
func DecodeModel(r io.Reader, optFns ...func(*DecodeModelOptions)) (Resolver, error) {
	var opts DecodeModelOptions
	opts.Set(optFns...)
	modelDef := modelDefinition{}
	if err := json.NewDecoder(r).Decode(&modelDef); err != nil {
		return nil, newDecodeModelError("failed to decode endpoints model", err)
	}
	var version string
	if b, ok := modelDef["version"]; ok {
		version = string(b)
	} else {
		return nil, newDecodeModelError("endpoints version not found in model", nil)
	}
	if version == "3" {
		return decodeV3Endpoints(modelDef, opts)
	}
	return nil, newDecodeModelError(
		fmt.Sprintf("endpoints version %s, not supported", version), nil)
}
func DecodeModel ( r io . Reader , optFns ... func ( * DecodeModelOptions ) ) ( Resolver , error ) { var opts DecodeModelOptions opts . Set ( optFns ... ) modelDef := modelDefinition { } if err := json . NewDecoder ( r ) . Decode ( & modelDef ) ; err != nil { return nil , newDecodeModelError ( " " , err ) } var version string if b , ok := modelDef [ " " ] ; ok { version = string ( b ) } else { return nil , newDecodeModelError ( " " , nil ) } if version == " " { return decodeV3Endpoints ( modelDef , opts ) } return nil , newDecodeModelError ( fmt . Sprintf ( " " , version ) , nil ) }
DecodeModel unmarshals a Regions and Endpoint model definition file into
a endpoint Resolver.
DecodeModel unmarshals a Regions and Endpoint model definition file into a endpoint Resolver .
// Get the version of the partition file to determine what // unmarshaling model to use.