Skip to content

Commit

Permalink
Add Gatekeeper for creating a case in SF through thrift service
Browse files Browse the repository at this point in the history
Summary:
We are using thrift service for providing our case creation API from Care Platform to BSE team in fbcode.
They will call a python method, that calls our case creation method in www and all of that is implemented with thrift service.

In this diff I have added a Gatekeeper in order to enable the feature only for developers while the feature is in development.

Differential Revision: D66708306

fbshipit-source-id: 25453a22b452b7c4ee1f95dfee397aed4f279da4
Adlet Zeineken authored and facebook-github-bot committed Dec 10, 2024
1 parent 284c2ae commit ad1bdc3
Showing 1 changed file with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from create_salesforce_case_with_mail.create_salesforce_case_with_mail_draft_service.thrift_clients import (
CreateSalesforceCaseWithMailDraftService,
)

from create_salesforce_case_with_mail.create_salesforce_case_with_mail_draft_service.thrift_types import (
CreateSalesforceCaseWithMailDraftRequest,
CreateSalesforceCaseWithMailDraftResponse_Thrift,
)
from gatekeeper.py.gk import GK
from libfb.py import employee

from servicerouter.python.sync_client import get_sr_client

GK_NAME = "care_platform_fbcode_thrift_case_creation_service"
TIER_NAME = "care_platform.create_case_with_mail_for_bse.fbcode_www_thrift_service"


def create_case_with_mail(request: CreateSalesforceCaseWithMailDraftRequest):
with get_sr_client(
CreateSalesforceCaseWithMailDraftService,
tier="care_platform.create_case_with_mail_for_bse.fbcode_www_thrift_service",
) as client:
response = client.genCreateSalesforceCaseWithMailDraft(request)
if GK.check(GK_NAME, employee.get_current_unix_user_fbid()):
with get_sr_client(
CreateSalesforceCaseWithMailDraftService,
tier=TIER_NAME,
) as client:
return client.genCreateSalesforceCaseWithMailDraft(request)
else:
return CreateSalesforceCaseWithMailDraftResponse_Thrift()

0 comments on commit ad1bdc3

Please sign in to comment.