func (lgc *Logic) UpdateStream(prms *graylog.StreamUpdateParams) (*graylog.Stream, int, error) {
	if prms == nil {
		return nil, 400, fmt.Errorf("stream is nil")
	}
	if err := validator.UpdateValidator.Struct(prms); err != nil {
		return nil, 400, err
	}
	stream, sc, err := lgc.GetStream(prms.ID)
	if err != nil {
		LogWE(sc, lgc.Logger().WithFields(log.Fields{
			"error": err, "id": prms.ID, "status_code": sc,
		}), "failed to get a stream")
		return nil, sc, err
	}
	if stream.IsDefault {
		return nil, 400, fmt.Errorf("the default stream cannot be edited")
	}
	// check index set existence
	if prms.IndexSetID != "" {
		is, sc, err := lgc.GetIndexSet(prms.IndexSetID)
		if err != nil {
			LogWE(sc, lgc.Logger().WithFields(log.Fields{
				"error": err, "index_set_id": prms.IndexSetID, "status_code": sc,
			}), "failed to get an index set")
			return nil, sc, err
		}
		if !is.Writable {
			return nil, 400, fmt.Errorf("assigned index set must be writable")
		}
	}
	s, err := lgc.store.UpdateStream(prms)
	if err != nil {
		return nil, 500, err
	}
	return s, 200, nil
}
// UpdateStream updates a stream at the Server.
UpdateStream updates a stream at the Server.
// UpdateStream updates a stream at the Server .
func (lgc *Logic) UpdateStream(prms *graylog.StreamUpdateParams) (*graylog.Stream, int, error) {
	if prms == nil {
		return nil, 400, fmt.Errorf("stream is nil")
	}
	if err := validator.UpdateValidator.Struct(prms); err != nil {
		return nil, 400, err
	}
	stream, sc, err := lgc.GetStream(prms.ID)
	if err != nil {
		LogWE(sc, lgc.Logger().WithFields(log.Fields{
			"error": err, "id": prms.ID, "status_code": sc,
		}), "failed to get a stream")
		return nil, sc, err
	}
	if stream.IsDefault {
		return nil, 400, fmt.Errorf("the default stream cannot be edited")
	}
	if prms.IndexSetID != "" {
		is, sc, err := lgc.GetIndexSet(prms.IndexSetID)
		if err != nil {
			LogWE(sc, lgc.Logger().WithFields(log.Fields{
				"error": err, "index_set_id": prms.IndexSetID, "status_code": sc,
			}), "failed to get an index set")
			return nil, sc, err
		}
		if !is.Writable {
			return nil, 400, fmt.Errorf("assigned index set must be writable")
		}
	}
	s, err := lgc.store.UpdateStream(prms)
	if err != nil {
		return nil, 500, err
	}
	return s, 200, nil
}
func ( lgc * Logic ) UpdateStream ( prms * graylog . StreamUpdateParams ) ( * graylog . Stream , int , error ) { if prms == nil { return nil , 400 , fmt . Errorf ( " " ) } if err := validator . UpdateValidator . Struct ( prms ) ; err != nil { return nil , 400 , err } stream , sc , err := lgc . GetStream ( prms . ID ) if err != nil { LogWE ( sc , lgc . Logger ( ) . WithFields ( log . Fields { " " : err , " " : prms . ID , " " : sc , } ) , " " ) return nil , sc , err } if stream . IsDefault { return nil , 400 , fmt . Errorf ( " " ) } if prms . IndexSetID != " " { is , sc , err := lgc . GetIndexSet ( prms . IndexSetID ) if err != nil { LogWE ( sc , lgc . Logger ( ) . WithFields ( log . Fields { " " : err , " " : prms . IndexSetID , " " : sc , } ) , " " ) return nil , sc , err } if ! is . Writable { return nil , 400 , fmt . Errorf ( " " ) } } s , err := lgc . store . UpdateStream ( prms ) if err != nil { return nil , 500 , err } return s , 200 , nil }
UpdateStream updates a stream at the Server.
UpdateStream updates a stream at the Server .
// check index set existence