How to Stop an Instance in OCI Compute Classic

API w/ Java

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Response;

public final class ComputeSample {

  public static void main(final String[] args) {
    final Client client = ClientBuilder.newClient();

    final Response res = client.target("https://host/instance/sampleInstance").request("application/oracle-compute-v3+json").header("cookie", ...).put(Entity.entity("{ \"desired_state\": \"shutdown\" }", "application/oracle-compute-v3+json"));

    if (res.getStatus() == 200)
      out.println(res.readEntity(String.class));

    client.close();
  }

}

API w/ Node.js

const https = require('https');

const req = https.request({ headers: { accept: 'application/oracle-compute-v3+json', 'content-type': 'application/oracle-compute-v3+json', cookie: ... }, hostname: 'host', method: 'PUT', path: '/instance/sampleInstance' }, (res) => {

  if (res.statusCode === 200) {
    var body = '';

    res.on('data', (chunk) => {
      body += chunk.toString();
    });

    res.on('end', () => {
      console.log(body);
    });

  }

});

req.write('{ "desired_state": "shutdown" }');

req.end();

API w/ Python

import requests

res = requests.get('https://host/instance/sampleInstance', headers = { 'accept': 'application/oracle-compute-v3+json', 'content-type': 'application/oracle-compute-v3+json', 'cookie': ...}, json = { 'desired_state': 'shutdown' })

if res.ok:
  print(res.text)

API w/ Ruby

require 'rest-client'

res = RestClient.get 'https://host/instance/sampleInstance', '{ "desired_state": "shutdown" }', { :accept => 'application/oracle-compute-v3+json', :content_type => 'application/oracle-compute-v3+json', :cookies => ... }

if res.code == 200
 puts res.body
end

CLI

Not supported.

Advertisements

How to Get an Instance in OCI Compute Classic

API w/ Java

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

public final class ComputeSample {

  public static void main(final String[] args) {
    final Client client = ClientBuilder.newClient();

    final Response res = client.target("https://host/instance/sampleInstance").request("application/oracle-cloud-v3+json").header("cookie", ...).get();

    if (res.getStatus() == 200)
      out.println(res.readEntity(String.class));

    client.close();
  }

}

API w/ Node.js

const https = require('https');

const req = https.get({ headers: { accept: 'application/oracle-compute-v3+json', cookie: ... }, hostname: 'host', path: '/instance/sampleInstance' }, (res) => {

  if (res.statusCode === 200) {
    var body = '';

    res.on('data', (chunk) => {
      body += chunk.toString();
    });

    res.on('end', () => {
      console.log(body);
    });

  }

});

req.end();

API w/ Python

import requests

res = requests.get('https://host/instance/sampleInstance', headers = { 'accept': 'application/oracle-compute-v3+json', 'cookie': ...)

if res.ok:
  print(res.text)

API w/ Ruby

require 'rest-client'

res = RestClient.get 'https://host/instance/sampleInstance', { :accept => 'application/oracle-compute-v3+json', :cookies => cookie }

if res.code == 200
 puts res.body
end

CLI

1) Run the following command:

opc compute instances get sampleInstance

How to List Instances in OCI Compute Classic

API w/ Java

All Information

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

public final class ComputeSample {

  public static void main(final String[] args) {
    final Client client = ClientBuilder.newClient();

    final Response res = client.target("https://host/instance/sampleUser/").request("application/oracle-compute-v3+json").header("cookie", ...).get();

    if (res.getStatus() == 200)
      out.println(res.readEntity(String.class));

    client.close();
  }

}

Only Names

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

public final class ComputeSample {

  public static void main(final String[] args) {
    final Client client = ClientBuilder.newClient();

    final Response res = client.target("https://host/instance/sampleUser/").request("application/oracle-compute-v3+directory+json").header("cookie", ...).get();

    if (res.getStatus() == 200)
      out.println(res.readEntity(String.class));

    client.close();
  }

}

API w/ Node.js

All Information

const https = require('https');

const req = https.get({ headers: { accept: 'application/oracle-compute-v3+json', cookie: ... }, hostname: 'host', path: '/instance/sampleUser/' }, (res) => {

  if (res.statusCode === 200) {
    var body = '';

    res.on('data', (chunk) => {
      body += chunk.toString();
    });

    res.on('end', () => {
      console.log(body);
    });

  }

});

req.end();

Only Names

const https = require('https');

const req = https.get({ headers: { accept: 'application/oracle-compute-v3+directory+json', cookie: ... }, hostname: 'host', path: '/instance/sampleUser/' }, (res) => {

  if (res.statusCode === 200) {
    var body = '';

    res.on('data', (chunk) => {
      body += chunk.toString();
    });

    res.on('end', () => {
      console.log(body);
    });

  }

});

req.end();

API w/ Python

All Information

