Search This Blog

Wednesday, 11 November 2020

REST API

 

API is an application programming interface. It is a set of rules that allow programs to talk to each other. The developer creates the API on the server and allows the client to talk to it.


REST determines how the API looks like. It stands for “Representational State Transfer”. It is a set of rules that developers follow when they create their API. 



JSON (JavaScript Object Notation) a common format for sending and requesting data through a REST API. The response that Github sends back to you is also formatted as JSON.



The method is the type of request you send to the server. You can choose from these five types below:

  • GET
  • POST
  • PUT
  • PATCH
  • DELETE

They are used to perform four possible actions: CreateReadUpdate and Delete (CRUD).



Method NameRequest Meaning
`GET`This request is used to get a resource from a server. If you perform a `GET` request, the server looks for the data you requested and sends it back to you. In other words, a `GET` request performs a `READ` operation. This is the default request method.
`POST`This request is used to create a new resource on a server. If you perform a `POST` request, the server creates a new entry in the database and tells you whether the creation is successful. In other words, a `POST` request performs an `CREATE` operation.
`PUT` and `PATCH`These two requests are used to update a resource on a server. If you perform a `PUT` or `PATCH` request, the server updates an entry in the database and tells you whether the update is successful. In other words, a `PUT` or `PATCH` request performs an `UPDATE` operation.
`DELETE`This request is used to delete a resource from a server. If you perform a `DELETE` request, the server deletes an entry in the database and tells you whether the deletion is successful. In other words, a `DELETE` request performs a `DELETE` operation.
Headers are used to provide information to both the client and server. It can be used for many purposes, such as authentication and providing information about the body content. 

The data (sometimes called “body” or “message”) contains information you want to be sent to the server. This option is only used with POSTPUTPATCH or DELETE requests.


Response Codes:

2XX  - Success
3XX - Request redirected
4XX - Client Error
5XX - Server Error







































            

Tuesday, 19 November 2019

Basic SQLDB Learning

SQL: Structured Query Language

This language is comonnly  used to comunicate with any database like oracle,mysql,postgress...etc Sqlite
Oracle and MySQL is used for Enterprise purpose
Sqlite is opensource.
Sqlite is light weight compare to other DB and it is used in our daily activities like  ( music systems in car).

Basically we can perform Four operations in Database called CRUD Operations.

C - Create,R- Read,U- Update,D- Delete


SQL Syntax fro Create:

CREATE TABLE Contacts2 (First_Name  VARCHAR(30),Second_Name   VARCHAR(30),Mobile    INTEGER(10));

CREATE table Artist (id INTEGER NOt NULL PRIMARY KEY AUTOINCREMENT,name TEXT);   Variable ID as primary Key


Contacts- Table name

firstname and second name,Mobile are columns in table or Schema

Read  from Database:

SELECT First_Name FROM 'Contacts2';
SELECT *  FROM 'Contacts2';
SELECT * FROM 'Contacts2' WHERE First_Name='Sukesh' ;
SELECT * FROM 'Contacts2'  ORDER BY First_Name='*' ;
SELECT * FROM 'Contacts2'  ORDER BY First_Name='Sukesh' ;

Order by will sort  based on given column and display in ascending order

Insert Value to Database :

INSERT INTO Contacts2 (First_Name,Second_Name,Mobile) VALUES ('Sukesh','Yatakar',9637071671),('Manasa','Yatakar',9637071671)

Delete the contact from

we can delete row based on single value  only

DELETE from Contacts2 WHERE First_Name = 'Nandika'

Update in Table with New Values:

Update Contacts2 SET Mobile= '8237378289' where First_Name='Manasa'

Inetgration of database with Python:

If your application needs to support not only the SQLite database but also other databases such as MySQL, PostgreSQL, and Oracle, the PySQLite is a good




Relations:

Primary Key, - Key for for every row, which point to that row in other tables.Ending Point of URL
Logical Key  - which is used to search from outside world()
Foriegn Key-    Starting point of URL



