Codota Logo
Region
Code IndexAdd Codota to your IDE (free)

How to use
Region
in
io.cattle.platform.core.model

Best Java code snippets using io.cattle.platform.core.model.Region (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
OutputStreamWriter o =
  • Codota IconOutputStream out;new OutputStreamWriter(out)
  • Codota IconOutputStream out;String charsetName;new OutputStreamWriter(out, charsetName)
  • Codota IconHttpURLConnection connection;new OutputStreamWriter(connection.getOutputStream())
  • Smart code suggestions by Codota
}
origin: rancher/cattle

/**
 * {@inheritDoc}
 */
@Override
public void from(io.cattle.platform.core.model.Region from) {
  setId(from.getId());
  setName(from.getName());
  setAccountId(from.getAccountId());
  setKind(from.getKind());
  setUuid(from.getUuid());
  setDescription(from.getDescription());
  setState(from.getState());
  setCreated(from.getCreated());
  setRemoved(from.getRemoved());
  setRemoveTime(from.getRemoveTime());
  setData(from.getData());
  setUrl(from.getUrl());
  setPublicValue(from.getPublicValue());
  setSecretValue(from.getSecretValue());
  setLocal(from.getLocal());
}
origin: rancher/cattle

/**
 * {@inheritDoc}
 */
@Override
public <E extends io.cattle.platform.core.model.Region> E into(E into) {
  into.from(this);
  return into;
}
origin: rancher/cattle

private static Request setHeaders(Request req, Region region) {
  String publicKey = region.getPublicValue();
  String secretKey = region.getSecretValue();
  String encodedKeys = Base64.encodeBase64String(String.format("%s:%s", publicKey, secretKey).getBytes());
  String auth = String.format("Basic %s", encodedKeys);
  req.addHeader("Authorization", auth);
  req.addHeader("X-ENFORCE-AUTHENTICATION", "true");
  req.addHeader("Content-Type", "application/json");
  req.addHeader("Accept", "application/json");
  return req;
}
origin: rancher/cattle

private boolean regionUpdated(Object oldObj, Region region) {
  Map<String, Object> old = CollectionUtils.toMap(oldObj);
  if(old.containsKey("url")) {
    String oldURL = (String) old.get("url");
    if(isChanged(oldURL, region.getUrl())) {
      return true;
    }
  }
  if(old.containsKey("publicValue")) {
    String oldPublicValue = (String) old.get("publicValue");
    if(isChanged(oldPublicValue, region.getPublicValue())) {
      return true;
    }
  }
  if(old.containsKey("secretValue")) {
    String oldSecretValue = (String) old.get("secretValue");
    if(isChanged(oldSecretValue, region.getSecretValue())) {
      return true;
    }
  }
  return false; 
}

origin: rancher/cattle

  @Override
  public ExternalAgent handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
    if (response.getStatusLine().getStatusCode() >= 300) {
      throw new IOException(
          String.format("Failed to create external agent with uri [%s] in environment [%s] in region [%s]: response error code %s",
              params.get(AgentConstants.FIELD_URI),
              targetEnvName,
              targetRegion.getName(),
              response.getStatusLine().getReasonPhrase()));
    }
    return jsonMapper.readValue(response.getEntity().getContent(), ExternalAgent.class);
  }
});
origin: rancher/cattle

@Override
public boolean isRegionsEmpty(Agent agent, Account account, Map<String, Long> externalLinks,  Map<String, ExternalProject> projects, 
    Map<Long, Region> regionsIds, Map<String, Region> regionNameToRegion) {
    List<Region> regions = objectManager.find(Region.class, REGION.REMOVED, (Object) null);
    for(Region region : regions) {
      regionsIds.put(region.getId(), region);
      regionNameToRegion.put(region.getName(), region);
    }
    
  getLinkedEnvironments(account.getId(), externalLinks, regionsIds, projects);
  boolean noExternalLinks = externalLinks.isEmpty();
  List<? extends ExternalCredential> existing = DataAccessor.fieldObjectList(agent, AccountConstants.FIELD_EXTERNAL_CREDENTIALS, ExternalCredential.class,
      jsonMapper);
  boolean noExternalCreds = existing.isEmpty();
  if (noExternalLinks && noExternalCreds) {
    return true;
  }
    
    return false;
}
origin: rancher/cattle

  @Override
  public void doWithLockNoResult() {
    List<Region> regions = objectManager.find(Region.class, REGION.REMOVED, new Condition(ConditionType.NULL));
    if (regions.size() == 0) {
      return;
    }
    Account localAccount = objectManager.loadResource(Account.class, accountId);
    if (INVALID_STATES.contains(localAccount.getState())) {
      return;
    }
    Map<String, Region> regionsMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    Region localRegion = null;
    for (Region region : regions) {
      regionsMap.put(region.getName(), region);
      if (region.getLocal()) {
        localRegion = region;
      }
    }
    List<AccountLink> toRemove = new ArrayList<>();
    List<AccountLink> toUpdate = new ArrayList<>();
    Set<String> toCreate = new HashSet<>();
    fetchAccountLinks(accountId, regionsMap, localRegion, toRemove, toUpdate, toCreate);
    reconcileAccountLinks(accountId, regionsMap, toRemove, toUpdate, toCreate);
  }
});
origin: rancher/cattle

