Skip to content

Snet.organization

James Chong edited this page Mar 21, 2019 · 1 revision

Organization

Model for organization. Organization object can be retrieved from the Snet model with either listOrganization or getOrganization method.

const orgs = await snet.listOrganizations();
console.log(orgs[0]);
// {id: 'snet'}

const org = await snet.getOrganization('snet');
console.log(org);
// { id: 'snet',
//     name: 'snet',
//     owner: '0xFF2a327ed1Ca40CE93F116C5d6646b56991c0ddE',
//     members:
//      [ '0x4b4546ce47089925E5792E0a6d085BfB876cE621',... ]}

getServices

Get all available services from the organization.

 const services = await organization.getServices();

 const services = await organization.getServices({init:true});
Parameters
  1. InitOptions Options for initialising a model.
    • init: default to false. Only id is retrieve.
Returns

getService

const service = await organization.getService('example-service');
// { id: 'example-service',
//   organizationId: 'snet',
//   metadata:
//    { version: 1,
//      display_name: 'SingularityNET Example Service',
//      encoding: 'proto',
//      service_type: 'grpc', ... } },
//   tags: [ 'Service', 'Example', 'Arithmetic' ] }

const service = await organization.getService('example-service', {init:false});
console.log(service.data);
// {id: 'example-service', organizationId: 'snet'}
Parameters
  1. serviceId string
  2. InitOptions object (optional) Options for initialising a model.
    • init: default to false. Only id is retrieve.
Returns

init

const org = await snet.getOrganization('snet', {init:false});
console.log(org.isInit);
// false
console.log(org.data);
// {id: 'snet'}

await org.init();

console.log(orgservice.isInit);
// true
console.log(org.data);
// { id: 'snet',
//   name: 'snet',
//   owner: '0xFF2a327ed1Ca40CE93F116C5d6646b56991c0ddE',
//   members:
//      [ '0x4b4546ce47089925E5792E0a6d085BfB876cE621',... ]}
Parameters

none

Returns
  • Organization Initialized Organization object.

data

 console.log(organization.data);
Parameters

none

Returns
  • id string
  • name string
  • owner string
  • members string[]
Clone this wiki locally