Artist Table:
CREATE table Artist (id INTEGER NOt NULL PRIMARY KEY AUTOINCREMENT,name TEXT);
Insert into Artist (name) VALUES('Led Zepllin')
Insert into Artist (name) VALUES('AC\DC')

Genere Table:
CREATE table Genere (id INTEGER NOt NULL PRIMARY KEY AUTOINCREMENT,name TEXT);
Insert into genere (name) VALUES('Rock')
Insert into genere (name) VALUES('Metal')

Album Table:
CREATE table Album(id INTEGER NOt NULL PRIMARY KEY AUTOINCREMENT UNIQUE,artist_id INTEGER,title TEXT);
Insert into album (title,artist_id) VALUES('who made who',2)     It linked to Artiest 2nd row
Insert into album (title,artist_id) VALUES( 'IV',1)   It is linked to artist 1st row

Track Table:
CREATE table Track(id INTEGER NOt NULL PRIMARY KEY AUTOINCREMENT UNIQUE,title  TEXT,album_id INTEGER,genere_id INTEGER,len INTEGER,rating INTEGER,counnt INTEGER);

Insert into Track(title,rating,len,counnt,album_id,genere_id) VALUES ('about to rock',5,313,0,1,2),('who made who',5,207,0,1,2)



Joing Tables:

Joining Table Album to Artist

SELECT Album.title,Artist.name from Album join Artist ON Album.artist_id=Artist.id

If we dont give "on" clause it will make all combinations and display

Joining Table Track to Genere
SELECT Track.title,Track.rating,Genere.name from Track join Genere on Track.genere_id=Genere.id

Joinig Table Track to Album:
SELECT Track.title,Album.title from Track join Album on Track.album_id=Album.id


Combing all together:
SELECT Track.title,Album.title,Genere.name,Artist.name from Track join Album join Artist join Genere on Track.album_id=Album.id and Track.genere_id=Genere.id and Album.artist_id=Artist.id






Note: When create Id  give this "INTEGER NOT NULL PRIMARY KEY UNIQUE" other wise u get null issue while inserting values.

Many to Many Relations Table:

Create User Table:
 CREATE TABLE User (id  INTEGER NOT NULL PRIMARY KEY UNIQUE,name  TEXT,Email  TEXT)

Create Course Table:
CREATE TABLE Member (id  INTEGER NOT NULL UNIQUE,title  TEXT)

create Member Table:

CREATE TABLE Member (Userid  INTEGER,Courseid  INTEGER,role INTEGER, PRIMARY KEY (Userid,Courseid))



INsert values to User table :

INSERT INTO User (name,email) Values ('Jae','Jae@gmail.org');INSERT INTO User (name,email) Values ('Ed','Ed@gmail.org');INSERT INTO User (name,email) Values ('Sue','Sue@gmail.org')


INsert into Course table:

INSERT INTO Course (title) Values ('python');INSERT INTO Course (title) Values ('SQL');INSERT INTO Course (title) Values ('java')



Insert Values to Members Table:

INsert into Member (userid,courseid,role) Values(1,1,1);INsert into Member (userid,courseid,role) Values(2,1,0);INsert into Member (userid,courseid,role) Values(3,1,0);INsert into Member (userid,courseid,role) Values(1,2,0);INsert into Member (userid,courseid,role) Values(2,2,0);INsert into Member (userid,courseid,role) Values(2,3,1);INsert into Member (userid,courseid,role) Values(3,3,0)

Learn Linux 2

/ - indicates the root of the directory

ls -  to List the files
ls -l  to list in long format
ls -a to list the hidden files
ls -al to list files and dir in detail view
ls -R to list all  subdirectories in directiories

create a file in CLI and add content  ---- cat > filename
display content of file ------ Cat filename
remove a file -----   rm filename

create directry ---------- mkdir  filename
remove dirtry ------------ rmdir filename

move file or rename ------mv file1  file2

sudo  --- allows user to run with root permissions

man or help  ----- give information of command

history ---- help to view the previous commands executed

clear ---- clear the terminal

pr -    command is used  format the file content and print
pr -x    filename


cat - to read a file


Permission:

- indicates the file (-rwx)
d indicates the directory(drwx)


