code: func (s *Server) ListNetworks(ctx context.Context, request *api.ListNetworksRequest) (*api.ListNetworksResponse, error) {
  	var (
  		networks []*api.Network
  		err      error
  	)
  
  	s.store.View(func(tx store.ReadTx) {
  		switch {
  		case request.Filters != nil && len(request.Filters.Names) > 0:
  			networks, err = store.FindNetworks(tx, buildFilters(store.ByName, request.Filters.Names))
  		case request.Filters != nil && len(request.Filters.NamePrefixes) > 0:
  			networks, err = store.FindNetworks(tx, buildFilters(store.ByNamePrefix, request.Filters.NamePrefixes))
  		case request.Filters != nil && len(request.Filters.IDPrefixes) > 0:
  			networks, err = store.FindNetworks(tx, buildFilters(store.ByIDPrefix, request.Filters.IDPrefixes))
  		default:
  			networks, err = store.FindNetworks(tx, store.All)
  		}
  	})
  	if err != nil {
  		return nil, err
  	}
  
  	if request.Filters != nil {
  		networks = filterNetworks(networks,
  			func(e *api.Network) bool {
  				return filterContains(e.Spec.Annotations.Name, request.Filters.Names)
  			},
  			func(e *api.Network) bool {
  				return filterContainsPrefix(e.Spec.Annotations.Name, request.Filters.NamePrefixes)
  			},
  			func(e *api.Network) bool {
  				return filterContainsPrefix(e.ID, request.Filters.IDPrefixes)
  			},
  			func(e *api.Network) bool {
  				return filterMatchLabels(e.Spec.Annotations.Labels, request.Filters.Labels)
  			},
  		)
  	}
  
  	return &api.ListNetworksResponse{
  		Networks: networks,
  	}, nil
  }
docs: // ListNetworks returns a list of all networks.