Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Putting back prefixes in managers #226

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cloudfoundry_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
This module provides a client library for cloudfoundry_client v2/v3.
"""

__version__ = "1.37.1"
__version__ = "1.38.1"
22 changes: 12 additions & 10 deletions cloudfoundry_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def __init__(self, target_endpoint: str, credential_manager: "CloudFoundryClient


class V2(object):
def __init__(self, target_endpoint: str, credential_manager: "CloudFoundryClient"):
def __init__(self, cloud_controller_v2_url: str, credential_manager: "CloudFoundryClient"):
target_endpoint = cloud_controller_v2_url.removesuffix("/v2")
self.apps = AppManagerV2(target_endpoint, credential_manager)
self.buildpacks = BuildpackManagerV2(target_endpoint, credential_manager)
self.jobs = JobManagerV2(target_endpoint, credential_manager)
Expand All @@ -93,24 +94,25 @@ def __init__(self, target_endpoint: str, credential_manager: "CloudFoundryClient
self.service_plans = ServicePlanManagerV2(target_endpoint, credential_manager)
# Default implementations
self.event = EventManager(target_endpoint, credential_manager)
self.organizations = EntityManagerV2(target_endpoint, credential_manager, "/organizations")
self.private_domains = EntityManagerV2(target_endpoint, credential_manager, "/private_domains")
self.organizations = EntityManagerV2(target_endpoint, credential_manager, "/v2/organizations")
self.private_domains = EntityManagerV2(target_endpoint, credential_manager, "/v2/private_domains")
self.routes = RouteManager(target_endpoint, credential_manager)
self.services = EntityManagerV2(target_endpoint, credential_manager, "/services")
self.shared_domains = EntityManagerV2(target_endpoint, credential_manager, "/shared_domains")
self.services = EntityManagerV2(target_endpoint, credential_manager, "/v2/services")
self.shared_domains = EntityManagerV2(target_endpoint, credential_manager, "/v2/shared_domains")
self.spaces = SpaceManagerV2(target_endpoint, credential_manager)
self.stacks = EntityManagerV2(target_endpoint, credential_manager, "/stacks")
self.stacks = EntityManagerV2(target_endpoint, credential_manager, "/v2/stacks")
self.user_provided_service_instances = EntityManagerV2(
target_endpoint, credential_manager, "/user_provided_service_instances"
target_endpoint, credential_manager, "/v2/user_provided_service_instances"
)
self.security_groups = EntityManagerV2(target_endpoint, credential_manager, "/security_groups")
self.users = EntityManagerV2(target_endpoint, credential_manager, "/users")
self.security_groups = EntityManagerV2(target_endpoint, credential_manager, "/v2/security_groups")
self.users = EntityManagerV2(target_endpoint, credential_manager, "/v2/users")
# Resources implementation used by push operation
self.resources = ResourceManager(target_endpoint, credential_manager)


class V3(object):
def __init__(self, target_endpoint: str, credential_manager: "CloudFoundryClient"):
def __init__(self, cloud_controller_v3_url: str, credential_manager: "CloudFoundryClient"):
target_endpoint = cloud_controller_v3_url.removesuffix("/v3")
self.apps = AppManager(target_endpoint, credential_manager)
self.buildpacks = BuildpackManager(target_endpoint, credential_manager)
self.domains = DomainManager(target_endpoint, credential_manager)
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v2/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class AppManager(EntityManager):

def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(AppManager, self).__init__(
target_endpoint, client, "/apps", lambda pairs: Application(target_endpoint, client, pairs)
target_endpoint, client, "/v2/apps", lambda pairs: Application(target_endpoint, client, pairs)
)

def get_stats(self, application_guid: str) -> Dict[str, JsonObject]:
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v2/buildpacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class BuildpackManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(BuildpackManager, self).__init__(target_endpoint, client, "/buildpacks")
super(BuildpackManager, self).__init__(target_endpoint, client, "/v2/buildpacks")

def update(self, buildpack_guid: str, parameters: dict) -> Entity:
return super(BuildpackManager, self)._update(buildpack_guid, parameters)
2 changes: 1 addition & 1 deletion cloudfoundry_client/v2/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class EventManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(EventManager, self).__init__(target_endpoint, client, "/events")
super(EventManager, self).__init__(target_endpoint, client, "/v2/events")

def list_by_type(self, event_type: str) -> Generator[Entity, None, None]:
return self._list(self.entity_uri, type=event_type)
2 changes: 1 addition & 1 deletion cloudfoundry_client/v2/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
self.client = client

def get(self, job_guid: str) -> JsonObject:
return self.client.get("%s/jobs/%s" % (self.target_endpoint, job_guid)).json(object_pairs_hook=JsonObject)
return self.client.get("%s/v2/jobs/%s" % (self.target_endpoint, job_guid)).json(object_pairs_hook=JsonObject)
2 changes: 1 addition & 1 deletion cloudfoundry_client/v2/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
self.client = client

def match(self, items: List[dict]) -> List[JsonObject]:
response = self.client.put("%s/resource_match" % self.client.info.api_endpoint, json=items)
response = self.client.put("%s/v2/resource_match" % self.client.info.api_endpoint, json=items)
return response.json(object_pairs_hook=JsonObject)
2 changes: 1 addition & 1 deletion cloudfoundry_client/v2/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class RouteManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(RouteManager, self).__init__(target_endpoint, client, "/routes")
super(RouteManager, self).__init__(target_endpoint, client, "/v2/routes")

def create_tcp_route(self, domain_guid: str, space_guid: str, port: Optional[int] = None) -> Entity:
request = self._request(domain_guid=domain_guid, space_guid=space_guid)
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v2/service_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class ServiceBindingManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(ServiceBindingManager, self).__init__(target_endpoint, client, "/service_bindings")
super(ServiceBindingManager, self).__init__(target_endpoint, client, "/v2/service_bindings")

def create(self, app_guid: str, instance_guid: str, parameters: Optional[dict] = None, name: Optional[str] = None) -> Entity:
request = self._request(app_guid=app_guid, service_instance_guid=instance_guid)
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v2/service_brokers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class ServiceBrokerManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(ServiceBrokerManager, self).__init__(target_endpoint, client, "/service_brokers")
super(ServiceBrokerManager, self).__init__(target_endpoint, client, "/v2/service_brokers")

def create(
self, broker_url: str, broker_name: str, auth_username: str, auth_password: str, space_guid: Optional[str] = None
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v2/service_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ServiceInstanceManager(EntityManager):
list_query_parameters = ["page", "results-per-page", "order-direction", "return_user_provided_service_instances"]

def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(ServiceInstanceManager, self).__init__(target_endpoint, client, "/service_instances")
super(ServiceInstanceManager, self).__init__(target_endpoint, client, "/v2/service_instances")

def create(
self,
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v2/service_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class ServiceKeyManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(ServiceKeyManager, self).__init__(target_endpoint, client, "/service_keys")
super(ServiceKeyManager, self).__init__(target_endpoint, client, "/v2/service_keys")

def create(self, service_instance_guid: str, name: str, parameters: Optional[dict] = None) -> Entity:
request = self._request(service_instance_guid=service_instance_guid, name=name)
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v2/service_plan_visibilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class ServicePlanVisibilityManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(ServicePlanVisibilityManager, self).__init__(target_endpoint, client, "/service_plan_visibilities")
super(ServicePlanVisibilityManager, self).__init__(target_endpoint, client, "/v2/service_plan_visibilities")

def create(self, service_plan_guid: str, organization_guid: str) -> Entity:
request = self._request()
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v2/service_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class ServicePlanManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(ServicePlanManager, self).__init__(target_endpoint, client, "/service_plans")
super(ServicePlanManager, self).__init__(target_endpoint, client, "/v2/service_plans")

def create_from_resource_file(self, path: str) -> Entity:
raise NotImplementedError("No creation allowed")
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v2/spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class SpaceManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(SpaceManager, self).__init__(target_endpoint, client, "/spaces")
super(SpaceManager, self).__init__(target_endpoint, client, "/v2/spaces")

def delete_unmapped_routes(self, space_guid: str):
url = "%s%s/%s/unmapped_routes" % (self.target_endpoint, self.entity_uri, space_guid)
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v3/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class AppManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(AppManager, self).__init__(target_endpoint, client, "/apps")
super(AppManager, self).__init__(target_endpoint, client, "/v3/apps")

def restart(self, application_guid: str):
return super(AppManager, self)._post("%s%s/%s/actions/restart" % (self.target_endpoint,
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v3/buildpacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class BuildpackManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(BuildpackManager, self).__init__(target_endpoint, client, "/buildpacks")
super(BuildpackManager, self).__init__(target_endpoint, client, "/v3/buildpacks")

def create(
self,
Expand Down
4 changes: 2 additions & 2 deletions cloudfoundry_client/v3/domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, target_endpoint: str, client: "CloudFoundryClient", **kwargs)

class DomainManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(DomainManager, self).__init__(target_endpoint, client, "/domains", Domain)
super(DomainManager, self).__init__(target_endpoint, client, "/v3/domains", Domain)

def create(
self,
Expand All @@ -44,7 +44,7 @@ def create(
return super(DomainManager, self)._create(data)

def list_domains_for_org(self, org_guid: str, **kwargs) -> Pagination[Entity]:
uri = "/organizations/{guid}/domains".format(guid=org_guid)
uri = "/v3/organizations/{guid}/domains".format(guid=org_guid)
return self._list(uri, **kwargs)

def update(self, domain_guid: str, meta_labels: Optional[dict] = None, meta_annotations: Optional[dict] = None) -> Domain:
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v3/feature_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class FeatureFlagManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(FeatureFlagManager, self).__init__(target_endpoint, client, "/feature_flags")
super(FeatureFlagManager, self).__init__(target_endpoint, client, "/v3/feature_flags")

def update(self, name: str, enabled: Optional[bool] = True, custom_error_message: Optional[str] = None) -> Entity:
data = {"enabled": enabled, "custom_error_message": custom_error_message}
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v3/isolation_segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class IsolationSegmentManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(IsolationSegmentManager, self).__init__(target_endpoint, client, "/isolation_segments")
super(IsolationSegmentManager, self).__init__(target_endpoint, client, "/v3/isolation_segments")

def create(self, name: str, meta_labels: Optional[dict] = None, meta_annotations: Optional[dict] = None) -> Entity:
data = {"name": name, "metadata": {"labels": meta_labels, "annotations": meta_annotations}}
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v3/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class JobTimeout(Exception):

class JobManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(JobManager, self).__init__(target_endpoint, client, "/jobs")
super(JobManager, self).__init__(target_endpoint, client, "/v3/jobs")

def wait_for_job_completion(
self,
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v3/organization_quotas.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DomainsQuota:

class OrganizationQuotaManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super().__init__(target_endpoint, client, "/organization_quotas")
super().__init__(target_endpoint, client, "/v3/organization_quotas")

def remove(self, guid: str, asynchronous: bool = True) -> Optional[str]:
return super()._remove(guid, asynchronous)
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v3/organizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class OrganizationManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(OrganizationManager, self).__init__(target_endpoint, client, "/organizations")
super(OrganizationManager, self).__init__(target_endpoint, client, "/v3/organizations")

def create(
self, name: str, suspended: bool, meta_labels: Optional[dict] = None, meta_annotations: Optional[dict] = None
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v3/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@

class ProcessManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(ProcessManager, self).__init__(target_endpoint, client, "/processes")
super(ProcessManager, self).__init__(target_endpoint, client, "/v3/processes")
2 changes: 1 addition & 1 deletion cloudfoundry_client/v3/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class RoleManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(RoleManager, self).__init__(target_endpoint, client, "/roles")
super(RoleManager, self).__init__(target_endpoint, client, "/v3/roles")

def remove(self, role_guid: str, asynchronous: bool = True) -> Optional[str]:
return super(RoleManager, self)._remove(role_guid, asynchronous)
2 changes: 1 addition & 1 deletion cloudfoundry_client/v3/security_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class GloballyEnabled:

class SecurityGroupManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(SecurityGroupManager, self).__init__(target_endpoint, client, "/security_groups")
super(SecurityGroupManager, self).__init__(target_endpoint, client, "/v3/security_groups")

def create(self,
name: str,
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v3/service_brokers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class ServiceBrokerManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(ServiceBrokerManager, self).__init__(target_endpoint, client, "/service_brokers")
super(ServiceBrokerManager, self).__init__(target_endpoint, client, "/v3/service_brokers")

def create(
self,
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v3/service_credential_bindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class ServiceCredentialBindingManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(ServiceCredentialBindingManager, self).__init__(target_endpoint, client,
"/service_credential_bindings")
"/v3/service_credential_bindings")

def create(
self,
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v3/service_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class ServiceInstanceManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(ServiceInstanceManager, self).__init__(target_endpoint, client, "/service_instances")
super(ServiceInstanceManager, self).__init__(target_endpoint, client, "/v3/service_instances")

def create(
self,
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v3/service_offerings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class ServiceOfferingsManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(ServiceOfferingsManager, self).__init__(target_endpoint, client, "/service_offerings")
super(ServiceOfferingsManager, self).__init__(target_endpoint, client, "/v3/service_offerings")

def update(self, guid: str, meta_labels: Optional[dict] = None, meta_annotations: Optional[dict] = None) -> Entity:
payload = dict()
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v3/service_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class ServicePlanManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(ServicePlanManager, self).__init__(target_endpoint, client, "/service_plans")
super(ServicePlanManager, self).__init__(target_endpoint, client, "/v3/service_plans")

def update(
self,
Expand Down
2 changes: 1 addition & 1 deletion cloudfoundry_client/v3/spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class SpaceManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(SpaceManager, self).__init__(target_endpoint, client, "/spaces")
super(SpaceManager, self).__init__(target_endpoint, client, "/v3/spaces")

def create(self, name: str, org_guid: str) -> Entity:
return super(SpaceManager, self)._create(dict(name=name, relationships=dict(organization=ToOneRelationship(org_guid))))
Expand Down
6 changes: 3 additions & 3 deletions cloudfoundry_client/v3/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class TaskManager(EntityManager):
def __init__(self, target_endpoint: str, client: "CloudFoundryClient"):
super(TaskManager, self).__init__(target_endpoint, client, "/tasks")
super(TaskManager, self).__init__(target_endpoint, client, "/v3/tasks")

def create(
self,
Expand All @@ -24,7 +24,7 @@ def create(
request["disk_in_mb"] = disk_in_mb
request["memory_in_mb"] = memory_in_mb
request["droplet_guid"] = droplet_guid
return self._post("%s/apps/%s/tasks" % (self.target_endpoint, application_guid), data=request)
return self._post("%s/v3/apps/%s/tasks" % (self.target_endpoint, application_guid), data=request)

def cancel(self, task_guid: str) -> Entity:
return self._post("%s/tasks/%s/actions/cancel" % (self.target_endpoint, task_guid))
return self._post("%s/v3/tasks/%s/actions/cancel" % (self.target_endpoint, task_guid))
Empty file removed main/__init__.py
Empty file.
Loading
Loading