rwx- read,write,execute  for file
Users(Owner,Group,Others) for file

chmod - to give permission to file or directories
chown  - used to chnage owner or group name


Output redirection:

ls -l > txt

redirecting the output to file txt


PIPE:
Helps you to use two or more commands at same time

cat filename | less or Pg or more  ----- display  first page and we need to scroll down using arrow

FIND:
find . name 'filename'
. current directory
to search for file

GREP:

to search for string in file
cat requirements.txt | grep six
six==1.11.0

grep -c   --- display count of matching
grep -n  ---- display  matching line with number
grep  -i    --- display upper and lower case matching
grep -v    ---- display all lines donot macth string


Linux has a lot of filter commands like awk, grep, sed, spell, and wc

Regex:

.   replace any  character
^ start with character macthes
$ end with character macthes
* matches any character o or more
\ matches special chracter
? matches any single chracter

\+ matches  one or more  preceding character
\? matches zero or more preceding chracter

examples:

grep -E a\+t
grep -E a\?t

Range:
examples

echo {0..10}
echo {a..z}
echo test{0..8}



SORT:

sorting content of file alphabetically,numerically,case sensitive

sort   filename
-r    reverse sorting
-n   sort numerically
-f    case sentive

VOLTE IMS Overview

UE:
It is the mobile  terminal authorized to  be used in  and LTE Network.

An IMS Powered UE :

It required two components:-
UICC (Universal Intergrated circuit card):
UE must contain one UICC and UICC may have one or more modules .
              SIM: used by GSM network
  USIM: Used by UMTS or LTE network
CSIM: used by CDMA neytwork
ISIM:  used by IMS network .It contains IMPI(IP Multimedia Private Identity) , IMPU(IP multimedia Public identity) and secret key . IMPI is global identity given by home network. IMPU acts like telephone number or SIP URI.Secret key is used for  user authentication and sip registration.

SIP UA (SIP USerAgent)
 its acts as UAS and UAC



EnodeB:
The E-UTRAN handles the radio communications between the mobile and the evolved packet core( EPC)and just has one component, the evolved base stations, called eNodeB.
Each eBN connects with the EPC by means of the S1 interface used for signalling and it can also be connected to nearby base stations by the X2 interface for packet forwarding during handover.


EPC (Evolved Packet Core):

MME:
mobility management entity (MME) controls the high-level operation of the mobile by means of signalling messages and Home Subscriber Server (HSS).

HSS:
The Home Subscriber Server (HSS) component  is a central database that contains information about all the network operator's subscribers.

SGW(Serving Gateway): 
Acts as a router, and forwards data between the base station and the PDN gateway.

PGW(PDN Gateway):
Packet Data Network  Gateway communicate with outside network using Sgi Interface.Each PDN is identified by APN(Access Point Name).

PCRF(Policy Control and Charging Rules):


The interface between the serving and PDN gateways is known as S5/S8. s5 if two devices in same network s8 if devices in differenet network.
For VolteIMS Prospective two nodes are  important in EPC

IMS Core:
IMS Core handles  session management and media control.
IMS Core has following nodes:-

CSCF: Establishes monitor ,supports and releases multimedia sessions.
PCSCF : it is intial point of contact for any SIP UA,it handles all request from UE.
SCSCF: has knowledge about user and what applications are available for user.SCSCF decides wheter sip messages should go to application server or not.
ICSCF: ICSCF query  with HSS and  assign the SCSCF to the user

HSS:
HSS is a database that maintains user profiles and location information.HSS is also responsible for authentication and authorization.

SLF: Subscriber location Function) assigns HSS to user in home network. to acheive func it keep track of all HSS.

Ansible Basics Learning

Ansible tools:
ansible-tower   its UI based managing ansible playbooks
ansible- playbook  runs ansible playbook ,executing the defined tasks on targeted hosts
ansible -pull   to pull playbooks from repos and execute
ansible-inventory  used to display or dump the configured inventory as Ansible sees it
ansible-doc  it is documentation tool
ansible-galaxy    command to manage Ansible roles in shared repositories
ansible-console  console for executing ahoc commands
ansible-config     to  view ansible configuration
ansible-vault   encryption/decryption utility for Ansible data files




