Giter VIP home page Giter VIP logo

salesforce's Introduction

salesforce

Sesam-Salesforce connector that can be used to:

  • get/delete/upsert objects
  • get/delete/upsert valuesets(a.k.a. picklist)
  • perform tooling API operations

SesamCommunity CI&CD

ENV VARIABLES

CONFIG_NAME DESCRIPTION IS_REQUIRED DEFAULT_VALUE
USERNAME username for login yes n/a
PASSWORD password for login yes n/a
SECURITY_TOKEN security token for login. obtained from the profile page of the user yes n/a
LOGIN_CONFIG a dict with keys USERNAME, PASSWORD, SECURITY_TOKEN so that login details are kept in only 1 secret yes n/a
WEBFRAMEWORK set to 'FLASK' to use flask, otherwise it will run on cherrypy no n/a
LOG_LEVEL LOG_LEVEL. one of [CRITICAL|ERROR|WARNING|INFO|DEBUG] no 'INFO'
INSTANCE salesforce instance. set to 'sandbox' to work on test domain. Otherwise it will be non-test domain. no 'prod'
VALUESET_LIST a dict where keys are the aliases to be used in sesam and values are the paths to the corresponding valueset. Used when fetching all valusets and for patching. e.g.{"my_global_vs": "GlobalValueSet/0Nt5I0000008cw7SAA", "my_custom_vs": "CustomField/00N5I000004yDnkUAE"} no n/a
SF_OBJECTS_CONFIG dict for object level customizations. see schemas section for description. no n/a
DEFAULT_BULK_SWITCH_THRESHOLD Integer. Threshold value on the number of incoming entities to swith to bulk-api instead of rest-api.Disabled if not set. no None

ENDPOINTS

  1. /<datatype>, methods=["GET", "POST", "PUT", "PATCH", "DELETE"]

    By default Id is used to match target object. If Id is not available to Sesam, the SF_OBJECTS_CONFIG envvar can be configured for alternative match keys.

    • "GET": returns all data(upserted and deleted) of type datatype. Response is streamed, thus the response will give 200 status but malformed body when error is encountered.Id and SystemModstamp is set as _id and _updated, respectively.
    • "POST", "PUT", "PATCH": upserts objects or deletes if _deleted is true. Accepts dict or list of dicts.
    • "DELETE": deletes incoming objects.

    query params

    • since: Optional. Data updated after since value will be delivered. CAnnot be older then 30 days ago due to Salesforce REST API limitations.
    • where: Optional. Applicable to GET method condition that will be appended to SOQL select query.
    • extra_attributes: Optional. CSV of extra attributes to fetch. Fex, 'Createdby.name'. N.B. Transit encoding of datetime fields is not supported on these attributes.
    • do_create_if_key_is_empty: Optional. Applicable to POST/PUT/PATCH requests. Allows creation of object when the objectkey cannot be determined.

  1. /<datatype>/<ext_id_field>/<ext_id>, methods=["GET", "POST", "PUT", "PATCH", "DELETE"]

    Same as point 1, but here the the the objectkey(externalkey here) can additionally be read from the url.


  1. /<datatype>/<objectkey>, methods=["GET", "POST", "PUT", "PATCH", "DELETE"]

    Same as point 2, but here the the the objectkey(genuine objectkey/Id) can additionally be read from the url.


  1. /ValueSet, methods=["GET","POST"]

    • "GET": returns all valuesets that are specified in VALUESET_LIST envvar
    • "POST": Upserts values to valuesets. See ValueSet below in schemas section for description of payload.

    Note that a value is disabled via isActive flag in the json.

    query params

    • do_refine: Optional. If equals to one of "0", "false", "no" case-insensitively, the original payload will be returned in data field of the response. Otherwise, only the valueset section.

  1. /ValueSet/, methods=["GET", "POST"]

    Same as 4. (Sesam required the trailing slach for some reason.)


  1. /ValueSet/CustomField/<sf_id>, methods=["GET", "POST"]

    Same as 4, but for single valueset that is customfield.


  1. /ValueSet/GlobalValueSet/<sf_id>, methods=["GET", "POST"]

    Same as 6, but for single valueset that is global valueset.


  1. /ValueSet/SesamAlias/<alias_in_VALUSET_LIST_envvar>, methods=["GET", "POST"]

    Same as 6, but for single valueset that is global valueset.


  1. /sf/tooling/<path:path>, methods=["GET", "POST", "DELETE", "PATCH", "PUT"]

    This is endpoint that makes available the Salesforce tooling API.

    query params

    • preserve_as_list: Optional. Applicable to /sf/tooling/path:path requests. If sent as true or 1 and the payload is a list, the first element in the list will be sent forward, othwersie payload is sent forward as it comes in.

  1. /services/restful/<path:path> or /sf/rest/<path:path>, methods=["GET", "POST", "DELETE", "PATCH", "PUT"]