import requests

res = requests.get('https://host/instance/sampleUser/', headers = { 'accept': 'application/oracle-compute-v3+json', 'cookie': ...})

if res.ok:
  print(res.text)

Only Names

import requests

res = requests.get('https://host/instance/sampleUser/', headers = { 'accept': 'application/oracle-compute-v3+directory+json', 'cookie': ...})

if res.ok:
  print(res.text)

API w/ Ruby

All Information

require 'rest-client'

res = RestClient.get 'https://host/instance/sampleUser/', { :accept => 'application/oracle-compute-v3+json', :cookies => cookie }

if res.code == 200
 puts res.body
end

Only Names

require 'rest-client'

res = RestClient.get 'https://host/instance/sampleUser/', { :accept => 'application/oracle-compute-v3+directory+json', :cookies => cookie }

if res.code == 200
 puts res.body
end

CLI

1) Run the following command:

opc compute instances list sampleUser

How to Get a Shape in OCI Compute Classic

API w/ Java

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

public final class ComputeSample {

  public static void main(final String[] args) {
    final Client client = ClientBuilder.newClient();

    final Response res = client.target("https://host/shape/sampleShape").request("application/oracle-cloud-v3+json").header("cookie", ...).get();

    if (res.getStatus() == 200)
      out.println(res.readEntity(String.class));

    client.close();
  }

}

API w/ Node.js

const https = require('https');

const req = https.get({ headers: { accept: 'application/oracle-compute-v3+json', cookie: ... }, hostname: 'host', path: '/shape/shapeName' }, (res) => {

  if (res.statusCode === 200) {
    var body = '';

    res.on('data', (chunk) => {
      body += chunk.toString();
    });

    res.on('end', () => {
      console.log(body);
    });

  }

});

req.end();

API w/ Python

import requests

res = requests.get('https://host/shape/sampleShape', headers = { 'accept': 'application/oracle-compute-v3+json', 'cookie': ...})

if res.ok:
  print(res.text)

API w/ Ruby

require 'rest-client'

res = RestClient.get 'https://host/shape/sampleShape', { :accept => 'application/oracle-compute-v3+json', :cookies => ... }

if res.code == 200
 puts res.body
end

CLI

1) Run the following command:

opc compute shapes get shapeName

How to List Shapes in OCI Compute Classic

API w/ Java

import static java.lang.System.out;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Response;

public final class ComputeSample {

  public static void main(final String[] args) {
    final Client client = ClientBuilder.newClient();

    final Response res = client.target("https://host/shape/").request("application/oracle-cloud-v3+json").header("cookie", ...).get();

    if (res.getStatus() == 200)
      out.println(res.readEntity(String.class));

    client.close();
  }

}

API w/ Node.js

const https = require('https');

const req = https.get({ headers: { accept: 'application/oracle-compute-v3+json', cookie: ... }, hostname: 'host', path: '/shape/' }, (res) => {

  if (res.statusCode === 200) {
    var body = '';

    res.on('data', (chunk) => {
      body += chunk.toString();
    });

    res.on('end', () => {
      console.log(body);
    });

  }

});

req.end();

API w/ Python

import requests

res = requests.get('https://host/shape/', headers = { 'accept': 'application/oracle-compute-v3+json', 'cookie': ... })

if res.ok:
  print(res.text)

API w/ Ruby

require 'rest-client'

res = RestClient.get 'https://host/shape/', { :accept => 'application/oracle-compute-v3+json', :cookies => ... }

if res.code == 200
  puts res.body
end

CLI

1) Run the following command:

opc compute shapes list

How to Authenticate an User in OCI Compute Classic

API w/ Java

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;

public final class ComputeSample {

  public static void main(final String[] args) {
    final Client client = ClientBuilder.newClient();

    client.target("https://host/authenticate/").request().post(Entity.entity("{ \"password\": \"samplePassword\", \"user\": \"sampleUser\" }", "application/oracle-cloud-v3+json"));

    client.close();
  }

}

API w/ Node.js

const https = require('https');

const req = https.request({ headers: { 'content-type': 'application/oracle-compute-v3+json' }, hostname: 'host', method: 'POST', path: '/authenticate/' });

req.write('{ "password": "samplePassword", "user": "sampleUser" }')

req.end();

API w/ Python

import requests

requests.post('https://host/authenticate/', headers = { 'content-type': 'application/oracle-compute-v3+json' },  json = { 'password': 'samplePassword', 'user': 'sampleUser' })

API w/ Ruby

require 'rest-client'

RestClient.post 'https://host/authenticate/', '{ "password": "samplePassword", "user": "sampleUser" } ', :content_type => 'application/oracle-compute-v3+json'

CLI

1) Run the following command:

opc compute authentications add samplePassword sampleUser

