// @Title postStaticdnsentries
// @Description enter a new staticdnsentries
// @Accept  application/json
// @Param                 Body body     Staticdnsentries   true "Staticdnsentries object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/staticdnsentries [post]
func postStaticdnsentry(payload []byte, db *sqlx.DB) (interface{}, error) {
	var v Staticdnsentries
	err := json.Unmarshal(payload, &v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	sqlString := "INSERT INTO staticdnsentries("
	sqlString += "name"
	sqlString += ",type"
	sqlString += ",class"
	sqlString += ",ttl"
	sqlString += ",rdata"
	sqlString += ",deliveryservice"
	sqlString += ",cachegroup"
	sqlString += ",created_at"
	sqlString += ") VALUES ("
	sqlString += ":name"
	sqlString += ",:type"
	sqlString += ",:class"
	sqlString += ",:ttl"
	sqlString += ",:rdata"
	sqlString += ",:deliveryservice"
	sqlString += ",:cachegroup"
	sqlString += ",:created_at"
	sqlString += ")"
	result, err := db.NamedExec(sqlString, v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
Beispiel #2
0
// @Title postCachegroup
// @Description enter a new cachegroup
// @Accept  application/json
// @Param                 Body body     Cachegroup   true "Cachegroup object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/cachegroup [post]
func postCachegroup(payload []byte, db *sqlx.DB) (interface{}, error) {
	var v Cachegroup
	err := json.Unmarshal(payload, &v)
	if err != nil {
		log.Println(err)
	}
	sqlString := "INSERT INTO cachegroup("
	sqlString += "name"
	sqlString += ",short_name"
	sqlString += ",latitude"
	sqlString += ",longitude"
	sqlString += ",parent_cachegroup"
	sqlString += ",secondary_parent_cachegroup"
	sqlString += ",type"
	sqlString += ") VALUES ("
	sqlString += ":name"
	sqlString += ",:short_name"
	sqlString += ",:latitude"
	sqlString += ",:longitude"
	sqlString += ",:parent_cachegroup"
	sqlString += ",:secondary_parent_cachegroup"
	sqlString += ",:type"
	sqlString += ")"
	result, err := db.NamedExec(sqlString, v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
// @Title putStaticdnsentry
// @Description modify an existing staticdnsentryentry
// @Accept  application/json
// @Param   id              path    int     true        "The row id"
// @Param                 Body body     Staticdnsentry   true "Staticdnsentry object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/staticdnsentry/{id}  [put]
func putStaticdnsentry(id int, payload []byte, db *sqlx.DB) (interface{}, error) {
	var v Staticdnsentry
	err := json.Unmarshal(payload, &v)
	v.Id = int64(id) // overwrite the id in the payload
	if err != nil {
		log.Println(err)
		return nil, err
	}
	v.LastUpdated = time.Now()
	sqlString := "UPDATE staticdnsentry SET "
	sqlString += "host = :host"
	sqlString += ",address = :address"
	sqlString += ",type = :type"
	sqlString += ",ttl = :ttl"
	sqlString += ",deliveryservice = :deliveryservice"
	sqlString += ",cachegroup = :cachegroup"
	sqlString += ",last_updated = :last_updated"
	sqlString += " WHERE id=:id"
	result, err := db.NamedExec(sqlString, v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
// @Title putStaticdnsentries
// @Description modify an existing staticdnsentriesentry
// @Accept  application/json
// @Param   id              path    int     true        "The row id"
// @Param                 Body body     Staticdnsentries   true "Staticdnsentries object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/staticdnsentries/{id}  [put]
func putStaticdnsentry(id int64, payload []byte, db *sqlx.DB) (interface{}, error) {
	var arg Staticdnsentries
	err := json.Unmarshal(payload, &arg)
	arg.Id = id
	if err != nil {
		log.Println(err)
		return nil, err
	}
	sqlString := "UPDATE staticdnsentries SET "
	sqlString += "name = :name"
	sqlString += ",type = :type"
	sqlString += ",class = :class"
	sqlString += ",ttl = :ttl"
	sqlString += ",rdata = :rdata"
	sqlString += ",deliveryservice = :deliveryservice"
	sqlString += ",cachegroup = :cachegroup"
	sqlString += ",created_at = :created_at"
	sqlString += " WHERE id=:id"
	result, err := db.NamedExec(sqlString, arg)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
Beispiel #5
0
// @Title postUsers
// @Description enter a new users
// @Accept  application/json
// @Param                 Body body     Users   true "Users object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/users [post]
func postUser(payload []byte, db *sqlx.DB) (interface{}, error) {
	var v Users
	err := json.Unmarshal(payload, &v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	sqlString := "INSERT INTO users("
	sqlString += "username"
	sqlString += ",role"
	sqlString += ",email"
	sqlString += ",full_name"
	sqlString += ",ssh_pub_key"
	sqlString += ",local_password"
	sqlString += ",created_at"
	sqlString += ") VALUES ("
	sqlString += ":username"
	sqlString += ",:role"
	sqlString += ",:email"
	sqlString += ",:full_name"
	sqlString += ",:ssh_pub_key"
	sqlString += ",:local_password"
	sqlString += ",:created_at"
	sqlString += ")"
	result, err := db.NamedExec(sqlString, v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
// @Title postFederationUsers
// @Description enter a new federation_users
// @Accept  application/json
// @Param                 Body body     FederationUsers   true "FederationUsers object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/federation_users [post]
func postFederationUser(payload []byte, db *sqlx.DB) (interface{}, error) {
	var v FederationUsers
	err := json.Unmarshal(payload, &v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	sqlString := "INSERT INTO federation_users("
	sqlString += "federation_id"
	sqlString += ",username"
	sqlString += ",role"
	sqlString += ",created_at"
	sqlString += ") VALUES ("
	sqlString += ":federation_id"
	sqlString += ",:username"
	sqlString += ",:role"
	sqlString += ",:created_at"
	sqlString += ")"
	result, err := db.NamedExec(sqlString, v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
// @Title putExtensions
// @Description modify an existing extensionsentry
// @Accept  application/json
// @Param   id              path    int     true        "The row id"
// @Param                 Body body     Extensions   true "Extensions object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/extensions/{id}  [put]
func putExtension(name string, payload []byte, db *sqlx.DB) (interface{}, error) {
	var arg Extensions
	err := json.Unmarshal(payload, &arg)
	arg.Name = name
	if err != nil {
		log.Println(err)
		return nil, err
	}
	sqlString := "UPDATE extensions SET "
	sqlString += "name = :name"
	sqlString += ",short_name = :short_name"
	sqlString += ",description = :description"
	sqlString += ",version = :version"
	sqlString += ",info_url = :info_url"
	sqlString += ",script_file = :script_file"
	sqlString += ",active = :active"
	sqlString += ",additional_config_json = :additional_config_json"
	sqlString += ",type = :type"
	sqlString += ",created_at = :created_at"
	sqlString += " WHERE name=:name"
	result, err := db.NamedExec(sqlString, arg)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
Beispiel #8
0
// @Title postStatsSummary
// @Description enter a new stats_summary
// @Accept  application/json
// @Param                 Body body     StatsSummary   true "StatsSummary object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/stats_summary [post]
func postStatsSummary(payload []byte, db *sqlx.DB) (interface{}, error) {
	var v StatsSummary
	err := json.Unmarshal(payload, &v)
	if err != nil {
		log.Println(err)
	}
	sqlString := "INSERT INTO stats_summary("
	sqlString += "cdn_name"
	sqlString += ",deliveryservice_name"
	sqlString += ",stat_name"
	sqlString += ",stat_value"
	sqlString += ",summary_time"
	sqlString += ",stat_date"
	sqlString += ") VALUES ("
	sqlString += ":cdn_name"
	sqlString += ",:deliveryservice_name"
	sqlString += ",:stat_name"
	sqlString += ",:stat_value"
	sqlString += ",:summary_time"
	sqlString += ",:stat_date"
	sqlString += ")"
	result, err := db.NamedExec(sqlString, v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
Beispiel #9
0
// @Title postJobResult
// @Description enter a new job_result
// @Accept  application/json
// @Param                 Body body     JobResult   true "JobResult object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/job_result [post]
func postJobResult(payload []byte, db *sqlx.DB) (interface{}, error) {
	var v JobResult
	err := json.Unmarshal(payload, &v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	sqlString := "INSERT INTO job_result("
	sqlString += "job"
	sqlString += ",job_agent"
	sqlString += ",result"
	sqlString += ",description"
	sqlString += ") VALUES ("
	sqlString += ":job"
	sqlString += ",:job_agent"
	sqlString += ",:result"
	sqlString += ",:description"
	sqlString += ")"
	result, err := db.NamedExec(sqlString, v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
Beispiel #10
0
// @Title putToExtension
// @Description modify an existing to_extensionentry
// @Accept  application/json
// @Param   id              path    int     true        "The row id"
// @Param                 Body body     ToExtension   true "ToExtension object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/to_extension/{id}  [put]
func putToExtension(id int, payload []byte, db *sqlx.DB) (interface{}, error) {
	var v ToExtension
	err := json.Unmarshal(payload, &v)
	v.Id = int64(id) // overwrite the id in the payload
	if err != nil {
		log.Println(err)
		return nil, err
	}
	v.LastUpdated = time.Now()
	sqlString := "UPDATE to_extension SET "
	sqlString += "name = :name"
	sqlString += ",version = :version"
	sqlString += ",info_url = :info_url"
	sqlString += ",script_file = :script_file"
	sqlString += ",isactive = :isactive"
	sqlString += ",additional_config_json = :additional_config_json"
	sqlString += ",description = :description"
	sqlString += ",servercheck_short_name = :servercheck_short_name"
	sqlString += ",servercheck_column_name = :servercheck_column_name"
	sqlString += ",type = :type"
	sqlString += ",last_updated = :last_updated"
	sqlString += " WHERE id=:id"
	result, err := db.NamedExec(sqlString, v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
Beispiel #11
0
// @Title putJob
// @Description modify an existing jobentry
// @Accept  application/json
// @Param   id              path    int     true        "The row id"
// @Param                 Body body     Job   true "Job object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/job/{id}  [put]
func putJob(id int, payload []byte, db *sqlx.DB) (interface{}, error) {
	var v Job
	err := json.Unmarshal(payload, &v)
	v.Id = int64(id) // overwrite the id in the payload
	if err != nil {
		log.Println(err)
		return nil, err
	}
	v.LastUpdated = time.Now()
	sqlString := "UPDATE job SET "
	sqlString += "job_agent = :job_agent"
	sqlString += ",object_type = :object_type"
	sqlString += ",object_name = :object_name"
	sqlString += ",keyword = :keyword"
	sqlString += ",parameters = :parameters"
	sqlString += ",asset_url = :asset_url"
	sqlString += ",asset_type = :asset_type"
	sqlString += ",status = :status"
	sqlString += ",start_time = :start_time"
	sqlString += ",entered_time = :entered_time"
	sqlString += ",tm_user = :tm_user"
	sqlString += ",last_updated = :last_updated"
	sqlString += ",deliveryservice = :deliveryservice"
	sqlString += " WHERE id=:id"
	result, err := db.NamedExec(sqlString, v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
Beispiel #12
0
// @Title putCachegroup
// @Description modify an existing cachegroupentry
// @Accept  application/json
// @Param   id              path    int     true        "The row id"
// @Param                 Body body     Cachegroup   true "Cachegroup object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/cachegroup/{id}  [put]
func putCachegroup(id int, payload []byte, db *sqlx.DB) (interface{}, error) {
	var v Cachegroup
	err := json.Unmarshal(payload, &v)
	v.Id = int64(id) // overwrite the id in the payload
	if err != nil {
		log.Println(err)
		return nil, err
	}
	v.LastUpdated = time.Now()
	sqlString := "UPDATE cachegroup SET "
	sqlString += "name = :name"
	sqlString += ",short_name = :short_name"
	sqlString += ",latitude = :latitude"
	sqlString += ",longitude = :longitude"
	sqlString += ",parent_cachegroup = :parent_cachegroup"
	sqlString += ",secondary_parent_cachegroup = :secondary_parent_cachegroup"
	sqlString += ",type = :type"
	sqlString += ",last_updated = :last_updated"
	sqlString += " WHERE id=:id"
	result, err := db.NamedExec(sqlString, v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
// @Title postFederations
// @Description enter a new federations
// @Accept  application/json
// @Param                 Body body     Federations   true "Federations object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/federations [post]
func postFederation(payload []byte, db *sqlx.DB) (interface{}, error) {
	var v Federations
	err := json.Unmarshal(payload, &v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	sqlString := "INSERT INTO federations("
	sqlString += "cname"
	sqlString += ",description"
	sqlString += ",ttl"
	sqlString += ",created_at"
	sqlString += ") VALUES ("
	sqlString += ":cname"
	sqlString += ",:description"
	sqlString += ",:ttl"
	sqlString += ",:created_at"
	sqlString += ")"
	result, err := db.NamedExec(sqlString, v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
Beispiel #14
0
// @Title putDeliveryservice
// @Description modify an existing deliveryserviceentry
// @Accept  application/json
// @Param   id              path    int     true        "The row id"
// @Param                 Body body     Deliveryservice   true "Deliveryservice object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/deliveryservice/{id}  [put]
func putDeliveryservice(id int, payload []byte, db *sqlx.DB) (interface{}, error) {
	var v Deliveryservice
	err := json.Unmarshal(payload, &v)
	v.Id = int64(id) // overwrite the id in the payload
	if err != nil {
		log.Println(err)
		return nil, err
	}
	v.LastUpdated = time.Now()
	sqlString := "UPDATE deliveryservice SET "
	sqlString += "xml_id = :xml_id"
	sqlString += ",active = :active"
	sqlString += ",dscp = :dscp"
	sqlString += ",signed = :signed"
	sqlString += ",qstring_ignore = :qstring_ignore"
	sqlString += ",geo_limit = :geo_limit"
	sqlString += ",http_bypass_fqdn = :http_bypass_fqdn"
	sqlString += ",dns_bypass_ip = :dns_bypass_ip"
	sqlString += ",dns_bypass_ip6 = :dns_bypass_ip6"
	sqlString += ",dns_bypass_ttl = :dns_bypass_ttl"
	sqlString += ",org_server_fqdn = :org_server_fqdn"
	sqlString += ",type = :type"
	sqlString += ",profile = :profile"
	sqlString += ",cdn = :cdn"
	sqlString += ",ccr_dns_ttl = :ccr_dns_ttl"
	sqlString += ",global_max_mbps = :global_max_mbps"
	sqlString += ",global_max_tps = :global_max_tps"
	sqlString += ",long_desc = :long_desc"
	sqlString += ",long_desc_1 = :long_desc_1"
	sqlString += ",long_desc_2 = :long_desc_2"
	sqlString += ",max_dns_answers = :max_dns_answers"
	sqlString += ",info_url = :info_url"
	sqlString += ",miss_lat = :miss_lat"
	sqlString += ",miss_long = :miss_long"
	sqlString += ",check_path = :check_path"
	sqlString += ",last_updated = :last_updated"
	sqlString += ",protocol = :protocol"
	sqlString += ",ssl_key_version = :ssl_key_version"
	sqlString += ",ipv6_routing_enabled = :ipv6_routing_enabled"
	sqlString += ",range_request_handling = :range_request_handling"
	sqlString += ",edge_header_rewrite = :edge_header_rewrite"
	sqlString += ",origin_shield = :origin_shield"
	sqlString += ",mid_header_rewrite = :mid_header_rewrite"
	sqlString += ",regex_remap = :regex_remap"
	sqlString += ",cacheurl = :cacheurl"
	sqlString += ",remap_text = :remap_text"
	sqlString += ",multi_site_origin = :multi_site_origin"
	sqlString += ",display_name = :display_name"
	sqlString += ",tr_response_headers = :tr_response_headers"
	sqlString += ",initial_dispersion = :initial_dispersion"
	sqlString += ",dns_bypass_cname = :dns_bypass_cname"
	sqlString += ",tr_request_headers = :tr_request_headers"
	sqlString += " WHERE id=:id"
	result, err := db.NamedExec(sqlString, v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
Beispiel #15
0
func ActionMove(db *sqlx.DB, params ActionParams) (err error) {
	fmt.Println(params)
	fmt.Println("Move", params.Oldslotid, "to", params.Slotid, "where charges =", params.Oldquantity, ",id =", params.Itemid)
	result, err := db.NamedExec(`UPDATE inventory SET 
		itemid = :itemid, 
		slotid = :slotid, 
		charges = :quantity,
		charid = :charid
		WHERE slotid = :oldslotid AND
		itemid = :itemid AND 
		charid = :charid
		`, params)

	if err != nil {
		return
	}
	count, err := result.RowsAffected()
	if err != nil {
		return
	}
	if count < 1 {
		err = fmt.Errorf("No rows affected.")
	}
	return
}
// @Title putPhysLocation
// @Description modify an existing phys_locationentry
// @Accept  application/json
// @Param   id              path    int     true        "The row id"
// @Param                 Body body     PhysLocation   true "PhysLocation object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/phys_location/{id}  [put]
func putPhysLocation(id int, payload []byte, db *sqlx.DB) (interface{}, error) {
	var v PhysLocation
	err := json.Unmarshal(payload, &v)
	v.Id = int64(id) // overwrite the id in the payload
	if err != nil {
		log.Println(err)
		return nil, err
	}
	v.LastUpdated = time.Now()
	sqlString := "UPDATE phys_location SET "
	sqlString += "name = :name"
	sqlString += ",short_name = :short_name"
	sqlString += ",address = :address"
	sqlString += ",city = :city"
	sqlString += ",state = :state"
	sqlString += ",zip = :zip"
	sqlString += ",poc = :poc"
	sqlString += ",phone = :phone"
	sqlString += ",email = :email"
	sqlString += ",comments = :comments"
	sqlString += ",region = :region"
	sqlString += ",last_updated = :last_updated"
	sqlString += " WHERE id=:id"
	result, err := db.NamedExec(sqlString, v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
// @Title putStatsSummary
// @Description modify an existing stats_summaryentry
// @Accept  application/json
// @Param   id              path    int     true        "The row id"
// @Param                 Body body     StatsSummary   true "StatsSummary object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/stats_summary/{id}  [put]
func putStatsSummary(cdnName string, deliveryservice string, statName string, statDate time.Time, payload []byte, db *sqlx.DB) (interface{}, error) {
	var arg StatsSummary
	err := json.Unmarshal(payload, &arg)
	arg.CdnName = cdnName
	arg.Deliveryservice = deliveryservice
	arg.StatName = statName
	arg.StatDate = statDate
	if err != nil {
		log.Println(err)
		return nil, err
	}
	sqlString := "UPDATE stats_summary SET "
	sqlString += "cdn_name = :cdn_name"
	sqlString += ",deliveryservice = :deliveryservice"
	sqlString += ",stat_name = :stat_name"
	sqlString += ",stat_value = :stat_value"
	sqlString += ",stat_date = :stat_date"
	sqlString += ",created_at = :created_at"
	sqlString += " WHERE cdn_name=:cdn_name AND deliveryservice=:deliveryservice AND stat_name=:stat_name AND stat_date=:stat_date"
	result, err := db.NamedExec(sqlString, arg)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
// @Title putPhysLocations
// @Description modify an existing phys_locationsentry
// @Accept  application/json
// @Param   id              path    int     true        "The row id"
// @Param                 Body body     PhysLocations   true "PhysLocations object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/phys_locations/{id}  [put]
func putPhysLocation(name string, payload []byte, db *sqlx.DB) (interface{}, error) {
	var arg PhysLocations
	err := json.Unmarshal(payload, &arg)
	arg.Name = name
	if err != nil {
		log.Println(err)
		return nil, err
	}
	sqlString := "UPDATE phys_locations SET "
	sqlString += "name = :name"
	sqlString += ",short_name = :short_name"
	sqlString += ",address = :address"
	sqlString += ",city = :city"
	sqlString += ",state = :state"
	sqlString += ",zip = :zip"
	sqlString += ",poc = :poc"
	sqlString += ",phone = :phone"
	sqlString += ",email = :email"
	sqlString += ",comments = :comments"
	sqlString += ",region = :region"
	sqlString += ",created_at = :created_at"
	sqlString += " WHERE name=:name"
	result, err := db.NamedExec(sqlString, arg)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
// @Title postCachegroups
// @Description enter a new cachegroups
// @Accept  application/json
// @Param                 Body body     Cachegroups   true "Cachegroups object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/cachegroups [post]
func postCachegroup(payload []byte, db *sqlx.DB) (interface{}, error) {
	var v Cachegroups
	err := json.Unmarshal(payload, &v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	sqlString := "INSERT INTO cachegroups("
	sqlString += "name"
	sqlString += ",description"
	sqlString += ",latitude"
	sqlString += ",longitude"
	sqlString += ",parent_cachegroup"
	sqlString += ",type"
	sqlString += ",created_at"
	sqlString += ") VALUES ("
	sqlString += ":name"
	sqlString += ",:description"
	sqlString += ",:latitude"
	sqlString += ",:longitude"
	sqlString += ",:parent_cachegroup"
	sqlString += ",:type"
	sqlString += ",:created_at"
	sqlString += ")"
	result, err := db.NamedExec(sqlString, v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
Beispiel #20
0
// @Title postLog
// @Description enter a new log
// @Accept  application/json
// @Param                 Body body     Log   true "Log object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/log [post]
func postLog(payload []byte, db *sqlx.DB) (interface{}, error) {
	var v Log
	err := json.Unmarshal(payload, &v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	sqlString := "INSERT INTO log("
	sqlString += "level"
	sqlString += ",message"
	sqlString += ",username"
	sqlString += ",ticketnum"
	sqlString += ",created_at"
	sqlString += ") VALUES ("
	sqlString += ":level"
	sqlString += ",:message"
	sqlString += ",:username"
	sqlString += ",:ticketnum"
	sqlString += ",:created_at"
	sqlString += ")"
	result, err := db.NamedExec(sqlString, v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
func (c Comment) NewComment(db *sqlx.DB) {

	_, err := db.NamedExec(sqlInsertComments, &c)
	if err != nil {
		panic(err)
	}
}
Beispiel #22
0
func StoreAnswer(db *sqlx.DB, answer *SecurityAnswer) error {
	_, err := db.NamedExec("replace into security_answer (user_name,question_id,answer,created_at) values (:user_name, :question_id, :answer, now())", answer)
	if err != nil {
		return err
	}

	return nil
}
Beispiel #23
0
func InsertUser(db *sqlx.DB, user *models.User) error {
	_, err := db.NamedExec(db.Rebind(`INSERT INTO users (fbid, first_name, last_name, roles) VALUES (:fbid, :first_name, :last_name, :roles)`), user)
	if err != nil {
		return err
	}

	return nil
}
Beispiel #24
0
func (l *List) AddMovie(db *sqlx.DB, m Movie) error {
	m.List_ID = l.ID
	_, err := db.NamedExec(QNewMovie, m)
	if err != nil {
		return err
	}
	return nil
}
// @Title putDeliveryservices
// @Description modify an existing deliveryservicesentry
// @Accept  application/json
// @Param   id              path    int     true        "The row id"
// @Param                 Body body     Deliveryservices   true "Deliveryservices object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/deliveryservices/{id}  [put]
func putDeliveryservice(name string, payload []byte, db *sqlx.DB) (interface{}, error) {
	var arg Deliveryservices
	err := json.Unmarshal(payload, &arg)
	arg.Name = name
	if err != nil {
		log.Println(err)
		return nil, err
	}
	sqlString := "UPDATE deliveryservices SET "
	sqlString += "name = :name"
	sqlString += ",display_name = :display_name"
	sqlString += ",description = :description"
	sqlString += ",cdn = :cdn"
	sqlString += ",domain = :domain"
	sqlString += ",active = :active"
	sqlString += ",dscp = :dscp"
	sqlString += ",signed = :signed"
	sqlString += ",qstring_ignore = :qstring_ignore"
	sqlString += ",geo_limit = :geo_limit"
	sqlString += ",http_bypass_fqdn = :http_bypass_fqdn"
	sqlString += ",dns_bypass_ip = :dns_bypass_ip"
	sqlString += ",dns_bypass_ip6 = :dns_bypass_ip6"
	sqlString += ",dns_bypass_ttl = :dns_bypass_ttl"
	sqlString += ",org_server_fqdn = :org_server_fqdn"
	sqlString += ",type = :type"
	sqlString += ",profile = :profile"
	sqlString += ",dns_ttl = :dns_ttl"
	sqlString += ",global_max_mbps = :global_max_mbps"
	sqlString += ",global_max_tps = :global_max_tps"
	sqlString += ",max_dns_answers = :max_dns_answers"
	sqlString += ",info_url = :info_url"
	sqlString += ",miss_lat = :miss_lat"
	sqlString += ",miss_long = :miss_long"
	sqlString += ",check_path = :check_path"
	sqlString += ",protocol = :protocol"
	sqlString += ",ssl_key_version = :ssl_key_version"
	sqlString += ",ipv6_routing_enabled = :ipv6_routing_enabled"
	sqlString += ",range_request_handling = :range_request_handling"
	sqlString += ",edge_header_rewrite = :edge_header_rewrite"
	sqlString += ",origin_shield = :origin_shield"
	sqlString += ",mid_header_rewrite = :mid_header_rewrite"
	sqlString += ",regex_remap = :regex_remap"
	sqlString += ",cacheurl = :cacheurl"
	sqlString += ",remap_text = :remap_text"
	sqlString += ",multi_site_origin = :multi_site_origin"
	sqlString += ",tr_response_headers = :tr_response_headers"
	sqlString += ",initial_dispersion = :initial_dispersion"
	sqlString += ",dns_bypass_cname = :dns_bypass_cname"
	sqlString += ",tr_request_headers = :tr_request_headers"
	sqlString += ",created_at = :created_at"
	sqlString += " WHERE name=:name"
	result, err := db.NamedExec(sqlString, arg)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
// @Title delGooseDbVersionById
// @Description deletes goose_db_version information for a certain id
// @Accept  application/json
// @Param   id              path    int     false        "The row id"
// @Success 200 {array}    GooseDbVersion
// @Resource /api/2.0
// @Router /api/2.0/goose_db_version/{id} [delete]
func delGooseDbVersion(id int, db *sqlx.DB) (interface{}, error) {
	arg := GooseDbVersion{Id: int64(id)}
	result, err := db.NamedExec("DELETE FROM goose_db_version WHERE id=:id", arg)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
Beispiel #27
0
func NewToken(db *sqlx.DB, uid, email string) (*Token, error) {
	t := Token{UserName: uid, Email: email, Token: randToken()}
	_, err := db.NamedExec("replace into token (user_name,email, token,attempts,created_at) values (:user_name, :email, :token, 0, now())", t)
	if err != nil {
		return nil, err
	}

	return &t, nil
}
func (a Activity) Create(db *sqlx.DB) {

	fmt.Println("\n\n\n", a)

	_, err := db.NamedExec(sqlInsertActivity, &a)
	if err != nil {
		panic(err)
	}
}
Beispiel #29
0
// @Title postTmUser
// @Description enter a new tm_user
// @Accept  application/json
// @Param                 Body body     TmUser   true "TmUser object that should be added to the table"
// @Success 200 {object}    output_format.ApiWrapper
// @Resource /api/2.0
// @Router /api/2.0/tm_user [post]
func postTmUser(payload []byte, db *sqlx.DB) (interface{}, error) {
	var v TmUser
	err := json.Unmarshal(payload, &v)
	if err != nil {
		log.Println(err)
	}
	sqlString := "INSERT INTO tm_user("
	sqlString += "username"
	sqlString += ",role"
	sqlString += ",uid"
	sqlString += ",gid"
	sqlString += ",local_passwd"
	sqlString += ",confirm_local_passwd"
	sqlString += ",company"
	sqlString += ",email"
	sqlString += ",full_name"
	sqlString += ",new_user"
	sqlString += ",address_line1"
	sqlString += ",address_line2"
	sqlString += ",city"
	sqlString += ",state_or_province"
	sqlString += ",phone_number"
	sqlString += ",postal_code"
	sqlString += ",country"
	sqlString += ",local_user"
	sqlString += ",token"
	sqlString += ",registration_sent"
	sqlString += ") VALUES ("
	sqlString += ":username"
	sqlString += ",:role"
	sqlString += ",:uid"
	sqlString += ",:gid"
	sqlString += ",:local_passwd"
	sqlString += ",:confirm_local_passwd"
	sqlString += ",:company"
	sqlString += ",:email"
	sqlString += ",:full_name"
	sqlString += ",:new_user"
	sqlString += ",:address_line1"
	sqlString += ",:address_line2"
	sqlString += ",:city"
	sqlString += ",:state_or_province"
	sqlString += ",:phone_number"
	sqlString += ",:postal_code"
	sqlString += ",:country"
	sqlString += ",:local_user"
	sqlString += ",:token"
	sqlString += ",:registration_sent"
	sqlString += ")"
	result, err := db.NamedExec(sqlString, v)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}
Beispiel #30
0
// @Title delServercheckById
// @Description deletes servercheck information for a certain id
// @Accept  application/json
// @Param   id              path    int     false        "The row id"
// @Success 200 {array}    Servercheck
// @Resource /api/2.0
// @Router /api/2.0/servercheck/{id} [delete]
func delServercheck(id int, db *sqlx.DB) (interface{}, error) {
	arg := Servercheck{}
	arg.Id = int64(id)
	result, err := db.NamedExec("DELETE FROM servercheck WHERE id=:id", arg)
	if err != nil {
		log.Println(err)
		return nil, err
	}
	return result, err
}