示例#1
0
文件: route.go 项目: sebrandon1/cli
// DeleteRoute deletes the Route associated with the provided Route GUID.
func (client *CloudControllerClient) DeleteRoute(routeGUID string) (Warnings, error) {
	request := cloudcontroller.NewRequest(
		internal.DeleteRouteRequest,
		map[string]string{"route_guid": routeGUID},
		nil,
		nil,
	)

	var response cloudcontroller.Response
	err := client.connection.Make(request, &response)
	return response.Warnings, err
}
示例#2
0
// DeleteServiceBinding will destroy the requested Service Binding.
func (client *CloudControllerClient) DeleteServiceBinding(serviceBindingGUID string) (Warnings, error) {
	request := cloudcontroller.NewRequest(
		internal.DeleteServiceBindingRequest,
		map[string]string{"service_binding_guid": serviceBindingGUID},
		nil,
		nil,
	)

	var response cloudcontroller.Response
	err := client.connection.Make(request, &response)
	return response.Warnings, err
}
示例#3
0
文件: info.go 项目: sebrandon1/cli
// Info returns back endpoint and API information from /v2/info.
func (client *CloudControllerClient) Info() (APIInformation, Warnings, error) {
	request := cloudcontroller.NewRequest(
		internal.InfoRequest,
		nil,
		nil,
		nil,
	)

	var info APIInformation
	response := cloudcontroller.Response{
		Result: &info,
	}

	err := client.connection.Make(request, &response)
	return info, response.Warnings, err
}
示例#4
0
文件: domain.go 项目: sebrandon1/cli
// GetPrivateDomain returns the Private Domain associated with the provided
// Domain GUID.
func (client *CloudControllerClient) GetPrivateDomain(domainGUID string) (Domain, Warnings, error) {
	request := cloudcontroller.NewRequest(
		internal.PrivateDomainRequest,
		map[string]string{"private_domain_guid": domainGUID},
		nil,
		nil,
	)

	var domain Domain
	response := cloudcontroller.Response{
		Result: &domain,
	}

	err := client.connection.Make(request, &response)
	if err != nil {
		return Domain{}, response.Warnings, err
	}

	return domain, response.Warnings, nil
}
示例#5
0
// GetServiceBindings returns back a list of Service Bindings based off of the
// provided queries.
func (client *CloudControllerClient) GetServiceBindings(queries []Query) ([]ServiceBinding, Warnings, error) {
	request := cloudcontroller.NewRequest(
		internal.ServiceBindingsRequest,
		nil,
		nil,
		FormatQueryParameters(queries),
	)

	allServiceBindingsList := []ServiceBinding{}
	allWarningsList := Warnings{}

	for {
		var serviceBindings []ServiceBinding
		wrapper := PaginatedWrapper{
			Resources: &serviceBindings,
		}
		response := cloudcontroller.Response{
			Result: &wrapper,
		}

		err := client.connection.Make(request, &response)
		allWarningsList = append(allWarningsList, response.Warnings...)
		if err != nil {
			return nil, allWarningsList, err
		}

		allServiceBindingsList = append(allServiceBindingsList, serviceBindings...)

		if wrapper.NextURL == "" {
			break
		}
		request = cloudcontroller.NewRequestFromURI(
			wrapper.NextURL,
			http.MethodGet,
			nil,
		)
	}

	return allServiceBindingsList, allWarningsList, nil
}
示例#6
0
文件: route.go 项目: sebrandon1/cli
// GetSpaceRoutes returns a list of Routes associated with the provided Space
// GUID, and filtered by the provided queries.
func (client *CloudControllerClient) GetSpaceRoutes(spaceGUID string, queryParams []Query) ([]Route, Warnings, error) {
	request := cloudcontroller.NewRequest(
		internal.RoutesFromSpaceRequest,
		map[string]string{"space_guid": spaceGUID},
		nil,
		FormatQueryParameters(queryParams),
	)

	fullRoutesList := []Route{}
	fullWarningsList := Warnings{}

	for {
		var routes []Route
		wrapper := PaginatedWrapper{
			Resources: &routes,
		}
		response := cloudcontroller.Response{
			Result: &wrapper,
		}

		err := client.connection.Make(request, &response)
		fullWarningsList = append(fullWarningsList, response.Warnings...)
		if err != nil {
			return nil, fullWarningsList, err
		}
		fullRoutesList = append(fullRoutesList, routes...)

		if wrapper.NextURL == "" {
			break
		}
		request = cloudcontroller.NewRequestFromURI(
			wrapper.NextURL,
			http.MethodGet,
			nil,
		)
	}

	return fullRoutesList, fullWarningsList, nil
}