Views API

This module provides the functionalities to interact with Amorphic views API.

Usage

  1. Initialize Amorphic wrapper

from amorphicutils.api.amorphic import Amorphic

url = "https://bw7rwkd87f.execute-api.us-east-1.amazonaws.com"
environment = "master"
role_id = "admin-role-535343eb-0g44-4h34-g5df-766u87ed5ded"

amorphic_api = Amorphic(url, environment, role_id)
  1. Create redshift views

payload = {
      "ViewName": "RedshiftView",
      "Description": "Test view created via amorphicutils integration test",
      "ViewType": "standard",
      "TargetLocation": "redshift",
      "SqlStatement": "CREATE VIEW test.RedshiftView AS SELECT SYSDATE",
      "Domain": "test"
    }

response = amorphic_api.views.create(**payload)
  1. Updating redshift views

payload = {
            "ViewName": "RedshiftView",
            "Description": "Updated Test view created via amorphicutils integration test",
            "SqlStatement": "CREATE OR REPLACE VIEW test.RedshiftView AS SELECT SYSDATE"
        }

response = amorphic_api.views.update(**payload)

Implementation

class amorphicutils.api.models.views.Views(api_wrapper)

Class to call dataset related API

create(ViewName, Domain, TargetLocation, SqlStatement, ViewType='standard', Description=None, DataClassification=None, Keywords=None, AutoRefresh=True, **view_kwargs)

Creates the view

Parameters
  • ViewName – Name of the view

  • Domain – Domain for the view

  • TargetLocation – Target location. Must be one of [‘redshift’, ‘s3athena’]

  • SqlStatement – SQL statement for the view

  • ViewType – Type of the view. Must be one of [‘standard’], Default: standard

  • Description – Description of the view

  • DataClassification – Data classification for the view

  • Keywords – Keywords for the view

  • AutoRefresh – True if want view to be autorefreshed. Default: True

  • view_kwargs – Extra keyword arguments for view creation

Returns

delete(ViewName=None, ViewId=None)

Deletes the view

Parameters
  • ViewName – Name of the view

  • ViewId – Id of the view

Returns

get(ViewName=None, ViewId=None)

Get the details for view based on ViewName or ViewId

Parameters
  • ViewName – Name of the view

  • ViewId – Id of the view

Returns

get_all(views_list=None)

Get all the views

Parameters

views_list

Returns

update(Description=None, Keywords=None, DataClassification=None, SqlStatement=None, ViewName=None, ViewId=None, AutoRefresh=True)

Updates an existing view

Parameters
  • Description – Description of the view

  • Keywords – Keywords for the view

  • DataClassification – Data classification for the view

  • SqlStatement – SQL statement for the view

  • ViewName – Name of the view

  • ViewId – Id of the view

  • AutoRefresh – True if want view to be autorefreshed. Default: True

Returns