def test_tenant():
    client = talent.TenantServiceClient()
    external_id = f'test_tenant_{uuid.uuid4().hex}'
    parent = f"projects/{PROJECT_ID}"
    tenant = {"external_id": external_id}
    resp = client.create_tenant(parent=parent, tenant=tenant)

    yield resp

    client.delete_tenant(name=resp.name)
def test_tenant():
    client = talent.TenantServiceClient()
    external_id = f'test_tenant_{uuid.uuid4().hex}'
    parent = client.project_path(PROJECT_ID)
    tenant = {"external_id": external_id}
    resp = client.create_tenant(parent, tenant)

    yield resp

    client.delete_tenant(resp.name)
Exemplo n.º 3
0
def list_tenants(project_id):
    """List Tenants"""

    client = talent.TenantServiceClient()

    # project_id = 'Your Google Cloud Project ID'

    if isinstance(project_id, six.binary_type):
        project_id = project_id.decode("utf-8")
    parent = client.project_path(project_id)

    # Iterate over all results
    for response_item in client.list_tenants(parent):
        print("Tenant Name: {}".format(response_item.name))
        print("External ID: {}".format(response_item.external_id))
Exemplo n.º 4
0
def delete_tenant(project_id, tenant_id):
    """Delete Tenant"""

    client = talent.TenantServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID)'

    if isinstance(project_id, six.binary_type):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, six.binary_type):
        tenant_id = tenant_id.decode("utf-8")
    name = client.tenant_path(project_id, tenant_id)

    client.delete_tenant(name)
    print("Deleted Tenant.")
Exemplo n.º 5
0
def get_tenant(project_id, tenant_id):
    """Get Tenant by name"""

    client = talent.TenantServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # tenant_id = 'Your Tenant ID'

    if isinstance(project_id, six.binary_type):
        project_id = project_id.decode("utf-8")
    if isinstance(tenant_id, six.binary_type):
        tenant_id = tenant_id.decode("utf-8")
    name = client.tenant_path(project_id, tenant_id)

    response = client.get_tenant(name)
    print("Name: {}".format(response.name))
    print("External ID: {}".format(response.external_id))
Exemplo n.º 6
0
def create_tenant(project_id, external_id):
    """Create Tenant for scoping resources, e.g. companies and jobs"""

    client = talent.TenantServiceClient()

    # project_id = 'Your Google Cloud Project ID'
    # external_id = 'Your Unique Identifier for Tenant'

    if isinstance(project_id, six.binary_type):
        project_id = project_id.decode("utf-8")
    if isinstance(external_id, six.binary_type):
        external_id = external_id.decode("utf-8")
    parent = client.project_path(project_id)
    tenant = {"external_id": external_id}

    response = client.create_tenant(parent, tenant)
    print("Created Tenant")
    print("Name: {}".format(response.name))
    print("External ID: {}".format(response.external_id))
    return response.name
Exemplo n.º 7
0
from typing import Optional

from google.cloud import talent
from pydantic import constr, PrivateAttr

from pytalentsolution import settings
from pytalentsolution.cts import CTSModel

client_tenant = talent.TenantServiceClient()

# TODO: this is absent in `.venv/Lib/site-packages/google/cloud/talent_v4/types/tenant.py`
# class DataUsageType(AutoName):
#     """
#     https://cloud.google.com/talent-solution/job-search/docs/reference/rest/v4beta1/projects.tenants#DataUsageType
#     """
#     DATA_USAGE_TYPE_UNSPECIFIED = auto()
#     AGGREGATED = auto()
#     ISOLATED = auto()


class TenantInCreate(CTSModel):
    """
        https://cloud.google.com/talent-solution/job-search/docs/reference/rest/v4beta1/projects.tenants
    """

    external_id: constr(max_length=255)

    # TODO: this is absent in `.venv/Lib/site-packages/google/cloud/talent_v4/types/tenant.py`
    # usage_type: Optional[DataUsageType] = None
    # keyword_searchable_profile_custom_attributes: Optional[List[str]] = None