m   module name
all  it search for local host first not found check at deafault under /etc/andible/hosts
--extra-vars   to pass varaible from outside playbook
-i  pass custom   inventory file create inside playbook
-l   pass the group or hostname to be executed from inverntory file or hosts file
-v or -vvv or -vvvv   verbosity to view logs in debugging mode
--private-key   to pass ssh key
-u User name
-a to execute any ycommand on nodes
--check    to perform dryrun before execute
-- help

default host path:      etc/ansible/hosts
default config path:  /etc/ansible/ansible.cfg


--gather facts     gethering information from remote systems before connecting to remote system
- name  to describe the task going to perform
- hosts: host name/group  you want to connect
-connection    types of connection  local,netconf
- tasks:    block to write task to be performed
-loop:  to loop through task below
-vars:   define list  of values in varaible


Modules:

Service  module   - to check status of service on  remote node (name,state,enable)
raw Module:    to  execute  linux command on  remote node ( ls -l )
fail : print message if fails
when :  check error is foudn in previous result and print fail message
redhat subscription module :   to perform redhat subscription on rhel.
uri module -- to call apis










It is opensource automation tool
It is used to automate IT infrastruvcture
It is used to configure Networdk devices and deploy software on remote devices

Advantages:
It is easy to use and deploy
It is agent less
simple syntax written in YAML called Playbooks
It is powerfull and flexible

Ansible terms:

Controller Machine: The machine where Ansible is installed, responsible for running the provisioning on the servers you are managing.
Inventory: An initialization file that contains information about the servers you are managing.
Playbook: The entry point for Ansible provisioning, where the automation is defined through tasks using YAML format.
Task: A block that defines a single procedure to be executed, e.g. Install a package.

Module: A module typically abstracts a system task, like dealing with packages or creating and changing files. Ansible has a multitude of built-in modules, but you can also create custom ones.
Role: A pre-defined way for organizing playbooks and other files in order to facilitate sharing and reusing portions of a provisioning.
Play: A provisioning executed from start to finish is called a play. In simple words, execution of a playbook is called a play.
Facts: Global variables containing information about the system, like network interfaces or operating system.
Handlers: Used to trigger service status changes, like restarting or stopping a service.

OPenstack

OPenstack:
Openstack is software for building  and managing  cloud computing platforms for private and public Cloud. It is Considered as  IaaS.
OPenstack has big community and it is managed by Openstack Foundation.
It is a OPen source  platform.
There  are many ways to install  and deploy openstack  through different distributions like ubuntu,redhat,suse linux

Openstack Version:

OpenStack is developed and released around 6-month cycles.After the initial release, additional stable point releases will be released in each release series
Present release  Series is "Train" ,15 version.
Under Development  "Ussuri" Series

OPenstack Components:

Openstack platform is managed by a web UI dashboard. It comprises of nine Core key components


  • Nova is a computing engine. It is used for deploying and managing large numbers of virtual machines.
  • Neutron provides the networking capability.
  • Horizon is the dashboard of Openstack. It is the only graphical interface (WEB UI).
  • Keystone provides identity services. It is essentially a central list of all the users.
  • Glance provides image services to OpenStack. In this case, "images" refers to images (or virtual copies) of hard disks.
  • Heat allows developers to store the requirements of a cloud application in a file that defines what resources are necessary for that application.
  • Swift is a storage system for objects and files.
  • Cinder is a block storage component. It accesses specific locations on a disk drive.
  • Ceilometer provides telemetry services, which allow the cloud to provide billing services to individual users of the cloud.

Cloud Computing

Cloud Computing  is the on demand availiability of  Computer system resources.

There are three types of  cloud computing service

IaaS   Infrastructure as a Service (Openstack),Typically, IaaS provides hardware, storage, servers and data center space or network components
SaaS  Software as a service 
PaaS Platform as a Service

REST API

  API  is an application programming interface. It is a set of rules that allow programs to talk to each other. The developer creates the AP...