private void loadRepositories(@Nullable Runnable onComplete) { if (cloudProject == null) { return; } Optional<CredentialedUser> user = Services.getLoginService().getLoggedInUser(cloudProject.googleUsername()); if (!user.isPresent()) { return; } if (repositories == null) { repositories = new ProjectRepositoriesModelItem(); } repositories.loadRepositories(cloudProject.projectId(), user.get(), onComplete); }
private void createUIComponents() { commonPanel = new ServiceAccountKeyDownloadedPanel(cloudProject.projectId(), downloadPath); runConfigurationTable = new RunConfigurationTable(); runConfigurationTable.setTableHeader(null); }
void setActiveCloudProject( @NotNull CloudProject activeCloudProject, @NotNull Project ideProject) { PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(ideProject); propertiesComponent.setValue(PROJECT_ACCOUNT_KEY, activeCloudProject.googleUsername()); propertiesComponent.setValue(PROJECT_NAME_KEY, activeCloudProject.projectName()); propertiesComponent.setValue(PROJECT_ID_KEY, activeCloudProject.projectId()); if (activeCloudProject.projectNumber() != null) { propertiesComponent.setValue( PROJECT_NUMBER_KEY, activeCloudProject.projectNumber().toString()); } }
@Nullable private String getCurrentUrlText() { CloudProject selectedProject = projectSelector.getSelectedProject(); Optional<CredentialedUser> selectedUser = selectedProject == null ? Optional.empty() : Services.getLoginService().getLoggedInUser(selectedProject.googleUsername()); if (selectedProject == null || !selectedUser.isPresent() || StringUtil.isEmpty(repositorySelector.getText())) { return null; } return GcpHttpAuthDataProvider.getGcpUrl( selectedProject.projectId(), repositorySelector.getText()); }
/** * Shared implementation of {@link * com.intellij.openapi.options.SettingsEditor#applyEditorTo(Object)}. To be invoked by users of * this panel in the overriden method. */ public void applyEditorTo(@NotNull AppEngineDeploymentConfiguration configuration) { configuration.setVersion(versionIdField.getText()); configuration.setPromote(promoteCheckbox.isSelected()); configuration.setStopPreviousVersion(stopPreviousVersionCheckbox.isSelected()); configuration.setDeployAllConfigs(deployAllConfigsCheckbox.isSelected()); CloudProject selectedProject = projectSelector.getSelectedProject(); if (selectedProject != null) { configuration.setCloudProjectName(selectedProject.projectId()); configuration.setGoogleUsername(selectedProject.googleUsername()); } }
@Override protected void doOKAction() { CloudProject selectedProject = projectSelector.getSelectedProject(); projectId = selectedProject.projectId(); repositoryId = repositorySelector.getText(); remoteName = remoteNameSelector.getText(); credentialedUser = Services.getLoginService().getLoggedInUser(selectedProject.googleUsername()).orElse(null); super.doOKAction(); } }
String.format( PANTHEON_CREATE_REPO_URL_PATTERN, cloudProject.projectId(), cloudProject.googleUsername()))); } catch (IOException e) {
/** * Updates the text of the panel as follows: if no project is selected, no message is displayed, * if the project represents a valid project, the project details are displayed, if the project * represents an invalid project, an error message is displayed. */ private void refreshApplicationInfoPanel(CloudProject selectedProject) { if (selectedProject == null) { applicationInfoPanel.clearMessage(); return; } Optional<CredentialedUser> user = Services.getLoginService().getLoggedInUser(selectedProject.googleUsername()); if (user.isPresent()) { applicationInfoPanel.refresh(selectedProject.projectId(), user.get().getCredential()); } else { applicationInfoPanel.setMessage( AppEngineMessageBundle.getString("appengine.infopanel.no.region"), true /* isError*/); } }
void refresh() { showNotificationPanel(); if (!Services.getLoginService().isLoggedIn()) { notificationLabel.setText( GoogleCloudStorageMessageBundle.message("gcs.panel.bucket.listing.not.logged.in")); } else if (projectSelector.getSelectedProject() == null) { notificationLabel.setText( GoogleCloudStorageMessageBundle.message("gcs.panel.bucket.listing.no.project.selected")); } else { CloudProject cloudProject = projectSelector.getSelectedProject(); Optional<CredentialedUser> user = Services.getLoginService().getLoggedInUser(cloudProject.googleUsername()); if (user.isPresent()) { loadAndDisplayBuckets(cloudProject.projectId(), user.get()); } else { notificationLabel.setText( GoogleCloudStorageMessageBundle.message( "gcs.panel.bucket.listing.error.loading.buckets")); log.warn("Cloud not load credentialed user for GCS operation. User may not be logged."); } } }
notifyApisEnabled(enabledApis, cloudProject.projectId(), project);
@Test public void applyEditorTo_doesSetCloudProjectName() { CloudProject project = CloudProject.create("some-project", "some-project", EMAIL); when(projectSelector.getSelectedProject()).thenReturn(project); editor.applyEditorTo(configuration); assertThat(configuration.getCloudProjectName()).isEqualTo(project.projectId()); }
private void launchDialog(List<RunnerAndConfigurationSettings> configurationSettingsList) { when(mockCloudProject.projectId()).thenReturn("gcpProjectId"); ApplicationManager.getApplication() .invokeAndWait( () -> dialog = new ServiceAccountKeyDisplayDialog( testFixture.getProject(), mockCloudProject, "downloadPath")); dialog.initTableModel(configurationSettingsList); } }
resourceManager .projects() .getIamPolicy(cloudProject.projectId(), new GetIamPolicyRequest()) .execute(); List<Binding> bindings = Lists.newArrayList(existingPolicy.getBindings()); policyRequest.setPolicy(newPolicy); resourceManager.projects().setIamPolicy(cloudProject.projectId(), policyRequest).execute();
DebugTarget item = new DebugTarget(debuggee, cloudProject.projectId()); if (!Strings.isNullOrEmpty(item.getModule()) && !Strings.isNullOrEmpty(item.getVersion())) {
/** Creates a new {@link ServiceAccount} for the given {@link CloudProject} using the IAM API. */ private static ServiceAccount createServiceAccount( CredentialedUser user, String name, CloudProject cloudProject) throws IOException { CreateServiceAccountRequest request = new CreateServiceAccountRequest(); ServiceAccount serviceAccount = new ServiceAccount(); serviceAccount.setDisplayName(name); request.setServiceAccount(serviceAccount); request.setAccountId(createServiceAccountId(name)); Iam iam = GoogleApiClientFactory.getInstance().getIamClient(user.getCredential()); return iam.projects() .serviceAccounts() .create( String.format(SERVICE_ACCOUNT_CREATE_REQUEST_PROJECT_FORMAT, cloudProject.projectId()), request) .execute(); }
private static void enableApi( CloudLibrary library, CloudProject cloudProject, CredentialedUser user) throws IOException { UsageTrackerService.getInstance() .trackEvent(GctTracking.CLIENT_LIBRARY_ENABLE_API) .addMetadata(GctTracking.METADATA_LABEL_KEY, library.getName()) .ping(); ServiceManagement serviceManagement = GoogleApiClientFactory.getInstance().getServiceManagementClient(user.getCredential()); serviceManagement .services() .enable( library.getServiceName(), new EnableServiceRequest() .setConsumerId( String.format(SERVICE_REQUEST_PROJECT_FORMAT, cloudProject.projectId()))) .execute(); }
Services.getLoginService().getLoggedInUser(selectedProject.googleUsername()); if (!StringUtil.isEmpty(selectedProject.projectId()) && !user.isPresent()) { setErrorText(CloudReposMessageBundle.message("cloud.repository.dialog.invalid.project")); setOKActionEnabled(false);