예제 #1
0
파일: session.go 프로젝트: jkoelndorfer/cli
// verify tests whether or not the given session token is still valid
func verify(settings *models.Settings) bool {
	resp := httpclient.Get(fmt.Sprintf("%s/v2/auth/verify", settings.BaasHost), false, settings)
	m := make(map[string]string)
	json.Unmarshal(resp, &m)
	// the verify route returns userId and not usersId like everything else...
	if m["userId"] != "" {
		settings.UsersID = m["userId"]
	}
	return m["userId"] != ""
}
예제 #2
0
// ListBackups returns a list of all backups regardless of their status for a
// given service
func ListBackups(serviceID string, page int, pageSize int, settings *models.Settings) *[]models.Job {
	resp := httpclient.Get(fmt.Sprintf("%s/v1/environments/%s/services/%s/backup?pageNum=%d&pageSize=%d", settings.PaasHost, settings.EnvironmentID, serviceID, page, pageSize), true, settings)
	var jobsMap map[string]models.Job
	json.Unmarshal(resp, &jobsMap)
	var jobs []models.Job
	for jobID, job := range jobsMap {
		job.ID = jobID
		jobs = append(jobs, job)
	}
	return &jobs
}
예제 #3
0
파일: pods.go 프로젝트: jkoelndorfer/cli
// RetrievePodMetadata retrieves information about a certain Pod API
func RetrievePodMetadata(podID string, settings *models.Settings) *models.PodMetadata {
	resp := httpclient.Get(fmt.Sprintf("%s/v1/pods/metadata", settings.PaasHost), true, settings)
	var pods []models.PodMetadata
	json.Unmarshal(resp, &pods)
	var pod models.PodMetadata
	for _, p := range pods {
		if p.ID == podID {
			pod = p
			break
		}
	}
	if pod.ID == "" {
		fmt.Println("Could not find the pod associated with your environment. Please contact Catalyze support ([email protected]). Please include your environment ID - found via \"catalyze support-ids\"")
		os.Exit(1)
	}
	return &pod
}
예제 #4
0
// ListEnvVars returns all env vars for the associated Service
func ListEnvVars(settings *models.Settings) map[string]string {
	resp := httpclient.Get(fmt.Sprintf("%s/v1/environments/%s/services/%s/env", settings.PaasHost, settings.EnvironmentID, settings.ServiceID), true, settings)
	var envVars map[string]string
	json.Unmarshal(resp, &envVars)
	return envVars
}
예제 #5
0
// RetrieveTempUploadURL fetches a temporary URL that can be used for uploading
// a file for an Import job. These URLs are signed and only valid for a short
// period of time.
func RetrieveTempUploadURL(serviceID string, settings *models.Settings) *models.TempURL {
	resp := httpclient.Get(fmt.Sprintf("%s/v1/environments/%s/services/%s/restore/url", settings.PaasHost, settings.EnvironmentID, serviceID), true, settings)
	var tempURL models.TempURL
	json.Unmarshal(resp, &tempURL)
	return &tempURL
}
예제 #6
0
// RetrieveServiceMetrics fetches metrics for a single service for a specified
// number of minutes.
func RetrieveServiceMetrics(mins int, settings *models.Settings) *models.Metrics {
	resp := httpclient.Get(fmt.Sprintf("%s/v1/environments/%s/metrics/%s?mins=%d", settings.PaasHost, settings.EnvironmentID, settings.ServiceID, mins), true, settings)
	var metrics models.Metrics
	json.Unmarshal(resp, &metrics)
	return &metrics
}
예제 #7
0
// RetrieveConsoleTokens returns the information necessary for connecting to a
// console service. The console service must already be ready and awaiting a
// connection.
func RetrieveConsoleTokens(jobID string, serviceID string, settings *models.Settings) *models.ConsoleCredentials {
	resp := httpclient.Get(fmt.Sprintf("%s/v1/environments/%s/services/%s/console/token/%s", settings.PaasHost, settings.EnvironmentID, serviceID, jobID), true, settings)
	var credentials models.ConsoleCredentials
	json.Unmarshal(resp, &credentials)
	return &credentials
}
예제 #8
0
// RetrieveService returns a service model for the associated ServiceID
func RetrieveService(settings *models.Settings) *models.Service {
	resp := httpclient.Get(fmt.Sprintf("%s/v1/environments/%s/services/%s", settings.PaasHost, settings.EnvironmentID, settings.ServiceID), true, settings)
	var service models.Service
	json.Unmarshal(resp, &service)
	return &service
}
예제 #9
0
파일: invites.go 프로젝트: jkoelndorfer/cli
// ListEnvironmentInvites lists all invites for the associated environment.
func ListEnvironmentInvites(settings *models.Settings) *[]models.Invite {
	resp := httpclient.Get(fmt.Sprintf("%s/v1/environments/%s/invites", settings.PaasHost, settings.EnvironmentID), true, settings)
	var invites []models.Invite
	json.Unmarshal(resp, &invites)
	return &invites
}
예제 #10
0
파일: jobs.go 프로젝트: jkoelndorfer/cli
// RetrieveJobFromTaskID translates a task into a job
func RetrieveJobFromTaskID(taskID string, settings *models.Settings) *models.Job {
	resp := httpclient.Get(fmt.Sprintf("%s/v1/environments/%s/tasks/%s", settings.PaasHost, settings.EnvironmentID, taskID), true, settings)
	var job models.Job
	json.Unmarshal(resp, &job)
	return &job
}
예제 #11
0
파일: jobs.go 프로젝트: jkoelndorfer/cli
// RetrieveJob fetches a Job model by its ID
func RetrieveJob(jobID string, serviceID string, settings *models.Settings) *models.Job {
	resp := httpclient.Get(fmt.Sprintf("%s/v1/environments/%s/services/%s/jobs/%s", settings.PaasHost, settings.EnvironmentID, serviceID, jobID), true, settings)
	var job models.Job
	json.Unmarshal(resp, &job)
	return &job
}
예제 #12
0
// RetrieveEnvironment returns the associated environment model. The source
// parameter specifies where the data should come from. If source is `pod` then
// the Environment data will be fetched from the Pod API, otherwise the data
// will be retrieved from the Customer API.
func RetrieveEnvironment(source string, settings *models.Settings) *models.Environment {
	resp := httpclient.Get(fmt.Sprintf("%s/v1/environments/%s?source=%s", settings.PaasHost, settings.EnvironmentID, source), true, settings)
	var env models.Environment
	json.Unmarshal(resp, &env)
	return &env
}
예제 #13
0
// ListEnvironmentUsers returns a list of all users who have access to the
// associated environment
func ListEnvironmentUsers(settings *models.Settings) *models.EnvironmentUsers {
	resp := httpclient.Get(fmt.Sprintf("%s/v1/environments/%s/users", settings.PaasHost, settings.EnvironmentID), true, settings)
	var users models.EnvironmentUsers
	json.Unmarshal(resp, &users)
	return &users
}
예제 #14
0
// ListEnvironments returns a list of all environments the authorized
// user has access to
func ListEnvironments(source string, settings *models.Settings) *[]models.Environment {
	resp := httpclient.Get(fmt.Sprintf("%s/v1/environments?pageSize=1000&source=%s", settings.PaasHost, source), true, settings)
	var envs []models.Environment
	json.Unmarshal(resp, &envs)
	return &envs
}