How to Get Start, End and Home Zone Center Resource Locations in the Oracle Field Service Cloud with the Resource Management API

Java

import static java.lang.System.out;

import toatech.resourcemanagement._1.AuthNodeElement;
import toatech.resourcemanagement._1.GetResourcesLocationsElement;
import toatech.resourcemanagement._1.LocationResourceParams;
import toatech.resourcemanagement._1.LocationResourceParamsList;
import toatech.resourcemanagement._1.ResourceManagementPort;
import toatech.resourcemanagement._1.ResourceManagementService;

public final class OfscSample {

  public static void main(final String[] args) {
    final ResourceManagementService service = new ResourceManagementService();

    final ResourceManagementPort port = service.getResourceManagementPort();

    final GetResourcesLocationsElement req = new GetResourcesLocationsElement();

    final AuthNodeElement user = new AuthNodeElement();

    user.setNow("2017-01-01T00:00:00Z");

    user.setLogin("SampleLogin");

    user.setCompany("SampleCompany");

    user.setAuthString("f3a904e1b89e0433f4f9f4a453370f44c3791d632f8ba50757301ba46f11047f");

    req.setUser(user);

    final LocationResourceParamsList resources = new LocationResourceParamsList();

    final LocationResourceParams resource = new LocationResourceParams();

    resource.setResourceId("SampleResource");

    resources.getResource().add(resource);

    req.setResources(resources);

    out.println(port.getResourcesLocations(req));
  }

}

Node.js

Python

Ruby

How to Set Start, End and Home Zone Center Resource Locations in the Oracle Field Service Cloud with the Resource Management API

Java

import static java.lang.System.out;

import toatech.resourcemanagement._1.AuthNodeElement;
import toatech.resourcemanagement._1.ResourceLocationElement;
import toatech.resourcemanagement._1.ResourceLocationList;
import toatech.resourcemanagement._1.ResourceManagementPort;
import toatech.resourcemanagement._1.ResourceManagementService;
import toatech.resourcemanagement._1.SetResourcesLocationsElement;
import toatech.resourcemanagement._1.WeekdaysList;

public final class OfscSample {

  public static void main(final String[] args) {
    final ResourceManagementService service = new ResourceManagementService();

    final ResourceManagementPort port = service.getResourceManagementPort();

    final SetResourcesLocationsElement req = new SetResourcesLocationsElement();

    final AuthNodeElement user = new AuthNodeElement();

    user.setNow("2017-01-01T00:00:00Z");

    user.setLogin("SampleLogin");

    user.setCompany("SampleCompany");

    user.setAuthString("f3a904e1b89e0433f4f9f4a453370f44c3791d632f8ba50757301ba46f11047f");

    req.setUser(user);

    final ResourceLocationList resourceLocations = new ResourceLocationList();

    final ResourceLocationElement resourceLocation = new ResourceLocationElement();

    resourceLocation.setResourceId("SampleResource");

    resourceLocation.setLocationLabel("Sample Location");

    resourceLocation.setType("start"); // or "end", "home_zone_center"

    final WeekdaysList weekdays = new WeekdaysList();

    weekdays.getWd().add("Mon"); // one of "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" or "all"

    resourceLocation.setWeekdays(weekdays);

    resourceLocations.getResourceLocation().add(resourceLocation);

    req.setResourceLocations(resourceLocations);

    out.println(port.setResourcesLocations(req));
  }

}

Node.js

Python

Ruby

How to Get Resource Locations in the Oracle Field Service Cloud with the Resource Management API

Java

import static java.lang.System.out;

import toatech.resourcemanagement._1.AuthNodeElement;
import toatech.resourcemanagement._1.GetLocationsElement;
import toatech.resourcemanagement._1.LocationResourceParams;
import toatech.resourcemanagement._1.LocationResourceParamsList;
import toatech.resourcemanagement._1.ResourceManagementPort;
import toatech.resourcemanagement._1.ResourceManagementService;

public final class OfscSample {

  public static void main(final String[] args) {
    final ResourceManagementService service = new ResourceManagementService();

    final ResourceManagementPort port = service.getResourceManagementPort();

    final GetLocationsElement req = new GetLocationsElement();

    final AuthNodeElement user = new AuthNodeElement();

    user.setNow("2017-01-01T00:00:00Z");

    user.setLogin("SampleLogin");

    user.setCompany("SampleCompany");

    user.setAuthString("f3a904e1b89e0433f4f9f4a453370f44c3791d632f8ba50757301ba46f11047f");

    req.setUser(user);

    final LocationResourceParamsList resources = new LocationResourceParamsList();

    final LocationResourceParams resource = new LocationResourceParams();

    resource.setResourceId("SampleResource");

    resources.getResource().add(resource);

    req.setResources(resources);

    out.println(port.getLocations(req));
  }

}

Node.js

Python

Ruby