Skip to content

Commit

Permalink
Merge pull request #15 from FiniteStateInc/v0.1.4
Browse files Browse the repository at this point in the history
v0.1.4
  • Loading branch information
nickvido authored Jan 24, 2024
2 parents 5a8794f + 3e8444b commit 605bc88
Show file tree
Hide file tree
Showing 9 changed files with 4,569 additions and 4,414 deletions.
14 changes: 14 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Finite State Python SDK RELEASE NOTES

# v0.1.4

## New Features

* get_products call now takes product_id, and business_unit_id as optional parameters

## Bug Fixes

* get_products parameter business_unit_id was marked as optional but was not

## Breaking Changes

* Marked get_all_products as deprecated, and it will be removed in a future version

# v0.1.0

Updated minor version due to breaking change.
Expand Down
7,448 changes: 3,728 additions & 3,720 deletions docs/finite_state_sdk.html

Large diffs are not rendered by default.

1,285 changes: 675 additions & 610 deletions docs/finite_state_sdk/queries.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/finite_state_sdk/token_cache.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h2>API Documentation</h2>
</ul>


<footer>finite-state-sdk-python v0.1.2</footer>
<footer>finite-state-sdk-python v0.1.4</footer>

<a class="attribution" title="pdoc: Python API documentation generator" href="https://pdoc.dev" target="_blank">
built with <span class="visually-hidden">pdoc</span><img
Expand Down
2 changes: 1 addition & 1 deletion docs/search.js

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions finite_state_sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import requests
import time
from warnings import warn
import finite_state_sdk.queries as queries

API_URL = 'https://platform.finitestate.io/api/v1/graphql'
Expand Down Expand Up @@ -1108,7 +1109,10 @@ def get_all_products(token, organization_context):
Returns:
list: List of Product Objects
.. deprecated:: 0.1.4. Use get_products instead.
"""
warn('`get_all_products` is deprecated. Use: `get_products instead`', DeprecationWarning, stacklevel=2)
return get_all_paginated_results(token, organization_context, queries.ALL_PRODUCTS['query'], queries.ALL_PRODUCTS['variables'], 'allProducts')


Expand Down Expand Up @@ -1291,14 +1295,16 @@ def get_product_asset_versions(token, organization_context, product_id=None):
return get_all_paginated_results(token, organization_context, queries.GET_PRODUCT_ASSET_VERSIONS['query'], queries.GET_PRODUCT_ASSET_VERSIONS['variables'](product_id), 'allProducts')


def get_products(token, organization_context, business_unit_id=None) -> list:
def get_products(token, organization_context, product_id=None, business_unit_id=None) -> list:
"""
Gets all the products for the specified business unit.
Args:
token (str):
Auth token. This is the token returned by get_auth_token(). Just the token, do not include "Bearer" in this string, that is handled inside the method.
organization_context (str):
Organization context. This is provided by the Finite State API management. It looks like "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".
product_id (str, optional):
Product ID to get. If not provided, will get all products in the organization.
business_unit_id (str, optional):
Business Unit ID to get products for. If not provided, will get all products in the organization.
Raises:
Expand All @@ -1307,10 +1313,7 @@ def get_products(token, organization_context, business_unit_id=None) -> list:
list: List of Product Objects
"""

if not business_unit_id:
raise Exception("Business Unit ID is required")

return get_all_paginated_results(token, organization_context, queries.GET_PRODUCTS_BUSINESS_UNIT['query'], queries.GET_PRODUCTS_BUSINESS_UNIT['variables'](business_unit_id), 'allProducts')
return get_all_paginated_results(token, organization_context, queries.GET_PRODUCTS['query'], queries.GET_PRODUCTS['variables'](product_id=product_id, business_unit_id=business_unit_id), 'allProducts')


def generate_report_download_url(token, organization_context, asset_version_id=None, product_id=None, report_type=None, report_subtype=None, verbose=False) -> str:
Expand Down
65 changes: 65 additions & 0 deletions finite_state_sdk/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,25 @@ def artifact_variables(artifact_id=None, business_unit_id=None):
id
name
createdAt
createdBy {
id
email
__typename
}
deletedAt
ctx {
asset
businessUnits
products
}
defaultVersion {
name
createdAt
__typename
}
_versionsMeta {
count
}
__typename
}
}
Expand Down Expand Up @@ -666,6 +680,57 @@ def _create_GET_SOFTWARE_COMPONENTS_VARIABLES(asset_version_id=None, type=None):
}


def _create_GET_PRODUCTS_VARIABLES(product_id=None, business_unit_id=None):
variables = {
"filter": {},
"after": None,
"first": 100
}

if product_id:
variables["filter"]["id"] = product_id

if business_unit_id:
variables["filter"]["group"] = {
"id": business_unit_id
}

return variables


GET_PRODUCTS = {
"query": """
query GetAllProducts(
$filter: ProductFilter!,
$after: String,
$first: Int
) {
allProducts(
filter: $filter,
after: $after,
first: $first
) {
_cursor
id
name
createdAt
createdBy {
id
email
__typename
}
group {
id
name
}
__typename
}
}
""",
"variables": lambda product_id=None, business_unit_id=None: _create_GET_PRODUCTS_VARIABLES(product_id=product_id, business_unit_id=business_unit_id)
}


GET_PRODUCTS_BUSINESS_UNIT = {
"query": """
query GetAllProducts(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "finite-state-sdk"
version = "0.1.2"
version = "0.1.4"
authors = [
"Finite State, Inc. <[email protected]>"
]
Expand Down
Loading

0 comments on commit 605bc88

Please sign in to comment.