github.com/qiniu/go-sdk/v7@v7.27.0/cdn/data_type.go (about)

     1  package cdn
     2  
     3  //go:generate stringer -type DataType -linecomment
     4  type DataType int
     5  
     6  const (
     7  	// 静态cdn带宽(bps)
     8  	DataTypeBandwidth DataType = iota + 1 // bandwidth
     9  	// 302cdn带宽(bps)
    10  	DataType302Bandwidth // 302bandwidth
    11  	// 302MIX带宽(bps)
    12  	DataType302mBandwidth // 302mbandwidth
    13  	// 静态cdn流量(bytes)
    14  	DataTypeFlow // flow
    15  	// 302cdn流量(bytes)
    16  	DataType302Flow // 302flow
    17  	// 302MIX流量(bytes)
    18  	DataType302mFlow // 302mflow
    19  )
    20  
    21  func DataTypeOf(datatype string) DataType {
    22  	for d := DataTypeBandwidth; d <= DataType302mFlow; d++ {
    23  		if d.String() == datatype {
    24  			return d
    25  		}
    26  	}
    27  	return -1
    28  }
    29  
    30  func (d DataType) Valid() bool {
    31  	return DataTypeBandwidth <= d && d <= DataType302mFlow
    32  }