@Override
public void run() {
  List<Region> regions = objectManager.find(Region.class, REGION.REMOVED, new Condition(ConditionType.NULL));
  if (regions.size() == 0) {
    return;
  }
  Region localRegion = null;
  Map<Long, Region> regionMap = new HashMap<Long, Region>();
  for(Region region : regions) {
    regionMap.put(region.getId(), region);
    if(region.getLocal()) {
      localRegion = region;
    }
  }
  
  HashSet<String> existingLinks = new HashSet<String>();
  cleanLinks(regionMap, existingLinks, localRegion);
  
  cleanAgents(existingLinks);
      
  reconcileAccountLinks();
}
origin: rancher/cattle

Region region = regionsMap.get(regionName);
ExternalProject externalProject = null;
if (region != null && !INVALID_STATES.contains(region.getState())) {
  try {
    String externalProjectKey = String.format("%s:%s", regionName, envName);
      ACCOUNT_LINK.LINKED_REGION_ID, region.getId(), "linkedAccountUuid", externalProject.getUuid());
  toUpdate.add(link);
  } catch(Exception ex) {
origin: rancher/cattle

private static String getUrl(Region region) {
  return region.getUrl();
}
origin: rancher/cattle

@Override
public boolean reconcileAgentExternalCredentials(Agent agent, Account account, Map<String, Long> externalLinks, Map<String, ExternalProject> projects, 
    Map<Long, Region> regionsIds, Map<String, Region> regionNameToRegion) {
  Region localRegion = null;
  for (Region region : regionsIds.values()) {
    if (region.getLocal()) {
      localRegion = region;
    }
  }
  boolean success = true;
  // 2. Reconcile agent's credentials
  try {
    reconcileExternalCredentials(account, agent, localRegion, externalLinks, projects, regionNameToRegion);
  } catch (Exception ex) {
    success = false;
    log.error(String.format("Fail to reconcile credentials for agent [%d]", agent.getId()), ex);
  }
  return success;
}
origin: rancher/cattle

  private void cleanupExternalLinks(Region region) {
    for (AccountLink link : objectManager.find(AccountLink.class, ACCOUNT_LINK.REMOVED, null, ACCOUNT_LINK.LINKED_REGION_ID, region.getId())) {
      if (!link.getState().equalsIgnoreCase(CommonStatesConstants.REMOVING)) {
        objectProcessManager.executeStandardProcess(StandardProcess.REMOVE, link, null);
      }
    }
  }
}
origin: rancher/cattle

public MetaHelperInfo(Account account, Map<Long, Account> accounts, Set<Long> otherAccountsServicesIds,
    Set<Long> otherAccountsStackIds,
    MetaDataInfoDao dao, Region regionObj) {
  super();
  this.accounts = accounts;
  this.otherAccountsServicesIds = otherAccountsServicesIds;
  this.otherAccountsStackIds = otherAccountsStackIds;
  this.account = account;
  // may be fix in the future - get health checker hosts ids for instances of other accounts
  // otherwise this info is irrelevant
  this.instanceIdToHealthCheckers = dao.getInstanceIdToHealthCheckers(account);
  this.hostIdToHostMetadata = dao.getHostIdToHostMetadata(account, accounts, otherAccountsServicesIds);
  if (regionObj != null) {
    regionName = regionObj.getName();
  }
}
origin: rancher/cattle

