Riferimento API

Applicazione

Verificare app.capabilities per il supporto delle funzionalità e app.access insieme alle autorizzazioni host per l’autorizzazione. Gli esempi usano valori sintetici; sostituire percorsi, ID, input e filtri prima della chiamata.

Definizioni di tipo

graphql
type Mutation {
  clearAppCache: Boolean!
  restartHttpServer(httpPort: Int, httpsPort: Int): HttpServerState!
  relaunchApp: Boolean!
  requestAccess(feature: AccessFeature!): Boolean!
  setTempValue(key: String!, value: String!): KeyValuePair!
  updateDeviceName(name: String!): Boolean!
}

type Query {
  appCacheSize: Long!
  appUpdate: AppUpdate!
  httpServer: HttpServer!
  app: App!
}

type Subscription {
  httpServerChanged: HttpServer!
  deviceNameUpdated: String!
  accessUpdated: Boolean!
  contentChanged: Boolean!
}

enum AccessFeature {
	IMAGES
	VIDEOS
	AUDIO
	DOCS
	FILES
	CONTACTS
	SMS
	CALLS
	CALL_PHONE
	PHONE_NUMBER
	APPS
	NOTIFICATIONS
	CLIPBOARD
	ADB
}

type App {
	clientId: ID!
	httpPort: Int!
	httpsPort: Int!
	deviceName: String!
	developerMode: Boolean!
	urlToken: String!
	tlsCertificateSha256: String
	appDir: String!
	deviceType: DeviceType!
	capabilities: [Capability!]!
	buildChannel: AppChannelType!
	access: [AccessFeature!]!
	downloadsDir: String!
	debug: Boolean!
}

enum AppChannelType {
	GITHUB
	GOOGLE
	FDROID
}

type AppUpdate {
	currentVersion: String!
	latestVersion: String
	releaseName: String!
	publishedAt: Instant
	hasUpdate: Boolean!
	url: String
}

enum Capability {
	ADB
	BLE
	WIFI_AWARE
	APP_RELAUNCH
	MEDIA_TRASH
	MEDIA_DELETE
	MEDIA_MOVE
	MEDIA_FAVORITE
	APP_UPDATES
	MIRROR_AUDIO
	MEDIA_SCAN
	TELEPHONY
	PACKAGES
	SCREEN_MIRROR
	NOTIFICATIONS
	CLIPBOARD
	DISK_MANAGER
	HTTP_SERVER
}

enum DeviceType {
	COMPUTER
	PHONE
	TABLET
	TV
	NAS
	OTHER
}

type HttpServer {
	state: HttpServerState!
	addresses: [String!]!
	onlineClients: [ID!]!
	remoteAccess: Boolean!
	mdnsHostname: String!
}

type HttpServerState {
	revision: Long!
	restarting: Boolean!
	httpPort: Int!
	httpsPort: Int!
	error: String!
}

scalar Instant

type KeyValuePair {
	key: String!
	value: String!
}

scalar Long

Operazioni

mutation

clearAppCache

Eliminare i file temporanei della cache dell’applicazione.

graphql
mutation clearAppCache {
  clearAppCache
}
mutation

restartHttpServer

Modificare le porte HTTP/HTTPS e attendere che i nuovi listener siano pronti. Richiede HTTP_SERVER. Restituisce le porte effettive; riconnettersi se cambia l’indirizzo corrente.

graphql
mutation restartHttpServer($httpPort: Int, $httpsPort: Int) {
  restartHttpServer(httpPort: $httpPort, httpsPort: $httpsPort) { revision restarting httpPort httpsPort error }
}
query

appCacheSize

Restituire lo spazio usato dalla cache dell’applicazione in byte.

graphql
query appCacheSize {
  appCacheSize
}
query

appUpdate

Leggere le informazioni disponibili sugli aggiornamenti dell’applicazione.

graphql
query appUpdate {
  appUpdate { currentVersion latestVersion releaseName publishedAt hasUpdate url }
}
query

httpServer

Leggere lo stato HTTP/HTTPS, gli indirizzi LAN, i client connessi e lo stato dell’accesso remoto. Richiede un chiamante autenticato e HTTP_SERVER.

graphql
query httpServer {
  httpServer { addresses onlineClients remoteAccess mdnsHostname }
}
subscription

httpServerChanged

Ricevi lo stato corrente del server HTTP alla sottoscrizione e dopo modifiche ai listener, alla rete, ai client connessi o alle preferenze. Richiede un chiamante autenticato e il supporto HTTP_SERVER. Annulla la sottoscrizione quando esci dalla pagina e riattivala al ritorno.

graphql
subscription httpServerChanged {
  httpServerChanged { addresses onlineClients remoteAccess mdnsHostname }
}
subscription

deviceNameUpdated

Ricevere il nome visualizzato aggiornato del dispositivo.

graphql
subscription deviceNameUpdated {
  deviceNameUpdated
}
subscription

accessUpdated

Ricevere un segnale quando cambia l’autorizzazione delle funzionalità del dispositivo.

graphql
subscription accessUpdated {
  accessUpdated
}
subscription

contentChanged

Ricevere un segnale quando cambia il contenuto memorizzato.

graphql
subscription contentChanged {
  contentChanged
}
mutation

relaunchApp

Riavviare il processo PlainApp sul dispositivo.

graphql
# The app restarts itself; the response only acknowledges that the
# request was accepted, since the connection dies with the process.
mutation relaunchApp {
  relaunchApp
}
mutation

requestAccess

Richiedere l’autorizzazione del dispositivo per una funzionalità supportata; potrebbe essere necessario l’intervento dell’utente sul dispositivo.

graphql
mutation requestAccess($feature: AccessFeature!) {
  requestAccess(feature: $feature)
}
mutation

setTempValue

Impostare e restituire una coppia chiave/valore temporanea in memoria; non si tratta di dati Key Value persistenti.

graphql
mutation setTempValue($key: String!, $value: String!) {
  setTempValue(key: $key, value: $value) { key value }
}
mutation

updateDeviceName

Cambiare il nome del dispositivo visualizzato nell’interfaccia web e comunicato ai peer associati.

graphql
# Renaming the device also re-publishes the mDNS advertisement, so a
# client that waits for the new name to appear does see it.
mutation updateDeviceName($name: String!) {
  updateDeviceName(name: $name)
}
query

app

Leggere identità, configurazione, capacità e autorizzazioni dell’applicazione. app.urlToken appartiene alla sessione chiamante e cifra i collegamenti alle risorse; non è il token di autenticazione GraphQL.

graphql
# Everything a client needs to reach this device: its identity, the
# port it listens on and the token that authorises it.
query app {
  app { clientId httpPort httpsPort deviceName developerMode urlToken tlsCertificateSha256 appDir }
}