Exemplo n.º 1
0
// 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
}
Exemplo n.º 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
}
Exemplo n.º 3
0
// 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
}
Exemplo n.º 4
0
// 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
}
Exemplo n.º 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
}
Exemplo n.º 6
0
// 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
}