| 
									
										
										
										
											2014-12-16 19:04:08 +08:00
										 |  |  | package models | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-19 03:26:06 +08:00
										 |  |  | import ( | 
					
						
							|  |  |  | 	"errors" | 
					
						
							|  |  |  | 	"time" | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2014-12-16 19:04:08 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | const ( | 
					
						
							| 
									
										
										
										
											2014-12-18 22:41:38 +08:00
										 |  |  | 	DS_GRAPHITE      = "graphite" | 
					
						
							|  |  |  | 	DS_INFLUXDB      = "influxdb" | 
					
						
							|  |  |  | 	DS_ES            = "es" | 
					
						
							|  |  |  | 	DS_ACCESS_DIRECT = "direct" | 
					
						
							|  |  |  | 	DS_ACCESS_PROXY  = "proxy" | 
					
						
							| 
									
										
										
										
											2014-12-16 19:04:08 +08:00
										 |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-19 03:26:06 +08:00
										 |  |  | // Typed errors
 | 
					
						
							|  |  |  | var ( | 
					
						
							|  |  |  | 	ErrDataSourceNotFound = errors.New("Data source not found") | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-16 19:04:08 +08:00
										 |  |  | type DsType string | 
					
						
							|  |  |  | type DsAccess string | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type DataSource struct { | 
					
						
							|  |  |  | 	Id        int64 | 
					
						
							|  |  |  | 	AccountId int64 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Name      string | 
					
						
							|  |  |  | 	Type      DsType | 
					
						
							|  |  |  | 	Access    DsAccess | 
					
						
							|  |  |  | 	Url       string | 
					
						
							|  |  |  | 	Password  string | 
					
						
							|  |  |  | 	User      string | 
					
						
							|  |  |  | 	BasicAuth bool | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Created time.Time | 
					
						
							|  |  |  | 	Updated time.Time | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type GetDataSourcesQuery struct { | 
					
						
							|  |  |  | 	AccountId int64 | 
					
						
							| 
									
										
										
										
											2014-12-18 00:32:22 +08:00
										 |  |  | 	Result    []*DataSource | 
					
						
							| 
									
										
										
										
											2014-12-16 19:04:08 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2014-12-16 23:45:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-19 03:26:06 +08:00
										 |  |  | type GetDataSourceByNameQuery struct { | 
					
						
							|  |  |  | 	Name      string | 
					
						
							|  |  |  | 	AccountId int64 | 
					
						
							|  |  |  | 	Result    DataSource | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-16 23:45:07 +08:00
										 |  |  | type AddDataSourceCommand struct { | 
					
						
							|  |  |  | 	AccountId int64 | 
					
						
							|  |  |  | 	Name      string | 
					
						
							|  |  |  | 	Type      DsType | 
					
						
							|  |  |  | 	Access    DsAccess | 
					
						
							|  |  |  | 	Url       string | 
					
						
							|  |  |  | 	Password  string | 
					
						
							|  |  |  | 	User      string | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2014-12-18 00:32:22 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | type UpdateDataSourceCommand struct { | 
					
						
							|  |  |  | 	Id        int64 | 
					
						
							|  |  |  | 	AccountId int64 | 
					
						
							|  |  |  | 	Name      string | 
					
						
							|  |  |  | 	Type      DsType | 
					
						
							|  |  |  | 	Access    DsAccess | 
					
						
							|  |  |  | 	Url       string | 
					
						
							|  |  |  | 	Password  string | 
					
						
							|  |  |  | 	User      string | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type DeleteDataSourceCommand struct { | 
					
						
							|  |  |  | 	Id        int64 | 
					
						
							|  |  |  | 	AccountId int64 | 
					
						
							|  |  |  | } |