Skip to content

Commit

Permalink
YDA-5561: exclude 'expiration date' from SRAM API
Browse files Browse the repository at this point in the history
  • Loading branch information
kaur16 authored Jan 4, 2024
1 parent b886fdd commit 0383e4b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
5 changes: 2 additions & 3 deletions groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ def group_create(ctx, group_name, category, subcategory, schema_id, expiration_d

# Post SRAM collaboration and connect to service if SRAM is enabled.
if config.enable_sram:
response_sram = sram.sram_post_collaboration(ctx, group_name, description, expiration_date)
response_sram = sram.sram_post_collaboration(ctx, group_name, description)

if "error" in response_sram:
message = response_sram['message']
Expand Down Expand Up @@ -1323,14 +1323,13 @@ def rule_group_sram_sync(ctx):
members = group['members']
managers = group['managers']
description = group['description'] if 'description' in group else ''
expiration_date = group['expiration_date'] if 'expiration_date' in group else ''

log.write(ctx, "Sync group {} with SRAM".format(group_name))

sram_group, co_identifier = sram_enabled(ctx, group_name)
# Post collaboration group is not yet already SRAM enabled.
if not sram_group:
response_sram = sram.sram_post_collaboration(ctx, group_name, description, expiration_date)
response_sram = sram.sram_post_collaboration(ctx, group_name, description)

if "error" in response_sram:
message = response_sram['message']
Expand Down
13 changes: 1 addition & 12 deletions sram.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,18 @@
from util import *


def sram_post_collaboration(ctx, group_name, description, expiration_date):
def sram_post_collaboration(ctx, group_name, description):
"""Create SRAM Collaborative Organisation Identifier.
:param ctx: Combined type of a callback and rei struct
:param group_name: Name of the group to create
:param description: Description of the group to create
:param expiration_date: Retention period for the group
:returns: JSON object with new collaboration details
"""
url = "{}/api/collaborations/v1".format(config.sram_rest_api_url)
headers = {'Content-Type': 'application/json', 'charset': 'UTF-8', 'Authorization': 'bearer ' + config.sram_api_key}

if expiration_date == '':
# Now plus a year.
expiration_date = datetime.datetime.fromtimestamp(int(time.time() + 3600 * 24 * 365)).strftime('%Y-%m-%d')

# Get epoch expiry date.
date = datetime.datetime.strptime(expiration_date, "%Y-%m-%d")
epoch = datetime.datetime.utcfromtimestamp(0)
epoch_date = int((date - epoch).total_seconds())

disable_join_requests = True
if config.sram_flow == 'join_request':
disable_join_requests = False
Expand All @@ -47,7 +37,6 @@ def sram_post_collaboration(ctx, group_name, description, expiration_date):
"disable_join_requests": disable_join_requests,
"disclose_member_information": True,
"disclose_email_information": True,
"expiry_date": epoch_date,
"administrators": [session_vars.get_map(ctx.rei)["client_user"]["user_name"]]
}

Expand Down

0 comments on commit 0383e4b

Please sign in to comment.