// DjangoAdminLogsByContentTypeID retrieves a row from 'public.django_admin_log' as a DjangoAdminLog.
//
// Generated from index 'django_admin_log_417f1b1c'.
973249
func DjangoAdminLogsByContentTypeID(db XODB, contentTypeID sql.NullInt64) ([]*DjangoAdminLog, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`id, action_time, object_id, object_repr, action_flag, change_message, content_type_id, user_id ` +
		`FROM public.django_admin_log ` +
		`WHERE content_type_id = $1`

	// run query
	XOLog(sqlstr, contentTypeID)
	q, err := db.Query(sqlstr, contentTypeID)
	if err != nil {
		return nil, err
	}
	defer q.Close()

	// load results
	res := []*DjangoAdminLog{}
	for q.Next() {
		dal := DjangoAdminLog{
			_exists: true,
		}

		// scan
		err = q.Scan(&dal.ID, &dal.ActionTime, &dal.ObjectID, &dal.ObjectRepr, &dal.ActionFlag, &dal.ChangeMessage, &dal.ContentTypeID, &dal.UserID)
		if err != nil {
			return nil, err
		}

		res = append(res, &dal)
	}

	return res, nil
}
1241382
func DetectContentType(body interface{}) string {
	contentType := plainTextType
	kind := kindOf(body)
	switch kind {
	case reflect.Struct, reflect.Map:
		contentType = jsonContentType
	case reflect.String:
		contentType = plainTextType
	default:
		if b, ok := body.([]byte); ok {
			contentType = http.DetectContentType(b)
		} else if kind == reflect.Slice {
			contentType = jsonContentType
		}
	}

	return contentType
}
579433
func NewSmartSyncCreateAdminPrivilegeReportType(Description string) *SmartSyncCreateAdminPrivilegeReportType {
	s := new(SmartSyncCreateAdminPrivilegeReportType)
	s.Description = Description
	return s
}
37782
func detectContentType(body interface{}) string {
	contentType := "text/plain; charset=utf-8"
	kind := reflect.TypeOf(body).Kind()
	
	switch kind {
	case reflect.Struct, reflect.Map, reflect.Ptr:
		contentType = "application/json; charset=utf-8"
	case reflect.String:
		contentType = "text/plain; charset=utf-8"
	default:
		if b, ok := body.([]byte); ok {
			contentType = http.DetectContentType(b)
		} else if kind == reflect.Slice {
			contentType = "application/json; charset=utf-8"
		}
	}

	return contentType
}
274345
func (f *File) setContentTypes(index int) {
	content := f.contentTypesReader()
	content.Overrides = append(content.Overrides, xlsxOverride{
		PartName:    "/xl/worksheets/sheet" + strconv.Itoa(index) + ".xml",
		ContentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml",
	})
}
391314
func (s *Message) SetContentType(v string) *Message {
	s.ContentType = &v
	return s
}
466164
func ResolveContentType(req *Request) string {

	contentType := req.Header.Get("Content-Type")
	if contentType == "" {
		return "text/html"
	}
	return strings.ToLower(strings.TrimSpace(strings.Split(contentType, ";")[0]))
}
48289
func (c *Config) WithContentType(ct string) *Config {
	c.ContentType = ct
	return c
}
1312944
func (l *Limiter) GetMessageContentType() string {
	l.RLock()
	defer l.RUnlock()
	return l.messageContentType
}
113654
func (s *Upload) SetContentType(v string) *Upload {
	s.ContentType = &v
	return s
}
1063070
func (r *ReleaseAsset) GetContentType() string {
	if r == nil || r.ContentType == nil {
		return ""
	}
	return *r.ContentType
}
1019632
func (cm AsStandard) MLookupType(resource, lookup string) *metadata.MLookupType {
	mlt := metadata.MLookupType{}
	mi := metadata.MILookupType
	for _, cd := range cm.Elements[mi.Name] {
		if cd.Attr["Resource"] != resource {
			continue
		}
		if cd.Attr["Lookup"] != lookup {
			continue
		}
		metadata.FieldTransfer(cd.Attr).To(&mlt)
		for _, entry := range cd.Entries() {
			tmp := metadata.LookupType{}
			entry.SetFields(&tmp)
			mlt.LookupType = append(mlt.LookupType, tmp)
		}
	}
	return &mlt
}
705636
func (c *Connection) ObjectUpdateContentType(container string, objectName string, contentType string) (err error) {
	h := Headers{"Content-Type": contentType}
	_, err = c.ObjectCopy(container, objectName, container, objectName, h)
	return
}
343487
func DjangoContentTypeByAppLabelModel(db XODB, appLabel string, model string) (*DjangoContentType, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`id, app_label, model ` +
		`FROM django.django_content_type ` +
		`WHERE app_label = ? AND model = ?`

	// run query
	XOLog(sqlstr, appLabel, model)
	dct := DjangoContentType{
		_exists: true,
	}

	err = db.QueryRow(sqlstr, appLabel, model).Scan(&dct.ID, &dct.AppLabel, &dct.Model)
	if err != nil {
		return nil, err
	}

	return &dct, nil
}
655583
func InvalidContentType(w http.ResponseWriter, r *http.Request) {
	http.Error(w, "Invalid content type:"+r.Header.Get("Content-Type"), http.StatusBadRequest)
}
356314
func DjangoAdminLogByID(db XODB, id int) (*DjangoAdminLog, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`id, object_id, object_repr, action_flag, change_message, content_type_id, user_id, action_time ` +
		`FROM django_admin_log ` +
		`WHERE id = ?`

	// run query
	XOLog(sqlstr, id)
	dal := DjangoAdminLog{
		_exists: true,
	}

	err = db.QueryRow(sqlstr, id).Scan(&dal.ID, &dal.ObjectID, &dal.ObjectRepr, &dal.ActionFlag, &dal.ChangeMessage, &dal.ContentTypeID, &dal.UserID, &dal.ActionTime)
	if err != nil {
		return nil, err
	}

	return &dal, nil
}
964551
func getContentSubtype(contentType string) string {
	if !strings.HasPrefix(contentType, baseContentType) || len(contentType) == len(baseContentType) {
		return ""
	}
	switch contentType[len(baseContentType)] {
	case '+', ';':
		return contentType[len(baseContentType)+1:]
	default:
		return ""
	}
}