instance details
553840
@ApiOperation(value="Returns information about a specified job.",
            response=RequestInfoInstance.class, code=200)
    @ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), 
            @ApiResponse(code = 200, message = "Successfull response", examples=@Example(value= {
                    @ExampleProperty(mediaType=JSON, value=GET_REQUEST_RESPONSE_JSON)})) })
    @GET
    @Path(JOB_INSTANCE_GET_URI)
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response getRequestById(@javax.ws.rs.core.Context HttpHeaders headers, 
            @ApiParam(value = "identifier of the asynchronous job to be retrieved", required = true, example = "123") @PathParam("jobId") Long requestId,
            @ApiParam(value = "optional flag that indicats if errors should be loaded as well", required = false) @QueryParam("withErrors") boolean withErrors, 
            @ApiParam(value = "optional flag that indicats if input/output data should be loaded as well", required = false) @QueryParam("withData") boolean withData) {

        Variant v = getVariant(headers);
        String type = getContentType(headers);
        // no container id available so only used to transfer conversation id if given by client
        Header conversationIdHeader = buildConversationIdHeader("", context, headers);
        try {

            String response = executorServiceBase.getRequestById(requestId, withErrors, withData, type);

            return createResponse(response, v, Response.Status.OK, conversationIdHeader);
        } catch (IllegalArgumentException e) {
            return notFound(e.getMessage(), v, conversationIdHeader);
        } catch (Exception e) {
            logger.error("Unexpected error during processing {}", e.getMessage(), e);
            return internalServerError(errorMessage(e), v, conversationIdHeader);
        }
    }
1117748
private void printInstanceNames() {
        try {
            System.out.println("Instance name defined in database for server PowerSupply :");
            final String[] instnames = ApiUtil.get_db_obj().get_instance_name_list(ds_exec_name);
            for (final String instname : instnames) {
                System.out.println("\t" + instname);
            }
        } catch (final DevFailed e) {
            Except.print_exception(e);
        }
    }
706363
function new_instance()
	{
		$tab = $this->table_name();
		if(!$tab)
			bors_throw("Try to get new db instance with empty table_name()");

		if(!$this->get('create_time'))
			$this->set_create_time(time());

		if(!$this->get('modify_time'))
			$this->set_modify_time(time());

		$this->set('owner_id', bors()->user_id());
		$this->set('owner_ip', bors()->client()->ip());
		$this->set('last_editor_id', bors()->user_id());

		$this->storage()->create($this);
		$this->changed_fields = array();

		return $this;
	}
570992
public function indexAction()
    {
        $currentAccount = $this->securityContext->getAccount();
        $userWorkspace = $this->workspaceRepository->findOneByName(UserUtility::getPersonalWorkspaceNameForUsername($currentAccount->getAccountIdentifier()));
        /** @var Workspace $userWorkspace */

        $workspacesAndCounts = [
            $userWorkspace->getName() => [
                'workspace' => $userWorkspace,
                'changesCounts' => $this->computeChangesCount($userWorkspace),
                'canPublish' => false,
                'canManage' => false,
                'canDelete' => false
            ]
        ];

        foreach ($this->workspaceRepository->findAll() as $workspace) {
            /** @var Workspace $workspace */
            // FIXME: This check should be implemented through a specialized Workspace Privilege or something similar
            if (!$workspace->isPersonalWorkspace() && ($workspace->isInternalWorkspace() || $this->userService->currentUserCanManageWorkspace($workspace))) {
                $workspacesAndCounts[$workspace->getName()]['workspace'] = $workspace;
                $workspacesAndCounts[$workspace->getName()]['changesCounts'] = $this->computeChangesCount($workspace);
                $workspacesAndCounts[$workspace->getName()]['canPublish'] = $this->userService->currentUserCanPublishToWorkspace($workspace);
                $workspacesAndCounts[$workspace->getName()]['canManage'] = $this->userService->currentUserCanManageWorkspace($workspace);
                $workspacesAndCounts[$workspace->getName()]['dependentWorkspacesCount'] = count($this->workspaceRepository->findByBaseWorkspace($workspace));
            }
        }

        $this->view->assign('userWorkspace', $userWorkspace);
        $this->view->assign('workspacesAndChangeCounts', $workspacesAndCounts);
    }
1200908
private static int getInstanceAge(Instance myInstance) {
        Date launchDate = myInstance.getLaunchTime();
        long diffInMillies = System.currentTimeMillis() - launchDate.getTime();
        return (int) TimeUnit.DAYS
                .convert(diffInMillies, TimeUnit.MILLISECONDS);
    }
