func GetStream(cl *client.Client, server *mockserver.Server, mode int) (*graylog.Stream, func(string), error) {
	streams, _, _, err := cl.GetStreams()
	if err != nil {
		return nil, nil, err
	}
	if len(streams) != 0 {
		if mode == 1 {
			for _, stream := range streams {
				if stream.IsDefault {
					return &stream, nil, nil
				}
			}
			return nil, nil, fmt.Errorf("default stream is not found")
		}
		if mode == 2 {
			for _, stream := range streams {
				if !stream.IsDefault {
					return &stream, nil, nil
				}
			}
			return nil, nil, fmt.Errorf("not default stream is not found")
		}
		return &(streams[0]), nil, nil
	}
	is, f, err := GetIndexSet(cl, server, "hoge")
	if err != nil {
		return nil, nil, err
	}
	stream := Stream()
	stream.IndexSetID = is.ID
	if _, err := cl.CreateStream(stream); err != nil {
		if f != nil {
			f(is.ID)
		}
		return nil, nil, err
	}
	return stream, func(id string) {
		cl.DeleteStream(id)
		if f != nil {
			f(is.ID)
		}
	}, nil
}
// GetStream returns a stream.
GetStream returns a stream.
// GetStream returns a stream .
func GetStream(cl *client.Client, server *mockserver.Server, mode int) (*graylog.Stream, func(string), error) {
	streams, _, _, err := cl.GetStreams()
	if err != nil {
		return nil, nil, err
	}
	if len(streams) != 0 {
		if mode == 1 {
			for _, stream := range streams {
				if stream.IsDefault {
					return &stream, nil, nil
				}
			}
			return nil, nil, fmt.Errorf("default stream is not found")
		}
		if mode == 2 {
			for _, stream := range streams {
				if !stream.IsDefault {
					return &stream, nil, nil
				}
			}
			return nil, nil, fmt.Errorf("not default stream is not found")
		}
		return &(streams[0]), nil, nil
	}
	is, f, err := GetIndexSet(cl, server, "hoge")
	if err != nil {
		return nil, nil, err
	}
	stream := Stream()
	stream.IndexSetID = is.ID
	if _, err := cl.CreateStream(stream); err != nil {
		if f != nil {
			f(is.ID)
		}
		return nil, nil, err
	}
	return stream, func(id string) {
		cl.DeleteStream(id)
		if f != nil {
			f(is.ID)
		}
	}, nil
}
func GetStream ( cl * client . Client , server * mockserver . Server , mode int ) ( * graylog . Stream , func ( string ) , error ) { streams , _ , _ , err := cl . GetStreams ( ) if err != nil { return nil , nil , err } if len ( streams ) != 0 { if mode == 1 { for _ , stream := range streams { if stream . IsDefault { return & stream , nil , nil } } return nil , nil , fmt . Errorf ( " " ) } if mode == 2 { for _ , stream := range streams { if ! stream . IsDefault { return & stream , nil , nil } } return nil , nil , fmt . Errorf ( " " ) } return & ( streams [ 0 ] ) , nil , nil } is , f , err := GetIndexSet ( cl , server , " " ) if err != nil { return nil , nil , err } stream := Stream ( ) stream . IndexSetID = is . ID if _ , err := cl . CreateStream ( stream ) ; err != nil { if f != nil { f ( is . ID ) } return nil , nil , err } return stream , func ( id string ) { cl . DeleteStream ( id ) if f != nil { f ( is . ID ) } } , nil }
GetStream returns a stream.
GetStream returns a stream .