Skip to content

Commit

Permalink
Merge pull request #363 from hkad98/psdk-160
Browse files Browse the repository at this point in the history
RELATED: PSDK-160 add name support for user groups

Reviewed-by: https://github.com/pcerny
  • Loading branch information
gdgate authored Oct 2, 2023
2 parents 304deb1 + b3210a0 commit bf04eeb
Show file tree
Hide file tree
Showing 90 changed files with 2,398 additions and 2,235 deletions.
2 changes: 1 addition & 1 deletion gooddata-dbt/gooddata_dbt/dbt/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def run_job(self, logger: logging.Logger, job_id: str) -> Tuple[str, str]:
# Allow testing from localhost where CI_COMMIT_SHA is not set
# TODO - Gitlab only! Allow override it from the outside in the future
if os.getenv("CI_COMMIT_SHA"):
commit_sha = os.getenv("CI_COMMIT_SHA")
commit_sha = os.environ["CI_COMMIT_SHA"]
data = {
"cause": f"Triggered via API by gooddata-dbt plugin - {commit_sha=}",
"git_sha": commit_sha,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def store_to_disk(self, layout_organization_folder: Path) -> None:
@attr.s(auto_attribs=True, kw_only=True)
class CatalogDeclarativeUserGroup(Base):
id: str
name: Optional[str] = None
parents: Optional[List[CatalogUserGroupIdentifier]] = None
permissions: List[CatalogDeclarativeWorkspaceHierarchyPermission] = attr.field(factory=list)

Expand Down
22 changes: 20 additions & 2 deletions gooddata-sdk/gooddata_sdk/catalog/user/entity_model/user_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,34 @@ def update_user_group(self, user_group_parents_id: Optional[List[str]] = None) -
@attr.s(auto_attribs=True, kw_only=True)
class CatalogUserGroup(Base):
id: str
attributes: Optional[CatalogUserGroupAttributes] = None
relationships: Optional[CatalogUserGroupRelationships] = None

@staticmethod
def client_class() -> Type[JsonApiUserGroupIn]:
return JsonApiUserGroupIn

@classmethod
def init(cls, user_group_id: str, user_group_parent_ids: Optional[List[str]] = None) -> CatalogUserGroup:
def init(
cls,
user_group_id: str,
user_group_name: Optional[str] = None,
user_group_parent_ids: Optional[List[str]] = None,
) -> CatalogUserGroup:
attributes = CatalogUserGroupAttributes(name=user_group_name)
relationships = CatalogUserGroupRelationships.create_user_group_relationships(user_group_parent_ids)
return cls(id=user_group_id, relationships=relationships)
return cls(id=user_group_id, attributes=attributes, relationships=relationships)

@property
def get_parents(self) -> List[str]:
return self.relationships.get_parents if self.relationships is not None else []

@property
def name(self) -> Optional[str]:
if self.attributes is not None:
return self.attributes.name
return None


@attr.s(auto_attribs=True, kw_only=True)
class CatalogUserGroupRelationships(Base):
Expand All @@ -66,6 +79,11 @@ def get_parents(self) -> List[str]:
return self.parents.get_parents if self.parents is not None else []


@attr.s(auto_attribs=True, kw_only=True)
class CatalogUserGroupAttributes(Base):
name: Optional[str] = None


@attr.s(auto_attribs=True, kw_only=True)
class CatalogUserGroupParents(Base):
data: Optional[List[CatalogUserGroup]] = None
Expand Down
5 changes: 1 addition & 4 deletions gooddata-sdk/gooddata_sdk/catalog/user/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,11 @@ def create_or_update_user_group(self, user_group: CatalogUserGroup) -> None:
try:
self.get_user_group(user_group_id=user_group.id)
user_group_document = CatalogUserGroupDocument(data=user_group)
user_group_document.update_user_group(user_group_parents_id=user_group.get_parents)
self._entities_api.update_entity_user_groups(
id=user_group.id, json_api_user_group_in_document=user_group_document.to_api()
)
except NotFoundException:
user_group_document = CatalogUserGroupDocument.init(
user_group_id=user_group.id, user_group_parent_ids=user_group.get_parents
)
user_group_document = CatalogUserGroupDocument(data=user_group)
self._entities_api.create_entity_user_groups(user_group_document.to_api())

def get_user_group(self, user_group_id: str) -> CatalogUserGroup:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
{
"id": "adminGroup"
},
{
"id": "demoGroup",
"name": "demo group"
},
{
"id": "adminQA1Group",
"parents": [
Expand All @@ -12,11 +16,9 @@
}
]
},
{
"id": "demoGroup"
},
{
"id": "visitorsGroup",
"name": "visitors",
"parents": [
{
"id": "demoGroup",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ interactions:
to access it.
status: 404
title: Not Found
traceId: fff31964d92660e2
traceId: 9211a205f71f17e3
- request:
method: POST
uri: http://localhost:3000/api/v1/entities/dataSources
Expand Down Expand Up @@ -187,8 +187,8 @@ interactions:
- name: projectId
value: PROJECT_ID
type: BIGQUERY
schema: demo
name: Test
schema: demo
links:
self: http://localhost:3000/api/v1/entities/dataSources/test
- request:
Expand Down Expand Up @@ -282,8 +282,8 @@ interactions:
- name: projectId
value: PROJECT_ID
type: BIGQUERY
schema: demo
name: Test
schema: demo
links:
self: http://localhost:3000/api/v1/entities/dataSources/test
- request:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ interactions:
username: demouser
enableCaching: false
type: POSTGRESQL
schema: demo
name: demo-test-ds
schema: demo
links:
self: http://localhost:3000/api/v1/entities/dataSources/demo-test-ds
links:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ interactions:
attributes:
name: Default Organization
hostname: localhost
oauthClientId: 293eb77c-9ec2-4099-9cef-7a0f5d3576e4
oauthClientId: 6c626aec-2e86-409e-a5e3-f720a111fe2c
links:
self: http://localhost:3000/api/v1/entities/admin/organizations/default
- request:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ interactions:
body:
string:
queryDurationMillis:
simpleSelect: 0
simpleSelect: 1
successful: true
- request:
method: PUT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ interactions:
attributes:
title: '# of Active Customers'
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: '#,##0'
maql: SELECT COUNT({attribute/customer_id},{attribute/order_line_id})
Expand All @@ -96,7 +96,7 @@ interactions:
attributes:
title: '# of Orders'
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: '#,##0'
maql: SELECT COUNT({attribute/order_id})
Expand All @@ -111,7 +111,7 @@ interactions:
attributes:
title: '# of Top Customers'
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: '#,##0'
maql: 'SELECT {metric/amount_of_active_customers} WHERE (SELECT
Expand All @@ -128,7 +128,7 @@ interactions:
title: '# of Valid Orders'
description: ''
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: '#,##0.00'
maql: SELECT {metric/amount_of_orders} WHERE NOT ({label/order_status}
Expand All @@ -144,7 +144,7 @@ interactions:
attributes:
title: Campaign Spend
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: $#,##0
maql: SELECT SUM({fact/spend})
Expand All @@ -159,7 +159,7 @@ interactions:
attributes:
title: Order Amount
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: $#,##0
maql: SELECT SUM({fact/price}*{fact/quantity})
Expand All @@ -174,7 +174,7 @@ interactions:
attributes:
title: '% Revenue'
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: '#,##0.0%'
maql: SELECT {metric/revenue} / {metric/total_revenue}
Expand All @@ -189,7 +189,7 @@ interactions:
attributes:
title: '% Revenue from Top 10 Customers'
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: '#,##0.0%'
maql: "SELECT\n (SELECT {metric/revenue} WHERE (SELECT {metric/revenue_top_10}\
Expand All @@ -205,7 +205,7 @@ interactions:
attributes:
title: '% Revenue from Top 10% Customers'
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: '#,##0.0%'
maql: "SELECT\n (SELECT {metric/revenue} WHERE (SELECT {metric/revenue_top_10_percent}\
Expand All @@ -221,7 +221,7 @@ interactions:
attributes:
title: '% Revenue from Top 10% Products'
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: '#,##0.0%'
maql: "SELECT\n (SELECT {metric/revenue} WHERE (SELECT {metric/revenue_top_10_percent}\
Expand All @@ -237,7 +237,7 @@ interactions:
attributes:
title: '% Revenue from Top 10 Products'
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: '#,##0.0%'
maql: "SELECT\n (SELECT {metric/revenue} WHERE (SELECT {metric/revenue_top_10}\
Expand All @@ -253,7 +253,7 @@ interactions:
attributes:
title: '% Revenue in Category'
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: '#,##0.0%'
maql: SELECT {metric/revenue} / (SELECT {metric/revenue} BY {attribute/products.category},
Expand All @@ -269,7 +269,7 @@ interactions:
attributes:
title: '% Revenue per Product'
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: '#,##0.0%'
maql: SELECT {metric/revenue} / (SELECT {metric/revenue} BY ALL
Expand All @@ -286,7 +286,7 @@ interactions:
title: Revenue
description: ''
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: $#,##0
maql: SELECT {metric/order_amount} WHERE NOT ({label/order_status}
Expand All @@ -302,7 +302,7 @@ interactions:
attributes:
title: Revenue (Clothing)
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: $#,##0
maql: SELECT {metric/revenue} WHERE {label/products.category} IN
Expand All @@ -318,7 +318,7 @@ interactions:
attributes:
title: Revenue (Electronic)
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: $#,##0
maql: SELECT {metric/revenue} WHERE {label/products.category} IN
Expand All @@ -334,7 +334,7 @@ interactions:
attributes:
title: Revenue (Home)
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: $#,##0
maql: SELECT {metric/revenue} WHERE {label/products.category} IN
Expand All @@ -350,7 +350,7 @@ interactions:
attributes:
title: Revenue (Outdoor)
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: $#,##0
maql: SELECT {metric/revenue} WHERE {label/products.category} IN
Expand All @@ -366,7 +366,7 @@ interactions:
attributes:
title: Revenue per Customer
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: $#,##0.0
maql: SELECT AVG(SELECT {metric/revenue} BY {attribute/customer_id})
Expand All @@ -381,7 +381,7 @@ interactions:
attributes:
title: Revenue per Dollar Spent
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: $#,##0.0
maql: SELECT {metric/revenue} / {metric/campaign_spend}
Expand All @@ -396,7 +396,7 @@ interactions:
attributes:
title: Revenue / Top 10
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: $#,##0
maql: SELECT {metric/revenue} WHERE TOP(10) OF ({metric/revenue})
Expand All @@ -411,7 +411,7 @@ interactions:
attributes:
title: Revenue / Top 10%
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: $#,##0
maql: SELECT {metric/revenue} WHERE TOP(10%) OF ({metric/revenue})
Expand All @@ -426,7 +426,7 @@ interactions:
attributes:
title: Total Revenue
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: $#,##0
maql: SELECT {metric/revenue} BY ALL OTHER
Expand All @@ -441,7 +441,7 @@ interactions:
attributes:
title: Total Revenue (No Filters)
areRelationsValid: true
createdAt: 2023-08-21 10:43
createdAt: 2023-10-01 19:55
content:
format: $#,##0
maql: SELECT {metric/total_revenue} WITHOUT PARENT FILTER
Expand Down Expand Up @@ -558,7 +558,7 @@ interactions:
name: '# of Active Customers'
localIdentifier: dim_0
links:
executionResult: 3a0643699f98df2fa33b9fcc4c584201e5ae5526
executionResult: 86e786c4746a2845f5cd321e4e420b586bb258de
- request:
method: POST
uri: http://localhost:3000/api/v1/actions/dataSources/demo-test-ds/uploadNotification
Expand Down Expand Up @@ -732,4 +732,4 @@ interactions:
name: '# of Active Customers'
localIdentifier: dim_0
links:
executionResult: a0ae08c5fa80e0ad5f68ae719575ab0c87da7b75
executionResult: 1554ba48f13276f16b3a648cc2adc3b077b65c4f
Loading

0 comments on commit bf04eeb

Please sign in to comment.