1024817
def show_instance(name, conn=None, call=None):
    '''
    

    '''
    if call != 'action':
        raise SaltCloudSystemExit(
            'The show_instance action must be called with -a or --action.'
        )
    if conn is None:
        conn = get_conn()

    node = conn.get_server(name, bare=True)
    ret = dict(node)
    ret['id'] = node.id
    ret['name'] = node.name
    ret['size'] = conn.get_flavor(node.flavor.id).name
    ret['state'] = node.status
    ret['private_ips'] = _get_ips(node, 'private')
    ret['public_ips'] = _get_ips(node, 'public')
    ret['floating_ips'] = _get_ips(node, 'floating')
    ret['fixed_ips'] = _get_ips(node, 'fixed')
    if isinstance(node.image, six.string_types):
        ret['image'] = node.image
    else:
        ret['image'] = conn.get_image(node.image.id).name
    return ret
603487
def show_instance(name, call=None):
    '''
    
    '''
    if call != 'action':
        raise SaltCloudSystemExit(
            'The show_instance action must be called with -a or --action.'
        )

    nodes = list_nodes_full()
    # Find under which cloud service the name is listed, if any
    if name not in nodes:
        return {}
    __utils__['cloud.cache_node'](nodes[name], __active_provider_name__, __opts__)
    return nodes[name]
757668
def show_instance(name, session=None, call=None):
    '''
    

    '''
    if call == 'function':
        raise SaltCloudException(
            'The show_instnce function must be called with -a or --action.'
        )
    log.debug('show_instance-> name: %s session: %s', name, session)
    if session is None:
        session = _get_session()
    vm = _get_vm(name, session=session)
    record = session.xenapi.VM.get_record(vm)
    if not record['is_a_template'] and not record['is_control_domain']:
        try:
            base_template_name = record['other_config']['base_template_name']
        except Exception:
            base_template_name = None
            log.debug(
                'VM %s, doesnt have base_template_name attribute',
                record['name_label']
            )
        ret = {'id': record['uuid'],
               'image': base_template_name,
               'name': record['name_label'],
               'size': record['memory_dynamic_max'],
               'state': record['power_state'],
               'private_ips': get_vm_ip(name, session),
               'public_ips': None}

        __utils__['cloud.cache_node'](
            ret,
            __active_provider_name__,
            __opts__
        )
    return ret
1108333
def _child_inst_names(self) -> Set[InstanceName]:
        """"""
        return frozenset([c.iname() for c in self.data_children()])
861322
protected void check(Instances data) throws Exception {
    if (m_Owner == null)
      throw new IllegalStateException("No owner set!");
    if (data == null)
      throw new IllegalStateException("No data provided!");
  }
258049
protected static function create_level_instances() {
        global $DB;

        $sql = "SELECT ".CONTEXT_COURSECAT.", cc.id
                  FROM {course_categories} cc
                 WHERE NOT EXISTS (SELECT 'x'
                                     FROM {context} cx
                                    WHERE cc.id = cx.instanceid AND cx.contextlevel=".CONTEXT_COURSECAT.")";
        $contextdata = $DB->get_recordset_sql($sql);
        foreach ($contextdata as $context) {
            context::insert_context_record(CONTEXT_COURSECAT, $context->id, null);
        }
        $contextdata->close();
    }
219676
private function processInstances(): void
    {
        $preliminaryMap = [];
        foreach ($this->instances as $instance) {
            $preliminaryMap[get_class($instance)][] = $instance;
            foreach (class_parents($instance) as $parentClass) {
                $preliminaryMap[$parentClass][] = $instance;
            }
            foreach (class_implements($instance) as $parentClass) {
                $preliminaryMap[$parentClass][] = $instance;
            }
        }

        $nextIndex    = 0;
        $hashMap      = []; // hash  => index
        $settingsData = []; // index => instance data
        $getIndex     = function (SettingsInterface $instance) use (&$nextIndex, &$hashMap, &$settingsData): int {
            $hash = spl_object_hash($instance);
            if (array_key_exists($hash, $hashMap) === true) {
                $index = $hashMap[$hash];
            } else {
                $hashMap[$hash]           = $nextIndex;
                $settingsData[$nextIndex] = $instance->get($this->getApplicationData());
                $index                    = $nextIndex++;
            }

            return $index;
        };

        $settingsMap  = []; // class => index
        $ambiguousMap = []; // class => true
        foreach ($preliminaryMap as $class => $instanceList) {
            if (count($instanceList) === 1) {
                $selected = $instanceList[0];
            } else {
                $selected = $this->selectChildSettings($instanceList);
            }
            if ($selected !== null) {
                $settingsMap[$class] = $getIndex($selected);
            } else {
                $ambiguousMap[$class] = true;
            }
        }

        $this->settingsMap  = $settingsMap;
        $this->settingsData = $settingsData;
        $this->ambiguousMap = $ambiguousMap;
        $this->isProcessed  = true;
    }
1153738
def iname(self) -> InstanceName:
        """"""
        dp = self.data_parent()
        return (self.name if dp and self.ns == dp.ns
                else self.ns + ":" + self.name)