private void getLinkedEnvironments(long accountId, Map<String, Long> links, Map<Long, Region> regionsIds,
    Map<String, ExternalProject> externalProjects) {
  List<AccountLink> accountLinks = objectManager.find(AccountLink.class, ACCOUNT_LINK.ACCOUNT_ID,
      accountId, ACCOUNT_LINK.REMOVED, null, ACCOUNT_LINK.LINKED_REGION_ID, new Condition(ConditionType.NOTNULL));
  for (AccountLink link : accountLinks) {
      if (link.getState().equalsIgnoreCase(CommonStatesConstants.REMOVING)) {
        continue;
      }
      if(link.getState().equalsIgnoreCase(CommonStatesConstants.REMOVED)) {
        continue;
      }
    Region targetRegion = regionsIds.get(link.getLinkedRegionId());
    if (targetRegion == null) {
      continue;
    }
    String UUID = getUUID(targetRegion.getName(), link.getLinkedAccount());
    if (!externalProjects.containsKey(UUID)) {
      links.put(UUID, targetRegion.getId());
    }
  }
}
origin: rancher/cattle

  @Override
  public void fetchCredentials(MetaHelperInfo helperInfo, Agent agent, OutputStream os) {
      Map<Long, Region> regionsIds = new HashMap<>();
      Map<String, Region> regionNameToRegion = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    Map<String, Long> externalLinks = new HashMap<>();
    Map<String, ExternalProject> projects = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
      
    if(regionService.isRegionsEmpty(agent, helperInfo.getAccount(), externalLinks, projects, regionsIds, regionNameToRegion)) {
        return;
      }
      
    regionService.reconcileAgentExternalCredentials(agent, helperInfo.getAccount(), externalLinks, projects, regionsIds, regionNameToRegion);
    List<ExternalCredential> creds = DataAccessor.fieldObjectList(objectMgr.reload(agent), AccountConstants.FIELD_EXTERNAL_CREDENTIALS,
        ExternalCredential.class, jsonMapper);
    for (ExternalCredential cred : creds) {
      Region region = regionNameToRegion.get(cred.getRegionName());
      CredentialMetaData meta = new CredentialMetaData(region.getUrl(), cred.getPublicValue(), cred.getSecretValue());
      writeToJson(os, meta);
    }
  }
}
origin: rancher/cattle

  @Override
  public boolean deactivateAndRemoveExternalAgent(Agent agent) {
    List<? extends ExternalCredential> creds = DataAccessor.fieldObjectList(agent, AccountConstants.FIELD_EXTERNAL_CREDENTIALS, ExternalCredential.class,
        jsonMapper);
    if (creds.isEmpty()) {
      return true;
    }

    Map<String, Region> regions = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    for (Region region : objectManager.find(Region.class, REGION.REMOVED, new Condition(ConditionType.NULL))) {
      regions.put(region.getName(), region);
    }
    for (ExternalCredential cred : creds) {
      if (!deactivateAndRemoveExternalAgent(agent, cred)) {
        return false;
      }
    }
    return true;
  }
}
origin: rancher/cattle

String UUID = getUUID(targetRegion.getName(), cred.getEnvironmentName());
ExternalProject targetResourceAccount = null;
if (externalProjects.containsKey(UUID)) {
  if (targetResourceAccount == null) {
    throw new RuntimeException(String.format("Failed to find target environment by name [%s] in region [%s]",
        cred.getEnvironmentName(), targetRegion.getName()));
String targetAgentUri = RegionUtil.getTargetAgentUri(localRegion.getName(), account.getName(), agent.getUuid(), targetResourceAccount.getUuid());
log.info(String.format("Creating external agent with uri [%s] in environment [%s] in region [%s]",
    targetAgentUri,
origin: rancher/cattle

    return;
ExternalRegion externalRegion = RegionUtil.getExternalRegion(targetRegion, localRegion.getName(), jsonMapper);
if (externalRegion == null) {
  throw new RuntimeException(String.format("Failed to find local region [%s] in external region [%s]",
      localRegion.getName(), targetRegion.getName()));
if (targetResourceAccount == null) {
  throw new RuntimeException(String.format("Failed to find target environment by name [%s] in region [%s]",
      link.getLinkedAccount(), localRegion.getName()));
origin: rancher/cattle

String externalRegionKey = String.format("%s:%s", targetRegion.getName(), localRegion.getName());
if(externalRegionMap.containsKey(externalRegionKey)) {
  externalRegion = externalRegionMap.get(externalRegionKey);
} else {
  externalRegion = RegionUtil.getExternalRegion(targetRegion, localRegion.getName(), jsonMapper);
  externalRegionMap.put(externalRegionKey, externalRegion); 
String externalProjectKey = String.format("%s:%s", targetRegion.getName(), link.getLinkedAccount());
if(externalProjectMap.containsKey(externalProjectKey)) {
  externalProjectResponse = externalProjectMap.get(externalProjectKey);
origin: rancher/cattle

toAdd.add(getUUID(localRegion.getName(), splitted[0]));
    rName = localRegion.getName();
io.cattle.platform.core.modelRegion

Javadoc

This class is generated by jOOQ.

Most used methods

  • getName
    Getter for cattle.region.name.
  • getUrl
    Getter for cattle.region.url.
  • getId
    Getter for cattle.region.id.
  • getLocal
    Getter for cattle.region.local.
  • getPublicValue
    Getter for cattle.region.public_value.
  • getSecretValue
    Getter for cattle.region.secret_value.
  • getState
    Getter for cattle.region.state.
  • from
    Load data from another generated Record/POJO implementing the common interface Region
  • getAccountId
    Getter for cattle.region.account_id.
  • getCreated
    Getter for cattle.region.created.
  • getData
    Getter for cattle.region.data.
  • getDescription
    Getter for cattle.region.description.
  • getData,
  • getDescription,
  • getKind,
  • getRemoveTime,
  • getRemoved,
  • getUuid

Popular in Java

  • Finding current android device location
  • getSharedPreferences (Context)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • getExternalFilesDir (Context)
  • BufferedReader (java.io)
    Reads text from a character-input stream, buffering characters so as to provide for the efficient re
  • IOException (java.io)
    Signals that an I/O exception of some sort has occurred. This class is the general class of exceptio
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • KeyStore (java.security)
    This class represents an in-memory collection of keys and certificates. It manages two types of entr
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • JTextField (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now