001/******************************************************************************* 002 * Copyright (c) 2017 Red Hat Inc 003 * All rights reserved. This program and the accompanying materials 004 * are made available under the terms of the Eclipse Public License v1.0 005 * which accompanies this distribution, and is available at 006 * http://www.eclipse.org/legal/epl-v10.html 007 * 008 * Contributors: 009 * Jens Reimann - initial API and implementation 010 *******************************************************************************/ 011package io.systemd.network; 012 013import java.util.List; 014import java.util.concurrent.CompletableFuture; 015 016import de.dentrassi.varlink.spi.Interface; 017import de.dentrassi.varlink.spi.Syncer; 018 019@Interface(factory = NetworkImpl.Factory.class) 020public interface Network { 021 022 public static class Netdev { 023 024 private int ifindex; 025 private String ifname; 026 027 public int getIfindex() { 028 return ifindex; 029 } 030 031 public void setIfindex(final int ifindex) { 032 this.ifindex = ifindex; 033 } 034 035 public String getIfname() { 036 return ifname; 037 } 038 039 public void setIfname(final String ifname) { 040 this.ifname = ifname; 041 } 042 043 } 044 045 public interface Async { 046 public CompletableFuture<List<Netdev>> list(); 047 } 048 049 public interface Sync { 050 public List<Netdev> list(); 051 } 052 053 public Async async(); 054 055 public default Sync sync() { 056 return new Sync() { 057 058 @Override 059 public List<Netdev> list() { 060 return Syncer.await(async().list()); 061 } 062 }; 063 } 064 065}