675279
public function describe()
    {
        $this->enableByDefault();
        $this->registerDefault(
            function (Settings $settings) {
                /** @var TransportInfrastructure $transportInfrastructure */
                $transportInfrastructure = $settings->get(TransportInfrastructure::class);
                $settings->setDefault(
                    KnownSettingsEnum::LOCAL_ADDRESS,
                    $transportInfrastructure->toTransportAddress($settings->get(KnownSettingsEnum::ENDPOINT_NAME))
                );
            }
        );
    }
746354
def get_info(cls):
        
        return '\n'.join(
            [str(cls._instances[key]) for key in cls._instances]
        )
531928
def instances_changed(self):
        """"""
        value = bool(lib.EnvGetInstancesChanged(self._env))
        lib.EnvSetInstancesChanged(self._env, int(False))

        return value
490747
public function index()
    {
        if (!userHasPermission('admin:invoice:invoice:manage')) {
            unauthorised();
        }

        // --------------------------------------------------------------------------

        //  Are we dealing with a filtered view?
        $oInput         = Factory::service('Input');
        $oCustomerModel = Factory::model('Customer', 'nails/module-invoice');
        $iCustomerId    = $oInput->get('customer_id');

        if ($iCustomerId) {
            $oCustomer = $oCustomerModel->getbyId($iCustomerId);
        }

        // --------------------------------------------------------------------------

        //  Set method info
        $this->data['page']->title = empty($oCustomer) ? 'Manage Invoices' : possessive($oCustomer->label) . ' invoices';

        // --------------------------------------------------------------------------

        $sTableAlias = $this->oInvoiceModel->getTableAlias();

        //  Get pagination and search/sort variables
        $iPage      = $oInput->get('page') ? $oInput->get('page') : 0;
        $iPerPage   = $oInput->get('perPage') ? $oInput->get('perPage') : 50;
        $sSortOn    = $oInput->get('sortOn') ? $oInput->get('sortOn') : $sTableAlias . '.created';
        $sSortOrder = $oInput->get('sortOrder') ? $oInput->get('sortOrder') : 'desc';
        $sKeywords  = $oInput->get('keywords') ? $oInput->get('keywords') : '';

        // --------------------------------------------------------------------------

        //  Define the sortable columns
        $aSortColumns = [
            $sTableAlias . '.created'  => 'Created Date',
            $sTableAlias . '.modified' => 'Modified Date',
            $sTableAlias . '.state'    => 'Invoice State',
        ];

        // --------------------------------------------------------------------------

        //  Define the filters
        $aCbFilters = [];

        //  States
        $aStateOptions = [];
        $aStates       = $this->oInvoiceModel->getStates();

        foreach ($aStates as $sState => $sLabel) {
            $aStateOptions[] = [
                $sLabel,
                $sState,
                true,
            ];
        }

        $aCbFilters[] = Helper::searchFilterObject(
            $sTableAlias . '.state',
            'State',
            $aStateOptions
        );

        //  Currencies
        $oCurrency        = Factory::service('Currency', 'nails/module-currency');
        $aCurrencyOptions = [];
        $aCurrencies      = $oCurrency->getAllEnabled();

        foreach ($aCurrencies as $oCurrency) {
            $aCurrencyOptions[] = [
                $oCurrency->code,
                $oCurrency->code,
                true,
            ];
        }

        $aCbFilters[] = Helper::searchFilterObject(
            $sTableAlias . '.currency',
            'Currency',
            $aCurrencyOptions
        );

        // --------------------------------------------------------------------------

        //  Define the $aData variable for the queries
        $aData = [
            'where'     => array_filter([
                !empty($oCustomer) ? ['customer_id', $oCustomer->id] : null,
            ]),
            'sort'      => [
                [$sSortOn, $sSortOrder],
            ],
            'expand'    => ['customer', 'payments'],
            'keywords'  => $sKeywords,
            'cbFilters' => $aCbFilters,
        ];

        //  Get the items for the page
        $iTotalRows             = $this->oInvoiceModel->countAll($aData);
        $this->data['invoices'] = $this->oInvoiceModel->getAll($iPage, $iPerPage, $aData);

        //  Set Search and Pagination objects for the view
        $this->data['search']     = Helper::searchObject(true, $aSortColumns, $sSortOn, $sSortOrder, $iPerPage, $sKeywords, $aCbFilters);
        $this->data['pagination'] = Helper::paginationObject($iPage, $iPerPage, $iTotalRows);

        //  Add a header button
        if (userHasPermission('admin:invoice:invoice:create')) {
            Helper::addHeaderButton(
                'admin/invoice/invoice/create',
                'Create Invoice'
            );
        }

        // --------------------------------------------------------------------------

        Helper::loadView('index');
    }