This is endpoint that makes available any REST call to Salesforce RestAPI. If the original endpoint is `services/data/v{{version}}/mypath1/mypath2/mypath3`, the path in this endpoint should be `/mypath1/mypath2/mypath3`. Query params are passed over.

#### query params     
 * `preserve_as_list`: Optional.  Applicable to /sf/tooling/<path:path> requests. If sent as _true_ or _1_ and the payload is a list, the first element in the list will be sent forward, othwersie payload is sent forward as it comes in. 

  1. /services/apexrest/<path:path>, methods=["GET", "POST", "DELETE", "PATCH", "PUT"]
This is endpoint that makes available the [apexrest webservices](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_rest.htm). If the original endpoint is `services/apexrest/mypath1/mypath2/mypath3`, the path in this endpoint should be `/mypath1/mypath2/mypath3`. Query params are passed over.

#### query params     
 * `preserve_as_list`: Optional.  Applicable to /sf/tooling/<path:path> requests. If sent as _true_ or _1_ and the payload is a list, the first element in the list will be sent forward, othwersie payload is sent forward as it comes in. 

Schema Examples

  • SF_OBJECTS_CONFIG is a dict where keysa are sobject names that to be customized. Value is a dict for different customizations available:
    • ordered_key_fields: a ordered list of strings. Effective when setting _id value and Id is not available. The first field that reveals a non-null value will be used to ser _id.
{
        "aadgroup__c": {
            "ordered_key_fields": [
                "sesam_ext_id__c",
                "some_ext_id__c"
            ]
        },
        "Product2":{
            "ordered_key_fields": [
                "sesam_ext_id__c",
                "some_ext_id__c"
            ]
        }
    }
  • VALUSET_LIST:
   {
       "alias1": "/GlobalValueSet/0Nt5I0000008cw7SAA",
       "alias2": "/CustomField/00N5I000004yDnkUAE"
   }
  • ValueSet:
[
	{
		"data": [
			{
				"color": null,
				"default": false,
				"description": null,
				"isActive": true,
				"label": "mylabel",
				"urls": null,
				"valueName": "myvalue"
			}
		]
	}
]

Example configs:

system:

{
  "_id": "salesforce",
  "type": "system:microservice",
  "metadata": {
    "tags": ["salesforce"]
  },
  "connect_timeout": 60,
  "docker": {
    "environment": {
      "DEFAULT_BULK_SWITCH_THRESHOLD": 999,
      "INSTANCE": "sandbox",
      "LOGIN_CONFIG": "$SECRET(salesforce_login_config)",
      "LOG_LEVEL": "DEBUG",
      "SF_OBJECTS_CONFIG": {
        "Account": {
          "ordered_key_fields": ["myExternalIdFieldForAccount1", "myExternalIdFieldForAccount2", "myExternalIdFieldForAccount3"]
        },
        "Case": {
          "ordered_key_fields": ["myExternalIdFieldFroCaseObject1"]
        }
      }
    },
    "image": "sesamcommunity/salesforce:2.0.0",
    "memory": 8192,
    "port": 5000
  },
  "read_timeout": 7200
}

Input pipe

...
...
...

      "source": {
        "type": "json",
        "system": "salesforce",
        "is_chronological": false,
        "is_since_comparable": true,
        "supports_since": true,
        "url": "/account?extra_attributes=CreatedBy.name&where=IsPersonAccount=false and PersonEmail='[email protected]'"
      }
...
...
...

salesforce's People

Contributors

axelborge avatar baardbouvet avatar meyhane avatar

Watchers

 avatar  avatar  avatar  avatar

salesforce's Issues

Salesforce throws exeption if lastmodified is bigger than 1 month

simple_salesforce.exceptions.SalesforceMalformedRequest: Malformed request https://cs86.salesforce.com/services/data/v38.0/sobjects/User/updated/?start=2017-06-07T22%3A21%3A55%2B00%3A00&end=2017-08-10T07%3A39%3A31%2B00%3A00. Response content: [{'message': 'startDate cannot be more than 30 days ago', 'errorCode': 'INVALID_REPLICATION_DATE'}]

Workaround for now is to not use supports_since in the node

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.